/// <summary> /// Uses the devToolsWebContents as the target WebContents to show devtools. /// </summary> /// <param name="devToolsWebContents"></param> public void setDevToolsWebContents(WebContents devToolsWebContents) { string script = ScriptBuilder.Build( "{0}.setDevToolsWebContents({1});", Script.GetObject(API.id), Script.GetObject(devToolsWebContents.API.id) ); API.ExecuteJavaScript(script); }
/// <summary> /// Sets the handler which can be used to respond to permission requests for the session. /// Calling callback(true) will allow the permission and callback(false) will reject it. /// To clear the handler, call setPermissionRequestHandler(null). /// </summary> public void setPermissionRequestHandler(Action <WebContents, string, Action <bool>, JsonObject> handler) { string eventName = "_setPermissionRequestHandler"; CallbackItem item = null; item = API.CreateCallbackItem(eventName, (object[] args) => { WebContents webContents = API.CreateObject <WebContents>(args[0]); string permission = Convert.ToString(args[1]); JSObject _callback = API.CreateObject <JSObject>(args[2]); JsonObject details = new JsonObject(args[3]); Action <bool> callback = (permissionGranted) => { _callback?.API.Invoke(permissionGranted); }; handler?.Invoke(webContents, permission, callback, details); }); API.Apply("setPermissionRequestHandler", item); }
/// <summary> /// Returns BrowserView | null - The BrowserView that owns /// the given webContents or null if the contents are not owned by a BrowserView. /// </summary> /// <param name="webContents"></param> /// <returns></returns> public BrowserView fromWebContents(WebContents webContents) { return(API.ApplyAndGetObject <BrowserView>("fromWebContents", webContents)); }