Exemplo n.º 1
0
        public void SetMessagingEnabled(WebView view, bool messagingEnabled)
        {
            var webViewData = GetWebViewData(view);

            if (messagingEnabled)
            {
                var bridge = new WebViewBridge(view.GetTag());
                bridge.MessagePosted += OnMessagePosted;
                webViewData.Bridge    = bridge;
            }
            else if (webViewData.Bridge != null)
            {
                webViewData.Bridge.MessagePosted -= OnMessagePosted;
                webViewData.Bridge = null;
            }
        }
        public void SetMessagingEnabled(WebBrowser view, bool messagingEnabled)
        {
            var webViewData = GetWebViewData(view);

            if (messagingEnabled)
            {
                var bridge = new WebViewBridge(view.GetTag());
                bridge.MessagePosted += OnMessagePosted;
                webViewData.Bridge    = bridge;

                view.ObjectForScripting = webViewData.Bridge;
            }
            else if (webViewData.Bridge != null)
            {
                webViewData.Bridge.MessagePosted -= OnMessagePosted;
                webViewData.Bridge = null;

                view.ObjectForScripting = null;
            }
            else
            {
                view.ObjectForScripting = null;
            }
        }