From ef4f212fc1482136dba1e690ec589b315b4a377f Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Tue, 8 Nov 2016 12:37:03 -0500 Subject: build 0.7.0 --- .../cordova-plugin-inappbrowser/CONTRIBUTING.md | 29 +- .../plugins/cordova-plugin-inappbrowser/LICENSE | 0 .../plugins/cordova-plugin-inappbrowser/NOTICE | 0 .../plugins/cordova-plugin-inappbrowser/README.md | 312 ++++++++++++++- .../cordova-plugin-inappbrowser/RELEASENOTES.md | 66 +++ .../cordova-plugin-inappbrowser/doc/de/README.md | 0 .../cordova-plugin-inappbrowser/doc/de/index.md | 0 .../cordova-plugin-inappbrowser/doc/es/README.md | 0 .../cordova-plugin-inappbrowser/doc/es/index.md | 0 .../cordova-plugin-inappbrowser/doc/fr/README.md | 0 .../cordova-plugin-inappbrowser/doc/fr/index.md | 0 .../cordova-plugin-inappbrowser/doc/it/README.md | 0 .../cordova-plugin-inappbrowser/doc/it/index.md | 0 .../cordova-plugin-inappbrowser/doc/ja/README.md | 0 .../cordova-plugin-inappbrowser/doc/ja/index.md | 0 .../cordova-plugin-inappbrowser/doc/ko/README.md | 0 .../cordova-plugin-inappbrowser/doc/ko/index.md | 0 .../cordova-plugin-inappbrowser/doc/pl/README.md | 0 .../cordova-plugin-inappbrowser/doc/pl/index.md | 0 .../cordova-plugin-inappbrowser/doc/ru/index.md | 0 .../cordova-plugin-inappbrowser/doc/zh/README.md | 0 .../cordova-plugin-inappbrowser/doc/zh/index.md | 0 .../cordova-plugin-inappbrowser/package.json | 25 +- .../plugins/cordova-plugin-inappbrowser/plugin.xml | 2 +- .../src/amazon/InAppBrowser.java | 0 .../src/amazon/InAppChromeClient.java | 0 .../src/android/InAppBrowser.java | 294 ++++++++++---- .../src/android/InAppBrowserDialog.java | 1 - .../src/android/InAppChromeClient.java | 0 .../res/drawable-hdpi/ic_action_next_item.png | Bin .../res/drawable-hdpi/ic_action_previous_item.png | Bin .../android/res/drawable-hdpi/ic_action_remove.png | Bin .../res/drawable-mdpi/ic_action_next_item.png | Bin .../res/drawable-mdpi/ic_action_previous_item.png | Bin .../android/res/drawable-mdpi/ic_action_remove.png | Bin .../res/drawable-xhdpi/ic_action_next_item.png | Bin .../res/drawable-xhdpi/ic_action_previous_item.png | Bin .../res/drawable-xhdpi/ic_action_remove.png | Bin .../res/drawable-xxhdpi/ic_action_next_item.png | Bin .../drawable-xxhdpi/ic_action_previous_item.png | Bin .../res/drawable-xxhdpi/ic_action_remove.png | Bin .../src/blackberry10/README.md | 0 .../src/blackberry10/doc/de/README.md | 0 .../src/blackberry10/doc/es/README.md | 0 .../src/blackberry10/doc/fr/README.md | 0 .../src/blackberry10/doc/it/README.md | 0 .../src/blackberry10/doc/ja/README.md | 0 .../src/blackberry10/doc/ko/README.md | 0 .../src/blackberry10/doc/pl/README.md | 0 .../src/blackberry10/doc/zh/README.md | 0 .../src/browser/InAppBrowserProxy.js | 35 +- .../src/firefoxos/InAppBrowserProxy.js | 24 +- .../src/ios/CDVInAppBrowser.h | 1 - .../src/ios/CDVInAppBrowser.m | 86 ++-- .../src/ubuntu/InAppBrowser.qml | 0 .../src/ubuntu/InAppBrowser_escapeScript.js | 3 + .../src/ubuntu/close.png | Bin .../src/ubuntu/inappbrowser.cpp | 0 .../src/ubuntu/inappbrowser.h | 0 .../src/windows/InAppBrowserProxy.js | 442 ++++++++++++--------- .../src/wp/InAppBrowser.cs | 0 .../cordova-plugin-inappbrowser/tests/plugin.xml | 4 +- .../tests/resources/inject.css | 0 .../tests/resources/inject.html | 0 .../tests/resources/inject.js | 2 +- .../tests/resources/local.html | 0 .../tests/resources/local.pdf | Bin .../tests/resources/video.html | 3 + .../cordova-plugin-inappbrowser/tests/tests.js | 155 +++++++- .../www/inappbrowser.css | 74 ++++ .../www/inappbrowser.js | 155 ++++---- .../www/windows8/InAppBrowserProxy.js | 5 - 72 files changed, 1279 insertions(+), 439 deletions(-) mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/CONTRIBUTING.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/LICENSE mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/NOTICE mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/README.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/RELEASENOTES.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/doc/de/README.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/doc/de/index.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/doc/es/README.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/doc/es/index.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/doc/fr/README.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/doc/fr/index.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/doc/it/README.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/doc/it/index.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/doc/ja/README.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/doc/ja/index.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/doc/ko/README.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/doc/ko/index.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/doc/pl/README.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/doc/pl/index.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/doc/ru/index.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/doc/zh/README.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/doc/zh/index.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/package.json mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/plugin.xml mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/src/amazon/InAppBrowser.java mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/src/amazon/InAppChromeClient.java mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/InAppBrowser.java mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/InAppBrowserDialog.java mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/InAppChromeClient.java mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-hdpi/ic_action_next_item.png mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-hdpi/ic_action_previous_item.png mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-hdpi/ic_action_remove.png mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-mdpi/ic_action_next_item.png mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-mdpi/ic_action_previous_item.png mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-mdpi/ic_action_remove.png mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-xhdpi/ic_action_next_item.png mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-xhdpi/ic_action_previous_item.png mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-xhdpi/ic_action_remove.png mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-xxhdpi/ic_action_next_item.png mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-xxhdpi/ic_action_previous_item.png mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-xxhdpi/ic_action_remove.png mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/README.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/de/README.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/es/README.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/fr/README.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/it/README.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/ja/README.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/ko/README.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/pl/README.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/zh/README.md mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/src/browser/InAppBrowserProxy.js mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/src/firefoxos/InAppBrowserProxy.js mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/src/ios/CDVInAppBrowser.h mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/src/ios/CDVInAppBrowser.m mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/src/ubuntu/InAppBrowser.qml mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/src/ubuntu/InAppBrowser_escapeScript.js mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/src/ubuntu/close.png mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/src/ubuntu/inappbrowser.cpp mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/src/ubuntu/inappbrowser.h mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/src/windows/InAppBrowserProxy.js mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/src/wp/InAppBrowser.cs mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/tests/plugin.xml mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/tests/resources/inject.css mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/tests/resources/inject.html mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/tests/resources/inject.js mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/tests/resources/local.html mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/tests/resources/local.pdf mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/tests/resources/video.html mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/tests/tests.js mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/www/inappbrowser.css mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/www/inappbrowser.js mode change 100755 => 100644 StoneIsland/plugins/cordova-plugin-inappbrowser/www/windows8/InAppBrowserProxy.js (limited to 'StoneIsland/plugins/cordova-plugin-inappbrowser') diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/CONTRIBUTING.md b/StoneIsland/plugins/cordova-plugin-inappbrowser/CONTRIBUTING.md old mode 100755 new mode 100644 index 4c8e6a5e..39378f26 --- a/StoneIsland/plugins/cordova-plugin-inappbrowser/CONTRIBUTING.md +++ b/StoneIsland/plugins/cordova-plugin-inappbrowser/CONTRIBUTING.md @@ -26,7 +26,7 @@ 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 +For instructions on this, start with the [contribution overview](http://cordova.apache.org/contribute/). The details are explained there, but the important items are: @@ -35,3 +35,30 @@ The details are explained there, but the important items are: - Run the tests so your patch doesn't break existing functionality. We look forward to your contributions! + +The notes on [Commit Workflow](https://github.com/apache/cordova-coho/blob/master/docs/committer-workflow.md#commit-workflow) can be helpful even if you are not a committer. + +## Running plugin tests + +* clone and install [cordova-plugin-test-framework](https://github.com/apache/cordova-plugin-test-framework) +``` +git clone git@github.com:apache/cordova-plugin-test-framework.git +``` +* edit ```cordova-plugin-test-framework/www/assets/index.html``` and add the following line +``` + +``` +* create test project +``` +cordova create plugintest +cd plugintest +cordova platform add android +cordova plugin add ../cordova-plugin-inappbrowser +cordova plugin add ../cordova-plugin-inappbrowser/tests +cordova plugin add ../cordova-plugin-test-framework +``` +* edit ```config.xml``` and replace `````` with `````` +* run application +``` +cordova run +``` diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/LICENSE b/StoneIsland/plugins/cordova-plugin-inappbrowser/LICENSE old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/NOTICE b/StoneIsland/plugins/cordova-plugin-inappbrowser/NOTICE old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/README.md b/StoneIsland/plugins/cordova-plugin-inappbrowser/README.md old mode 100755 new mode 100644 index f5c847d1..e7e96972 --- a/StoneIsland/plugins/cordova-plugin-inappbrowser/README.md +++ b/StoneIsland/plugins/cordova-plugin-inappbrowser/README.md @@ -1,3 +1,7 @@ +--- +title: Inappbrowser +description: Open an in-app browser window. +--- +|Android|iOS| Windows 8.1 Store | Windows 8.1 Phone | Windows 10 Store | Travis CI | +|:-:|:-:|:-:|:-:|:-:|:-:| +|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=android,PLUGIN=cordova-plugin-inappbrowser)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=android,PLUGIN=cordova-plugin-inappbrowser/)|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=ios,PLUGIN=cordova-plugin-inappbrowser)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=ios,PLUGIN=cordova-plugin-inappbrowser/)|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=windows-8.1-store,PLUGIN=cordova-plugin-inappbrowser)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=windows-8.1-store,PLUGIN=cordova-plugin-inappbrowser/)|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=windows-8.1-phone,PLUGIN=cordova-plugin-inappbrowser)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=windows-8.1-phone,PLUGIN=cordova-plugin-inappbrowser/)|[![Build Status](http://cordova-ci.cloudapp.net:8080/buildStatus/icon?job=cordova-periodic-build/PLATFORM=windows-10-store,PLUGIN=cordova-plugin-inappbrowser)](http://cordova-ci.cloudapp.net:8080/job/cordova-periodic-build/PLATFORM=windows-10-store,PLUGIN=cordova-plugin-inappbrowser/)|[![Build Status](https://travis-ci.org/apache/cordova-plugin-inappbrowser.svg?branch=master)](https://travis-ci.org/apache/cordova-plugin-inappbrowser)| + # cordova-plugin-inappbrowser +You can show helpful articles, videos, and web resources inside of your app. Users can view web pages without leaving your app. + +> To get a few ideas, check out the [sample](#sample) at the bottom of this page or go straight to the [reference](#reference) content. + This plugin provides a web browser view that displays when calling `cordova.InAppBrowser.open()`. var ref = cordova.InAppBrowser.open('http://apache.org', '_blank', 'location=yes'); @@ -54,10 +66,10 @@ Although `window.open` is in the global scope, InAppBrowser is not available unt console.log("window.open works well"); } -:warning: Report issues on the [Apache Cordova issue tracker](https://issues.apache.org/jira/issues/?jql=project%20%3D%20CB%20AND%20status%20in%20%28Open%2C%20%22In%20Progress%22%2C%20Reopened%29%20AND%20resolution%20%3D%20Unresolved%20AND%20component%20%3D%20%22Plugin%20InAppBrowser%22%20ORDER%20BY%20priority%20DESC%2C%20summary%20ASC%2C%20updatedDate%20DESC) - +Report issues with this plugin on the [Apache Cordova issue tracker](https://issues.apache.org/jira/issues/?jql=project%20%3D%20CB%20AND%20status%20in%20%28Open%2C%20%22In%20Progress%22%2C%20Reopened%29%20AND%20resolution%20%3D%20Unresolved%20AND%20component%20%3D%20%22Plugin%20InAppBrowser%22%20ORDER%20BY%20priority%20DESC%2C%20summary%20ASC%2C%20updatedDate%20DESC) +## Reference ## Installation cordova plugin add cordova-plugin-inappbrowser @@ -77,7 +89,7 @@ instance, or the system browser. var ref = cordova.InAppBrowser.open(url, target, options); -- __ref__: Reference to the `InAppBrowser` window. _(InAppBrowser)_ +- __ref__: Reference to the `InAppBrowser` window when the target is set to `'_blank'`. _(InAppBrowser)_ - __url__: The URL to load _(String)_. Call `encodeURI()` on this if the URL contains Unicode characters. @@ -100,6 +112,8 @@ instance, or the system browser. - __clearsessioncache__: set to `yes` to have the session cookie cache cleared before the new window is opened - __zoom__: set to `yes` to show Android browser's zoom controls, set to `no` to hide them. Default value is `yes`. - __hardwareback__: set to `yes` to use the hardware back button to navigate backwards through the `InAppBrowser`'s history. If there is no previous page, the `InAppBrowser` will close. The default value is `yes`, so you must set it to `no` if you want the back button to simply close the InAppBrowser. + - __mediaPlaybackRequiresUserAction__: Set to `yes` to prevent HTML5 audio or video from autoplaying (defaults to `no`). + - __shouldPauseOnSuspend__: Set to `yes` to make InAppBrowser WebView to pause/resume with the app to stop background audio (this may be required to avoid Google Play issues like described in [CB-11013](https://issues.apache.org/jira/browse/CB-11013)). iOS only: @@ -110,7 +124,7 @@ instance, or the system browser. - __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`). + - __mediaPlaybackRequiresUserAction__: Set to `yes` to prevent HTML5 audio or video from autoplaying (defaults to `no`). - __allowInlineMediaPlayback__: Set to `yes` or `no` to allow in-line HTML5 media playback, displaying within the browser window rather than a device-specific playback interface. The HTML's `video` element must also include the `webkit-playsinline` attribute (defaults to `no`) - __keyboardDisplayRequiresUserAction__: Set to `yes` or `no` to open the keyboard when form elements receive focus via JavaScript's `focus()` call (defaults to `yes`). - __suppressesIncrementalRendering__: Set to `yes` or `no` to wait until all new view content is received before being rendered (defaults to `no`). @@ -122,6 +136,7 @@ instance, or the system browser. - __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. - __fullscreen__: set to `yes` to create the browser control without a border around it. Please note that if __location=no__ is also specified, there will be no control presented to user to close IAB window. + - __hardwareback__: works the same way as on Android platform. ### Supported Platforms @@ -172,6 +187,10 @@ opened with `target='_blank'`. The rules might look like these ### Windows Quirks +Windows 8.0, 8.1 and Windows Phone 8.1 don't support remote urls to be opened in the Cordova WebView so remote urls are always showed in the system's web browser if opened with `target='_self'`. + +On Windows 10 if the URL is NOT in the white list and is opened with `target='_self'` it will be showed in the system's web browser instead of InAppBrowser popup. + Similar to Firefox OS IAB window visual behaviour can be overridden via `inAppBrowserWrap`/`inAppBrowserWrapFullscreen` CSS classes ### Browser Quirks @@ -182,7 +201,7 @@ Similar to Firefox OS IAB window visual behaviour can be overridden via `inAppBr ## InAppBrowser -The object returned from a call to `cordova.InAppBrowser.open`. +The object returned from a call to `cordova.InAppBrowser.open` when the target is set to `'_blank'`. ### Methods @@ -193,7 +212,7 @@ The object returned from a call to `cordova.InAppBrowser.open`. - executeScript - insertCSS -## addEventListener +## InAppBrowser.addEventListener > Adds a listener for an event from the `InAppBrowser`. @@ -210,6 +229,76 @@ The object returned from a call to `cordova.InAppBrowser.open`. - __callback__: the function that executes when the event fires. The function is passed an `InAppBrowserEvent` object as a parameter. +## Example + +```javascript + +var inAppBrowserRef; + +function showHelp(url) { + + var target = "_blank"; + + var options = "location=yes,hidden=yes"; + + inAppBrowserRef = cordova.InAppBrowser.open(url, target, options); + + inAppBrowserRef.addEventListener('loadstart', loadStartCallBack); + + inAppBrowserRef.addEventListener('loadstop', loadStopCallBack); + + inAppBrowserRef.addEventListener('loaderror', loadErrorCallBack); + +} + +function loadStartCallBack() { + + $('#status-message').text("loading please wait ..."); + +} + +function loadStopCallBack() { + + if (inAppBrowserRef != undefined) { + + inAppBrowserRef.insertCSS({ code: "body{font-size: 25px;" }); + + $('#status-message').text(""); + + inAppBrowserRef.show(); + } + +} + +function loadErrorCallBack(params) { + + $('#status-message').text(""); + + var scriptErrorMesssage = + "alert('Sorry we cannot open that page. Message from the server is : " + + params.message + "');" + + inAppBrowserRef.executeScript({ code: scriptErrorMesssage }, executeScriptCallBack); + + inAppBrowserRef.close(); + + inAppBrowserRef = undefined; + +} + +function executeScriptCallBack(params) { + + if (params[0] == null) { + + $('#status-message').text( + "Sorry we couldn't open that page. Message from the server is : '" + + params.message + "'"); + } + +} + +``` + ### InAppBrowserEvent Properties - __type__: the eventname, either `loadstart`, `loadstop`, `loaderror`, or `exit`. _(String)_ @@ -239,7 +328,7 @@ The object returned from a call to `cordova.InAppBrowser.open`. var ref = cordova.InAppBrowser.open('http://apache.org', '_blank', 'location=yes'); ref.addEventListener('loadstart', function(event) { alert(event.url); }); -## removeEventListener +## InAppBrowser.removeEventListener > Removes a listener for an event from the `InAppBrowser`. @@ -273,7 +362,7 @@ The function is passed an `InAppBrowserEvent` object. ref.addEventListener('loadstart', myCallback); ref.removeEventListener('loadstart', myCallback); -## close +## InAppBrowser.close > Closes the `InAppBrowser` window. @@ -296,7 +385,7 @@ The function is passed an `InAppBrowserEvent` object. var ref = cordova.InAppBrowser.open('http://apache.org', '_blank', 'location=yes'); ref.close(); -## show +## InAppBrowser.show > Displays an InAppBrowser window that was opened hidden. Calling this has no effect if the InAppBrowser was already visible. @@ -318,7 +407,7 @@ The function is passed an `InAppBrowserEvent` object. // some time later... ref.show(); -## executeScript +## InAppBrowser.executeScript > Injects JavaScript code into the `InAppBrowser` window @@ -360,7 +449,7 @@ The function is passed an `InAppBrowserEvent` object. Due to [MSDN docs](https://msdn.microsoft.com/en-us/library/windows.ui.xaml.controls.webview.invokescriptasync.aspx) the invoked script can return only string values, otherwise the parameter, passed to __callback__ will be `[null]`. -## insertCSS +## InAppBrowser.insertCSS > Injects CSS into the `InAppBrowser` window. @@ -387,3 +476,204 @@ Due to [MSDN docs](https://msdn.microsoft.com/en-us/library/windows.ui.xaml.cont ref.addEventListener('loadstop', function() { ref.insertCSS({file: "mystyles.css"}); }); +__ + +## Sample: Show help pages with an InAppBrowser + +You can use this plugin to show helpful documentation pages within your app. Users can view online help documents and then close them without leaving the app. + +Here's a few snippets that show how you do this. + +* [Give users a way to ask for help](#give). +* [Load a help page](#load). +* [Let users know that you're getting their page ready](#let). +* [Show the help page](#show). +* [Handle page errors](#handle). + +### Give users a way to ask for help + +There's lots of ways to do this in your app. A drop down list is a simple way to do that. + +```html + + + +``` + +Gather the users choice in the ``onDeviceReady`` function of the page and then send an appropriate URL to a helper function in some shared library file. Our helper function is named ``showHelp()`` and we'll write that function next. + +```javascript + +$('#help-select').on('change', function (e) { + + var url; + + switch (this.value) { + + case "article": + url = "https://cordova.apache.org/docs/en/latest/" + + "reference/cordova-plugin-inappbrowser/index.html"; + break; + + case "video": + url = "https://youtu.be/F-GlVrTaeH0"; + break; + + case "search": + url = "https://www.google.com/#q=inAppBrowser+plugin"; + break; + } + + showHelp(url); + +}); + +``` + +### Load a help page + +We'll use the ``open`` function to load the help page. We're setting the ``hidden`` property to ``yes`` so that we can show the browser only after the page content has loaded. That way, users don't see a blank browser while they wait for content to appear. When the ``loadstop`` event is raised, we'll know when the content has loaded. We'll handle that event shortly. + +```javascript + +function showHelp(url) { + + var target = "_blank"; + + var options = "location=yes,hidden=yes"; + + inAppBrowserRef = cordova.InAppBrowser.open(url, target, options); + + inAppBrowserRef.addEventListener('loadstart', loadStartCallBack); + + inAppBrowserRef.addEventListener('loadstop', loadStopCallBack); + + inAppBrowserRef.addEventListener('loaderror', loadErrorCallBack); + +} + +``` + +### Let users know that you're getting their page ready + +Because the browser doesn't immediately appear, we can use the ``loadstart`` event to show a status message, progress bar, or other indicator. This assures users that content is on the way. + +```javascript + +function loadStartCallBack() { + + $('#status-message').text("loading please wait ..."); + +} + +``` + +### Show the help page + +When the ``loadstopcallback`` event is raised, we know that the content has loaded and we can make the browser visible. This sort of trick can create the impression of better performance. The truth is that whether you show the browser before content loads or not, the load times are exactly the same. + +```javascript + +function loadStopCallBack() { + + if (inAppBrowserRef != undefined) { + + inAppBrowserRef.insertCSS({ code: "body{font-size: 25px;" }); + + $('#status-message').text(""); + + inAppBrowserRef.show(); + } + +} + +``` +You might have noticed the call to the ``insertCSS`` function. This serves no particular purpose in our scenario. But it gives you an idea of why you might use it. In this case, we're just making sure that the font size of your pages have a certain size. You can use this function to insert any CSS style elements. You can even point to a CSS file in your project. + +### Handle page errors + +Sometimes a page no longer exists, a script error occurs, or a user lacks permission to view the resource. How or if you handle that situation is completely up to you and your design. You can let the browser show that message or you can present it in another way. + +We'll try to show that error in a message box. We can do that by injecting a script that calls the ``alert`` function. That said, this won't work in browsers on Windows devices so we'll have to look at the parameter of the ``executeScript`` callback function to see if our attempt worked. If it didn't work out for us, we'll just show the error message in a ``
`` on the page. + +```javascript + +function loadErrorCallBack(params) { + + $('#status-message').text(""); + + var scriptErrorMesssage = + "alert('Sorry we cannot open that page. Message from the server is : " + + params.message + "');" + + inAppBrowserRef.executeScript({ code: scriptErrorMesssage }, executeScriptCallBack); + + inAppBrowserRef.close(); + + inAppBrowserRef = undefined; + +} + +function executeScriptCallBack(params) { + + if (params[0] == null) { + + $('#status-message').text( + "Sorry we couldn't open that page. Message from the server is : '" + + params.message + "'"); + } + +} + +``` + +## More Usage Info + +### Local Urls ( source is in the app package ) +``` +var iab = cordova.InAppBrowser; + +iab.open('local-url.html'); // loads in the Cordova WebView +iab.open('local-url.html', '_self'); // loads in the Cordova WebView +iab.open('local-url.html', '_system'); // Security error: system browser, but url will not load (iOS) +iab.open('local-url.html', '_blank'); // loads in the InAppBrowser +iab.open('local-url.html', 'random_string'); // loads in the InAppBrowser +iab.open('local-url.html', 'random_string', 'location=no'); // loads in the InAppBrowser, no location bar + +``` + + + +### Whitelisted Content + +``` +var iab = cordova.InAppBrowser; + +iab.open('http://whitelisted-url.com'); // loads in the Cordova WebView +iab.open('http://whitelisted-url.com', '_self'); // loads in the Cordova WebView +iab.open('http://whitelisted-url.com', '_system'); // loads in the system browser +iab.open('http://whitelisted-url.com', '_blank'); // loads in the InAppBrowser +iab.open('http://whitelisted-url.com', 'random_string'); // loads in the InAppBrowser + +iab.open('http://whitelisted-url.com', 'random_string', 'location=no'); // loads in the InAppBrowser, no location bar + +``` + +### Urls that are not white-listed + +``` +var iab = cordova.InAppBrowser; + +iab.open('http://url-that-fails-whitelist.com'); // loads in the InAppBrowser +iab.open('http://url-that-fails-whitelist.com', '_self'); // loads in the InAppBrowser +iab.open('http://url-that-fails-whitelist.com', '_system'); // loads in the system browser +iab.open('http://url-that-fails-whitelist.com', '_blank'); // loads in the InAppBrowser +iab.open('http://url-that-fails-whitelist.com', 'random_string'); // loads in the InAppBrowser +iab.open('http://url-that-fails-whitelist.com', 'random_string', 'location=no'); // loads in the InAppBrowser, no location bar + +``` \ No newline at end of file diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/RELEASENOTES.md b/StoneIsland/plugins/cordova-plugin-inappbrowser/RELEASENOTES.md old mode 100755 new mode 100644 index 1e2005d8..5d8f3e71 --- a/StoneIsland/plugins/cordova-plugin-inappbrowser/RELEASENOTES.md +++ b/StoneIsland/plugins/cordova-plugin-inappbrowser/RELEASENOTES.md @@ -20,6 +20,72 @@ --> # Release Notes +### 1.5.0 (Sep 08, 2016) +* [CB-11795](https://issues.apache.org/jira/browse/CB-11795) Add 'protective' entry to cordovaDependencies +* Add intent scheme to be handled by OS +* Plugin uses `Android Log class` and not `Cordova LOG class` +* Adding links to guide content and reference content at the top of the readme file Github: close #163 +* [CB-10973](https://issues.apache.org/jira/browse/CB-10973) **Browser**: wrong height of webview with `location=yes` +* Size and position in browser platform +* [CB-10973](https://issues.apache.org/jira/browse/CB-10973) **Windows**: wrong height of webview with `location=yes` +* [CB-11013](https://issues.apache.org/jira/browse/CB-11013) IAB enabling background play of YouTube videos? +* [CB-10467](https://issues.apache.org/jira/browse/CB-10467) Hardware back button, while `InAppBrowser` is opened, closes the app too in addition to closing `InAppBrowser` +* [CB-11178](https://issues.apache.org/jira/browse/CB-11178) allow to open other apps on **iOS 9** +* fix some calls which used api level 16 +* [CB-5402](https://issues.apache.org/jira/browse/CB-5402) added extra content from wiki page +* [CB-2063](https://issues.apache.org/jira/browse/CB-2063) (**ios**) Fixed presentation style +* [CB-11012](https://issues.apache.org/jira/browse/CB-11012) added some clarifications about `InAppBrowser` object +* [CB-3360](https://issues.apache.org/jira/browse/CB-3360) Set custom `inappbrowser` user agent for **ios** +* Add badges for paramedic builds on Jenkins +* [CB-11381](https://issues.apache.org/jira/browse/CB-11381) android: Does not pass sonarqube scan +* Add pull request template. +* [CB-10866](https://issues.apache.org/jira/browse/CB-10866) Adding engine requirements to `package.json` +* [CB-110003](https://issues.apache.org/jira/browse/CB-110003) Adding samples to Readme. +* [CB-10996](https://issues.apache.org/jira/browse/CB-10996) Adding front matter to README.md + +### 1.4.0 (Apr 15, 2016) +* [CB-7679](https://issues.apache.org/jira/browse/CB-7679) add fix for **iOS** upload. +* [CB-10944](https://issues.apache.org/jira/browse/CB-10944) `NoSuchMethodError` in `InAppBrowser` plugin +* [CB-10937](https://issues.apache.org/jira/browse/CB-10937) fix stretched icons +* [CB-10760](https://issues.apache.org/jira/browse/CB-10760) Fixing README for display on Cordova website +* [CB-10636](https://issues.apache.org/jira/browse/CB-10636) Add `JSHint` for plugins + +### 1.3.0 (Feb 09, 2016) +* [CB-3360](https://issues.apache.org/jira/browse/CB-3360) Set custom inappbrowser user agent for android +* [CB-10538](https://issues.apache.org/jira/browse/CB-10538) cordova-plugin-inappbrowser timeout issue +* [CB-10395](https://issues.apache.org/jira/browse/CB-10395) InAppBrowser's WebView not storing cookies reliable on Android +* Edit package.json license to match SPDX id +* [CB-10305](https://issues.apache.org/jira/browse/CB-10305) Gray bar appears in the wrong place on iOS +* [CB-7786](https://issues.apache.org/jira/browse/CB-7786) Support mediaPlaybackRequiresUserAction on Android +* [CB-7500](https://issues.apache.org/jira/browse/CB-7500) executeScript with callback kills/blurs inAppBrowser window on Android + +### 1.2.1 (Feb 02, 2016) +* [CB-10407](https://issues.apache.org/jira/browse/CB-10407) InAppBrowser not firing loadstart event on android +* [CB-10428](https://issues.apache.org/jira/browse/CB-10428) Fix syntax error when browserifying inAppBrowser plugin +* handle app store urls in system browser +* [CB-6702](https://issues.apache.org/jira/browse/CB-6702) InAppBrowser hangs when opening more than one instance +* [CB-10456](https://issues.apache.org/jira/browse/CB-10456) InAppBrowser is not closed if I close it programmatically on Android +* [CB-10451](https://issues.apache.org/jira/browse/CB-10451) InAppBrowser: loadstart event is not triggered on Windows +* [CB-10452](https://issues.apache.org/jira/browse/CB-10452) InAppBrowser: 'exit' event is not triggered on Windows +* [CB-10454](https://issues.apache.org/jira/browse/CB-10454) InAppBrowser: 'loaderror' event does not have code and message on Windows +* [CB-10450](https://issues.apache.org/jira/browse/CB-10450) InAppBrowser: Unable to get property 'canGoBack' of undefined on Windows +* [CB-10441](https://issues.apache.org/jira/browse/CB-10441) Add auto tests for InAppBrowser plugin + +### 1.2.0 (Jan 15, 2016) +* [CB-8180](https://issues.apache.org/jira/browse/CB-8180) Changing methods of interception in `WebViewClient` class +* [CB-10009](https://issues.apache.org/jira/browse/CB-10009) Improve `InAppBrowser` toolbar look and feel on **Windows** +* Open a new window on the **Browser** platform + +### 1.1.1 (Dec 10, 2015) + +* [CB-9445](https://issues.apache.org/jira/browse/CB-9445) Improves executeScript callbacks on iOS +* [CB-10035](https://issues.apache.org/jira/browse/CB-10035) Incremented plugin version. +* [CB-10040](https://issues.apache.org/jira/browse/CB-10040) - re-fix: backwards compatible with cordova-ios < 4.0 +* [CB-8534](https://issues.apache.org/jira/browse/CB-8534) Allow plugins to respond to onReceivedHttpAuthRequest. This closes #82 +* [CB-3750](https://issues.apache.org/jira/browse/CB-3750) Fixes spinner on iOS. This closes #89 +* [CB-7696](https://issues.apache.org/jira/browse/CB-7696) Document target=_self behavior for Windows +* [CB-10040](https://issues.apache.org/jira/browse/CB-10040) - Compile Error in InAppBrowser Plugin for iOS - No known instance method for selector 'URLIsWhitelisted:' + ### 1.1.0 (Nov 18, 2015) * [CB-10035](https://issues.apache.org/jira/browse/CB-10035) Updated `RELEASENOTES` to be newest to oldest * Invoke webview if using local file diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/doc/de/README.md b/StoneIsland/plugins/cordova-plugin-inappbrowser/doc/de/README.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/doc/de/index.md b/StoneIsland/plugins/cordova-plugin-inappbrowser/doc/de/index.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/doc/es/README.md b/StoneIsland/plugins/cordova-plugin-inappbrowser/doc/es/README.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/doc/es/index.md b/StoneIsland/plugins/cordova-plugin-inappbrowser/doc/es/index.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/doc/fr/README.md b/StoneIsland/plugins/cordova-plugin-inappbrowser/doc/fr/README.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/doc/fr/index.md b/StoneIsland/plugins/cordova-plugin-inappbrowser/doc/fr/index.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/doc/it/README.md b/StoneIsland/plugins/cordova-plugin-inappbrowser/doc/it/README.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/doc/it/index.md b/StoneIsland/plugins/cordova-plugin-inappbrowser/doc/it/index.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/doc/ja/README.md b/StoneIsland/plugins/cordova-plugin-inappbrowser/doc/ja/README.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/doc/ja/index.md b/StoneIsland/plugins/cordova-plugin-inappbrowser/doc/ja/index.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/doc/ko/README.md b/StoneIsland/plugins/cordova-plugin-inappbrowser/doc/ko/README.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/doc/ko/index.md b/StoneIsland/plugins/cordova-plugin-inappbrowser/doc/ko/index.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/doc/pl/README.md b/StoneIsland/plugins/cordova-plugin-inappbrowser/doc/pl/README.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/doc/pl/index.md b/StoneIsland/plugins/cordova-plugin-inappbrowser/doc/pl/index.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/doc/ru/index.md b/StoneIsland/plugins/cordova-plugin-inappbrowser/doc/ru/index.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/doc/zh/README.md b/StoneIsland/plugins/cordova-plugin-inappbrowser/doc/zh/README.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/doc/zh/index.md b/StoneIsland/plugins/cordova-plugin-inappbrowser/doc/zh/index.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/package.json b/StoneIsland/plugins/cordova-plugin-inappbrowser/package.json old mode 100755 new mode 100644 index cba3e5f2..8da20900 --- a/StoneIsland/plugins/cordova-plugin-inappbrowser/package.json +++ b/StoneIsland/plugins/cordova-plugin-inappbrowser/package.json @@ -1,6 +1,6 @@ { "name": "cordova-plugin-inappbrowser", - "version": "1.1.0", + "version": "1.5.0", "description": "Cordova InAppBrowser Plugin", "cordova": { "id": "cordova-plugin-inappbrowser", @@ -37,12 +37,23 @@ "cordova-windows", "cordova-firefoxos" ], - "engines": [ - { - "name": "cordova", - "version": ">=3.1.0" + "scripts": { + "test": "npm run jshint", + "jshint": "node node_modules/jshint/bin/jshint www && node node_modules/jshint/bin/jshint src && node node_modules/jshint/bin/jshint tests" + }, + "engines": { + "cordovaDependencies": { + "0.2.3": { + "cordova": ">=3.1.0" + }, + "2.0.0": { + "cordova": ">100" + } } - ], + }, "author": "Apache Software Foundation", - "license": "Apache 2.0" + "license": "Apache-2.0", + "devDependencies": { + "jshint": "^2.6.0" + } } diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/plugin.xml b/StoneIsland/plugins/cordova-plugin-inappbrowser/plugin.xml old mode 100755 new mode 100644 index a05fddc7..a27be5cf --- a/StoneIsland/plugins/cordova-plugin-inappbrowser/plugin.xml +++ b/StoneIsland/plugins/cordova-plugin-inappbrowser/plugin.xml @@ -20,7 +20,7 @@ + version="1.5.0"> InAppBrowser Cordova InAppBrowser Plugin diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/amazon/InAppBrowser.java b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/amazon/InAppBrowser.java old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/amazon/InAppChromeClient.java b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/amazon/InAppChromeClient.java old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/InAppBrowser.java b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/InAppBrowser.java old mode 100755 new mode 100644 index 60437451..8f4f3d97 --- a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/InAppBrowser.java +++ b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/InAppBrowser.java @@ -19,7 +19,6 @@ package org.apache.cordova.inappbrowser; import android.annotation.SuppressLint; -import org.apache.cordova.inappbrowser.InAppBrowserDialog; import android.content.Context; import android.content.Intent; import android.provider.Browser; @@ -30,7 +29,6 @@ import android.net.Uri; import android.os.Build; import android.os.Bundle; import android.text.InputType; -import android.util.Log; import android.util.TypedValue; import android.view.Gravity; import android.view.KeyEvent; @@ -41,17 +39,21 @@ import android.view.WindowManager.LayoutParams; import android.view.inputmethod.EditorInfo; import android.view.inputmethod.InputMethodManager; import android.webkit.CookieManager; +import android.webkit.CookieSyncManager; +import android.webkit.HttpAuthHandler; import android.webkit.WebSettings; import android.webkit.WebView; import android.webkit.WebViewClient; -import android.widget.Button; import android.widget.EditText; +import android.widget.ImageButton; +import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.RelativeLayout; import org.apache.cordova.CallbackContext; import org.apache.cordova.Config; import org.apache.cordova.CordovaArgs; +import org.apache.cordova.CordovaHttpAuthHandler; import org.apache.cordova.CordovaPlugin; import org.apache.cordova.CordovaWebView; import org.apache.cordova.LOG; @@ -61,6 +63,7 @@ import org.json.JSONException; import org.json.JSONObject; import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Field; import java.lang.reflect.Method; import java.util.HashMap; import java.util.StringTokenizer; @@ -82,6 +85,8 @@ public class InAppBrowser extends CordovaPlugin { private static final String CLEAR_ALL_CACHE = "clearcache"; private static final String CLEAR_SESSION_CACHE = "clearsessioncache"; private static final String HARDWARE_BACK_BUTTON = "hardwareback"; + private static final String MEDIA_PLAYBACK_REQUIRES_USER_ACTION = "mediaPlaybackRequiresUserAction"; + private static final String SHOULD_PAUSE = "shouldPauseOnSuspend"; private InAppBrowserDialog dialog; private WebView inAppWebView; @@ -93,6 +98,8 @@ public class InAppBrowser extends CordovaPlugin { private boolean clearAllCache = false; private boolean clearSessionCache = false; private boolean hadwareBackButton = true; + private boolean mediaPlaybackRequiresUserGesture = false; + private boolean shouldPauseInAppBrowser = false; /** * Executes the request and returns PluginResult. @@ -113,7 +120,7 @@ public class InAppBrowser extends CordovaPlugin { final String target = t; final HashMap features = parseFeature(args.optString(2)); - Log.d(LOG_TAG, "target = " + target); + LOG.d(LOG_TAG, "target = " + target); this.cordova.getActivity().runOnUiThread(new Runnable() { @Override @@ -121,7 +128,7 @@ public class InAppBrowser extends CordovaPlugin { String result = ""; // SELF if (SELF.equals(target)) { - Log.d(LOG_TAG, "in self"); + LOG.d(LOG_TAG, "in self"); /* This code exists for compatibility between 3.x and 4.x versions of Cordova. * Previously the Config class had a static method, isUrlWhitelisted(). That * responsibility has been moved to the plugins, with an aggregating method in @@ -136,8 +143,11 @@ public class InAppBrowser extends CordovaPlugin { Method iuw = Config.class.getMethod("isUrlWhiteListed", String.class); shouldAllowNavigation = (Boolean)iuw.invoke(null, url); } catch (NoSuchMethodException e) { + LOG.d(LOG_TAG, e.getLocalizedMessage()); } catch (IllegalAccessException e) { + LOG.d(LOG_TAG, e.getLocalizedMessage()); } catch (InvocationTargetException e) { + LOG.d(LOG_TAG, e.getLocalizedMessage()); } } if (shouldAllowNavigation == null) { @@ -147,20 +157,23 @@ public class InAppBrowser extends CordovaPlugin { Method san = pm.getClass().getMethod("shouldAllowNavigation", String.class); shouldAllowNavigation = (Boolean)san.invoke(pm, url); } catch (NoSuchMethodException e) { + LOG.d(LOG_TAG, e.getLocalizedMessage()); } catch (IllegalAccessException e) { + LOG.d(LOG_TAG, e.getLocalizedMessage()); } catch (InvocationTargetException e) { + LOG.d(LOG_TAG, e.getLocalizedMessage()); } } // load in webview if (Boolean.TRUE.equals(shouldAllowNavigation)) { - Log.d(LOG_TAG, "loading in webview"); + LOG.d(LOG_TAG, "loading in webview"); webView.loadUrl(url); } //Load the dialer else if (url.startsWith(WebView.SCHEME_TEL)) { try { - Log.d(LOG_TAG, "loading in dialer"); + LOG.d(LOG_TAG, "loading in dialer"); Intent intent = new Intent(Intent.ACTION_DIAL); intent.setData(Uri.parse(url)); cordova.getActivity().startActivity(intent); @@ -170,18 +183,18 @@ public class InAppBrowser extends CordovaPlugin { } // load in InAppBrowser else { - Log.d(LOG_TAG, "loading in InAppBrowser"); + LOG.d(LOG_TAG, "loading in InAppBrowser"); result = showWebPage(url, features); } } // SYSTEM else if (SYSTEM.equals(target)) { - Log.d(LOG_TAG, "in system"); + LOG.d(LOG_TAG, "in system"); result = openExternal(url); } // BLANK - or anything else else { - Log.d(LOG_TAG, "in blank"); + LOG.d(LOG_TAG, "in blank"); result = showWebPage(url, features); } @@ -197,7 +210,7 @@ public class InAppBrowser extends CordovaPlugin { else if (action.equals("injectScriptCode")) { String jsWrapper = null; if (args.getBoolean(1)) { - jsWrapper = String.format("prompt(JSON.stringify([eval(%%s)]), 'gap-iab://%s')", callbackContext.getCallbackId()); + jsWrapper = String.format("(function(){prompt(JSON.stringify([eval(%%s)]), 'gap-iab://%s')})()", callbackContext.getCallbackId()); } injectDeferredObject(args.getString(0), jsWrapper); } @@ -253,6 +266,26 @@ public class InAppBrowser extends CordovaPlugin { closeDialog(); } + /** + * Called when the system is about to start resuming a previous activity. + */ + @Override + public void onPause(boolean multitasking) { + if (shouldPauseInAppBrowser) { + inAppWebView.onPause(); + } + } + + /** + * Called when the activity will start interacting with the user. + */ + @Override + public void onResume(boolean multitasking) { + if (shouldPauseInAppBrowser) { + inAppWebView.onResume(); + } + } + /** * Called by AccelBroker when listener is to be shut down. * Stop listener. @@ -350,7 +383,7 @@ public class InAppBrowser extends CordovaPlugin { this.cordova.getActivity().startActivity(intent); return ""; } catch (android.content.ActivityNotFoundException e) { - Log.d(LOG_TAG, "InAppBrowser: Error loading url "+url+":"+ e.toString()); + LOG.d(LOG_TAG, "InAppBrowser: Error loading url "+url+":"+ e.toString()); return e.toString(); } } @@ -359,20 +392,22 @@ public class InAppBrowser extends CordovaPlugin { * Closes the dialog */ public void closeDialog() { - final WebView childView = this.inAppWebView; - // The JS protects against multiple calls, so this should happen only when - // closeDialog() is called by other native code. - if (childView == null) { - return; - } this.cordova.getActivity().runOnUiThread(new Runnable() { @Override public void run() { + final WebView childView = inAppWebView; + // The JS protects against multiple calls, so this should happen only when + // closeDialog() is called by other native code. + if (childView == null) { + return; + } + childView.setWebViewClient(new WebViewClient() { // NB: wait for about:blank before dismissing public void onPageFinished(WebView view, String url) { if (dialog != null) { dialog.dismiss(); + dialog = null; } } }); @@ -380,16 +415,16 @@ public class InAppBrowser extends CordovaPlugin { // other than your app's UI thread, it can cause unexpected results." // http://developer.android.com/guide/webapps/migrating.html#Threads childView.loadUrl("about:blank"); + + try { + JSONObject obj = new JSONObject(); + obj.put("type", EXIT_EVENT); + sendUpdate(obj, false); + } catch (JSONException ex) { + LOG.d(LOG_TAG, "Should never happen"); + } } }); - - try { - JSONObject obj = new JSONObject(); - obj.put("type", EXIT_EVENT); - sendUpdate(obj, false); - } catch (JSONException ex) { - Log.d(LOG_TAG, "Should never happen"); - } } /** @@ -468,6 +503,8 @@ public class InAppBrowser extends CordovaPlugin { showLocationBar = true; showZoomControls = true; openWindowHidden = false; + mediaPlaybackRequiresUserGesture = false; + if (features != null) { Boolean show = features.get(LOCATION); if (show != null) { @@ -485,6 +522,10 @@ public class InAppBrowser extends CordovaPlugin { if (hardwareBack != null) { hadwareBackButton = hardwareBack.booleanValue(); } + Boolean mediaPlayback = features.get(MEDIA_PLAYBACK_REQUIRES_USER_ACTION); + if (mediaPlayback != null) { + mediaPlaybackRequiresUserGesture = mediaPlayback.booleanValue(); + } Boolean cache = features.get(CLEAR_ALL_CACHE); if (cache != null) { clearAllCache = cache.booleanValue(); @@ -494,6 +535,10 @@ public class InAppBrowser extends CordovaPlugin { clearSessionCache = cache.booleanValue(); } } + Boolean shouldPause = features.get(SHOULD_PAUSE); + if (shouldPause != null) { + shouldPauseInAppBrowser = shouldPause.booleanValue(); + } } final CordovaWebView thatWebView = this.webView; @@ -516,6 +561,12 @@ public class InAppBrowser extends CordovaPlugin { @SuppressLint("NewApi") public void run() { + + // CB-6702 InAppBrowser hangs when opening more than one instance + if (dialog != null) { + dialog.dismiss(); + }; + // Let's create the main dialog dialog = new InAppBrowserDialog(cordova.getActivity(), android.R.style.Theme_NoTitleBar); dialog.getWindow().getAttributes().windowAnimations = android.R.style.Animation_Dialog; @@ -541,26 +592,28 @@ public class InAppBrowser extends CordovaPlugin { actionButtonContainer.setLayoutParams(new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); actionButtonContainer.setHorizontalGravity(Gravity.LEFT); actionButtonContainer.setVerticalGravity(Gravity.CENTER_VERTICAL); - actionButtonContainer.setId(1); + actionButtonContainer.setId(Integer.valueOf(1)); // Back button - Button back = new Button(cordova.getActivity()); + ImageButton back = new ImageButton(cordova.getActivity()); RelativeLayout.LayoutParams backLayoutParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); backLayoutParams.addRule(RelativeLayout.ALIGN_LEFT); back.setLayoutParams(backLayoutParams); back.setContentDescription("Back Button"); - back.setId(2); + back.setId(Integer.valueOf(2)); Resources activityRes = cordova.getActivity().getResources(); int backResId = activityRes.getIdentifier("ic_action_previous_item", "drawable", cordova.getActivity().getPackageName()); Drawable backIcon = activityRes.getDrawable(backResId); - if(android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN) - { - back.setBackgroundDrawable(backIcon); - } + if (Build.VERSION.SDK_INT >= 16) + back.setBackground(null); else - { - back.setBackground(backIcon); - } + back.setBackgroundDrawable(null); + back.setImageDrawable(backIcon); + back.setScaleType(ImageView.ScaleType.FIT_CENTER); + back.setPadding(0, this.dpToPixels(10), 0, this.dpToPixels(10)); + if (Build.VERSION.SDK_INT >= 16) + back.getAdjustViewBounds(); + back.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { goBack(); @@ -568,22 +621,24 @@ public class InAppBrowser extends CordovaPlugin { }); // Forward button - Button forward = new Button(cordova.getActivity()); + ImageButton forward = new ImageButton(cordova.getActivity()); RelativeLayout.LayoutParams forwardLayoutParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); forwardLayoutParams.addRule(RelativeLayout.RIGHT_OF, 2); forward.setLayoutParams(forwardLayoutParams); forward.setContentDescription("Forward Button"); - forward.setId(3); + forward.setId(Integer.valueOf(3)); int fwdResId = activityRes.getIdentifier("ic_action_next_item", "drawable", cordova.getActivity().getPackageName()); Drawable fwdIcon = activityRes.getDrawable(fwdResId); - if(android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN) - { - forward.setBackgroundDrawable(fwdIcon); - } + if (Build.VERSION.SDK_INT >= 16) + forward.setBackground(null); else - { - forward.setBackground(fwdIcon); - } + forward.setBackgroundDrawable(null); + forward.setImageDrawable(fwdIcon); + forward.setScaleType(ImageView.ScaleType.FIT_CENTER); + forward.setPadding(0, this.dpToPixels(10), 0, this.dpToPixels(10)); + if (Build.VERSION.SDK_INT >= 16) + forward.getAdjustViewBounds(); + forward.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { goForward(); @@ -596,7 +651,7 @@ public class InAppBrowser extends CordovaPlugin { textLayoutParams.addRule(RelativeLayout.RIGHT_OF, 1); textLayoutParams.addRule(RelativeLayout.LEFT_OF, 5); edittext.setLayoutParams(textLayoutParams); - edittext.setId(4); + edittext.setId(Integer.valueOf(4)); edittext.setSingleLine(true); edittext.setText(url); edittext.setInputType(InputType.TYPE_TEXT_VARIATION_URI); @@ -614,22 +669,24 @@ public class InAppBrowser extends CordovaPlugin { }); // Close/Done button - Button close = new Button(cordova.getActivity()); + ImageButton close = new ImageButton(cordova.getActivity()); RelativeLayout.LayoutParams closeLayoutParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); closeLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT); close.setLayoutParams(closeLayoutParams); forward.setContentDescription("Close Button"); - close.setId(5); + close.setId(Integer.valueOf(5)); int closeResId = activityRes.getIdentifier("ic_action_remove", "drawable", cordova.getActivity().getPackageName()); Drawable closeIcon = activityRes.getDrawable(closeResId); - if(android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN) - { - close.setBackgroundDrawable(closeIcon); - } + if (Build.VERSION.SDK_INT >= 16) + close.setBackground(null); else - { - close.setBackground(closeIcon); - } + close.setBackgroundDrawable(null); + close.setImageDrawable(closeIcon); + close.setScaleType(ImageView.ScaleType.FIT_CENTER); + back.setPadding(0, this.dpToPixels(10), 0, this.dpToPixels(10)); + if (Build.VERSION.SDK_INT >= 16) + close.getAdjustViewBounds(); + close.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { closeDialog(); @@ -639,6 +696,7 @@ public class InAppBrowser extends CordovaPlugin { // WebView inAppWebView = new WebView(cordova.getActivity()); inAppWebView.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); + inAppWebView.setId(Integer.valueOf(6)); inAppWebView.setWebChromeClient(new InAppChromeClient(thatWebView)); WebViewClient client = new InAppBrowserClient(thatWebView, edittext); inAppWebView.setWebViewClient(client); @@ -648,6 +706,20 @@ public class InAppBrowser extends CordovaPlugin { settings.setBuiltInZoomControls(showZoomControls); settings.setPluginState(android.webkit.WebSettings.PluginState.ON); + if(android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR1) { + settings.setMediaPlaybackRequiresUserGesture(mediaPlaybackRequiresUserGesture); + } + + String overrideUserAgent = preferences.getString("OverrideUserAgent", null); + String appendUserAgent = preferences.getString("AppendUserAgent", null); + + if (overrideUserAgent != null) { + settings.setUserAgentString(overrideUserAgent); + } + if (appendUserAgent != null) { + settings.setUserAgentString(settings.getUserAgentString() + appendUserAgent); + } + //Toggle whether this is enabled or not! Bundle appSettings = cordova.getActivity().getIntent().getExtras(); boolean enableDatabase = appSettings == null ? true : appSettings.getBoolean("InAppBrowserStorageEnabled", true); @@ -665,7 +737,7 @@ public class InAppBrowser extends CordovaPlugin { } inAppWebView.loadUrl(url); - inAppWebView.setId(6); + inAppWebView.setId(Integer.valueOf(6)); inAppWebView.getSettings().setLoadWithOverviewMode(true); inAppWebView.getSettings().setUseWideViewPort(true); inAppWebView.requestFocus(); @@ -753,34 +825,30 @@ public class InAppBrowser extends CordovaPlugin { } /** - * Notify the host application that a page has started loading. + * Override the URL that should be loaded + * + * This handles a small subset of all the URIs that would be encountered. * - * @param view The webview initiating the callback. - * @param url The url of the page. + * @param webView + * @param url */ @Override - public void onPageStarted(WebView view, String url, Bitmap favicon) { - super.onPageStarted(view, url, favicon); - String newloc = ""; - if (url.startsWith("http:") || url.startsWith("https:") || url.startsWith("file:")) { - newloc = url; - } - // If dialing phone (tel:5551212) - else if (url.startsWith(WebView.SCHEME_TEL)) { + public boolean shouldOverrideUrlLoading(WebView webView, String url) { + if (url.startsWith(WebView.SCHEME_TEL)) { try { Intent intent = new Intent(Intent.ACTION_DIAL); intent.setData(Uri.parse(url)); cordova.getActivity().startActivity(intent); + return true; } catch (android.content.ActivityNotFoundException e) { LOG.e(LOG_TAG, "Error dialing " + url + ": " + e.toString()); } - } - - else if (url.startsWith("geo:") || url.startsWith(WebView.SCHEME_MAILTO) || url.startsWith("market:")) { + } else if (url.startsWith("geo:") || url.startsWith(WebView.SCHEME_MAILTO) || url.startsWith("market:") || url.startsWith("intent:")) { try { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse(url)); cordova.getActivity().startActivity(intent); + return true; } catch (android.content.ActivityNotFoundException e) { LOG.e(LOG_TAG, "Error with " + url + ": " + e.toString()); } @@ -795,8 +863,7 @@ public class InAppBrowser extends CordovaPlugin { int parmIndex = url.indexOf('?'); if (parmIndex == -1) { address = url.substring(4); - } - else { + } else { address = url.substring(4, parmIndex); // If body, then set sms body @@ -812,32 +879,64 @@ public class InAppBrowser extends CordovaPlugin { intent.putExtra("address", address); intent.setType("vnd.android-dir/mms-sms"); cordova.getActivity().startActivity(intent); + return true; } catch (android.content.ActivityNotFoundException e) { LOG.e(LOG_TAG, "Error sending sms " + url + ":" + e.toString()); } } - else { + return false; + } + + + /* + * onPageStarted fires the LOAD_START_EVENT + * + * @param view + * @param url + * @param favicon + */ + @Override + public void onPageStarted(WebView view, String url, Bitmap favicon) { + super.onPageStarted(view, url, favicon); + String newloc = ""; + if (url.startsWith("http:") || url.startsWith("https:") || url.startsWith("file:")) { + newloc = url; + } + else + { + // Assume that everything is HTTP at this point, because if we don't specify, + // it really should be. Complain loudly about this!!! + LOG.e(LOG_TAG, "Possible Uncaught/Unknown URI"); newloc = "http://" + url; } + // Update the UI if we haven't already if (!newloc.equals(edittext.getText().toString())) { edittext.setText(newloc); - } + } try { JSONObject obj = new JSONObject(); obj.put("type", LOAD_START_EVENT); obj.put("url", newloc); - sendUpdate(obj, true); } catch (JSONException ex) { - Log.d(LOG_TAG, "Should never happen"); + LOG.e(LOG_TAG, "URI passed in has caused a JSON error."); } } + + public void onPageFinished(WebView view, String url) { super.onPageFinished(view, url); + // CB-10395 InAppBrowser's WebView not storing cookies reliable to local device storage + if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) { + CookieManager.getInstance().flush(); + } else { + CookieSyncManager.getInstance().sync(); + } + try { JSONObject obj = new JSONObject(); obj.put("type", LOAD_STOP_EVENT); @@ -845,7 +944,7 @@ public class InAppBrowser extends CordovaPlugin { sendUpdate(obj, true); } catch (JSONException ex) { - Log.d(LOG_TAG, "Should never happen"); + LOG.d(LOG_TAG, "Should never happen"); } } @@ -861,9 +960,46 @@ public class InAppBrowser extends CordovaPlugin { sendUpdate(obj, true, PluginResult.Status.ERROR); } catch (JSONException ex) { - Log.d(LOG_TAG, "Should never happen"); + LOG.d(LOG_TAG, "Should never happen"); } } + + /** + * On received http auth request. + */ + @Override + public void onReceivedHttpAuthRequest(WebView view, HttpAuthHandler handler, String host, String realm) { + + // Check if there is some plugin which can resolve this auth challenge + PluginManager pluginManager = null; + try { + Method gpm = webView.getClass().getMethod("getPluginManager"); + pluginManager = (PluginManager)gpm.invoke(webView); + } catch (NoSuchMethodException e) { + LOG.d(LOG_TAG, e.getLocalizedMessage()); + } catch (IllegalAccessException e) { + LOG.d(LOG_TAG, e.getLocalizedMessage()); + } catch (InvocationTargetException e) { + LOG.d(LOG_TAG, e.getLocalizedMessage()); + } + + if (pluginManager == null) { + try { + Field pmf = webView.getClass().getField("pluginManager"); + pluginManager = (PluginManager)pmf.get(webView); + } catch (NoSuchFieldException e) { + LOG.d(LOG_TAG, e.getLocalizedMessage()); + } catch (IllegalAccessException e) { + LOG.d(LOG_TAG, e.getLocalizedMessage()); + } + } + + if (pluginManager != null && pluginManager.onReceivedHttpAuthRequest(webView, new CordovaHttpAuthHandler(handler), host, realm)) { + return; + } + + // By default handle 401 like we'd normally do! + super.onReceivedHttpAuthRequest(view, handler, host, realm); + } } } - diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/InAppBrowserDialog.java b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/InAppBrowserDialog.java old mode 100755 new mode 100644 index d7017202..e7b212f2 --- a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/InAppBrowserDialog.java +++ b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/InAppBrowserDialog.java @@ -21,7 +21,6 @@ package org.apache.cordova.inappbrowser; import android.app.AlertDialog; import android.app.Dialog; import android.content.Context; -import android.util.Log; import org.json.JSONException; import org.json.JSONObject; diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/InAppChromeClient.java b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/InAppChromeClient.java old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-hdpi/ic_action_next_item.png b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-hdpi/ic_action_next_item.png old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-hdpi/ic_action_previous_item.png b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-hdpi/ic_action_previous_item.png old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-hdpi/ic_action_remove.png b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-hdpi/ic_action_remove.png old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-mdpi/ic_action_next_item.png b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-mdpi/ic_action_next_item.png old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-mdpi/ic_action_previous_item.png b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-mdpi/ic_action_previous_item.png old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-mdpi/ic_action_remove.png b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-mdpi/ic_action_remove.png old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-xhdpi/ic_action_next_item.png b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-xhdpi/ic_action_next_item.png old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-xhdpi/ic_action_previous_item.png b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-xhdpi/ic_action_previous_item.png old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-xhdpi/ic_action_remove.png b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-xhdpi/ic_action_remove.png old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-xxhdpi/ic_action_next_item.png b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-xxhdpi/ic_action_next_item.png old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-xxhdpi/ic_action_previous_item.png b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-xxhdpi/ic_action_previous_item.png old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-xxhdpi/ic_action_remove.png b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-xxhdpi/ic_action_remove.png old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/README.md b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/README.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/de/README.md b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/de/README.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/es/README.md b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/es/README.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/fr/README.md b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/fr/README.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/it/README.md b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/it/README.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/ja/README.md b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/ja/README.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/ko/README.md b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/ko/README.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/pl/README.md b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/pl/README.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/zh/README.md b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/zh/README.md old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/browser/InAppBrowserProxy.js b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/browser/InAppBrowserProxy.js old mode 100755 new mode 100644 index 33fbe476..da7dacd3 --- a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/browser/InAppBrowserProxy.js +++ b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/browser/InAppBrowserProxy.js @@ -19,9 +19,7 @@ * */ -var cordova = require('cordova'), - channel = require('cordova/channel'), - urlutil = require('cordova/urlutil'); +var modulemapper = require('cordova/modulemapper'); var browserWrap, popup, @@ -68,19 +66,23 @@ var IAB = { open: function (win, lose, args) { var strUrl = args[0], target = args[1], - features = args[2], - url; + features = args[2]; - if (target === "_system" || target === "_self" || !target) { + if (target === "_self" || !target) { window.location = strUrl; + } else if (target === "_system") { + modulemapper.getOriginalSymbol(window, 'window.open').call(window, strUrl, "_blank"); } else { // "_blank" or anything else if (!browserWrap) { browserWrap = document.createElement("div"); browserWrap.style.position = "absolute"; + browserWrap.style.top = "0"; + browserWrap.style.left = "0"; + browserWrap.style.boxSizing = "border-box"; browserWrap.style.borderWidth = "40px"; - browserWrap.style.width = "calc(100% - 80px)"; - browserWrap.style.height = "calc(100% - 80px)"; + browserWrap.style.width = "100vw"; + browserWrap.style.height = "100vh"; browserWrap.style.borderStyle = "solid"; browserWrap.style.borderColor = "rgba(0,0,0,0.25)"; @@ -105,6 +107,7 @@ var IAB = { if (features.indexOf("location=yes") !== -1 || features.indexOf("location") === -1) { popup.style.height = "calc(100% - 60px)"; + popup.style.marginBottom = "-4px"; navigationButtonsDiv = document.createElement("div"); navigationButtonsDiv.style.height = "60px"; @@ -190,7 +193,9 @@ var IAB = { if (browserWrap && popup) { try { popup.contentWindow.eval(code); - hasCallback && win([]); + if (hasCallback) { + win([]); + } } catch(e) { console.error('Error occured while trying to injectScriptCode: ' + JSON.stringify(e)); } @@ -200,19 +205,25 @@ var IAB = { injectScriptFile: function (win, fail, args) { var msg = 'Browser cordova-plugin-inappbrowser injectScriptFile is not yet implemented'; console.warn(msg); - fail && fail(msg); + if (fail) { + fail(msg); + } }, injectStyleCode: function (win, fail, args) { var msg = 'Browser cordova-plugin-inappbrowser injectStyleCode is not yet implemented'; console.warn(msg); - fail && fail(msg); + if (fail) { + fail(msg); + } }, injectStyleFile: function (win, fail, args) { var msg = 'Browser cordova-plugin-inappbrowser injectStyleFile is not yet implemented'; console.warn(msg); - fail && fail(msg); + if (fail) { + fail(msg); + } } }; diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/firefoxos/InAppBrowserProxy.js b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/firefoxos/InAppBrowserProxy.js old mode 100755 new mode 100644 index f0d44c12..c09e3583 --- a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/firefoxos/InAppBrowserProxy.js +++ b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/firefoxos/InAppBrowserProxy.js @@ -21,9 +21,7 @@ // https://developer.mozilla.org/en-US/docs/WebAPI/Browser -var cordova = require('cordova'), - channel = require('cordova/channel'), - modulemapper = require('cordova/modulemapper'); +var modulemapper = require('cordova/modulemapper'); var origOpenFunc = modulemapper.getOriginalSymbol(window, 'window.open'); var browserWrap; @@ -49,9 +47,7 @@ var IABExecs = { var strUrl = args[0], target = args[1], features_string = args[2] || "location=yes", //location=yes is default - features = {}, - url, - elem; + features = {}; var features_list = features_string.split(','); features_list.forEach(function(feature) { @@ -61,7 +57,7 @@ var IABExecs = { } else if (tup[1] == 'no') { tup[1] = false; } else { - var number = parseInt(tup[1]); + var number = parseInt(tup[1]); if (!isNaN(number)) { tup[1] = number; } @@ -115,7 +111,7 @@ var IABExecs = { back.classList.add('inAppBrowserBack'); forward.classList.add('inAppBrowserForward'); - function checkForwardBackward() { + var checkForwardBackward = function () { var backReq = browserElem.getCanGoBack(); backReq.onsuccess = function() { if (this.result) { @@ -123,7 +119,7 @@ var IABExecs = { } else { back.classList.add('disabled'); } - } + }; var forwardReq = browserElem.getCanGoForward(); forwardReq.onsuccess = function() { if (this.result) { @@ -131,7 +127,7 @@ var IABExecs = { } else { forward.classList.add('disabled'); } - } + }; }; browserElem.addEventListener('mozbrowserloadend', checkForwardBackward); @@ -163,16 +159,16 @@ var IABExecs = { win({ type:'loadstart', url : e.detail - }) + }); }, false); browserElem.addEventListener('mozbrowserloadend', function(e){ - win({type:'loadstop'}) + win({type:'loadstop'}); }, false); browserElem.addEventListener('mozbrowsererror', function(e){ - win({type:'loaderror'}) + win({type:'loaderror'}); }, false); browserElem.addEventListener('mozbrowserclose', function(e){ - win({type:'exit'}) + win({type:'exit'}); }, false); } else { window.location = strUrl; diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/ios/CDVInAppBrowser.h b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/ios/CDVInAppBrowser.h old mode 100755 new mode 100644 index 1ccc7b14..6bb0ec16 --- a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/ios/CDVInAppBrowser.h +++ b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/ios/CDVInAppBrowser.h @@ -30,7 +30,6 @@ @class CDVInAppBrowserViewController; @interface CDVInAppBrowser : CDVPlugin { - BOOL _injectedIframeBridge; } @property (nonatomic, retain) CDVInAppBrowserViewController* inAppBrowserViewController; diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/ios/CDVInAppBrowser.m b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/ios/CDVInAppBrowser.m old mode 100755 new mode 100644 index 47a8ab3a..b342ca73 --- a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/ios/CDVInAppBrowser.m +++ b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/ios/CDVInAppBrowser.m @@ -47,6 +47,11 @@ _callbackIdPattern = nil; } +- (id)settingForKey:(NSString*)key +{ + return [self.commandDelegate.settings objectForKey:[key lowercaseString]]; +} + - (void)onReset { [self close:nil]; @@ -137,8 +142,16 @@ } if (self.inAppBrowserViewController == nil) { - NSString* originalUA = [CDVUserAgentUtil originalUserAgent]; - self.inAppBrowserViewController = [[CDVInAppBrowserViewController alloc] initWithUserAgent:originalUA prevUserAgent:[self.commandDelegate userAgent] browserOptions: browserOptions]; + NSString* userAgent = [CDVUserAgentUtil originalUserAgent]; + NSString* overrideUserAgent = [self settingForKey:@"OverrideUserAgent"]; + NSString* appendUserAgent = [self settingForKey:@"AppendUserAgent"]; + if(overrideUserAgent){ + userAgent = overrideUserAgent; + } + if(appendUserAgent){ + userAgent = [userAgent stringByAppendingString: appendUserAgent]; + } + self.inAppBrowserViewController = [[CDVInAppBrowserViewController alloc] initWithUserAgent:userAgent prevUserAgent:[self.commandDelegate userAgent] browserOptions: browserOptions]; self.inAppBrowserViewController.navigationDelegate = self; if ([self.viewController conformsToProtocol:@protocol(CDVScreenOrientationDelegate)]) { @@ -218,6 +231,7 @@ initWithRootViewController:self.inAppBrowserViewController]; nav.orientationDelegate = self.inAppBrowserViewController; nav.navigationBarHidden = YES; + nav.modalPresentationStyle = self.inAppBrowserViewController.modalPresentationStyle; __weak CDVInAppBrowser* weakSelf = self; @@ -231,25 +245,25 @@ - (void)openInCordovaWebView:(NSURL*)url withOptions:(NSString*)options { - if ([self.commandDelegate URLIsWhitelisted:url]) { - NSURLRequest* request = [NSURLRequest requestWithURL:url]; + NSURLRequest* request = [NSURLRequest requestWithURL:url]; + #ifdef __CORDOVA_4_0_0 - [self.webViewEngine loadRequest:request]; + // the webview engine itself will filter for this according to policy + // in config.xml for cordova-ios-4.0 + [self.webViewEngine loadRequest:request]; #else + if ([self.commandDelegate URLIsWhitelisted:url]) { [self.webView loadRequest:request]; -#endif } else { // this assumes the InAppBrowser can be excepted from the white-list [self openInInAppBrowser:url withOptions:options]; } +#endif } - (void)openInSystem:(NSURL*)url { - if ([[UIApplication sharedApplication] canOpenURL:url]) { - [[UIApplication sharedApplication] openURL:url]; - } else { // handle any custom schemes to plugins - [[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:CDVPluginHandleOpenURLNotification object:url]]; - } + [[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:CDVPluginHandleOpenURLNotification object:url]]; + [[UIApplication sharedApplication] openURL:url]; } // This is a helper method for the inject{Script|Style}{Code|File} API calls, which @@ -263,11 +277,8 @@ - (void)injectDeferredObject:(NSString*)source withWrapper:(NSString*)jsWrapper { - if (!_injectedIframeBridge) { - _injectedIframeBridge = YES; - // Create an iframe bridge in the new document to communicate with the CDVInAppBrowserViewController - [self.inAppBrowserViewController.webView stringByEvaluatingJavaScriptFromString:@"(function(d){var e = _cdvIframeBridge = d.createElement('iframe');e.style.display='none';d.body.appendChild(e);})(document)"]; - } + // Ensure an iframe bridge is created to communicate with the CDVInAppBrowserViewController + [self.inAppBrowserViewController.webView stringByEvaluatingJavaScriptFromString:@"(function(d){_cdvIframeBridge=d.getElementById('_cdvIframeBridge');if(!_cdvIframeBridge) {var e = _cdvIframeBridge = d.createElement('iframe');e.id='_cdvIframeBridge'; e.style.display='none';d.body.appendChild(e);}})(document)"]; if (jsWrapper != nil) { NSData* jsonData = [NSJSONSerialization dataWithJSONObject:@[source] options:0 error:nil]; @@ -390,7 +401,14 @@ [self.commandDelegate sendPluginResult:pluginResult callbackId:scriptCallbackId]; return NO; } - } else if ((self.callbackId != nil) && isTopLevelNavigation) { + } + //if is an app store link, let the system handle it, otherwise it fails to load it + else if ([[ url scheme] isEqualToString:@"itms-appss"] || [[ url scheme] isEqualToString:@"itms-apps"]) { + [theWebView stopLoading]; + [self openInSystem:url]; + return NO; + } + else if ((self.callbackId != nil) && isTopLevelNavigation) { // Send a loadstart event for each top-level navigation (includes redirects). CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:@{@"type":@"loadstart", @"url":[url absoluteString]}]; @@ -404,7 +422,6 @@ - (void)webViewDidStartLoad:(UIWebView*)theWebView { - _injectedIframeBridge = NO; } - (void)webViewDidFinishLoad:(UIWebView*)theWebView @@ -512,15 +529,15 @@ self.webView.scalesPageToFit = NO; self.webView.userInteractionEnabled = YES; - self.spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite]; + self.spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray]; self.spinner.alpha = 1.000; self.spinner.autoresizesSubviews = YES; - self.spinner.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleTopMargin; + self.spinner.autoresizingMask = (UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleRightMargin); self.spinner.clearsContextBeforeDrawing = NO; self.spinner.clipsToBounds = NO; self.spinner.contentMode = UIViewContentModeScaleToFill; - self.spinner.frame = CGRectMake(454.0, 231.0, 20.0, 20.0); - self.spinner.hidden = YES; + self.spinner.frame = CGRectMake(CGRectGetMidX(self.webView.frame), CGRectGetMidY(self.webView.frame), 20.0, 20.0); + self.spinner.hidden = NO; self.spinner.hidesWhenStopped = YES; self.spinner.multipleTouchEnabled = NO; self.spinner.opaque = NO; @@ -749,6 +766,10 @@ return UIStatusBarStyleDefault; } +- (BOOL)prefersStatusBarHidden { + return NO; +} + - (void)close { [CDVUserAgentUtil releaseLock:&_userAgentLockToken]; @@ -988,19 +1009,38 @@ @implementation CDVInAppBrowserNavigationController : UINavigationController +- (void) dismissViewControllerAnimated:(BOOL)flag completion:(void (^)(void))completion { + if ( self.presentedViewController) { + [super dismissViewControllerAnimated:flag completion:completion]; + } +} + - (void) viewDidLoad { CGRect frame = [UIApplication sharedApplication].statusBarFrame; // simplified from: http://stackoverflow.com/a/25669695/219684 - UIToolbar* bgToolbar = [[UIToolbar alloc] initWithFrame:frame]; + UIToolbar* bgToolbar = [[UIToolbar alloc] initWithFrame:[self invertFrameIfNeeded:frame]]; bgToolbar.barStyle = UIBarStyleDefault; + [bgToolbar setAutoresizingMask:UIViewAutoresizingFlexibleWidth]; [self.view addSubview:bgToolbar]; [super viewDidLoad]; } +- (CGRect) invertFrameIfNeeded:(CGRect)rect { + // We need to invert since on iOS 7 frames are always in Portrait context + if (!IsAtLeastiOSVersion(@"8.0")) { + if (UIInterfaceOrientationIsLandscape([[UIApplication sharedApplication] statusBarOrientation])) { + CGFloat temp = rect.size.width; + rect.size.width = rect.size.height; + rect.size.height = temp; + } + rect.origin = CGPointZero; + } + return rect; +} #pragma mark CDVScreenOrientationDelegate diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/ubuntu/InAppBrowser.qml b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/ubuntu/InAppBrowser.qml old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/ubuntu/InAppBrowser_escapeScript.js b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/ubuntu/InAppBrowser_escapeScript.js old mode 100755 new mode 100644 index 07661bb6..b01daeb5 --- a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/ubuntu/InAppBrowser_escapeScript.js +++ b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/ubuntu/InAppBrowser_escapeScript.js @@ -19,6 +19,9 @@ * */ +/* jshint -W061 */ +/* global oxide */ + oxide.addMessageHandler("EXECUTE", function(msg) { var code = msg.args.code; try { diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/ubuntu/close.png b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/ubuntu/close.png old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/ubuntu/inappbrowser.cpp b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/ubuntu/inappbrowser.cpp old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/ubuntu/inappbrowser.h b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/ubuntu/inappbrowser.h old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/windows/InAppBrowserProxy.js b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/windows/InAppBrowserProxy.js old mode 100755 new mode 100644 index fc037bdb..23f6e547 --- a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/windows/InAppBrowserProxy.js +++ b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/windows/InAppBrowserProxy.js @@ -19,13 +19,10 @@ * */ -/*jslint sloppy:true */ -/*global Windows:true, require, document, setTimeout, window, module */ - - +/* jslint sloppy:true */ +/* global Windows:true, setImmediate */ var cordova = require('cordova'), - channel = require('cordova/channel'), urlutil = require('cordova/urlutil'); var browserWrap, @@ -35,11 +32,13 @@ var browserWrap, backButton, forwardButton, closeButton, - bodyOverflowStyle; + bodyOverflowStyle, + navigationEventsCallback, + hardwareBackCallback; // x-ms-webview is available starting from Windows 8.1 (platformId is 'windows') // http://msdn.microsoft.com/en-us/library/windows/apps/dn301831.aspx -var isWebViewAvailable = cordova.platformId == 'windows'; +var isWebViewAvailable = cordova.platformId === 'windows'; function attachNavigationEvents(element, callback) { if (isWebViewAvailable) { @@ -48,19 +47,32 @@ function attachNavigationEvents(element, callback) { }); element.addEventListener("MSWebViewNavigationCompleted", function (e) { - callback({ type: e.isSuccess ? "loadstop" : "loaderror", url: e.uri}, {keepCallback: true}); + if (e.isSuccess) { + callback({ type: "loadstop", url: e.uri }, { keepCallback: true }); + } else { + callback({ type: "loaderror", url: e.uri, code: e.webErrorStatus, message: "Navigation failed with error code " + e.webErrorStatus}, { keepCallback: true }); + } }); element.addEventListener("MSWebViewUnviewableContentIdentified", function (e) { // WebView found the content to be not HTML. // http://msdn.microsoft.com/en-us/library/windows/apps/dn609716.aspx - callback({ type: "loaderror", url: e.uri}, {keepCallback: true}); + callback({ type: "loaderror", url: e.uri, code: e.webErrorStatus, message: "Navigation failed with error code " + e.webErrorStatus}, { keepCallback: true }); }); element.addEventListener("MSWebViewContentLoading", function (e) { - if (navigationButtonsDiv) { - backButton.disabled = !popup.canGoBack; - forwardButton.disabled = !popup.canGoForward; + if (navigationButtonsDiv && popup) { + if (popup.canGoBack) { + backButton.removeAttribute("disabled"); + } else { + backButton.setAttribute("disabled", "true"); + } + + if (popup.canGoForward) { + forwardButton.removeAttribute("disabled"); + } else { + forwardButton.setAttribute("disabled", "true"); + } } }); } else { @@ -83,228 +95,266 @@ function attachNavigationEvents(element, callback) { var IAB = { close: function (win, lose) { - if (browserWrap) { - if (win) win({ type: "exit" }); - - browserWrap.parentNode.removeChild(browserWrap); - // Reset body overflow style to initial value - document.body.style.msOverflowStyle = bodyOverflowStyle; - browserWrap = null; - popup = null; - } - }, - show: function (win, lose) { - if (browserWrap) { - browserWrap.style.display = "block"; - } - }, - open: function (win, lose, args) { - var strUrl = args[0], - target = args[1], - features = args[2], - url; - - if (target === "_system") { - url = new Windows.Foundation.Uri(strUrl); - Windows.System.Launcher.launchUriAsync(url); - } else if (target === "_self" || !target) { - window.location = strUrl; - } else { - // "_blank" or anything else - if (!browserWrap) { - var browserWrapStyle = document.createElement('link'); - browserWrapStyle.rel = "stylesheet"; - browserWrapStyle.type = "text/css"; - browserWrapStyle.href = urlutil.makeAbsolute("/www/css/inappbrowser.css"); - - document.head.appendChild(browserWrapStyle); - - browserWrap = document.createElement("div"); - browserWrap.className = "inAppBrowserWrap"; - - if (features.indexOf("fullscreen=yes") > -1) { - browserWrap.classList.add("inAppBrowserWrapFullscreen"); + setImmediate(function () { + if (browserWrap) { + if (navigationEventsCallback) { + navigationEventsCallback({ type: "exit" }); } - // Save body overflow style to be able to reset it back later - bodyOverflowStyle = document.body.style.msOverflowStyle; - - browserWrap.onclick = function () { - setTimeout(function () { - IAB.close(win); - }, 0); - }; - - document.body.appendChild(browserWrap); - // Hide scrollbars for the whole body while inappbrowser's window is open - document.body.style.msOverflowStyle = "none"; - } + browserWrap.parentNode.removeChild(browserWrap); + // Reset body overflow style to initial value + document.body.style.msOverflowStyle = bodyOverflowStyle; + browserWrap = null; + popup = null; - if (features.indexOf("hidden=yes") !== -1) { - browserWrap.style.display = "none"; + document.removeEventListener("backbutton", hardwareBackCallback, false); } - - popup = document.createElement(isWebViewAvailable ? "x-ms-webview" : "iframe"); - if (popup instanceof HTMLIFrameElement) { - // For iframe we need to override bacground color of parent element here - // otherwise pages without background color set will have transparent background - popup.style.backgroundColor = "white"; + }); + }, + show: function (win, lose) { + setImmediate(function () { + if (browserWrap) { + browserWrap.style.display = "block"; } - popup.style.borderWidth = "0px"; - popup.style.width = "100%"; - - browserWrap.appendChild(popup); + }); + }, + open: function (win, lose, args) { + // make function async so that we can add navigation events handlers before view is loaded and navigation occured + setImmediate(function () { + var strUrl = args[0], + target = args[1], + features = args[2], + url; + + navigationEventsCallback = win; + + if (target === "_system") { + url = new Windows.Foundation.Uri(strUrl); + Windows.System.Launcher.launchUriAsync(url); + } else if (target === "_self" || !target) { + window.location = strUrl; + } else { + // "_blank" or anything else + if (!browserWrap) { + var browserWrapStyle = document.createElement('link'); + browserWrapStyle.rel = "stylesheet"; + browserWrapStyle.type = "text/css"; + browserWrapStyle.href = urlutil.makeAbsolute("/www/css/inappbrowser.css"); - if (features.indexOf("location=yes") !== -1 || features.indexOf("location") === -1) { - popup.style.height = "calc(100% - 60px)"; + document.head.appendChild(browserWrapStyle); - navigationButtonsDiv = document.createElement("div"); - navigationButtonsDiv.style.height = "60px"; - navigationButtonsDiv.style.backgroundColor = "#404040"; - navigationButtonsDiv.style.zIndex = "999"; - navigationButtonsDiv.onclick = function (e) { - e.cancelBubble = true; - }; + browserWrap = document.createElement("div"); + browserWrap.className = "inAppBrowserWrap"; - navigationButtonsDivInner = document.createElement("div"); - navigationButtonsDivInner.style.paddingTop = "10px"; - navigationButtonsDivInner.style.height = "50px"; - navigationButtonsDivInner.style.width = "160px"; - navigationButtonsDivInner.style.margin = "0 auto"; - navigationButtonsDivInner.style.backgroundColor = "#404040"; - navigationButtonsDivInner.style.zIndex = "999"; - navigationButtonsDivInner.onclick = function (e) { - e.cancelBubble = true; - }; + if (features.indexOf("fullscreen=yes") > -1) { + browserWrap.classList.add("inAppBrowserWrapFullscreen"); + } + // Save body overflow style to be able to reset it back later + bodyOverflowStyle = document.body.style.msOverflowStyle; - backButton = document.createElement("button"); - backButton.style.width = "40px"; - backButton.style.height = "40px"; - backButton.style.borderRadius = "40px"; + browserWrap.onclick = function () { + setTimeout(function () { + IAB.close(navigationEventsCallback); + }, 0); + }; - backButton.innerText = "<-"; - backButton.addEventListener("click", function (e) { - if (popup.canGoBack) - popup.goBack(); - }); + document.body.appendChild(browserWrap); + // Hide scrollbars for the whole body while inappbrowser's window is open + document.body.style.msOverflowStyle = "none"; + } - forwardButton = document.createElement("button"); - forwardButton.style.marginLeft = "20px"; - forwardButton.style.width = "40px"; - forwardButton.style.height = "40px"; - forwardButton.style.borderRadius = "40px"; + if (features.indexOf("hidden=yes") !== -1) { + browserWrap.style.display = "none"; + } - forwardButton.innerText = "->"; - forwardButton.addEventListener("click", function (e) { - if (popup.canGoForward) - popup.goForward(); - }); + popup = document.createElement(isWebViewAvailable ? "x-ms-webview" : "iframe"); + if (popup instanceof HTMLIFrameElement) { + // For iframe we need to override bacground color of parent element here + // otherwise pages without background color set will have transparent background + popup.style.backgroundColor = "white"; + } + popup.style.borderWidth = "0px"; + popup.style.width = "100%"; + popup.style.marginBottom = "-3px"; - closeButton = document.createElement("button"); - closeButton.style.marginLeft = "20px"; - closeButton.style.width = "40px"; - closeButton.style.height = "40px"; - closeButton.style.borderRadius = "40px"; + browserWrap.appendChild(popup); - closeButton.innerText = "x"; - closeButton.addEventListener("click", function (e) { + var closeHandler = function (e) { setTimeout(function () { - IAB.close(win); + IAB.close(navigationEventsCallback); }, 0); - }); + }; - if (!isWebViewAvailable) { - // iframe navigation is not yet supported - backButton.disabled = true; - forwardButton.disabled = true; + if (features.indexOf("hardwareback=yes") > -1 || features.indexOf("hardwareback") === -1) { + hardwareBackCallback = function () { + if (browserWrap.style.display === 'none') { + // NOTE: backbutton handlers have to throw an exception in order to prevent + // returning 'true' inside cordova-js, which would mean that the event is handled by user. + // Throwing an exception means that the default/system navigation behavior will take place, + // which is to exit the app if the navigation stack is empty. + throw 'Exit the app'; + } + + if (popup.canGoBack) { + popup.goBack(); + } else { + closeHandler(); + } + }; + } else if (features.indexOf("hardwareback=no") > -1) { + hardwareBackCallback = function () { + if (browserWrap.style.display === 'none') { + // See comment above + throw 'Exit the app'; + } + + closeHandler(); + }; } - navigationButtonsDivInner.appendChild(backButton); - navigationButtonsDivInner.appendChild(forwardButton); - navigationButtonsDivInner.appendChild(closeButton); - navigationButtonsDiv.appendChild(navigationButtonsDivInner); + document.addEventListener("backbutton", hardwareBackCallback, false); - browserWrap.appendChild(navigationButtonsDiv); - } else { - popup.style.height = "100%"; - } + if (features.indexOf("location=yes") !== -1 || features.indexOf("location") === -1) { + popup.style.height = "calc(100% - 70px)"; + + navigationButtonsDiv = document.createElement("div"); + navigationButtonsDiv.className = "inappbrowser-app-bar"; + navigationButtonsDiv.onclick = function (e) { + e.cancelBubble = true; + }; + + navigationButtonsDivInner = document.createElement("div"); + navigationButtonsDivInner.className = "inappbrowser-app-bar-inner"; + navigationButtonsDivInner.onclick = function (e) { + e.cancelBubble = true; + }; - // start listening for navigation events - attachNavigationEvents(popup, win); + backButton = document.createElement("div"); + backButton.innerText = "back"; + backButton.className = "app-bar-action action-back"; + backButton.addEventListener("click", function (e) { + if (popup.canGoBack) + popup.goBack(); + }); + + forwardButton = document.createElement("div"); + forwardButton.innerText = "forward"; + forwardButton.className = "app-bar-action action-forward"; + forwardButton.addEventListener("click", function (e) { + if (popup.canGoForward) + popup.goForward(); + }); + + closeButton = document.createElement("div"); + closeButton.innerText = "close"; + closeButton.className = "app-bar-action action-close"; + closeButton.addEventListener("click", closeHandler); + + if (!isWebViewAvailable) { + // iframe navigation is not yet supported + backButton.setAttribute("disabled", "true"); + forwardButton.setAttribute("disabled", "true"); + } + + navigationButtonsDivInner.appendChild(backButton); + navigationButtonsDivInner.appendChild(forwardButton); + navigationButtonsDivInner.appendChild(closeButton); + navigationButtonsDiv.appendChild(navigationButtonsDivInner); + + browserWrap.appendChild(navigationButtonsDiv); + } else { + popup.style.height = "100%"; + } + + // start listening for navigation events + attachNavigationEvents(popup, navigationEventsCallback); - if (isWebViewAvailable) { - strUrl = strUrl.replace("ms-appx://", "ms-appx-web://"); + if (isWebViewAvailable) { + strUrl = strUrl.replace("ms-appx://", "ms-appx-web://"); + } + popup.src = strUrl; } - popup.src = strUrl; - } + }); }, injectScriptCode: function (win, fail, args) { - var code = args[0], - hasCallback = args[1]; - - if (isWebViewAvailable && browserWrap && popup) { - var op = popup.invokeScriptAsync("eval", code); - op.oncomplete = function (e) { - // return null if event target is unavailable by some reason - var result = (e && e.target) ? [e.target.result] : [null]; - hasCallback && win(result); - }; - op.onerror = function () { }; - op.start(); - } + setImmediate(function () { + var code = args[0], + hasCallback = args[1]; + + if (isWebViewAvailable && browserWrap && popup) { + var op = popup.invokeScriptAsync("eval", code); + op.oncomplete = function (e) { + if (hasCallback) { + // return null if event target is unavailable by some reason + var result = (e && e.target) ? [e.target.result] : [null]; + win(result); + } + }; + op.onerror = function () { }; + op.start(); + } + }); }, injectScriptFile: function (win, fail, args) { - var filePath = args[0], - hasCallback = args[1]; + setImmediate(function () { + var filePath = args[0], + hasCallback = args[1]; - if (!!filePath) { - filePath = urlutil.makeAbsolute(filePath); - } + if (!!filePath) { + filePath = urlutil.makeAbsolute(filePath); + } - if (isWebViewAvailable && browserWrap && popup) { - var uri = new Windows.Foundation.Uri(filePath); - Windows.Storage.StorageFile.getFileFromApplicationUriAsync(uri).done(function (file) { - Windows.Storage.FileIO.readTextAsync(file).done(function (code) { - var op = popup.invokeScriptAsync("eval", code); - op.oncomplete = function(e) { - var result = [e.target.result]; - hasCallback && win(result); - }; - op.onerror = function () { }; - op.start(); + if (isWebViewAvailable && browserWrap && popup) { + var uri = new Windows.Foundation.Uri(filePath); + Windows.Storage.StorageFile.getFileFromApplicationUriAsync(uri).done(function (file) { + Windows.Storage.FileIO.readTextAsync(file).done(function (code) { + var op = popup.invokeScriptAsync("eval", code); + op.oncomplete = function(e) { + if (hasCallback) { + var result = [e.target.result]; + win(result); + } + }; + op.onerror = function () { }; + op.start(); + }); }); - }); - } + } + }); }, injectStyleCode: function (win, fail, args) { - var code = args[0], - hasCallback = args[1]; + setImmediate(function () { + var code = args[0], + hasCallback = args[1]; - if (isWebViewAvailable && browserWrap && popup) { - injectCSS(popup, code, hasCallback && win); - } + if (isWebViewAvailable && browserWrap && popup) { + injectCSS(popup, code, hasCallback && win); + } + }); }, injectStyleFile: function (win, fail, args) { - var filePath = args[0], - hasCallback = args[1]; - - filePath = filePath && urlutil.makeAbsolute(filePath); - - if (isWebViewAvailable && browserWrap && popup) { - var uri = new Windows.Foundation.Uri(filePath); - Windows.Storage.StorageFile.getFileFromApplicationUriAsync(uri).then(function (file) { - return Windows.Storage.FileIO.readTextAsync(file); - }).done(function (code) { - injectCSS(popup, code, hasCallback && win); - }, function () { - // no-op, just catch an error - }); - } + setImmediate(function () { + var filePath = args[0], + hasCallback = args[1]; + + filePath = filePath && urlutil.makeAbsolute(filePath); + + if (isWebViewAvailable && browserWrap && popup) { + var uri = new Windows.Foundation.Uri(filePath); + Windows.Storage.StorageFile.getFileFromApplicationUriAsync(uri).then(function (file) { + return Windows.Storage.FileIO.readTextAsync(file); + }).done(function (code) { + injectCSS(popup, code, hasCallback && win); + }, function () { + // no-op, just catch an error + }); + } + }); } }; @@ -316,7 +366,9 @@ function injectCSS (webView, cssCode, callback) { var op = webView.invokeScriptAsync("eval", evalWrapper); op.oncomplete = function() { - callback && callback([]); + if (callback) { + callback([]); + } }; op.onerror = function () { }; op.start(); diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/wp/InAppBrowser.cs b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/wp/InAppBrowser.cs old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/tests/plugin.xml b/StoneIsland/plugins/cordova-plugin-inappbrowser/tests/plugin.xml old mode 100755 new mode 100644 index f4f3be36..2cccd40a --- a/StoneIsland/plugins/cordova-plugin-inappbrowser/tests/plugin.xml +++ b/StoneIsland/plugins/cordova-plugin-inappbrowser/tests/plugin.xml @@ -20,10 +20,12 @@ + version="1.5.0"> Cordova InAppBrowser Plugin Tests Apache 2.0 + + diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/tests/resources/inject.css b/StoneIsland/plugins/cordova-plugin-inappbrowser/tests/resources/inject.css old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/tests/resources/inject.html b/StoneIsland/plugins/cordova-plugin-inappbrowser/tests/resources/inject.html old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/tests/resources/inject.js b/StoneIsland/plugins/cordova-plugin-inappbrowser/tests/resources/inject.js old mode 100755 new mode 100644 index 6f254939..a89a4215 --- a/StoneIsland/plugins/cordova-plugin-inappbrowser/tests/resources/inject.js +++ b/StoneIsland/plugins/cordova-plugin-inappbrowser/tests/resources/inject.js @@ -16,5 +16,5 @@ * specific language governing permissions and limitations * under the License. */ -var d = document.getElementById("header") +var d = document.getElementById("header"); d.innerHTML = "Script file successfully injected"; diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/tests/resources/local.html b/StoneIsland/plugins/cordova-plugin-inappbrowser/tests/resources/local.html old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/tests/resources/local.pdf b/StoneIsland/plugins/cordova-plugin-inappbrowser/tests/resources/local.pdf old mode 100755 new mode 100644 diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/tests/resources/video.html b/StoneIsland/plugins/cordova-plugin-inappbrowser/tests/resources/video.html old mode 100755 new mode 100644 index 64ea3d11..4f167f8c --- a/StoneIsland/plugins/cordova-plugin-inappbrowser/tests/resources/video.html +++ b/StoneIsland/plugins/cordova-plugin-inappbrowser/tests/resources/video.html @@ -38,5 +38,8 @@
+ diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/tests/tests.js b/StoneIsland/plugins/cordova-plugin-inappbrowser/tests/tests.js old mode 100755 new mode 100644 index a8279868..1a96029d --- a/StoneIsland/plugins/cordova-plugin-inappbrowser/tests/tests.js +++ b/StoneIsland/plugins/cordova-plugin-inappbrowser/tests/tests.js @@ -19,11 +19,118 @@ * */ +/* jshint jasmine: true */ +/* global MSApp */ + var cordova = require('cordova'); var isWindows = cordova.platformId == 'windows'; window.alert = window.alert || navigator.notification.alert; +exports.defineAutoTests = function () { + + describe('cordova.InAppBrowser', function () { + + it("inappbrowser.spec.1 should exist", function () { + expect(cordova.InAppBrowser).toBeDefined(); + }); + + it("inappbrowser.spec.2 should contain open function", function () { + expect(cordova.InAppBrowser.open).toBeDefined(); + expect(cordova.InAppBrowser.open).toEqual(jasmine.any(Function)); + }); + }); + + describe('open method', function () { + + var iabInstance; + var originalTimeout; + var url = 'https://dist.apache.org/repos/dist/dev/cordova/'; + var badUrl = 'http://bad-uri/'; + + beforeEach(function () { + // increase timeout to ensure test url could be loaded within test time + originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL; + jasmine.DEFAULT_TIMEOUT_INTERVAL = 30000; + + iabInstance = null; + }); + + afterEach(function (done) { + // restore original timeout + jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout; + + if (iabInstance !== null && iabInstance.close) { + iabInstance.close(); + } + iabInstance = null; + // add some extra time so that iab dialog is closed + setTimeout(done, 2000); + }); + + function verifyEvent(evt, type) { + expect(evt).toBeDefined(); + expect(evt.type).toEqual(type); + if (type !== 'exit') { // `exit` event does not have url field + expect(evt.url).toEqual(url); + } + } + + function verifyLoadErrorEvent(evt) { + expect(evt).toBeDefined(); + expect(evt.type).toEqual('loaderror'); + expect(evt.url).toEqual(badUrl); + expect(evt.code).toEqual(jasmine.any(Number)); + expect(evt.message).toEqual(jasmine.any(String)); + } + + it("inappbrowser.spec.3 should retun InAppBrowser instance with required methods", function () { + iabInstance = cordova.InAppBrowser.open(url, '_blank'); + + expect(iabInstance).toBeDefined(); + + expect(iabInstance.addEventListener).toEqual(jasmine.any(Function)); + expect(iabInstance.removeEventListener).toEqual(jasmine.any(Function)); + expect(iabInstance.close).toEqual(jasmine.any(Function)); + expect(iabInstance.show).toEqual(jasmine.any(Function)); + expect(iabInstance.executeScript).toEqual(jasmine.any(Function)); + expect(iabInstance.insertCSS).toEqual(jasmine.any(Function)); + }); + + it("inappbrowser.spec.4 should support loadstart and loadstop events", function (done) { + var onLoadStart = jasmine.createSpy('loadstart event callback').and.callFake(function (evt) { + verifyEvent(evt, 'loadstart'); + }); + + iabInstance = cordova.InAppBrowser.open(url, '_blank'); + iabInstance.addEventListener('loadstart', onLoadStart); + iabInstance.addEventListener('loadstop', function (evt) { + verifyEvent(evt, 'loadstop'); + expect(onLoadStart).toHaveBeenCalled(); + done(); + }); + }); + + it("inappbrowser.spec.5 should support exit event", function (done) { + iabInstance = cordova.InAppBrowser.open(url, '_blank'); + iabInstance.addEventListener('exit', function (evt) { + verifyEvent(evt, 'exit'); + done(); + }); + iabInstance.close(); + iabInstance = null; + }); + + it("inappbrowser.spec.6 should support loaderror event", function (done) { + iabInstance = cordova.InAppBrowser.open(badUrl, '_blank'); + iabInstance.addEventListener('loaderror', function (evt) { + verifyLoadErrorEvent(evt); + done(); + }); + }); + }); +}; + exports.defineManualTests = function (contentEl, createActionButton) { function doOpen(url, target, params, numExpectedRedirects, useWindowOpen) { @@ -79,13 +186,13 @@ exports.defineManualTests = function (contentEl, createActionButton) { if (e.url != lastLoadStartURL) { alert('Unexpected: ' + e.type + ' event.url != loadstart\'s event.url'); } - if (numExpectedRedirects === 0 && counts['loadstart'] !== 1) { + if (numExpectedRedirects === 0 && counts.loadstart !== 1) { // Do allow a loaderror without a loadstart (e.g. in the case of an invalid URL). - if (!(e.type == 'loaderror' && counts['loadstart'] === 0)) { - alert('Unexpected: got multiple loadstart events. (' + counts['loadstart'] + ')'); + if (!(e.type == 'loaderror' && counts.loadstart === 0)) { + alert('Unexpected: got multiple loadstart events. (' + counts.loadstart + ')'); } - } else if (numExpectedRedirects > 0 && counts['loadstart'] < (numExpectedRedirects + 1)) { - alert('Unexpected: should have got at least ' + (numExpectedRedirects + 1) + ' loadstart events, but got ' + counts['loadstart']); + } else if (numExpectedRedirects > 0 && counts.loadstart < (numExpectedRedirects + 1)) { + alert('Unexpected: should have got at least ' + (numExpectedRedirects + 1) + ' loadstart events, but got ' + counts.loadstart); } wasReset = true; numExpectedRedirects = 0; @@ -93,7 +200,7 @@ exports.defineManualTests = function (contentEl, createActionButton) { } // Verify that loadend / loaderror was called. if (e.type == 'exit') { - var numStopEvents = counts['loadstop'] + counts['loaderror']; + var numStopEvents = counts.loadstop + counts.loaderror; if (numStopEvents === 0 && !wasReset) { alert('Unexpected: browser closed without a loadstop or loaderror.'); } else if (numStopEvents > 1) { @@ -319,7 +426,11 @@ exports.defineManualTests = function (contentEl, createActionButton) { var video_tag_tests = '

Video tag

' + '
' + - 'Expected result: open successfully in InAppBrowser with an embedded video that works after clicking the "play" button.'; + 'Expected result: open successfully in InAppBrowser with an embedded video plays automatically on iOS and Android.' + + '
' + + 'Expected result: open successfully in InAppBrowser with an embedded video plays automatically on iOS and Android.' + + '
' + + 'Expected result: open successfully in InAppBrowser with an embedded video does not play automatically on iOS and Android but rather works after clicking the "play" button.'; var local_with_anchor_tag_tests = '

Local with anchor tag

' + '
' + @@ -327,16 +438,24 @@ exports.defineManualTests = function (contentEl, createActionButton) { '

' + 'Expected result: open successfully in InAppBrowser to the local page, scrolled to the beginning of the tall div with border.'; + var hardwareback_tests = '

HardwareBack

' + + '

' + + 'Expected result: By default hardwareback is yes so pressing back button should navigate backwards in history then close InAppBrowser' + + '

' + + 'Expected result: hardwareback=yes pressing back button should navigate backwards in history then close InAppBrowser' + + '

' + + 'Expected result: hardwareback=no pressing back button should close InAppBrowser regardless history'; + // CB-7490 We need to wrap this code due to Windows security restrictions // see http://msdn.microsoft.com/en-us/library/windows/apps/hh465380.aspx#differences for details if (window.MSApp && window.MSApp.execUnsafeLocalFunction) { MSApp.execUnsafeLocalFunction(function() { contentEl.innerHTML = info_div + local_tests + white_listed_tests + non_white_listed_tests + page_with_redirects_tests + pdf_url_tests + invalid_url_tests + - css_js_injection_tests + open_hidden_tests + clearing_cache_tests + video_tag_tests + local_with_anchor_tag_tests; + css_js_injection_tests + open_hidden_tests + clearing_cache_tests + video_tag_tests + local_with_anchor_tag_tests + hardwareback_tests; }); } else { contentEl.innerHTML = info_div + local_tests + white_listed_tests + non_white_listed_tests + page_with_redirects_tests + pdf_url_tests + invalid_url_tests + - css_js_injection_tests + open_hidden_tests + clearing_cache_tests + video_tag_tests + local_with_anchor_tag_tests; + css_js_injection_tests + open_hidden_tests + clearing_cache_tests + video_tag_tests + local_with_anchor_tag_tests + hardwareback_tests; } document.getElementById("user-agent").textContent = navigator.userAgent; @@ -507,6 +626,12 @@ exports.defineManualTests = function (contentEl, createActionButton) { createActionButton('Remote Video', function () { doOpen(videohtml, '_blank'); }, 'openRemoteVideo'); + createActionButton('Remote Need User No Video', function () { + doOpen(videohtml, '_blank', 'mediaPlaybackRequiresUserAction=no'); + }, 'openRemoteNeedUserNoVideo'); + createActionButton('Remote Need User Yes Video', function () { + doOpen(videohtml, '_blank', 'mediaPlaybackRequiresUserAction=yes'); + }, 'openRemoteNeedUserYesVideo'); //Local With Anchor Tag createActionButton('Anchor1', function () { @@ -515,5 +640,15 @@ exports.defineManualTests = function (contentEl, createActionButton) { createActionButton('Anchor2', function () { doOpen(localhtml + '#anchor2', '_blank'); }, 'openAnchor2'); -}; + // Hardwareback + createActionButton('no hardwareback (defaults to yes)', function () { + doOpen('http://cordova.apache.org', '_blank'); + }, 'openHardwareBackDefault'); + createActionButton('hardwareback=yes', function () { + doOpen('http://cordova.apache.org', '_blank', 'hardwareback=yes'); + }, 'openHardwareBackYes'); + createActionButton('hardwareback=no', function () { + doOpen('http://cordova.apache.org', '_blank', 'hardwareback=no'); + }, 'openHardwareBackNo'); +}; diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/www/inappbrowser.css b/StoneIsland/plugins/cordova-plugin-inappbrowser/www/inappbrowser.css old mode 100755 new mode 100644 index bd1526d3..5762c746 --- a/StoneIsland/plugins/cordova-plugin-inappbrowser/www/inappbrowser.css +++ b/StoneIsland/plugins/cordova-plugin-inappbrowser/www/inappbrowser.css @@ -38,3 +38,77 @@ .inAppBrowserWrapFullscreen { border: 0; } + +.inappbrowser-app-bar { + height: 70px; + background-color: #404040; + z-index: 9999999; +} + +.inappbrowser-app-bar-inner { + padding-top: 10px; + height: 60px; + width: 155px; + margin: 0 auto; + background-color: #404040; + z-index: 9999999; +} + +.app-bar-action { + width: auto; + height: 40px; + margin-left: 20px; + font-family: "Segoe UI Symbol"; + float: left; + color: white; + font-size: 12px; + text-transform: lowercase; + text-align: center; + cursor: default; +} + +.app-bar-action[disabled] { + color: gray; + /*disable click*/ + pointer-events: none; +} + +.app-bar-action::before { + font-size: 28px; + display: block; + height: 36px; +} + +/* Back */ +.action-back { + margin-left: 0px; +} + +.action-back::before { + content: "\E0BA"; +} + +.action-back:not([disabled]):hover::before { + content: "\E0B3"; +} + +/* Forward */ +.action-forward::before { + content: "\E0AC"; +} + +.action-forward:not([disabled]):hover::before { + content: "\E0AF"; +} + +/* Close */ +.action-close::before { + content: "\E0C7"; + /* close icon is larger so we re-size it to fit other icons */ + font-size: 20px; + line-height: 40px; +} + +.action-close:not([disabled]):hover::before { + content: "\E0CA"; +} diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/www/inappbrowser.js b/StoneIsland/plugins/cordova-plugin-inappbrowser/www/inappbrowser.js old mode 100755 new mode 100644 index 93eb4207..25f62711 --- a/StoneIsland/plugins/cordova-plugin-inappbrowser/www/inappbrowser.js +++ b/StoneIsland/plugins/cordova-plugin-inappbrowser/www/inappbrowser.js @@ -19,92 +19,93 @@ * */ -// special patch to correctly work on Ripple emulator (CB-9760) -if (window.parent && !!window.parent.ripple) { // https://gist.github.com/triceam/4658021 - module.exports = window.open.bind(window); // fallback to default window.open behaviour - return; -} +(function() { + // special patch to correctly work on Ripple emulator (CB-9760) + if (window.parent && !!window.parent.ripple) { // https://gist.github.com/triceam/4658021 + module.exports = window.open.bind(window); // fallback to default window.open behaviour + return; + } -var exec = require('cordova/exec'); -var channel = require('cordova/channel'); -var modulemapper = require('cordova/modulemapper'); -var urlutil = require('cordova/urlutil'); + var exec = require('cordova/exec'); + var channel = require('cordova/channel'); + var modulemapper = require('cordova/modulemapper'); + var urlutil = require('cordova/urlutil'); -function InAppBrowser() { - this.channels = { - 'loadstart': channel.create('loadstart'), - 'loadstop' : channel.create('loadstop'), - 'loaderror' : channel.create('loaderror'), - 'exit' : channel.create('exit') - }; -} + function InAppBrowser() { + this.channels = { + 'loadstart': channel.create('loadstart'), + 'loadstop' : channel.create('loadstop'), + 'loaderror' : channel.create('loaderror'), + 'exit' : channel.create('exit') + }; + } -InAppBrowser.prototype = { - _eventHandler: function (event) { - if (event && (event.type in this.channels)) { - this.channels[event.type].fire(event); - } - }, - close: function (eventname) { - exec(null, null, "InAppBrowser", "close", []); - }, - show: function (eventname) { - exec(null, null, "InAppBrowser", "show", []); - }, - addEventListener: function (eventname,f) { - if (eventname in this.channels) { - this.channels[eventname].subscribe(f); - } - }, - removeEventListener: function(eventname, f) { - if (eventname in this.channels) { - this.channels[eventname].unsubscribe(f); - } - }, + InAppBrowser.prototype = { + _eventHandler: function (event) { + if (event && (event.type in this.channels)) { + this.channels[event.type].fire(event); + } + }, + close: function (eventname) { + exec(null, null, "InAppBrowser", "close", []); + }, + show: function (eventname) { + exec(null, null, "InAppBrowser", "show", []); + }, + addEventListener: function (eventname,f) { + if (eventname in this.channels) { + this.channels[eventname].subscribe(f); + } + }, + removeEventListener: function(eventname, f) { + if (eventname in this.channels) { + this.channels[eventname].unsubscribe(f); + } + }, - executeScript: function(injectDetails, cb) { - if (injectDetails.code) { - exec(cb, null, "InAppBrowser", "injectScriptCode", [injectDetails.code, !!cb]); - } else if (injectDetails.file) { - exec(cb, null, "InAppBrowser", "injectScriptFile", [injectDetails.file, !!cb]); - } else { - throw new Error('executeScript requires exactly one of code or file to be specified'); - } - }, + executeScript: function(injectDetails, cb) { + if (injectDetails.code) { + exec(cb, null, "InAppBrowser", "injectScriptCode", [injectDetails.code, !!cb]); + } else if (injectDetails.file) { + exec(cb, null, "InAppBrowser", "injectScriptFile", [injectDetails.file, !!cb]); + } else { + throw new Error('executeScript requires exactly one of code or file to be specified'); + } + }, - insertCSS: function(injectDetails, cb) { - if (injectDetails.code) { - exec(cb, null, "InAppBrowser", "injectStyleCode", [injectDetails.code, !!cb]); - } else if (injectDetails.file) { - exec(cb, null, "InAppBrowser", "injectStyleFile", [injectDetails.file, !!cb]); - } else { - throw new Error('insertCSS requires exactly one of code or file to be specified'); + insertCSS: function(injectDetails, cb) { + if (injectDetails.code) { + exec(cb, null, "InAppBrowser", "injectStyleCode", [injectDetails.code, !!cb]); + } else if (injectDetails.file) { + exec(cb, null, "InAppBrowser", "injectStyleFile", [injectDetails.file, !!cb]); + } else { + throw new Error('insertCSS requires exactly one of code or file to be specified'); + } } - } -}; - -module.exports = function(strUrl, strWindowName, strWindowFeatures, callbacks) { - // Don't catch calls that write to existing frames (e.g. named iframes). - if (window.frames && window.frames[strWindowName]) { - var origOpenFunc = modulemapper.getOriginalSymbol(window, 'open'); - return origOpenFunc.apply(window, arguments); - } + }; - strUrl = urlutil.makeAbsolute(strUrl); - var iab = new InAppBrowser(); + module.exports = function(strUrl, strWindowName, strWindowFeatures, callbacks) { + // Don't catch calls that write to existing frames (e.g. named iframes). + if (window.frames && window.frames[strWindowName]) { + var origOpenFunc = modulemapper.getOriginalSymbol(window, 'open'); + return origOpenFunc.apply(window, arguments); + } - callbacks = callbacks || {}; - for (var callbackName in callbacks) { - iab.addEventListener(callbackName, callbacks[callbackName]); - } + strUrl = urlutil.makeAbsolute(strUrl); + var iab = new InAppBrowser(); - var cb = function(eventname) { - iab._eventHandler(eventname); - }; + callbacks = callbacks || {}; + for (var callbackName in callbacks) { + iab.addEventListener(callbackName, callbacks[callbackName]); + } - strWindowFeatures = strWindowFeatures || ""; + var cb = function(eventname) { + iab._eventHandler(eventname); + }; - exec(cb, cb, "InAppBrowser", "open", [strUrl, strWindowName, strWindowFeatures]); - return iab; -}; + strWindowFeatures = strWindowFeatures || ""; + exec(cb, cb, "InAppBrowser", "open", [strUrl, strWindowName, strWindowFeatures]); + return iab; + }; +})(); diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/www/windows8/InAppBrowserProxy.js b/StoneIsland/plugins/cordova-plugin-inappbrowser/www/windows8/InAppBrowserProxy.js old mode 100755 new mode 100644 index 42d15d2c..ed954770 --- a/StoneIsland/plugins/cordova-plugin-inappbrowser/www/windows8/InAppBrowserProxy.js +++ b/StoneIsland/plugins/cordova-plugin-inappbrowser/www/windows8/InAppBrowserProxy.js @@ -22,10 +22,6 @@ /*jslint sloppy:true */ /*global Windows:true, require, document, setTimeout, window, module */ - -var cordova = require('cordova'), - channel = require('cordova/channel'); - var browserWrap; var IAB = { @@ -45,7 +41,6 @@ var IAB = { open: function (win, lose, args) { var strUrl = args[0], target = args[1], - features = args[2], url, elem; -- cgit v1.2.3-70-g09d2