Skip to content

Commit

Permalink
[MAC] fix url handling for OnNavigateToUrl
Browse files Browse the repository at this point in the history
  • Loading branch information
sevoku committed Jun 10, 2014
1 parent 93b1d3c commit 858c710
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
4 changes: 2 additions & 2 deletions TestApps/Samples/Samples/WebViewSample.cs
Expand Up @@ -94,9 +94,9 @@ public WebViewSample ()
forward.Sensitive = wb.CanGoForward;
};
wb.NavigateToUrl += delegate(object sender, NavigateToUrlEventArgs e) {
if (e.Uri.Host == "www.facebook.com") {
if (e.Uri.Host.EndsWith("facebook.com")) {
e.SetHandled ();
MessageDialog.ShowMessage ("Loading www.facebook.com overriden");
MessageDialog.ShowMessage ("Loading *.facebook.com overriden");
}
else {
}
Expand Down
6 changes: 4 additions & 2 deletions Xwt.Gtk.Mac/WebViewBackend.cs
Expand Up @@ -138,8 +138,10 @@ public override void DisableEvent (object eventId)
void HandleStartedProvisionalLoad (object sender, MonoMac.WebKit.WebFrameEventArgs e)
{
var url = String.Empty;
if (e.ForFrame.DataSource.Request.MainDocumentURL != null)
e.ForFrame.DataSource.Request.MainDocumentURL.ToString ();
if (e.ForFrame.ProvisionalDataSource.Request.MainDocumentURL != null)
url = e.ForFrame.ProvisionalDataSource.Request.MainDocumentURL.ToString ();
if (String.IsNullOrEmpty (url))
return;

bool cancel = false;
ApplicationContext.InvokeUserCode (delegate {
Expand Down
6 changes: 4 additions & 2 deletions Xwt.Mac/Xwt.Mac/WebViewBackend.cs
Expand Up @@ -140,8 +140,10 @@ public override void DisableEvent (object eventId)
void HandleStartedProvisionalLoad (object sender, WebFrameEventArgs e)
{
var url = String.Empty;
if (e.ForFrame.DataSource.Request.MainDocumentURL != null)
e.ForFrame.DataSource.Request.MainDocumentURL.ToString ();
if (e.ForFrame.ProvisionalDataSource.Request.MainDocumentURL != null)
url = e.ForFrame.ProvisionalDataSource.Request.MainDocumentURL.ToString ();
if (String.IsNullOrEmpty (url))
return;

bool cancel = false;
ApplicationContext.InvokeUserCode (delegate {
Expand Down
2 changes: 1 addition & 1 deletion Xwt/Xwt/WebView.cs
Expand Up @@ -45,7 +45,7 @@ protected new class WidgetBackendHost : Widget.WidgetBackendHost, IWebViewEventS
{
public bool OnNavigateToUrl (string url)
{
var args = new NavigateToUrlEventArgs (new Uri(url));
var args = new NavigateToUrlEventArgs (new Uri(url, UriKind.RelativeOrAbsolute));
((WebView)Parent).OnNavigateToUrl (args);
return args.Handled;
}
Expand Down

0 comments on commit 858c710

Please sign in to comment.