From 5680f18bb4d28e6d6bc1a621e6588a010080c964 Mon Sep 17 00:00:00 2001 From: Andrew Grieve <agrieve@chromium.org> Date: Wed, 5 Mar 2014 14:38:13 -0500 Subject: [PATCH 01/26] Incremented plugin version on dev branch. --- plugin.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.xml b/plugin.xml index 932ff83..d0046fa 100644 --- a/plugin.xml +++ b/plugin.xml @@ -2,7 +2,7 @@ <plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" id="org.apache.cordova.inappbrowser" - version="0.3.3"> + version="0.3.4-dev"> <name>InAppBrowser</name> <description>Cordova InAppBrowser Plugin</description> From 7dbad601f0321095bfe06bdd91b5576dfe55e433 Mon Sep 17 00:00:00 2001 From: Andrew Grieve <agrieve@chromium.org> Date: Thu, 6 Mar 2014 20:48:00 -0500 Subject: [PATCH 02/26] Tweak RELEASENOTES.md (missed a bug fix in last release) --- RELEASENOTES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 2d40026..364f4e9 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -80,5 +80,6 @@ * Removed some iOS6 Deprecations ### 0.3.3 (Mar 5, 2014) +* CB-5534 Fix video/audio does not stop playing when browser is closed * CB-6172 Fix broken install on case-sensitive file-systems From aa9a5db9413ebaf3fec60e41b24591c64953b12a Mon Sep 17 00:00:00 2001 From: Bryan Higgins <bhiggins@blackberry.com> Date: Tue, 11 Mar 2014 12:22:17 -0400 Subject: [PATCH 03/26] CB-6218 Update docs for BB10 --- doc/index.md | 6 ------ 1 file changed, 6 deletions(-) diff --git a/doc/index.md b/doc/index.md index 61f702c..e82b29b 100644 --- a/doc/index.md +++ b/doc/index.md @@ -133,7 +133,6 @@ The object returned from a call to `window.open`. - Amazon Fire OS - Android -- BlackBerry 10 - iOS - Windows Phone 7 and 8 @@ -164,7 +163,6 @@ The function is passed an `InAppBrowserEvent` object. - Amazon Fire OS - Android -- BlackBerry 10 - iOS - Windows Phone 7 and 8 @@ -187,7 +185,6 @@ The function is passed an `InAppBrowserEvent` object. - Amazon Fire OS - Android -- BlackBerry 10 - iOS - Windows Phone 7 and 8 @@ -208,7 +205,6 @@ The function is passed an `InAppBrowserEvent` object. - Amazon Fire OS - Android -- BlackBerry 10 - iOS ### Quick Example @@ -240,7 +236,6 @@ The function is passed an `InAppBrowserEvent` object. - Amazon Fire OS - Android -- BlackBerry 10 - iOS ### Quick Example @@ -268,7 +263,6 @@ The function is passed an `InAppBrowserEvent` object. - Amazon Fire OS - Android -- BlackBerry 10 - iOS ### Quick Example From fceea502a3f7f3308247a4bb2841b60a5d902c12 Mon Sep 17 00:00:00 2001 From: James Jong <wjamesjong@gmail.com> Date: Wed, 12 Mar 2014 13:35:17 -0400 Subject: [PATCH 04/26] CB-6212 iOS: fix warnings compiled under arm64 64-bit --- src/ios/CDVInAppBrowser.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ios/CDVInAppBrowser.m b/src/ios/CDVInAppBrowser.m index 88b737c..2b0dc41 100644 --- a/src/ios/CDVInAppBrowser.m +++ b/src/ios/CDVInAppBrowser.m @@ -395,7 +395,7 @@ if (self.callbackId != nil) { NSString* url = [self.inAppBrowserViewController.currentURL absoluteString]; CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR - messageAsDictionary:@{@"type":@"loaderror", @"url":url, @"code": [NSNumber numberWithInt:error.code], @"message": error.localizedDescription}]; + messageAsDictionary:@{@"type":@"loaderror", @"url":url, @"code": [NSNumber numberWithInteger:error.code], @"message": error.localizedDescription}]; [pluginResult setKeepCallback:[NSNumber numberWithBool:YES]]; [self.commandDelegate sendPluginResult:pluginResult callbackId:self.callbackId]; @@ -834,7 +834,7 @@ - (void)webView:(UIWebView*)theWebView didFailLoadWithError:(NSError*)error { // log fail message, stop spinner, update back/forward - NSLog(@"webView:didFailLoadWithError - %i: %@", error.code, [error localizedDescription]); + NSLog(@"webView:didFailLoadWithError - %ld: %@", (long)error.code, [error localizedDescription]); self.backButton.enabled = theWebView.canGoBack; self.forwardButton.enabled = theWebView.canGoForward; From 749d55c67688404399ad2902c50ebd6e4b584460 Mon Sep 17 00:00:00 2001 From: Jesse MacFadyen <purplecabbage@gmail.com> Date: Wed, 19 Mar 2014 22:26:01 -0700 Subject: [PATCH 05/26] CB-6253 Add Network Capability to WMAppManifest.xml --- plugin.xml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/plugin.xml b/plugin.xml index d0046fa..13adc8d 100644 --- a/plugin.xml +++ b/plugin.xml @@ -93,6 +93,10 @@ <!-- wp7 --> <platform name="wp7"> + <config-file target="Properties/WMAppManifest.xml" parent="/Deployment/App/Capabilities"> + <Capability Name="ID_CAP_NETWORKING"/> + </config-file> + <js-module src="www/inappbrowser.js" name="inappbrowser"> <clobbers target="window.open" /> </js-module> @@ -107,6 +111,10 @@ <!-- wp8 --> <platform name="wp8"> + <config-file target="Properties/WMAppManifest.xml" parent="/Deployment/App/Capabilities"> + <Capability Name="ID_CAP_NETWORKING"/> + </config-file> + <js-module src="www/inappbrowser.js" name="inappbrowser"> <clobbers target="window.open" /> </js-module> From 9399ed39559d94c51567b226a8bf2cfb390de15c Mon Sep 17 00:00:00 2001 From: Rocco Georgi <rocco@pavingways.com> Date: Sun, 23 Mar 2014 00:04:24 +0100 Subject: [PATCH 06/26] Doc update: event name and example param (closes #31) --- doc/index.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/index.md b/doc/index.md index e82b29b..5201927 100644 --- a/doc/index.md +++ b/doc/index.md @@ -56,7 +56,7 @@ instance, or the system browser. Android only: - __closebuttoncaption__: set to a string to use as the __Done__ button's caption. - - __hidden__: set to `yes` to create the browser and load the page, but not show it. The load event fires when loading is complete. Omit or set to `no` (default) to have the browser open and load normally. + - __hidden__: set to `yes` to create the browser and load the page, but not show it. The loadstop event fires when loading is complete. Omit or set to `no` (default) to have the browser open and load normally. - __clearcache__: set to `yes` to have the browser's cookie cache cleared before the new window is opened - __clearsessioncache__: set to `yes` to have the session cookie cache cleared before the new window is opened @@ -64,7 +64,7 @@ instance, or the system browser. - __closebuttoncaption__: set to a string to use as the __Done__ button's caption. Note that you need to localize this value yourself. - __disallowoverscroll__: Set to `yes` or `no` (default is `no`). Turns on/off the UIWebViewBounce property. - - __hidden__: set to `yes` to create the browser and load the page, but not show it. The load event fires when loading is complete. Omit or set to `no` (default) to have the browser open and load normally. + - __hidden__: set to `yes` to create the browser and load the page, but not show it. The loadstop event fires when loading is complete. Omit or set to `no` (default) to have the browser open and load normally. - __toolbar__: set to `yes` or `no` to turn the toolbar on or off for the InAppBrowser (defaults to `yes`) - __enableViewportScale__: Set to `yes` or `no` to prevent viewport scaling through a meta tag (defaults to `no`). - __mediaPlaybackRequiresUserAction__: Set to `yes` or `no` to prevent HTML5 audio or video from autoplaying (defaults to `no`). @@ -139,7 +139,7 @@ The object returned from a call to `window.open`. ### Quick Example var ref = window.open('http://apache.org', '_blank', 'location=yes'); - ref.addEventListener('loadstart', function() { alert(event.url); }); + ref.addEventListener('loadstart', function(event) { alert(event.url); }); ## removeEventListener @@ -169,7 +169,7 @@ The function is passed an `InAppBrowserEvent` object. ### Quick Example var ref = window.open('http://apache.org', '_blank', 'location=yes'); - var myCallback = function() { alert(event.url); } + var myCallback = function(event) { alert(event.url); } ref.addEventListener('loadstart', myCallback); ref.removeEventListener('loadstart', myCallback); From bdf4ade2bb1e5805ebd632f264fcdd09109cc5d1 Mon Sep 17 00:00:00 2001 From: Nadya Atanasova <nadya.it@gmail.com> Date: Wed, 26 Mar 2014 15:51:49 +0200 Subject: [PATCH 07/26] Add necessary capability so the plugin works on its own --- plugin.xml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/plugin.xml b/plugin.xml index 932ff83..d2ec6f5 100644 --- a/plugin.xml +++ b/plugin.xml @@ -102,6 +102,10 @@ </feature> </config-file> + <config-file target="Properties/WMAppManifest.xml" parent="/Deployment/App/Capabilities"> + <Capability Name="ID_CAP_NETWORKING" /> + </config-file> + <source-file src="src/wp/InAppBrowser.cs" /> </platform> @@ -116,6 +120,10 @@ </feature> </config-file> + <config-file target="Properties/WMAppManifest.xml" parent="/Deployment/App/Capabilities"> + <Capability Name="ID_CAP_NETWORKING" /> + </config-file> + <source-file src="src/wp/InAppBrowser.cs" /> </platform> From 22c7a0e51e560b35e46e94dea667a5fb0ef5a270 Mon Sep 17 00:00:00 2001 From: mbradshawabs <mbradshaw@americanbible.org> Date: Wed, 2 Apr 2014 09:19:05 -0500 Subject: [PATCH 08/26] CB-6389 CB-3617: Add clearcache and clearsessioncache options to iOS (like Android) --- src/ios/CDVInAppBrowser.h | 2 ++ src/ios/CDVInAppBrowser.m | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/src/ios/CDVInAppBrowser.h b/src/ios/CDVInAppBrowser.h index 8e2ab12..e643962 100644 --- a/src/ios/CDVInAppBrowser.h +++ b/src/ios/CDVInAppBrowser.h @@ -45,6 +45,8 @@ @property (nonatomic, assign) BOOL toolbar; @property (nonatomic, copy) NSString* closebuttoncaption; @property (nonatomic, copy) NSString* toolbarposition; +@property (nonatomic, assign) BOOL clearcache; +@property (nonatomic, assign) BOOL clearsessioncache; @property (nonatomic, copy) NSString* presentationstyle; @property (nonatomic, copy) NSString* transitionstyle; diff --git a/src/ios/CDVInAppBrowser.m b/src/ios/CDVInAppBrowser.m index 2b0dc41..6625545 100644 --- a/src/ios/CDVInAppBrowser.m +++ b/src/ios/CDVInAppBrowser.m @@ -115,6 +115,29 @@ - (void)openInInAppBrowser:(NSURL*)url withOptions:(NSString*)options { CDVInAppBrowserOptions* browserOptions = [CDVInAppBrowserOptions parseOptions:options]; + + if (browserOptions.clearcache) { + NSHTTPCookie *cookie; + NSHTTPCookieStorage *storage = [NSHTTPCookieStorage sharedHTTPCookieStorage]; + for (cookie in [storage cookies]) + { + if (![cookie.domain isEqual: @".^filecookies^"]) { + [storage deleteCookie:cookie]; + } + } + } + + if (browserOptions.clearsessioncache) { + NSHTTPCookie *cookie; + NSHTTPCookieStorage *storage = [NSHTTPCookieStorage sharedHTTPCookieStorage]; + for (cookie in [storage cookies]) + { + if (![cookie.domain isEqual: @".^filecookies^"] && cookie.isSessionOnly) { + [storage deleteCookie:cookie]; + } + } + } + if (self.inAppBrowserViewController == nil) { NSString* originalUA = [CDVUserAgentUtil originalUserAgent]; self.inAppBrowserViewController = [[CDVInAppBrowserViewController alloc] initWithUserAgent:originalUA prevUserAgent:[self.commandDelegate userAgent] browserOptions: browserOptions]; @@ -885,6 +908,8 @@ self.toolbar = YES; self.closebuttoncaption = nil; self.toolbarposition = kInAppBrowserToolbarBarPositionBottom; + self.clearcache = NO; + self.clearsessioncache = NO; self.enableviewportscale = NO; self.mediaplaybackrequiresuseraction = NO; From 51879d8e2f2a9b9209022774ada265164abdc620 Mon Sep 17 00:00:00 2001 From: Piotr Zalewa <piotr@zalewa.info> Date: Fri, 4 Apr 2014 12:16:01 +0200 Subject: [PATCH 09/26] CB-6396 [Firefox OS] Adding basic support --- doc/index.md | 11 +++ plugin.xml | 9 +++ src/firefoxos/InAppBrowserProxy.js | 108 +++++++++++++++++++++++++++++ 3 files changed, 128 insertions(+) create mode 100644 src/firefoxos/InAppBrowserProxy.js diff --git a/doc/index.md b/doc/index.md index 5201927..ebc4734 100644 --- a/doc/index.md +++ b/doc/index.md @@ -30,6 +30,17 @@ and can't access Cordova APIs. cordova plugin add org.apache.cordova.inappbrowser +### Firefox OS + +Create __www/manifest.webapp__ as described in +[Manifest Docs](https://developer.mozilla.org/en-US/Apps/Developing/Manifest). +Add relevant permisions. + + "permissions": { + "browser": {} + } + + ## window.open Opens a URL in a new `InAppBrowser` instance, the current browser diff --git a/plugin.xml b/plugin.xml index 13adc8d..0d52960 100644 --- a/plugin.xml +++ b/plugin.xml @@ -137,5 +137,14 @@ </js-module> </platform> + <!-- firefoxos --> + <platform name="firefoxos"> + <js-module src="www/inappbrowser.js" name="inappbrowser"> + <clobbers target="window.open" /> + </js-module> + <js-module src="src/firefoxos/InAppBrowserProxy.js" name="InAppBrowserProxy"> + <merges target="" /> + </js-module> + </platform> </plugin> diff --git a/src/firefoxos/InAppBrowserProxy.js b/src/firefoxos/InAppBrowserProxy.js new file mode 100644 index 0000000..fc2388b --- /dev/null +++ b/src/firefoxos/InAppBrowserProxy.js @@ -0,0 +1,108 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * +*/ + +// https://developer.mozilla.org/en-US/docs/WebAPI/Browser + +var cordova = require('cordova'), + channel = require('cordova/channel'), + modulemapper = require('cordova/modulemapper'); + +var origOpenFunc = modulemapper.getOriginalSymbol(window, 'window.open'); +var browserWrap; + +var IABExecs = { + + close: function (win, lose) { + if (browserWrap) { + browserWrap.parentNode.removeChild(browserWrap); + browserWrap = null; + } + }, + + /* + * Reveal browser if opened hidden + */ + show: function (win, lose) { + console.error('[FirefoxOS] show not implemented'); + }, + + open: function (win, lose, args) { + var strUrl = args[0], + target = args[1], + features = args[2], + url, + elem; + + if (target === '_system') { + origOpenFunc.apply(window, [strUrl, '_blank']); + } else if (target === '_blank') { + var browserElem = document.createElement('iframe'); + browserElem.setAttribute('mozbrowser', true); + // make this loaded in its own child process + browserElem.setAttribute('remote', true); + browserElem.setAttribute('src', strUrl); + if (browserWrap) { + document.body.removeChild(browserWrap); + } + browserWrap = document.createElement('div'); + browserWrap.style.position = 'absolute'; + browserWrap.style.backgroundColor = 'rgba(0,0,0,0.75)'; + browserWrap.style.color = 'rgba(235,235,235,1.0)'; + browserWrap.style.width = window.innerWidth + 'px'; + browserWrap.style.height = window.innerHeight + 'px'; + browserWrap.style.padding = '10px,0,0,0'; + browserElem.style.position = 'absolute'; + browserElem.style.top = '60px'; + browserElem.style.left = '0px'; + browserElem.style.height = (window.innerHeight - 60) + 'px'; + browserElem.style.width = browserWrap.style.width; + + browserWrap.addEventListener('click', function () { + setTimeout(function () { + IAB.close(); + }, 0); + }, false); + var p = document.createElement('p'); + p.appendChild(document.createTextNode('close')); + // TODO: make all buttons - ← → × + p.style.paddingTop = '10px'; + p.style.textAlign = 'center'; + browserWrap.appendChild(p); + browserWrap.appendChild(browserElem); + document.body.appendChild(browserWrap); + // assign browser element to browserWrap for future + // reference + browserWrap.browser = browserElem; + } else { + window.location = strUrl; + } + }, + injectScriptCode: function (code, bCB) { + console.error('[FirefoxOS] injectScriptCode not implemented'); + }, + injectScriptFile: function (file, bCB) { + console.error('[FirefoxOS] injectScriptFile not implemented'); + } +}; + +module.exports = IABExecs; + +require('cordova/firefoxos/commandProxy').add('InAppBrowser', module.exports); From 04de070dcd613db5a4d012b91831f730ca506e2b Mon Sep 17 00:00:00 2001 From: Ian Clelland <iclelland@chromium.org> Date: Mon, 7 Apr 2014 10:08:20 -0600 Subject: [PATCH 10/26] CB-3617: Document clearcache and clearsessioncache for ios --- doc/index.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/index.md b/doc/index.md index 5201927..1db39db 100644 --- a/doc/index.md +++ b/doc/index.md @@ -65,6 +65,8 @@ instance, or the system browser. - __closebuttoncaption__: set to a string to use as the __Done__ button's caption. Note that you need to localize this value yourself. - __disallowoverscroll__: Set to `yes` or `no` (default is `no`). Turns on/off the UIWebViewBounce property. - __hidden__: set to `yes` to create the browser and load the page, but not show it. The loadstop event fires when loading is complete. Omit or set to `no` (default) to have the browser open and load normally. + - __clearcache__: set to `yes` to have the browser's cookie cache cleared before the new window is opened + - __clearsessioncache__: set to `yes` to have the session cookie cache cleared before the new window is opened - __toolbar__: set to `yes` or `no` to turn the toolbar on or off for the InAppBrowser (defaults to `yes`) - __enableViewportScale__: Set to `yes` or `no` to prevent viewport scaling through a meta tag (defaults to `no`). - __mediaPlaybackRequiresUserAction__: Set to `yes` or `no` to prevent HTML5 audio or video from autoplaying (defaults to `no`). From 25f306d11eb090805417a94e5feeb594e50959c0 Mon Sep 17 00:00:00 2001 From: Jesse MacFadyen <purplecabbage@gmail.com> Date: Tue, 8 Apr 2014 16:29:32 -0700 Subject: [PATCH 11/26] CB-6422 [windows8] use cordova/exec/proxy --- www/windows8/InAppBrowserProxy.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/windows8/InAppBrowserProxy.js b/www/windows8/InAppBrowserProxy.js index d173778..944284e 100644 --- a/www/windows8/InAppBrowserProxy.js +++ b/www/windows8/InAppBrowserProxy.js @@ -108,4 +108,4 @@ var IAB = { module.exports = IAB; -require("cordova/windows8/commandProxy").add("InAppBrowser", module.exports); +require("cordova/exec/proxy").add("InAppBrowser", module.exports); From 88f330abd804365170c20ef26fd705e4eb378d45 Mon Sep 17 00:00:00 2001 From: Piotr Zalewa <piotr@zalewa.info> Date: Wed, 9 Apr 2014 15:16:52 +0200 Subject: [PATCH 12/26] refactoring fixed --- src/firefoxos/InAppBrowserProxy.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/firefoxos/InAppBrowserProxy.js b/src/firefoxos/InAppBrowserProxy.js index fc2388b..8ee3736 100644 --- a/src/firefoxos/InAppBrowserProxy.js +++ b/src/firefoxos/InAppBrowserProxy.js @@ -77,7 +77,7 @@ var IABExecs = { browserWrap.addEventListener('click', function () { setTimeout(function () { - IAB.close(); + IABExecs.close(); }, 0); }, false); var p = document.createElement('p'); From bddf86c3cefd9d787876d15e771beb499e43eb2f Mon Sep 17 00:00:00 2001 From: Jesse MacFadyen <purplecabbage@gmail.com> Date: Wed, 9 Apr 2014 12:26:47 -0700 Subject: [PATCH 13/26] CB-6402 [WP8] pass empty string instead of null for [optional] windowFeatures string --- www/inappbrowser.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/www/inappbrowser.js b/www/inappbrowser.js index ebcfa24..3535b6f 100644 --- a/www/inappbrowser.js +++ b/www/inappbrowser.js @@ -90,6 +90,8 @@ module.exports = function(strUrl, strWindowName, strWindowFeatures) { iab._eventHandler(eventname); }; + strWindowFeatures = strWindowFeatures || ""; + exec(cb, cb, "InAppBrowser", "open", [strUrl, strWindowName, strWindowFeatures]); return iab; }; From 2fc9f3da1fc683442a4c41811e826476d2ca9dd6 Mon Sep 17 00:00:00 2001 From: Nadya Atanasova <nadya.it@gmail.com> Date: Fri, 11 Apr 2014 17:57:45 +0300 Subject: [PATCH 14/26] Make InAppBrowser work with embedded files, using system behavior The plugin is changed to work with embedded files, using the system behavior. If one needs the system behavior, they need to pass "_system" as target when using the plugin. As the InAppBrowser for WP8 does not handle by itself the embedded pdf files, system behavior is called. The plugin also is tested and working for wp7 --- src/wp/InAppBrowser.cs | 106 +++++++++++++++++++++++++++++------------ 1 file changed, 75 insertions(+), 31 deletions(-) diff --git a/src/wp/InAppBrowser.cs b/src/wp/InAppBrowser.cs index 454464d..ae88b51 100644 --- a/src/wp/InAppBrowser.cs +++ b/src/wp/InAppBrowser.cs @@ -1,21 +1,24 @@ using System; -using System.Net; +using System.Diagnostics; +using System.IO; +using System.Runtime.Serialization; using System.Windows; using System.Windows.Controls; -using System.Windows.Documents; -using System.Windows.Ink; -using System.Windows.Input; using System.Windows.Media; -using System.Windows.Media.Animation; -using System.Windows.Shapes; using Microsoft.Phone.Controls; -using System.Diagnostics; -using System.Runtime.Serialization; -using WPCordovaClassLib.Cordova; -using WPCordovaClassLib.Cordova.Commands; -using WPCordovaClassLib.Cordova.JSON; using Microsoft.Phone.Shell; + +#if WP8 +using System.Threading.Tasks; +using Windows.ApplicationModel; +using Windows.Storage; +using Windows.System; + +//Use alias in case Cordova File Plugin is enabled. Then the File class will be declared in both and error will occur. +using IOFile = System.IO.File; +#else using Microsoft.Phone.Tasks; +#endif namespace WPCordovaClassLib.Cordova.Commands { @@ -53,27 +56,29 @@ namespace WPCordovaClassLib.Cordova.Commands string target = args[1]; string featString = args[2]; - string[] features = featString.Split(','); - foreach (string str in features) + if (!string.IsNullOrEmpty(featString)) { - try + string[] features = featString.Split(','); + foreach (string str in features) { - string[] split = str.Split('='); - switch (split[0]) + try { - case "location": - ShowLocation = split[1].ToLower().StartsWith("yes"); - break; - case "hidden": - StartHidden = split[1].ToLower().StartsWith("yes"); - break; + string[] split = str.Split('='); + switch (split[0]) + { + case "location": + ShowLocation = split[1].StartsWith("yes", StringComparison.OrdinalIgnoreCase); + break; + case "hidden": + StartHidden = split[1].StartsWith("yes", StringComparison.OrdinalIgnoreCase); + break; + } + } + catch (Exception) + { + // some sort of invalid param was passed, moving on ... } } - catch(Exception) - { - // some sort of invalid param was passed, moving on ... - } - } /* _self - opens in the Cordova WebView if url is in the white-list, else it opens in the InAppBrowser @@ -184,7 +189,6 @@ namespace WPCordovaClassLib.Cordova.Commands //throw new NotImplementedException("Windows Phone does not currently support 'insertCSS'"); } - private void ShowCordovaBrowser(string url) { Uri loc = new Uri(url, UriKind.RelativeOrAbsolute); @@ -208,13 +212,53 @@ namespace WPCordovaClassLib.Cordova.Commands }); } +#if WP8 + private async void ShowSystemBrowser(string url) + { + var pathUri = new Uri(url, UriKind.Absolute); + if (pathUri.Scheme == Uri.UriSchemeHttp || pathUri.Scheme == Uri.UriSchemeHttps) + { + Launcher.LaunchUriAsync(pathUri); + return; + } + + var file = await GetFile(pathUri.AbsolutePath.Replace('/', Path.DirectorySeparatorChar)); + if (file != null) + { + Launcher.LaunchFileAsync(file); + } + else + { + Debug.WriteLine("File not found."); + } + } + + private async Task<StorageFile> GetFile(string fileName) + { + //first try to get the file from the isolated storage + var localFolder = ApplicationData.Current.LocalFolder; + if (IOFile.Exists(Path.Combine(localFolder.Path, fileName))) + { + return await localFolder.GetFileAsync(fileName); + } + + //if file is not found try to get it from the xap + var filePath = Path.Combine(Package.Current.InstalledLocation.Path, fileName); + if (IOFile.Exists(filePath)) + { + return await StorageFile.GetFileFromPathAsync(filePath); + } + + return null; + } +#else private void ShowSystemBrowser(string url) { WebBrowserTask webBrowserTask = new WebBrowserTask(); webBrowserTask.Uri = new Uri(url, UriKind.Absolute); webBrowserTask.Show(); } - +#endif private void ShowInAppBrowser(string url) { @@ -326,7 +370,7 @@ namespace WPCordovaClassLib.Cordova.Commands { #if WP8 browser.GoBack(); -#else +#else browser.InvokeScript("execScript", "history.back();"); #endif } @@ -405,4 +449,4 @@ namespace WPCordovaClassLib.Cordova.Commands } } -} +} \ No newline at end of file From 34c29dc2ecf66dcde5fc96f1f85295d7332bde14 Mon Sep 17 00:00:00 2001 From: Jesse MacFadyen <purplecabbage@gmail.com> Date: Mon, 14 Apr 2014 17:01:35 -0700 Subject: [PATCH 15/26] await async calls, resolve warnings --- src/wp/InAppBrowser.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wp/InAppBrowser.cs b/src/wp/InAppBrowser.cs index ae88b51..7239c8a 100644 --- a/src/wp/InAppBrowser.cs +++ b/src/wp/InAppBrowser.cs @@ -218,14 +218,14 @@ namespace WPCordovaClassLib.Cordova.Commands var pathUri = new Uri(url, UriKind.Absolute); if (pathUri.Scheme == Uri.UriSchemeHttp || pathUri.Scheme == Uri.UriSchemeHttps) { - Launcher.LaunchUriAsync(pathUri); + await Launcher.LaunchUriAsync(pathUri); return; } var file = await GetFile(pathUri.AbsolutePath.Replace('/', Path.DirectorySeparatorChar)); if (file != null) { - Launcher.LaunchFileAsync(file); + await Launcher.LaunchFileAsync(file); } else { From 1c32236353d8fc118a8449464ba7cd8f93a5eee2 Mon Sep 17 00:00:00 2001 From: Jesse MacFadyen <purplecabbage@gmail.com> Date: Mon, 14 Apr 2014 17:11:36 -0700 Subject: [PATCH 16/26] CB-3324 Add support for back-button inappbrowser [WP8] if there is no history -> InAppBrowser is closed --- src/wp/InAppBrowser.cs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/wp/InAppBrowser.cs b/src/wp/InAppBrowser.cs index 7239c8a..4026a95 100644 --- a/src/wp/InAppBrowser.cs +++ b/src/wp/InAppBrowser.cs @@ -331,6 +331,8 @@ namespace WPCordovaClassLib.Cordova.Commands bar.IsVisible = !StartHidden; AppBar = bar; + page.BackKeyPress += page_BackKeyPress; + } } @@ -338,6 +340,23 @@ namespace WPCordovaClassLib.Cordova.Commands }); } + void page_BackKeyPress(object sender, System.ComponentModel.CancelEventArgs e) + { +#if WP8 + if (browser.CanGoBack) + { + browser.GoBack(); + } + else + { + close(); + } + e.Cancel = true; +#else + browser.InvokeScript("execScript", "history.back();"); +#endif + } + void browser_LoadCompleted(object sender, System.Windows.Navigation.NavigationEventArgs e) { @@ -405,8 +424,10 @@ namespace WPCordovaClassLib.Cordova.Commands grid.Children.Remove(browser); } page.ApplicationBar = null; + page.BackKeyPress -= page_BackKeyPress; } } + browser = null; string message = "{\"type\":\"exit\"}"; PluginResult result = new PluginResult(PluginResult.Status.OK, message); From 932f078e2dfd31a8208b9a3c0d53852289f94826 Mon Sep 17 00:00:00 2001 From: Robin North <github@robinnorth.co.uk> Date: Wed, 9 Apr 2014 16:48:00 +0100 Subject: [PATCH 17/26] CB-6360: Fix for crash on iOS < 6.0 (closes #37) --- src/ios/CDVInAppBrowser.m | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ios/CDVInAppBrowser.m b/src/ios/CDVInAppBrowser.m index 6625545..68675c5 100644 --- a/src/ios/CDVInAppBrowser.m +++ b/src/ios/CDVInAppBrowser.m @@ -552,7 +552,11 @@ self.addressLabel.enabled = YES; self.addressLabel.hidden = NO; self.addressLabel.lineBreakMode = NSLineBreakByTruncatingTail; - self.addressLabel.minimumScaleFactor = 10.000; + if (IsAtLeastiOSVersion(@"6.0")) { + self.addressLabel.minimumScaleFactor = 10.0/[UIFont labelFontSize]; + } else { + self.addressLabel.minimumFontSize = 10.000; + } self.addressLabel.multipleTouchEnabled = NO; self.addressLabel.numberOfLines = 1; self.addressLabel.opaque = NO; From c5061ec333fae8e214a867443bc53833bba0d3c6 Mon Sep 17 00:00:00 2001 From: Ian Clelland <iclelland@chromium.org> Date: Wed, 16 Apr 2014 16:19:05 -0400 Subject: [PATCH 18/26] CB-6460: Update license headers --- plugin.xml | 18 ++++++++++++++++++ src/amazon/InAppChromeClient.java | 18 ++++++++++++++++++ src/android/InAppChromeClient.java | 18 ++++++++++++++++++ src/blackberry10/README.md | 18 ++++++++++++++++++ src/wp/InAppBrowser.cs | 16 +++++++++++++++- 5 files changed, 87 insertions(+), 1 deletion(-) diff --git a/plugin.xml b/plugin.xml index 13adc8d..9eea784 100644 --- a/plugin.xml +++ b/plugin.xml @@ -1,4 +1,22 @@ <?xml version="1.0" encoding="UTF-8"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +--> <plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" id="org.apache.cordova.inappbrowser" diff --git a/src/amazon/InAppChromeClient.java b/src/amazon/InAppChromeClient.java index 7f2ddc3..37cf101 100644 --- a/src/amazon/InAppChromeClient.java +++ b/src/amazon/InAppChromeClient.java @@ -1,3 +1,21 @@ +/* + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +*/ package org.apache.cordova.inappbrowser; import org.apache.cordova.CordovaWebView; diff --git a/src/android/InAppChromeClient.java b/src/android/InAppChromeClient.java index f3fc741..a2145e6 100644 --- a/src/android/InAppChromeClient.java +++ b/src/android/InAppChromeClient.java @@ -1,3 +1,21 @@ +/* + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +*/ package org.apache.cordova.inappbrowser; import org.apache.cordova.CordovaWebView; diff --git a/src/blackberry10/README.md b/src/blackberry10/README.md index 0b16789..f0fa860 100644 --- a/src/blackberry10/README.md +++ b/src/blackberry10/README.md @@ -1,3 +1,21 @@ +<!--- + license: Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +--> # BlackBerry 10 In-App-Browser Plugin The in app browser functionality is entirely contained within common js. There is no native implementation required. diff --git a/src/wp/InAppBrowser.cs b/src/wp/InAppBrowser.cs index 4026a95..cbd5d26 100644 --- a/src/wp/InAppBrowser.cs +++ b/src/wp/InAppBrowser.cs @@ -1,4 +1,18 @@ -using System; +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +using System; using System.Diagnostics; using System.IO; using System.Runtime.Serialization; From 1c98bc5b3f1757e1ed6c7686aa055715f9bf9372 Mon Sep 17 00:00:00 2001 From: Ian Clelland <iclelland@chromium.org> Date: Thu, 17 Apr 2014 10:53:20 -0400 Subject: [PATCH 19/26] CB-6452 Updated version and RELEASENOTES.md for release 0.4.0 --- RELEASENOTES.md | 14 ++++++++++++++ plugin.xml | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 364f4e9..3d6cd70 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -83,3 +83,17 @@ * CB-5534 Fix video/audio does not stop playing when browser is closed * CB-6172 Fix broken install on case-sensitive file-systems + +### 0.4.0 (Apr 17, 2014) +* CB-6360: [ios] Fix for crash on iOS < 6.0 (closes #37) +* CB-3324: [WP8] Add support for back-button inappbrowser [WP8] if there is no history -> InAppBrowser is closed +* [WP] await async calls, resolve warnings +* [WP] Make InAppBrowser work with embedded files, using system behavior +* CB-6402: [WP8] pass empty string instead of null for [optional] windowFeatures string +* CB-6422: [windows8] use cordova/exec/proxy +* CB-6389 CB-3617: Add clearcache and clearsessioncache options to iOS (like Android) +* Doc update: event name and example param (closes #31) +* CB-6253: [WP] Add Network Capability to WMAppManifest.xml +* CB-6212: [iOS] fix warnings compiled under arm64 64-bit +* CB-6218: Update docs for BB10 +* CB-6460: Update license headers diff --git a/plugin.xml b/plugin.xml index 9eea784..c9e0169 100644 --- a/plugin.xml +++ b/plugin.xml @@ -20,7 +20,7 @@ <plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" id="org.apache.cordova.inappbrowser" - version="0.3.4-dev"> + version="0.4.0"> <name>InAppBrowser</name> <description>Cordova InAppBrowser Plugin</description> From 11f833b46d1318eee6b073d6ff2ec380fcb1ab89 Mon Sep 17 00:00:00 2001 From: Ian Clelland <iclelland@chromium.org> Date: Thu, 17 Apr 2014 11:16:03 -0400 Subject: [PATCH 20/26] CB-6452 Incremented plugin version on dev branch. --- plugin.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.xml b/plugin.xml index c9e0169..70d9fea 100644 --- a/plugin.xml +++ b/plugin.xml @@ -20,7 +20,7 @@ <plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" id="org.apache.cordova.inappbrowser" - version="0.4.0"> + version="0.4.1-dev"> <name>InAppBrowser</name> <description>Cordova InAppBrowser Plugin</description> From b9f8fcd8a93f802dcf85f620f70a6dcd23b0f9c7 Mon Sep 17 00:00:00 2001 From: Shazron Abdullah <shazron@apache.org> Date: Thu, 17 Apr 2014 16:32:34 -0700 Subject: [PATCH 21/26] CB-5649 - InAppBrowser overrides App's orientation --- src/ios/CDVInAppBrowser.h | 8 +++++++- src/ios/CDVInAppBrowser.m | 36 +++++++++++++++++++++++++++++++++++- 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/src/ios/CDVInAppBrowser.h b/src/ios/CDVInAppBrowser.h index e643962..0ba07f1 100644 --- a/src/ios/CDVInAppBrowser.h +++ b/src/ios/CDVInAppBrowser.h @@ -63,7 +63,7 @@ @end -@interface CDVInAppBrowserViewController : UIViewController <UIWebViewDelegate>{ +@interface CDVInAppBrowserViewController : UIViewController <UIWebViewDelegate, CDVScreenOrientationDelegate>{ @private NSString* _userAgent; NSString* _prevUserAgent; @@ -92,4 +92,10 @@ - (id)initWithUserAgent:(NSString*)userAgent prevUserAgent:(NSString*)prevUserAgent browserOptions: (CDVInAppBrowserOptions*) browserOptions; +@end + +@interface CDVInAppBrowserNavigationController : UINavigationController + +@property (nonatomic, weak) id <CDVScreenOrientationDelegate> orientationDelegate; + @end \ No newline at end of file diff --git a/src/ios/CDVInAppBrowser.m b/src/ios/CDVInAppBrowser.m index 68675c5..aed735c 100644 --- a/src/ios/CDVInAppBrowser.m +++ b/src/ios/CDVInAppBrowser.m @@ -216,8 +216,9 @@ _previousStatusBarStyle = [UIApplication sharedApplication].statusBarStyle; - UINavigationController* nav = [[UINavigationController alloc] + CDVInAppBrowserNavigationController* nav = [[CDVInAppBrowserNavigationController alloc] initWithRootViewController:self.inAppBrowserViewController]; + nav.orientationDelegate = self.inAppBrowserViewController; nav.navigationBarHidden = YES; // Run later to avoid the "took a long time" log message. dispatch_async(dispatch_get_main_queue(), ^{ @@ -964,4 +965,37 @@ return obj; } +@end + +@implementation CDVInAppBrowserNavigationController : UINavigationController + +#pragma mark CDVScreenOrientationDelegate + +- (BOOL)shouldAutorotate +{ + if ((self.orientationDelegate != nil) && [self.orientationDelegate respondsToSelector:@selector(shouldAutorotate)]) { + return [self.orientationDelegate shouldAutorotate]; + } + return YES; +} + +- (NSUInteger)supportedInterfaceOrientations +{ + if ((self.orientationDelegate != nil) && [self.orientationDelegate respondsToSelector:@selector(supportedInterfaceOrientations)]) { + return [self.orientationDelegate supportedInterfaceOrientations]; + } + + return 1 << UIInterfaceOrientationPortrait; +} + +- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation +{ + if ((self.orientationDelegate != nil) && [self.orientationDelegate respondsToSelector:@selector(shouldAutorotateToInterfaceOrientation:)]) { + return [self.orientationDelegate shouldAutorotateToInterfaceOrientation:interfaceOrientation]; + } + + return YES; +} + + @end From c25bc30d7d1715b0cb945051cdf1866c6436f61f Mon Sep 17 00:00:00 2001 From: Shazron Abdullah <shazron@apache.org> Date: Thu, 17 Apr 2014 16:52:21 -0700 Subject: [PATCH 22/26] CB-6360 - improvement: feature detection instead of iOS version detection --- src/ios/CDVInAppBrowser.m | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/ios/CDVInAppBrowser.m b/src/ios/CDVInAppBrowser.m index aed735c..5253688 100644 --- a/src/ios/CDVInAppBrowser.m +++ b/src/ios/CDVInAppBrowser.m @@ -553,11 +553,14 @@ self.addressLabel.enabled = YES; self.addressLabel.hidden = NO; self.addressLabel.lineBreakMode = NSLineBreakByTruncatingTail; - if (IsAtLeastiOSVersion(@"6.0")) { - self.addressLabel.minimumScaleFactor = 10.0/[UIFont labelFontSize]; - } else { - self.addressLabel.minimumFontSize = 10.000; + + if ([self.addressLabel respondsToSelector:NSSelectorFromString(@"setMinimumScaleFactor:")]) { + [self.addressLabel setValue:@(10.0/[UIFont labelFontSize]) forKey:@"minimumScaleFactor"]; + } else + if ([self.addressLabel respondsToSelector:NSSelectorFromString(@"setMinimumFontSize:")]) { + [self.addressLabel setValue:@(10.0) forKey:@"minimumFontSize"]; } + self.addressLabel.multipleTouchEnabled = NO; self.addressLabel.numberOfLines = 1; self.addressLabel.opaque = NO; From 40778ba23985019da58708b80e6d0016c8e0c4c1 Mon Sep 17 00:00:00 2001 From: Shazron Abdullah <shazron@apache.org> Date: Thu, 17 Apr 2014 17:02:59 -0700 Subject: [PATCH 23/26] Fixed use of iOS 6 deprecated methods --- src/ios/CDVInAppBrowser.m | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/ios/CDVInAppBrowser.m b/src/ios/CDVInAppBrowser.m index 5253688..8037a91 100644 --- a/src/ios/CDVInAppBrowser.m +++ b/src/ios/CDVInAppBrowser.m @@ -223,7 +223,7 @@ // Run later to avoid the "took a long time" log message. dispatch_async(dispatch_get_main_queue(), ^{ if (self.inAppBrowserViewController != nil) { - [self.viewController presentModalViewController:nav animated:YES]; + [self.viewController presentViewController:nav animated:YES completion:nil]; } }); } @@ -489,7 +489,6 @@ self.webView.clearsContextBeforeDrawing = YES; self.webView.clipsToBounds = YES; self.webView.contentMode = UIViewContentModeScaleToFill; - self.webView.contentStretch = CGRectFromString(@"{{0, 0}, {1, 1}}"); self.webView.multipleTouchEnabled = YES; self.webView.opaque = YES; self.webView.scalesPageToFit = NO; @@ -502,7 +501,6 @@ self.spinner.clearsContextBeforeDrawing = NO; self.spinner.clipsToBounds = NO; self.spinner.contentMode = UIViewContentModeScaleToFill; - self.spinner.contentStretch = CGRectFromString(@"{{0, 0}, {1, 1}}"); self.spinner.frame = CGRectMake(454.0, 231.0, 20.0, 20.0); self.spinner.hidden = YES; self.spinner.hidesWhenStopped = YES; @@ -530,7 +528,6 @@ self.toolbar.clearsContextBeforeDrawing = NO; self.toolbar.clipsToBounds = NO; self.toolbar.contentMode = UIViewContentModeScaleToFill; - self.toolbar.contentStretch = CGRectFromString(@"{{0, 0}, {1, 1}}"); self.toolbar.hidden = NO; self.toolbar.multipleTouchEnabled = NO; self.toolbar.opaque = NO; @@ -549,15 +546,13 @@ self.addressLabel.clearsContextBeforeDrawing = YES; self.addressLabel.clipsToBounds = YES; self.addressLabel.contentMode = UIViewContentModeScaleToFill; - self.addressLabel.contentStretch = CGRectFromString(@"{{0, 0}, {1, 1}}"); self.addressLabel.enabled = YES; self.addressLabel.hidden = NO; self.addressLabel.lineBreakMode = NSLineBreakByTruncatingTail; if ([self.addressLabel respondsToSelector:NSSelectorFromString(@"setMinimumScaleFactor:")]) { [self.addressLabel setValue:@(10.0/[UIFont labelFontSize]) forKey:@"minimumScaleFactor"]; - } else - if ([self.addressLabel respondsToSelector:NSSelectorFromString(@"setMinimumFontSize:")]) { + } else if ([self.addressLabel respondsToSelector:NSSelectorFromString(@"setMinimumFontSize:")]) { [self.addressLabel setValue:@(10.0) forKey:@"minimumFontSize"]; } @@ -750,7 +745,7 @@ if ([self respondsToSelector:@selector(presentingViewController)]) { [[self presentingViewController] dismissViewControllerAnimated:YES completion:nil]; } else { - [[self parentViewController] dismissModalViewControllerAnimated:YES]; + [[self parentViewController] dismissViewControllerAnimated:YES completion:nil]; } }); } From 8f2ad211ad60a10d7234124ff3c815e6a3b70ff1 Mon Sep 17 00:00:00 2001 From: sgrebnov <v-segreb@microsoft.com> Date: Fri, 18 Apr 2014 10:47:20 -0700 Subject: [PATCH 24/26] CB-6474 InAppBrowser. Add data urls support to WP8 --- src/wp/InAppBrowser.cs | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) 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); + } + } + } } From ab7494faa059a8e90fb8f88c5c5ef40e8a154478 Mon Sep 17 00:00:00 2001 From: sgrebnov <v-segreb@microsoft.com> Date: Mon, 21 Apr 2014 15:28:03 -0700 Subject: [PATCH 25/26] CB-6482 InAppBrowser calls incorrect callback on WP8 --- src/wp/InAppBrowser.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/wp/InAppBrowser.cs b/src/wp/InAppBrowser.cs index 454464d..9d49165 100644 --- a/src/wp/InAppBrowser.cs +++ b/src/wp/InAppBrowser.cs @@ -41,6 +41,8 @@ namespace WPCordovaClassLib.Cordova.Commands protected bool ShowLocation {get;set;} protected bool StartHidden {get;set;} + protected string NavigationCallbackId { get; set; } + public void open(string options) { // reset defaults on ShowLocation + StartHidden features @@ -52,6 +54,7 @@ namespace WPCordovaClassLib.Cordova.Commands string urlLoc = args[0]; string target = args[1]; string featString = args[2]; + this.NavigationCallbackId = args[3]; string[] features = featString.Split(','); foreach (string str in features) @@ -367,7 +370,7 @@ namespace WPCordovaClassLib.Cordova.Commands string message = "{\"type\":\"exit\"}"; PluginResult result = new PluginResult(PluginResult.Status.OK, message); result.KeepCallback = false; - this.DispatchCommandResult(result); + this.DispatchCommandResult(result, NavigationCallbackId); }); } } @@ -385,7 +388,7 @@ namespace WPCordovaClassLib.Cordova.Commands string message = "{\"type\":\"loadstop\", \"url\":\"" + e.Uri.OriginalString + "\"}"; PluginResult result = new PluginResult(PluginResult.Status.OK, message); result.KeepCallback = true; - this.DispatchCommandResult(result); + this.DispatchCommandResult(result, NavigationCallbackId); } void browser_NavigationFailed(object sender, System.Windows.Navigation.NavigationFailedEventArgs e) @@ -393,7 +396,7 @@ namespace WPCordovaClassLib.Cordova.Commands string message = "{\"type\":\"error\",\"url\":\"" + e.Uri.OriginalString + "\"}"; PluginResult result = new PluginResult(PluginResult.Status.ERROR, message); result.KeepCallback = true; - this.DispatchCommandResult(result); + this.DispatchCommandResult(result, NavigationCallbackId); } void browser_Navigating(object sender, NavigatingEventArgs e) @@ -401,7 +404,7 @@ namespace WPCordovaClassLib.Cordova.Commands string message = "{\"type\":\"loadstart\",\"url\":\"" + e.Uri.OriginalString + "\"}"; PluginResult result = new PluginResult(PluginResult.Status.OK, message); result.KeepCallback = true; - this.DispatchCommandResult(result); + this.DispatchCommandResult(result, NavigationCallbackId); } } From abf757edffe32495d6bf1cccba3f6cd8d388f05f Mon Sep 17 00:00:00 2001 From: Marcel Kinard <cmarcelk@gmail.com> Date: Wed, 30 Apr 2014 09:30:38 -0400 Subject: [PATCH 26/26] CB-6491 add CONTRIBUTING.md --- CONTRIBUTING.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..1594d12 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,16 @@ +# Contributing to Apache Cordova + +Anyone can contribute to Cordova. And we need your contributions. + +There are multiple ways to contribute: report bugs, improve the docs, and +contribute code. + +For instructions on this, start with the +[contribution overview](http://cordova.apache.org/#contribute). + +The details are explained there, but the important items are: + - Sign and submit an Apache ICLA (Contributor License Agreement). + - Have a Jira issue open that corresponds to your contribution. + - Run the tests so your patch doesn't break existing functionality. + +We look forward to your contributions!