cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From purplecabb...@apache.org
Subject [1/2] git commit: CB-6474 InAppBrowser. Add data urls support to WP8
Date Tue, 22 Apr 2014 00:59:00 GMT
Repository: cordova-plugin-inappbrowser
Updated Branches:
  refs/heads/dev 907bba6cf -> e2a0bb871


CB-6474 InAppBrowser. Add data urls support to WP8


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/commit/8f2ad211
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/tree/8f2ad211
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/diff/8f2ad211

Branch: refs/heads/dev
Commit: 8f2ad211ad60a10d7234124ff3c815e6a3b70ff1
Parents: e282cc9
Author: sgrebnov <v-segreb@microsoft.com>
Authored: Fri Apr 18 10:47:20 2014 -0700
Committer: sgrebnov <v-segreb@microsoft.com>
Committed: Fri Apr 18 10:47:20 2014 -0700

----------------------------------------------------------------------
 src/wp/InAppBrowser.cs | 31 ++++++++++++++++++++++++++++---
 1 file changed, 28 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser/blob/8f2ad211/src/wp/InAppBrowser.cs
----------------------------------------------------------------------
diff --git a/src/wp/InAppBrowser.cs b/src/wp/InAppBrowser.cs
index 454464d..844ae16 100644
--- a/src/wp/InAppBrowser.cs
+++ b/src/wp/InAppBrowser.cs
@@ -200,7 +200,7 @@ namespace WPCordovaClassLib.Cordova.Commands
                         if (cView != null)
                         {
                             WebBrowser br = cView.Browser;
-                            br.Navigate(loc);
+                            br.Navigate2(loc);
                         }
                     }
 
@@ -225,7 +225,7 @@ namespace WPCordovaClassLib.Cordova.Commands
                 if (browser != null)
                 {
                     //browser.IsGeolocationEnabled = opts.isGeolocationEnabled;
-                    browser.Navigate(loc);
+                    browser.Navigate2(loc);
                 }
                 else
                 {
@@ -248,7 +248,7 @@ namespace WPCordovaClassLib.Cordova.Commands
                                 browser.Navigating += new EventHandler<NavigatingEventArgs>(browser_Navigating);
                                 browser.NavigationFailed += new System.Windows.Navigation.NavigationFailedEventHandler(browser_NavigationFailed);
                                 browser.Navigated += new EventHandler<System.Windows.Navigation.NavigationEventArgs>(browser_Navigated);
-                                browser.Navigate(loc);
+                                browser.Navigate2(loc);
 
                                 if (StartHidden)
                                 {
@@ -405,4 +405,29 @@ namespace WPCordovaClassLib.Cordova.Commands
         }
 
     }
+
+    internal static class WebBrowserExtensions
+    {
+        /// <summary>
+        /// Improved method to initiate request to the provided URI. Supports 'data:text/html'
urls. 
+        /// </summary>
+        /// <param name="browser">The browser instance</param>
+        /// <param name="uri">The requested uri</param>
+        internal static void Navigate2(this WebBrowser browser, Uri uri)
+        {
+            // IE10 does not support data uri so we use NavigateToString method instead
+            if (uri.Scheme == "data")
+            {
+                // we should remove the scheme identifier and unescape the uri
+                string uriString = Uri.UnescapeDataString(uri.AbsoluteUri);
+                // format is 'data:text/html, ...'
+                string html = new System.Text.RegularExpressions.Regex("^data:text/html,").Replace(uriString,
"");
+                browser.NavigateToString(html);
+            }
+            else 
+            {
+                browser.Navigate(uri);
+            }
+        }
+    }
 }


Mime
View raw message