public LoadErrorEventArgs(CefFrame frame, CefErrorCode errorCode, string errorText, string failedUrl) { Frame = frame; ErrorCode = errorCode; ErrorText = errorText; FailedUrl = failedUrl; }
public CefNavigatingEventArgs(CefFrame frame, CefRequest request, CefHandlerNavType navType, bool isRedirect) { this.frame = frame; this.request = request; this.navType = navType; this.isRedirect = isRedirect; }
protected override bool OnBeforeBrowse(CefBrowser browser, CefFrame frame, CefRequest request, CefHandlerNavType navType, bool isRedirect) { #if DIAGNOSTICS Cef.Logger.Trace(LogTarget.CefRequestHandler, "OnBeforeBrowse: Method=[{0}] Url=[{1}] NavType=[{2}] IsRedirect=[{3}]", request.GetMethod(), request.GetURL(), navType, isRedirect); #endif var cancel = this.context.OnNavigating(frame, request, navType, isRedirect); if (cancel) return true; if (frame.IsMain) { // browser navigating to a new page this.context.ClearFrames(); this.context.AttachMainFrame(frame); this.context.ClearReadyState(); this.context.SetFrameReadyState(null, FrameReadyState.Navigating); } else if ((this.context.ReadyOptions & CefReadyOptions.Frames) != 0) { this.context.SetFrameReadyState(frame.GetName(), FrameReadyState.Navigating); } return false; }
protected override void OnAddressChange(CefBrowser browser, CefFrame frame, string url) { if (frame.IsMain) { _core.OnAddressChanged(url); } }
protected unsafe override void OnContextReleased(CefBrowser browser, CefFrame frame, CefV8Context context) { if (_context.MainFrame != null) { _context.MainFrame.UnbindV8Context(); } }
protected override bool OnJSPrompt(CefBrowser browser, CefFrame frame, string message, string defaultValue, out bool retval, out string result) { // TODO: CefWebJSDialogHandler.OnJSPrompt retval = false; result = null; return false; }
protected override void OnAddressChange(CefBrowser browser, CefFrame frame, string url) { if (frame.IsMain) { _core.InvokeIfRequired(() => _core.OnAddressChanged(new AddressChangedEventArgs(frame, url))); } }
public CefUncaughtExceptionEventArgs(CefBrowser browser, CefFrame frame, CefV8Context context, CefV8Exception exception, CefV8StackTrace stackTrace) { this.browser = browser; this.frame = frame; this.context = context; this.exception = exception; this.stackTrace = stackTrace; }
protected override void OnAddressChange(CefBrowser browser, CefFrame frame, string url) { #if DIAGNOSTICS Cef.Logger.Trace(LogTarget.CefDisplayHandler, "OnAddressChange: URL=[{0}] Frame.IsMain=[{1}]", url, frame.IsMain); #endif if (frame.IsMain) { this.context.OnAddressChanged(url); } }
protected override bool OnBeforePopup(CefBrowser browser, CefFrame frame, string targetUrl, string targetFrameName, CefPopupFeatures popupFeatures, CefWindowInfo windowInfo, ref CefClient client, CefBrowserSettings settings, ref bool noJavascriptAccess) { var e = new BeforePopupEventArgs(frame, targetUrl, targetFrameName, popupFeatures, windowInfo, client, settings, noJavascriptAccess); _core.InvokeIfRequired(() => _core.OnBeforePopup(e)); client = e.Client; noJavascriptAccess = e.NoJavascriptAccess; return e.Handled; }
protected unsafe override void OnContextCreated(CefBrowser browser, CefFrame frame, CefV8Context context) { if (frame.IsMain) { _context.MainFrame.BindContext(context); } var obj = context.GetGlobal(); Cef.JSBindingContext.BindObjects(obj); _context.JSBindingContext.BindObjects(obj); obj.Dispose(); }
public BeforePopupEventArgs( CefFrame frame, string targetUrl, string targetFrameName, CefPopupFeatures popupFeatures, CefWindowInfo windowInfo, CefClient client, CefBrowserSettings settings, bool noJavascriptAccess) { Frame = frame; TargetUrl = targetUrl; TargetFrameName = targetFrameName; PopupFeatures = popupFeatures; WindowInfo = windowInfo; Client = client; Settings = settings; NoJavascriptAccess = noJavascriptAccess; }
protected override bool OnBeforeBrowse(CefBrowser browser, CefFrame frame, CefRequest request, bool isRedirect) { DemoApp.BrowserMessageRouter.OnBeforeBrowse(browser, frame); return base.OnBeforeBrowse(browser, frame, request, isRedirect); }
protected override CefResourceHandler Create(CefBrowser browser, CefFrame frame, string schemeName, CefRequest request) { return new DumpRequestResourceHandler(); }
protected override void OnLoadStart(CefBrowser browser, CefFrame frame) { this._owner.OnLoadStart(frame); }
/// <summary> /// Executed when a query has been canceled either explicitly using the /// JavaScript cancel function or implicitly due to browser destruction, /// navigation or renderer process termination. It will only be called for /// the single handler that returned true from OnQuery for the same /// |query_id|. No references to the associated Callback object should be /// kept after this method is called, nor should any Callback methods be /// executed. /// </summary> public virtual void OnQueryCanceled(CefBrowser browser, CefFrame frame, long queryId) { }
/// <summary> /// Executed when a new query is received. |query_id| uniquely identifies the /// query for the life span of the router. Return true to handle the query /// or false to propagate the query to other registered handlers, if any. If /// no handlers return true from this method then the query will be /// automatically canceled with an error code of -1 delivered to the /// JavaScript onFailure callback. If this method returns true then a /// Callback method must be executed either in this method or asynchronously /// to complete the query. /// </summary> public virtual bool OnQuery(CefBrowser browser, CefFrame frame, long queryId, string request, bool persistent, Callback callback) { return false; }
protected override void OnUncaughtException(CefBrowser browser, CefFrame frame, CefV8Context context, CefV8Exception exception, CefV8StackTrace stackTrace) { _context.OnUncaughtException(browser, frame, context, exception, stackTrace); }
protected override bool OnJSConfirm(CefBrowser browser, CefFrame frame, string message, out bool retval) { // TODO: CefWebJSDialogHandler.OnJSConfirm retval = false; return false; }
/// <summary> /// The on context created. /// </summary> /// <param name="browser"> /// The browser. /// </param> /// <param name="frame"> /// The frame. /// </param> /// <param name="context"> /// The context. /// </param> protected override void OnContextCreated(CefBrowser browser, CefFrame frame, CefV8Context context) { #region Initialize var global = context.GetGlobal(); #endregion #region Exposed CefV8Value exposed = CefV8Value.CreateObject(); global.SetValue("exposed", exposed, CefV8PropertyAttribute.None); #endregion #region Cef Assembly var extension = new CefAssembly(browser, frame, context); extension.CreateObject(global, new List <string>() { "mscorlib", "System", "System.Core" }); //extension.CreateObject(global, AppDomain.CurrentDomain.GetAssemblies().Where(s => //{ // if (s.GetName().Name.StartsWith("blis")) return true; // return false; //}) //.Select(s => s.GetName().Name).ToList()); #endregion #region Custom XHR var xhr = new xhrObject(browser, frame, context); global.SetValue("xHttpRequest", xhr.CreateObject(), CefV8PropertyAttribute.None); #endregion #region V8 Engine API var v8Engine = new V8EngineObject(browser, frame, context); global.SetValue("V8Engine", v8Engine.CreateObject(), CefV8PropertyAttribute.None); #endregion #region Database API var database = new DatabaseObject(browser, frame, context); global.SetValue("DB", database.CreateObject(), CefV8PropertyAttribute.None); #endregion #region Console API var console = new ConsoleObject(browser, frame, context); global.SetValue("Console", database.CreateObject(), CefV8PropertyAttribute.None); #endregion #region Window API var window = new WindowObject(browser, frame, context); global.SetValue("Window", window.CreateObject(), CefV8PropertyAttribute.None); #endregion #region Server API var server = new ServerObject(browser, frame, context, this); global.SetValue("Server", server.CreateObject(), CefV8PropertyAttribute.None); #endregion #region ChromeDevToosProtocol Object var chromeDevToolsProtocol = new ChromeDevToolsProtocol(browser, frame, context); global.SetValue("DevTools", chromeDevToolsProtocol.CreateObject(), CefV8PropertyAttribute.None); #endregion #region V8 Object //var v8object = new V8Object(browser, frame, context); global.SetValue("V8Object", v8Engine.v8object.CreateObject(), CefV8PropertyAttribute.None); #endregion #region OnContextCreated MessageRouter.OnContextCreated(browser, frame, context); context.Dispose(); #endregion }
/// <summary> /// The create. /// </summary> /// <param name="browser"> /// The browser. /// </param> /// <param name="frame"> /// The frame. /// </param> /// <param name="schemeName"> /// The scheme name. /// </param> /// <param name="request"> /// The request. /// </param> /// <returns> /// The <see cref="CefResourceHandler"/>. /// </returns> protected override CefResourceHandler Create(CefBrowser browser, CefFrame frame, string schemeName, CefRequest request) { return(new DefaultResourceSchemeHandler(_chromelyErrorHandler)); }
protected override void OnFocusedNodeChanged(CefBrowser browser, CefFrame frame, CefDomNode node) { base.OnFocusedNodeChanged(browser, frame, node); }
protected override void OnUncaughtException(CefBrowser browser, CefFrame frame, CefV8Context context, CefV8Exception exception, CefV8StackTrace stackTrace) { base.OnUncaughtException(browser, frame, context, exception, stackTrace); }
public JavaScriptRendererSideAsyncFunctionCallback(CefFrame frame, Guid uuid, JavaScriptCommunicationBridge bridge) { this._frame = frame; this._uuid = uuid; _jsBridge = bridge; }
public ConsoleObject(CefBrowser browser, CefFrame frame, CefV8Context context) { }
protected override CefResourceHandler Create(CefBrowser browser, CefFrame frame, string schemeName, CefRequest request) { return(new CefGlueHttpSchemeHandler()); }
/// <summary> /// Called when a frame loses its connection to the renderer process and will /// be destroyed. /// </summary> /// <param name="browser">The <see cref="CefBrowser"/> object.</param> /// <param name="frame">The detached <see cref="CefFrame"/> object.</param> /// <remarks> /// Any pending or future commands will be discarded and <see cref="CefFrame.IsValid"/> /// will now return false for <paramref name="frame"/>. If called after /// <see cref="OnBeforeClose(CefBrowser)"/> during browser destruction then /// <see cref="CefBrowser.IsValid"/> will return false for <paramref name="browser"/>. /// </remarks> internal protected virtual void OnFrameDetached(CefBrowser browser, CefFrame frame) { WebView.RaiseCefFrameDetached(new FrameEventArgs(frame)); }
public override bool OnProcessMessageReceived(CefBrowser browser, CefFrame frame, CefProcessId sourceProcess, CefProcessMessage message) { return(_implementation.OnProcessMessageReceived(browser, frame, sourceProcess, message)); }
protected override void OnContextReleased(CefBrowser browser, CefFrame frame, CefV8Context context) { MessageRouter.OnContextReleased(browser, frame, context); }
public override void OnQueryCanceled(CefBrowser browser, CefFrame frame, long queryId) { }
protected override void OnLoadEnd(CefBrowser browser, CefFrame frame, int httpStatusCode) { m_core.InvokeAsyncIfPossible(() => m_core.OnLoadEnd(new LoadEndEventArgs(frame, httpStatusCode))); }
public CefNavigatedEventArgs(CefFrame frame) { this.frame = frame; }
protected override void OnLoadError(CefBrowser browser, CefFrame frame, CefErrorCode errorCode, string errorText, string failedUrl) { m_core.InvokeAsyncIfPossible(() => m_core.OnLoadError(new LoadErrorEventArgs(frame, errorCode, errorText, failedUrl))); }
/// <summary> /// Call from CefRequestHandler::OnBeforeBrowse only if the navigation is /// allowed to proceed. If |frame| is the main frame then any pending queries /// associated with |browser| will be canceled and Handler::OnQueryCanceled /// will be called. No JavaScript callbacks will be executed since this /// indicates destruction of the context. /// </summary> public void OnBeforeBrowse(CefBrowser browser, CefFrame frame) { if (frame.IsMain) CancelPendingFor(browser, null, false); }
protected override void OnLoadStart(CefBrowser browser, CefFrame frame, CefTransitionType transitionType) { m_core.InvokeAsyncIfPossible(() => m_core.OnLoadStart(new LoadStartEventArgs(frame))); }
public LoadStartEventArgs(CefFrame frame) { Frame = frame; }
protected override void OnLoadError(CefBrowser browser, CefFrame frame, CefErrorCode errorCode, string errorText, string failedUrl) { this._owner.OnLoadError(frame, errorCode, errorText, failedUrl); }
protected override void OnLoadEnd(CefBrowser browser, CefFrame frame, int httpStatusCode) { this._owner.OnLoadEnd(frame, httpStatusCode); }
public static void ExcuteJs(CefFrame cefFrame, string js2run) { cefFrame.ExecuteJavaScript(js2run, cefFrame.Url, 0); }
public LoadEndEventArgs(CefFrame frame, int httpStatusCode) { Frame = frame; HttpStatusCode = httpStatusCode; }
/// <summary> /// Called when the main frame changes due to /// <list type="bullet"> /// <item>initial browser creation;</item> /// <item>final browser destruction;</item> /// <item>cross-origin navigation;</item> /// <item>re-navigation after renderer process termination (due to crashes, etc).</item> /// </list> /// </summary> /// <param name="browser"> /// The <see cref="CefBrowser"/> object.<para/> /// If <see cref="OnMainFrameChanged"/> called after <see cref="OnBeforeClose"/> during browser /// destruction then <see cref="CefBrowser.IsValid"/> will return false. /// </param> /// <param name="oldFrame"> /// The old frame or null when a main frame is assigned to <paramref name="browser"/> for the first time. /// </param> /// <param name="newFrame"> /// The new frame or null when a main frame is removed from /// <paramref name="browser"/> for the last time.</param> /// <remarks> /// This function will be called after <see cref="OnFrameCreated"/> for <paramref name="newFrame"/> /// and/or after <see cref="OnFrameDetached"/> for <paramref name="oldFrame"/>. /// </remarks> internal protected virtual void OnMainFrameChanged(CefBrowser browser, CefFrame oldFrame, CefFrame newFrame) { }
public static void SetElementValueById(CefFrame cefFrame, string elementid, string elementvalue) { cefFrame.ExecuteJavaScript(" document.getElementById('{0}').focus();".With(elementid), cefFrame.Url, 0); cefFrame.ExecuteJavaScript(" document.getElementById('{0}').value = \"{1}\";".With(elementid, elementvalue), cefFrame.Url, 0); cefFrame.ExecuteJavaScript(" document.getElementById('{0}').blur();".With(elementid), cefFrame.Url, 0); }
public override void OnContextMenuDismissed(CefBrowser browser, CefFrame frame) { _implementation.OnContextMenuDismissed(browser, frame); }
protected override void OnContextCreated(CefBrowser browser, CefFrame frame, CefV8Context context) { if (frame.IsMain) { // Retrieve the context's window object and install the "vvvvReportDocumentSize" function // used to tell the node about the document size as well as the "vvvvSend" function // used to tell the node about variables computed inside the frame. using (var window = context.GetGlobal()) { var handler = new CustomCallbackHandler(browser, frame); var reportDocumentSizeFunc = CefV8Value.CreateFunction(CustomCallbackHandler.ReportDocumentSize, handler); window.SetValue(CustomCallbackHandler.ReportDocumentSize, reportDocumentSizeFunc); window.SetValue("vvvvQuery", CefV8Value.CreateFunction("vvvvQuery", new DelegatingHandler((name, obj, args) => { const string argForm = "{ request: 'NAME', arguments: {}, onSuccess: function(response) {}, onError: function(error_message) {} }"; string invalidArg = $"vvvvQuery expects one argument of the form {argForm}"; if (args.Length != 1) { throw new Exception($"vvvvQuery expects one argument"); } var x = args[0]; if (x is null || !x.IsObject) { throw new Exception($"The argument must be of the form {argForm}"); } var requestValue = x.GetValue("request"); if (requestValue.IsUndefined) { throw new Exception($"The request entry is missing"); } if (!requestValue.IsString) { throw new Exception($"The request must be a string"); } var onSuccessValue = x.GetValue("onSuccess"); if (!onSuccessValue.IsUndefined && !onSuccessValue.IsFunction) { throw new Exception($"The onSuccess entry must be a function"); } var onErrorValue = x.GetValue("onError"); if (!onErrorValue.IsUndefined && !onErrorValue.IsFunction) { throw new Exception($"The onError entry must be a function"); } var request = requestValue.GetStringValue(); var id = queryCount++; if (queries.TryAdd((request, id), (context, onSuccessValue, onErrorValue))) { using var message = CefProcessMessage.Create("query-request"); message.Arguments.SetString(0, request); message.Arguments.SetInt(1, id); message.Arguments.SetValue(2, ToValue(x.GetValue("arguments"))); frame.SendProcessMessage(CefProcessId.Browser, message); } return(default);
public override bool OnQuery(CefBrowser browser, CefFrame frame, long queryId, string request, bool persistent, CefMessageRouterBrowserSide.Callback callback) { if (request == "wait5") { new Thread(() => { Thread.Sleep(5000); callback.Success("success! responded after 5 sec timeout."); // TODO: at this place crash can occurs, if application closed }).Start(); return true; } if (request == "wait5f") { new Thread(() => { Thread.Sleep(5000); callback.Failure(12345, "success! responded after 5 sec timeout. responded as failure."); }).Start(); return true; } if (request == "wait30") { new Thread(() => { Thread.Sleep(30000); callback.Success("success! responded after 30 sec timeout."); }).Start(); return true; } if (request == "noanswer") { return true; } var chars = request.ToCharArray(); Array.Reverse(chars); var response = new string(chars); callback.Success(response); return true; }
/// <summary> /// The create. /// </summary> /// <param name="browser"> /// The browser. /// </param> /// <param name="frame"> /// The frame. /// </param> /// <param name="schemeName"> /// The scheme name. /// </param> /// <param name="request"> /// The request. /// </param> /// <returns> /// The <see cref="CefResourceHandler"/>. /// </returns> protected override CefResourceHandler Create(CefBrowser browser, CefFrame frame, string schemeName, CefRequest request) { return(new DefaultAssemblyResourceSchemeHandler(_config)); }
protected override bool OnJSAlert(CefBrowser browser, CefFrame frame, string message) { // TODO: CefWebJSDialogHandler.OnJSAlert return false; }
public override bool OnContextMenuCommand(CefBrowser browser, CefFrame frame, CefContextMenuParams @params, int commandId, CefEventFlags eventFlags) { return(_implementation.OnContextMenuCommand(browser, frame, @params, commandId, eventFlags)); }
public ResourceHandler(CefBrowser browser, CefFrame frame, CefRequest request) { this.browser = browser; this.frame = frame; this.request = request; }
protected override void OnLoadStart(CefBrowser browser, CefFrame frame, CefTransitionType transitionType) { this._owner.OnLoadStart(frame); }
/// <summary> /// Executed when a new query is received. |query_id| uniquely identifies the /// query for the life span of the router. Return true to handle the query /// or false to propagate the query to other registered handlers, if any. If /// no handlers return true from this method then the query will be /// automatically canceled with an error code of -1 delivered to the /// JavaScript onFailure callback. If this method returns true then a /// Callback method must be executed either in this method or asynchronously /// to complete the query. /// </summary> public virtual bool OnQuery(CefBrowser browser, CefFrame frame, long queryId, string request, bool persistent, Callback callback) { return(false); }
protected override void OnAddressChange(CefBrowser browser, CefFrame frame, string url) { }
protected override void OnBeforeContextMenu(CefBrowser browser, CefFrame frame, CefContextMenuParams state, CefMenuModel model) { model.Clear(); }
public CustomCallbackHandler(CefBrowser browser, CefFrame frame) { Browser = browser; Frame = frame; }