private void InitializeWebKit() { activationContext.Activate(); frameLoadDelegate = new WebFrameLoadDelegate(); Marshal.AddRef(Marshal.GetIUnknownForObject(frameLoadDelegate)); downloadDelegate = new WebDownloadDelegate(); Marshal.AddRef(Marshal.GetIUnknownForObject(downloadDelegate)); policyDelegate = new WebPolicyDelegate(AllowNavigation, AllowDownloads, AllowNewWindows); Marshal.AddRef(Marshal.GetIUnknownForObject(policyDelegate)); uiDelegate = new WebUIDelegate(this); Marshal.AddRef(Marshal.GetIUnknownForObject(uiDelegate)); webView.setPolicyDelegate(policyDelegate); webView.setFrameLoadDelegate(frameLoadDelegate); webView.setDownloadDelegate(downloadDelegate); webView.setUIDelegate(uiDelegate); webView.setHostWindow(this.host.Handle.ToInt32()); tagRECT rect = new tagRECT(); rect.top = rect.left = 0; rect.bottom = this.host.Height - 1; rect.right = this.host.Width - 1; webView.initWithFrame(rect, null, null); IWebViewPrivate webViewPrivate = (IWebViewPrivate)webView; webViewHWND = (IntPtr)webViewPrivate.viewWindow(); // Subscribe to FrameLoadDelegate events frameLoadDelegate.DidRecieveTitle += new DidRecieveTitleEvent(frameLoadDelegate_DidRecieveTitle); frameLoadDelegate.DidFinishLoadForFrame += new DidFinishLoadForFrameEvent(frameLoadDelegate_DidFinishLoadForFrame); frameLoadDelegate.DidStartProvisionalLoadForFrame += new DidStartProvisionalLoadForFrameEvent(frameLoadDelegate_DidStartProvisionalLoadForFrame); frameLoadDelegate.DidCommitLoadForFrame += new DidCommitLoadForFrameEvent(frameLoadDelegate_DidCommitLoadForFrame); frameLoadDelegate.DidFailLoadWithError += new DidFailLoadWithErrorEvent(frameLoadDelegate_DidFailLoadWithError); frameLoadDelegate.DidFailProvisionalLoadWithError += new DidFailProvisionalLoadWithErrorEvent(frameLoadDelegate_DidFailProvisionalLoadWithError); frameLoadDelegate.DidClearWindowObject += new DidClearWindowObjectEvent(frameLoadDelegate_DidClearWindowObject); // DownloadDelegate events downloadDelegate.DidReceiveResponse += new DidReceiveResponseEvent(downloadDelegate_DidReceiveResponse); downloadDelegate.DidReceiveDataOfLength += new DidReceiveDataOfLengthEvent(downloadDelegate_DidReceiveDataOfLength); downloadDelegate.DecideDestinationWithSuggestedFilename += new DecideDestinationWithSuggestedFilenameEvent(downloadDelegate_DecideDestinationWithSuggestedFilename); downloadDelegate.DidBegin += new DidBeginEvent(downloadDelegate_DidBegin); downloadDelegate.DidFinish += new DidFinishEvent(downloadDelegate_DidFinish); downloadDelegate.DidFailWithError += new DidFailWithErrorEvent(downloadDelegate_DidFailWithError); // UIDelegate events uiDelegate.CreateWebViewWithRequest += new CreateWebViewWithRequestEvent(uiDelegate_CreateWebViewWithRequest); uiDelegate.RunJavaScriptAlertPanelWithMessage += new RunJavaScriptAlertPanelWithMessageEvent(uiDelegate_RunJavaScriptAlertPanelWithMessage); uiDelegate.RunJavaScriptConfirmPanelWithMessage += new RunJavaScriptConfirmPanelWithMessageEvent(uiDelegate_RunJavaScriptConfirmPanelWithMessage); uiDelegate.RunJavaScriptTextInputPanelWithPrompt += new RunJavaScriptTextInputPanelWithPromptEvent(uiDelegate_RunJavaScriptTextInputPanelWithPrompt); activationContext.Deactivate(); }
public void ShowInspector() { if (webView != null) { IWebViewPrivate v = (IWebViewPrivate)webView; v.inspector().attach(); v.inspector().show(); } }