Inheritance: IWebUIDelegate, IWebUIDelegatePrivate, IWebUIDelegatePrivate2, IWebUIDelegatePrivate3, IWebUIDelegatePrivate4
Esempio n. 1
0
        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();
        }
Esempio n. 2
0
        public WebKitControl(Size size)
        {
            _activationContext    = new ActivationContextHelper();
            _webPolicyDelegate    = new WebPolicyDelegate();
            _webFrameLoadDelegate = new WebFrameLoadDelegate();
            _webUIDelegate        = new WebUIDelegate();
            _webDownloadDelegate  = new WebDownloadDelegate();

            _webFrameLoadDelegate.WebFrameLoaded = this.NavigationComplete;

            Application.OleRequired(); // Required otherwise WebKit will throw an OutOfMemoryException

            _activationContext.Activate();
            _webView = new WebViewClass();
            _activationContext.Deactivate();

            this.Width  = size.Width;
            this.Height = size.Height;
            this.Load  += OnLoad;
        }
Esempio n. 3
0
        private void InitializeWebKit()
        {
            activationContext.Activate();

            resourceIntercepter = new ResourcesIntercepter(this);
            Marshal.AddRef(Marshal.GetIUnknownForObject(resourceIntercepter));

            frameLoadDelegate = new WebFrameLoadDelegate();
            Marshal.AddRef(Marshal.GetIUnknownForObject(frameLoadDelegate));
            
            downloadDelegate = new WebDownloadDelegate(this);
            Marshal.AddRef(Marshal.GetIUnknownForObject(downloadDelegate));
            
            uiDelegate = new WebUIDelegate(this);
            Marshal.AddRef(Marshal.GetIUnknownForObject(uiDelegate));

            resourcesLoadDelegate = new WebResourceLoadDelegate(this);
            Marshal.AddRef(Marshal.GetIUnknownForObject(resourcesLoadDelegate));
            
            //editingDelegate = new WebEditingDelegate(this);
            //Marshal.AddRef(Marshal.GetIUnknownForObject(editingDelegate));
            // not used (yet)

            policyDelegate = new WebPolicyDelegate(AllowNavigation, AllowDownloads, AllowNewWindows, this);
            Marshal.AddRef(Marshal.GetIUnknownForObject(policyDelegate));

            formDelegate = new WebFormDelegate(this);
            Marshal.AddRef(Marshal.GetIUnknownForObject(formDelegate));

            center = new WebNotificationCenter();
            Marshal.AddRef(Marshal.GetIUnknownForObject(center));

            cssmanager = new WebKitDOMCSSManager(this);
            Marshal.AddRef(Marshal.GetIUnknownForObject(cssmanager));

            undoManager = new CustomUndoSystem(this);

            appearance = new AppearanceSettings(this);

            observer = new WebNotificationObserver();

            webView.setHostWindow(this.Handle.ToInt32());
            ((WebViewClass)webView).setPolicyDelegate(policyDelegate);
            webView.setFrameLoadDelegate(frameLoadDelegate);
            webView.setResourceLoadDelegate(resourcesLoadDelegate);
            webView.setDownloadDelegate(downloadDelegate);
            webView.setUIDelegate(uiDelegate);

            tagRECT rect = new tagRECT();
            rect.top = rect.left = 0;
            rect.bottom = this.Height - 1;
            rect.right = this.Width - 1;
            webView.initWithFrame(rect, null, null);

            IWebViewPrivate webViewPrivate = (IWebViewPrivate)webView;
            webViewHWND = (IntPtr)webViewPrivate.viewWindow();

            webViewPrivate.setFormDelegate(formDelegate);

            // Subscribe to FrameLoadDelegate events
            ((WebFrameLoadDelegate)frameLoadDelegate).DidRecieveTitle += new DidRecieveTitleEvent(frameLoadDelegate_DidRecieveTitle);
            ((WebFrameLoadDelegate)frameLoadDelegate).DidFinishLoadForFrame += new DidFinishLoadForFrameEvent(frameLoadDelegate_DidFinishLoadForFrame);
            ((WebFrameLoadDelegate)frameLoadDelegate).DidStartProvisionalLoadForFrame += new DidStartProvisionalLoadForFrameEvent(frameLoadDelegate_DidStartProvisionalLoadForFrame);
            ((WebFrameLoadDelegate)frameLoadDelegate).DidCommitLoadForFrame += new DidCommitLoadForFrameEvent(frameLoadDelegate_DidCommitLoadForFrame);
            ((WebFrameLoadDelegate)frameLoadDelegate).DidFailLoadWithError += new DidFailLoadWithErrorEvent(frameLoadDelegate_DidFailLoadWithError);
            ((WebFrameLoadDelegate)frameLoadDelegate).DidFailProvisionalLoadWithError += new DidFailProvisionalLoadWithErrorEvent(frameLoadDelegate_DidFailProvisionalLoadWithError);
 #if DEBUG || RELEASE
            ((WebFrameLoadDelegate)frameLoadDelegate).WindowScriptObjectAvailable += new WindowScriptObjectAvailableEvent(WebKitBrowser_WindowScriptObjectAvailable);
            ((WebFrameLoadDelegate)frameLoadDelegate).DidClearWindowObject += new DidClearWindowObjectEvent(WebKitBrowser_DidClearWindowObject);
#endif
            // DownloadDelegate events            
            
            downloadDelegate.DecideDestinationWithSuggestedFilename += new DecideDestinationWithSuggestedFilenameEvent(downloadDelegate_DecideDestinationWithSuggestedFilename);
            downloadDelegate.DidBegin += new DidBeginEvent(downloadDelegate_DidBegin);

            
            // UIDelegate events
            uiDelegate.CreateWebViewWithRequest += new CreateWebViewWithRequestEvent(uiDelegate_CreateWebViewWithRequest);
            uiDelegate.CloseWindowRequest += new CloseWindowRequest(uiDelegate_CloseWindowRequest);
            uiDelegate.StatusTextChanged += new StatusTextChangedEvent(uiDelegate_StatusTextChanged);
            uiDelegate.RunJavaScriptAlertPanelWithMessage += new RunJavaScriptAlertPanelWithMessageEvent(uiDelegate_RunJavaScriptAlertPanelWithMessage);
            uiDelegate.RunJavaScriptConfirmPanelWithMessage += new RunJavaScriptConfirmPanelWithMessageEvent(uiDelegate_RunJavaScriptConfirmPanelWithMessage);
            uiDelegate.RunJavaScriptTextInputPanelWithPrompt += new RunJavaScriptTextInputPanelWithPromptEvent(uiDelegate_RunJavaScriptTextInputPanelWithPrompt);
            uiDelegate.RunJavaScriptPromptBeforeUnload += new RunJavaScriptPromptBeforeUnload(uiDelegate_RunJavaScriptPromptBeforeUnload);
            uiDelegate.MouseDidMoveOverElement += new MouseDidMoveOverElement(uiDelegate_UpdateCurrentElement);
            uiDelegate.GeolocationReq += new AllowGeolocationRequest(uiDelegate_GeolocationReq);
            // FormDelegate Events
            formDelegate.SubmitForm += new SubmitForm(formDelegate_SubmitForm);
            formDelegate.TextChangedInArea += new TextChangedInArea(formDelegate_TextChangedInArea);
            formDelegate.TextChangedInField += new TextChangedInField(formDelegate_TextChangedInField);
            formDelegate.TextFieldBeginEditing += new TextFieldBeginEditing(formDelegate_TextFieldBeginEditing);
            formDelegate.TextFieldEndEditing += new TextFieldEndEditing(formDelegate_TextFieldEndEditing);
            
            // ResourcesLoadDelegate
            resourcesLoadDelegate.PluginFailed += new PluginFailedWithError(resourcesLoadDelegate_PluginFailed);
            resourcesLoadDelegate.ResourceLoaded += new ResourceFinishedLoading(resourcesLoadDelegate_ResourceLoaded);
            resourcesLoadDelegate.ResourceLoading += new ResourceStartedLoading(resourcesLoadDelegate_ResourceLoading);
            resourcesLoadDelegate.ResourceSizeAvailable += new ResourceSizeAvailableEventHandler(resourcesLoadDelegate_ResourceProgress);
            resourcesLoadDelegate.ResourceRequestSent += new ResourceRequest(resourcesLoadDelegate_ResourceRequestSent);
            resourcesLoadDelegate.ResourceFailedLoading += new ResourceFailed(resourcesLoadDelegate_ResourceFailedLoading);
            
            progs = new WebNotificationObserver();
            progf = new WebNotificationObserver();

            policyDelegate.NewWindowRequestUrlAvailable += new WebKit.NewWindowRequest(policyDelegate_NewWindowRequestUrlAvailable);

            ApplicationName = GlobalPreferences.ApplicationName;

            center.defaultCenter().addObserver(observer, "WebProgressEstimateChangedNotification", webView);            
            observer.OnNotify += new OnNotifyEvent(observer_OnNotify);

            center.defaultCenter().addObserver(progs, "WebViewProgressStartedNotification", webView);
            progs.OnNotify += new OnNotifyEvent(progs_OnNotify);
            
            center.defaultCenter().addObserver(progf, "WebViewProgressFinishedNotification", webView);
            progf.OnNotify += new OnNotifyEvent(progf_OnNotify);
            
            //WebView.preferences().setEditingBehavior(WebKitEditingBehavior.WebKitEditingWinBehavior);
            ((IWebPreferencesPrivate)WebView.preferences()).setDeveloperExtrasEnabled(1);
#if DEBUG || RELEASE
            m = new JSManagement(this);
#endif
            activationContext.Deactivate();
        }
Esempio n. 4
0
        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));

            webNotificationCenter = new WebNotificationCenter();
            Marshal.AddRef(Marshal.GetIUnknownForObject(webNotificationCenter)); // TODO: find out if this is really needed
            webNotificationObserver = new WebNotificationObserver();
            webNotificationCenter.defaultCenter().addObserver(webNotificationObserver, "WebProgressEstimateChangedNotification", webView);
            webNotificationCenter.defaultCenter().addObserver(webNotificationObserver, "WebProgressStartedNotification", webView);
            webNotificationCenter.defaultCenter().addObserver(webNotificationObserver, "WebProgressFinishedNotification", webView);

            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);

            // Notification events
            webNotificationObserver.OnNotify += new OnNotifyEvent(webNotificationObserver_OnNotify);

            activationContext.Deactivate();
        }
        private void InitializeWebKit()
        {
            activationContext.Activate();

            resourceLoadDelegate = new WebResourceLoadDelegate();
            Marshal.AddRef(Marshal.GetIUnknownForObject(resourceLoadDelegate));

            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.Handle.ToInt32());

            tagRECT rect = new tagRECT();
            rect.top = rect.left = 0;
            rect.bottom = this.Height - 1;
            rect.right = this.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);

            // 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);

            activationContext.Deactivate();
        }