예제 #1
0
        protected virtual bool OnNewWindowPolicyDecisionRequested(WebFrame frame, NetworkRequest request, WebNavigationAction action, WebPolicyDecision decision)
        {
            var val        = new Value(GType.Int);
            var valueArray = new ValueArray(5u);
            var array      = new Value[5];

            array [0] = new Value(this);
            valueArray.Append(array [0]);
            array [1] = new Value(frame);
            valueArray.Append(array [1]);
            array [2] = new Value(request);
            valueArray.Append(array [2]);
            array [3] = new Value(action);
            valueArray.Append(array [3]);
            array [4] = new Value(decision);
            valueArray.Append(array [4]);
            GLib.Object.g_signal_chain_from_overridden(valueArray.ArrayPtr, ref val);
            var array2 = array;

            for (int i = 0; i < array2.Length; i++)
            {
                var value = array2 [i];
                value.Dispose();
            }
            bool result = (bool)val;

            val.Dispose();
            return(result);
        }
            public override void FinishedLoad(WebKit.WebView sender, WebFrame forFrame)
            {
                Renderer._sentNavigating = false;

                if (Renderer.Control.IsLoading)
                {
                    return;
                }

                if (Renderer.Control.MainFrameUrl == $"file://{NSBundle.MainBundle.BundlePath}/")
                {
                    return;
                }

                Renderer._ignoreSourceChanges = true;
                Renderer.Element?.SetValueFromRenderer(WebView.SourceProperty, new UrlWebViewSource {
                    Url = Renderer.Control.MainFrameUrl
                });
                Renderer._ignoreSourceChanges = false;

                Renderer._lastEvent = Renderer._lastBackForwardEvent;
                Renderer.Element?.SendNavigated(new WebNavigatedEventArgs(Renderer._lastEvent, Renderer.Element?.Source, Renderer.Control.MainFrameUrl, WebNavigationResult.Success));

                Renderer.UpdateCanGoBackForward();
            }
예제 #3
0
        public void FinishedLoad(WebView sender, WebFrame forFrame)
        {
            Window.Title = _webView.MainFrameTitle ?? "Sign in";

            _progressIndicator.Hidden = true;
            _progressIndicator.StopAnimation(null);
        }
예제 #4
0
        private void CreateWebView()
        {
            webview                   = new WebView();
            webview.Editable          = false;
            webview.TitleChanged     += new TitleChangedHandler(OnTitleChanged);
            webview.HoveringOverLink += new HoveringOverLinkHandler(OnHoveringOverLink);

            webview.LoadStatusChanged += delegate {
/*
 *                              Console.WriteLine (webview.LoadStatus);
 *                              IntPtr raw_ret = webkit_web_view_get_main_frame(webview.Handle);
 *                              Console.WriteLine ("0x{0:x}", (int)raw_ret);
 *                              GLib.ObjectManager.RegisterType (raw_ret, typeof (WebKit.WebFrame));
 *                              WebKit.WebFrame ret = GLib.Object.GetObject(raw_ret) as WebKit.WebFrame;
 *                              Console.WriteLine (ret);
 */

                Console.WriteLine(webview.LoadStatus);
                WebFrame frame = webview.MainFrame;
                Console.WriteLine(frame);
                if (frame != null)
                {
                    Console.WriteLine(frame.Uri);
                }
//				if (webview.LoadStatus == LoadStatus.committed) {
                if (frame != null && !String.IsNullOrEmpty(frame.Uri))
                {
                    uri_entry.Text = frame.Uri;
                }
//				}
            };
        }
예제 #5
0
 public override void DecidePolicyForNavigation(WebView web_view, NSDictionary action_info,
                                                NSUrlRequest request, WebFrame frame, NSObject decision_token)
 {
     if (LinkClicked != null)
     {
         LinkClicked(request.Url.ToString());
     }
 }
예제 #6
0
 public void StartedProvisionalLoad(WebView sender, WebFrame forFrame)
 {
     Console.WriteLine("Load Started:");
     InvokeOnMainThread(() => {
         progress = 0;
         progressBar.DoubleValue = progress;
     });
 }
예제 #7
0
 public void FinishedLoad(WebView sender, WebFrame forFrame)
 {
     Console.WriteLine("Load Finished");
     InvokeOnMainThread(() => {
         progress = 100;
         progressBar.DoubleValue = progress;
     });
 }
예제 #8
0
 public void FailedLoadWithError(WebView sender, NSError error, WebFrame forFrame)
 {
     // Ignore the ""NSURLErrorDomain -999" authentication error with Instagram. Issue #98.
     if (error.Code != -999)
     {
         Authenticator.OnError(error.LocalizedDescription);
     }
 }
예제 #9
0
        public override void DecidePolicyForNavigation(WebView web_view, NSDictionary action_info,
                                                       NSUrlRequest request, WebFrame frame, NSObject decision_token)
        {
            string file_path = request.Url.ToString();

            file_path = file_path.Replace("%20", " ");

            NSWorkspace.SharedWorkspace.OpenFile(file_path);
        }
예제 #10
0
        public void WebFrameConstructor()
        {
            tlog.Debug(tag, $"WebFrameConstructor START");

            using (Tizen.NUI.BaseComponents.WebView webview = new Tizen.NUI.BaseComponents.WebView("Shanghai", "Asia/Shanghai"))
            {
                var testingTarget = new WebFrame(webview.SwigCPtr.Handle, false);
                Assert.IsNotNull(testingTarget, "null handle");
                Assert.IsInstanceOf <WebFrame>(testingTarget, "Should return WebFrame instance.");

                testingTarget.Dispose();
            }

            tlog.Debug(tag, $"WebFrameConstructor END (OK)");
        }
예제 #11
0
        public void FinishedLoad(WebView sender, WebFrame forFrame)
        {
            var url = sender.MainFrameUrl;

            if (!Authenticator.HasCompleted)
            {
                Uri uri;
                if (Uri.TryCreate(url, UriKind.Absolute, out uri))
                {
                    if (Authenticator.CheckUrl(uri, GetCookies(url)))
                    {
                        return;
                    }
                }
            }
        }
예제 #12
0
        public void FinishedLoad(WebView sender, WebFrame frame)
        {
            if (!loadingNewPlayer)
            {
                Console.WriteLine("Frame loaded!!!");
                var playerScriptPath = NSBundle.MainBundle.PathForResource("YoutubePlayer", "js");
                var playerScript     = NSData.FromFile(playerScriptPath).ToString(NSStringEncoding.UTF8).ToString();

                webView.Preferences.JavaScriptEnabled = true;
                sender.WindowScriptObject.EvaluateWebScript(playerScript.Replace("{{videoId}}", currentTrack.Id));
                Play();
                loadingNewPlayer = true;
                return;
            }

            loadingNewPlayer = false;
        }
예제 #13
0
        public void FailedProvisionalLoad(WebView sender, NSError error, WebFrame forFrame)
        {
            var url = sender.MainFrameUrl;

            if (!Authenticator.HasCompleted)
            {
                Uri uri;
                if (Uri.TryCreate(url, UriKind.Absolute, out uri))
                {
                    if (Authenticator.CheckUrl(uri, GetCookies(url)))
                    {
                        forFrame.StopLoading();
                        return;
                    }
                }
            }
            Authenticator.OnError(error.LocalizedDescription);
        }
예제 #14
0
            public override void FinishedLoad(WebKit.WebView sender, WebFrame forFrame)
            {
                _renderer._sentNavigating = false;

                if (_renderer.Control.IsLoading)
                {
                    return;
                }

                _renderer._ignoreSourceChanges = true;
                _renderer.Element?.SetValueFromRenderer(WebView.SourceProperty, new UrlWebViewSource {
                    Url = _renderer.Control.MainFrameUrl
                });
                _renderer._ignoreSourceChanges = false;

                _renderer._lastEvent = _renderer._lastBackForwardEvent;
                _renderer.Element?.SendNavigated(new WebNavigatedEventArgs(_renderer._lastEvent, _renderer.Element?.Source, _renderer.Control.MainFrameUrl, WebNavigationResult.Success));

                _renderer.UpdateCanGoBackForward();
            }
예제 #15
0
        public void FailedProvisionalLoad(WebView sender, NSError error, WebFrame forFrame)
        {
            var url = sender.MainFrameUrl;

            if (!Authenticator.HasCompleted)
            {
                Uri uri;
                if (Uri.TryCreate(url, UriKind.Absolute, out uri))
                {
                    if (Authenticator.CheckUrl(uri, GetCookies(url)))
                    {
                        forFrame.StopLoading();
                        return;
                    }
                }
            }
            // Ignore the ""NSURLErrorDomain -999" authentication error with Dropbox. Issue #76.
            if (error.Code != -999)
            {
                Authenticator.OnError(error.LocalizedDescription);
            }
        }
            public override void FailedLoadWithError(WebKit.WebView sender, NSError error, WebFrame forFrame)
            {
                Renderer._sentNavigating = false;

                Renderer._lastEvent = Renderer._lastBackForwardEvent;

                Renderer.Element?.SendNavigated(new WebNavigatedEventArgs(Renderer._lastEvent, new UrlWebViewSource {
                    Url = Renderer.Control.MainFrameUrl
                }, Renderer.Control.MainFrameUrl, WebNavigationResult.Failure));

                Renderer.UpdateCanGoBackForward();
            }
예제 #17
0
        private T GetControlFromLocator <T>(Locator aLocator) where T : WebControl
        {
            WebControl aWebCustomControl = null;

            if (typeof(T) == typeof(WebButton))
            {
                aWebCustomControl = new WebButton(myBrowser, aLocator);
            }

            if (typeof(T) == typeof(WebEditBox))
            {
                aWebCustomControl = new WebEditBox(myBrowser, aLocator);
            }

            if (typeof(T) == typeof(WebCalender))
            {
                aWebCustomControl = new WebCalender(myBrowser, aLocator);
            }

            if (typeof(T) == typeof(WebCheckBox))
            {
                aWebCustomControl = new WebCheckBox(myBrowser, aLocator);
            }

            if (typeof(T) == typeof(WebComboBox))
            {
                aWebCustomControl = new WebComboBox(myBrowser, aLocator);
            }

            if (typeof(T) == typeof(WebDialog))
            {
                aWebCustomControl = new WebDialog(myBrowser, aLocator);
            }

            if (typeof(T) == typeof(WebFrame))
            {
                aWebCustomControl = new WebFrame(myBrowser, aLocator);
            }

            if (typeof(T) == typeof(WebImage))
            {
                aWebCustomControl = new WebImage(myBrowser, aLocator);
            }

            if (typeof(T) == typeof(WebLabel))
            {
                aWebCustomControl = new WebLabel(myBrowser, aLocator);
            }

            if (typeof(T) == typeof(WebLink))
            {
                aWebCustomControl = new WebLink(myBrowser, aLocator);
            }

            if (typeof(T) == typeof(WebListBox))
            {
                aWebCustomControl = new WebListBox(myBrowser, aLocator);
            }

            if (typeof(T) == typeof(WebPage))
            {
                aWebCustomControl = new WebPage(myBrowser, aLocator);
            }

            if (typeof(T) == typeof(WebRadioButton))
            {
                aWebCustomControl = new WebRadioButton(myBrowser, aLocator);
            }

            if (typeof(T) == typeof(WebSpanArea))
            {
                aWebCustomControl = new WebSpanArea(myBrowser, aLocator);
            }

            if (typeof(T) == typeof(WebTable))
            {
                aWebCustomControl = new WebTable(myBrowser, aLocator);
            }

            if (typeof(T) == typeof(WebControl))
            {
                aWebCustomControl = new WebControl(myBrowser, aLocator);
            }

            if (null == aWebCustomControl)
            {
                aWebCustomControl = new WebControl(myBrowser, aLocator);
            }

            if (aWebCustomControl.IsControlPresent())
            {
                aWebCustomControl.GetControl();
            }

            return((T)aWebCustomControl);
        }
 public override void DecidePolicyForNavigation(WebView webView, NSDictionary actionInformation, NSUrlRequest request, WebFrame frame, NSObject decisionToken)
 {
     NSApplication.SharedApplication.InvokeOnMainThread(() => {
         if (tipWindow.HandleUrlOpen != null && tipWindow.HandleUrlOpen(new Uri(request.Url.AbsoluteString)))
         {
             WebView.DecideIgnore(decisionToken);
         }
         else
         {
             WebView.DecideUse(decisionToken);
         }
     });
 }
예제 #19
0
 internal JSStub(WebFrame frame, string name)
 {
     this.frame = frame;
     this.name  = name;
 }
예제 #20
0
        public void DecidePolicyForNavigation(WebView webView, NSDictionary actionInformation, NSUrlRequest request, WebFrame frame, NSObject decisionToken)
        {
            if (request == null)
            {
                WebView.DecideUse(decisionToken);
                return;
            }

            string requestUrlString = request.Url.ToString();

            if (requestUrlString.StartsWith(BrokerConstants.BrowserExtPrefix, StringComparison.OrdinalIgnoreCase))
            {
                var result = new AuthorizationResult(AuthorizationStatus.ProtocolError)
                {
                    Error            = "Unsupported request",
                    ErrorDescription = "Server is redirecting client to browser. This behavior is not yet defined on Mac OS X."
                };
                _callbackMethod(result);
                WebView.DecideIgnore(decisionToken);
                Close();
                return;
            }

            if (requestUrlString.ToLower(CultureInfo.InvariantCulture).StartsWith(_callback.ToLower(CultureInfo.InvariantCulture), StringComparison.OrdinalIgnoreCase) ||
                requestUrlString.StartsWith(BrokerConstants.BrowserExtInstallPrefix, StringComparison.OrdinalIgnoreCase))
            {
                _callbackMethod(new AuthorizationResult(AuthorizationStatus.Success, request.Url.ToString()));
                WebView.DecideIgnore(decisionToken);
                Close();
                return;
            }

            if (requestUrlString.StartsWith(BrokerConstants.DeviceAuthChallengeRedirect, StringComparison.CurrentCultureIgnoreCase))
            {
                var    uri   = new Uri(requestUrlString);
                string query = uri.Query;
                if (query.StartsWith("?", StringComparison.OrdinalIgnoreCase))
                {
                    query = query.Substring(1);
                }

                Dictionary <string, string> keyPair = CoreHelpers.ParseKeyValueList(query, '&', true, false, null);
                string responseHeader = DeviceAuthHelper.CreateDeviceAuthChallengeResponseAsync(keyPair).Result;

                var newRequest = (NSMutableUrlRequest)request.MutableCopy();
                newRequest.Url = new NSUrl(keyPair["SubmitUrl"]);
                newRequest[BrokerConstants.ChallengeResponseHeader] = responseHeader;
                webView.MainFrame.LoadRequest(newRequest);
                WebView.DecideIgnore(decisionToken);
                return;
            }

            if (!request.Url.AbsoluteString.Equals("about:blank", StringComparison.CurrentCultureIgnoreCase) &&
                !request.Url.Scheme.Equals("https", StringComparison.CurrentCultureIgnoreCase))
            {
                var result = new AuthorizationResult(AuthorizationStatus.ErrorHttp);
                result.Error            = AuthError.NonHttpsRedirectNotSupported;
                result.ErrorDescription = AuthErrorMessage.NonHttpsRedirectNotSupported;
                _callbackMethod(result);
                WebView.DecideIgnore(decisionToken);
                Close();
            }

            WebView.DecideUse(decisionToken);
        }
예제 #21
0
 public override void DecidePolicyForNavigation(WebView web_view, NSDictionary action_info,
                                                NSUrlRequest request, WebFrame frame, NSObject decision_token)
 {
     SparkleEventLogController.LinkClicked(request.Url.ToString());
 }
예제 #22
0
 private void WebViewDidReceiveTitleForFrame(WebView sender, NSString title, WebFrame frame)
 {
     this.window.Title = title;
 }
예제 #23
0
 public void FailedLoadWithError(WebView sender, NSError error, WebFrame forFrame)
 {
     Console.WriteLine("Load Failed: {0}", error.Description);
 }
예제 #24
0
 private void WebViewDidStartProvisionalLoadForFrame(WebView sender, WebFrame frame)
 {
     this.indicator.IsHidden = false;
     this.indicator.StartAnimation(null);
 }
예제 #25
0
        internal static WebControl GetWebControlFromIContol(IControl aControl, Browser aBrowser, Locator aLocator, ControlType aConrolType)
        {
            WebControl aWebControl = null;

            if (aConrolType == ControlType.Button)
            {
                WebButton aWebButton = new WebButton(aBrowser, aLocator);
                aWebButton.Control = aControl;
                aWebControl        = aWebButton;
            }

            if (aConrolType == ControlType.EditBox)
            {
                WebEditBox aWebEditBox = new WebEditBox(aBrowser, aLocator);
                aWebEditBox.Control = aControl;
                aWebControl         = aWebEditBox;
            }

            if (aConrolType == ControlType.Custom)
            {
                aWebControl         = new WebControl(aBrowser, aLocator);
                aWebControl.Control = aControl;
                //aWebControl = aWebEditBox;
            }
            if (aConrolType == ControlType.Calender)
            {
                WebCalender aWebCalender = new WebCalender(aBrowser, aLocator);
                aWebCalender.Control = aControl;
                aWebControl          = aWebCalender;
            }

            if (aConrolType == ControlType.ComboBox)
            {
                WebComboBox aWebComboBox = new WebComboBox(aBrowser, aLocator);
                aWebComboBox.Control = aControl;
                aWebControl          = aWebComboBox;
            }

            if (aConrolType == ControlType.CheckBox)
            {
                WebCheckBox aWebCheckBox = new WebCheckBox(aBrowser, aLocator);
                aWebCheckBox.Control = aControl;
                aWebControl          = aWebCheckBox;
            }

            if (aConrolType == ControlType.Dialog)
            {
                WebDialog aWebDialog = new WebDialog(aBrowser, aLocator);
                aWebDialog.Control = aControl;
                aWebControl        = aWebDialog;
            }

            if (aConrolType == ControlType.Frame)
            {
                WebFrame aWebFrame = new WebFrame(aBrowser, aLocator);
                aWebFrame.Control = aControl;
                aWebControl       = aWebFrame;
            }

            if (aConrolType == ControlType.Image)
            {
                WebImage aWebImage = new WebImage(aBrowser, aLocator);
                aWebImage.Control = aControl;
                aWebControl       = aWebImage;
            }

            if (aConrolType == ControlType.Label)
            {
                WebLabel aWebLabel = new WebLabel(aBrowser, aLocator);
                aWebLabel.Control = aControl;
                aWebControl       = aWebLabel;
            }

            if (aConrolType == ControlType.Link)
            {
                WebLink aWebLink = new WebLink(aBrowser, aLocator);
                aWebLink.Control = aControl;
                aWebControl      = aWebLink;
            }

            if (aConrolType == ControlType.ListBox)
            {
                WebListBox aWebListBox = new WebListBox(aBrowser, aLocator);
                aWebListBox.Control = aControl;
                aWebControl         = aWebListBox;
            }

            if (aConrolType == ControlType.Page)
            {
                WebPage aWebPage = new WebPage(aBrowser, aLocator);
                aWebPage.Control = aControl;
                aWebControl      = aWebPage;
            }

            if (aConrolType == ControlType.RadioButton)
            {
                WebRadioButton aWebRadioButton = new WebRadioButton(aBrowser, aLocator);
                aWebRadioButton.Control = aControl;
                aWebControl             = aWebRadioButton;
            }

            if (aConrolType == ControlType.SpanArea)
            {
                WebSpanArea aWebSpanArea = new WebSpanArea(aBrowser, aLocator);
                aWebSpanArea.Control = aControl;
                aWebControl          = aWebSpanArea;
            }

            if (aConrolType == ControlType.WebTable)
            {
                WebTable aWebTable = new WebTable(aBrowser, aLocator);
                aWebTable.Control = aControl;
                aWebControl       = aWebTable;
            }

            if (aConrolType == ControlType.WebRow)
            {
                WebRow aWebRow = new WebRow(aBrowser, aLocator);
                aWebRow.Control = aControl;
                aWebControl     = aWebRow;
            }

            if (aConrolType == ControlType.WebCell)
            {
                WebCell aWebCell = new WebCell(aBrowser, aLocator);
                aWebCell.Control = aControl;
                aWebControl      = aWebCell;
            }


            return(aWebControl);
        }
예제 #26
0
 // Ref: http://www.c-sharpcorner.com/UploadFile/mahesh/using-xaml-frame-in-wpf857/
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     // Can raise an exception, hanlded in dispatcher
     WebFrame.Navigate(new System.Uri("http://www.totalimagine.com/Service/MyCourse/", UriKind.Absolute));
 }
예제 #27
0
            public override void DecidePolicyForNavigation(
                WebView webView,
                NSDictionary actionInformation,
                NSUrlRequest request,
                WebFrame frame,
                NSObject decisionToken)
            {
                if (!initialNavigationPerformed)
                {
                    WebView.DecideUse(decisionToken);
                    initialNavigationPerformed = true;
                    return;
                }

                var originalRequestUrl = (NSUrl)actionInformation [WebActionOriginalUrlKey];

                if (originalRequestUrl.Scheme == "data")
                {
                    WebView.DecideUse(decisionToken);
                    return;
                }

                // Let iframes do their own navigation handling.
                if (frame != webView.MainFrame)
                {
                    if (originalRequestUrl.Scheme == "about")
                    {
                        WebView.DecideUse(decisionToken);
                    }
                    else
                    {
                        NSWorkspace.SharedWorkspace.OpenUrl(originalRequestUrl);
                        WebView.DecideIgnore(decisionToken);
                    }
                    return;
                }

                if (ScrollToElementWithId(webView, request.Url.Fragment))
                {
                    WebView.DecideIgnore(decisionToken);
                    return;
                }

                NSUrl workspaceUrl = null;

                try {
                    var resourceAction = ClientApp
                                         .SharedInstance
                                         .WebServer
                                         .TryGetLocalResourcePath(
                        originalRequestUrl,
                        out var localPath);

                    switch (resourceAction)
                    {
                    case ClientWebServer.ResourceAction.WorkbookResource:
                        workspaceUrl = NSUrl.FromFilename(localPath);
                        break;

                    case ClientWebServer.ResourceAction.ExternalResource:
                        workspaceUrl = originalRequestUrl;
                        break;
                    }
                } catch {
                    workspaceUrl = originalRequestUrl;
                }

                if (workspaceUrl != null)
                {
                    NSWorkspace.SharedWorkspace.OpenUrl(workspaceUrl);
                }

                WebView.DecideIgnore(decisionToken);
            }
예제 #28
0
            public override void DecidePolicyForNavigation(WebView webView, NSDictionary actionInformation, NSUrlRequest request, WebFrame frame, NSObject decisionToken)
            {
                switch ((WebNavigationType)((NSNumber)actionInformation [WebPolicyDelegate.WebActionNavigationTypeKey]).Int32Value)
                {
                case WebNavigationType.BackForward:
                case WebNavigationType.FormResubmitted:
                case WebNavigationType.FormSubmitted:
                    WebPolicyDelegate.DecideIgnore(decisionToken);
                    break;

                case WebNavigationType.LinkClicked:
                    NSWorkspace.SharedWorkspace.OpenUrl(actionInformation[WebPolicyDelegate.WebActionOriginalUrlKey] as NSUrl);
                    WebPolicyDelegate.DecideIgnore(decisionToken);
                    break;

                case WebNavigationType.Other:
                case WebNavigationType.Reload:
                    WebPolicyDelegate.DecideUse(decisionToken);
                    break;
                }
            }
 public override void FailedProvisionalLoad(WebKit.WebView sender, NSError error, WebFrame forFrame)
 {
     FailedLoadWithError(sender, error, forFrame);
 }
 public override void FinishedLoad(WebView sender, WebFrame forFrame)
 {
     viewController.LoadFinished("FinishedLoad");
 }
예제 #31
0
 public void FailedLoadWithError(WebView sender, NSError error, WebFrame forFrame)
 {
     Authenticator.OnError(error.LocalizedDescription);
 }
예제 #32
0
 public override void FinishedLoad(WebView sender, WebFrame forFrame)
 {
     document.ReloadDocument();
 }
예제 #33
0
 private void WebViewDidFinishLoadForFrame(WebView sender, WebFrame frame)
 {
     this.indicator.StopAnimation(null);
     this.indicator.IsHidden = true;
 }