Compare commits

...

105 Commits

Author SHA1 Message Date
jcesarmobile
eac7303ff5 chore: Remove unused inappbrowser.css file (#1038) 2023-11-28 22:04:30 +01:00
Niklas Merz
f27c663daa chore: incremented plugin version 6.0.1-dev 2023-11-10 11:26:46 +01:00
Niklas Merz
2b7288960f Updated version and RELEASENOTES.md for release 6.0.0 2023-11-10 11:16:38 +01:00
Niklas Merz
bc17634db3 chore: bump to next major release 6.0.0 (#1033)
* chore: bump to next major release 6.0.0

* update Cordova dependencies

* bump version just like geolocation

https://github.com/apache/cordova-plugin-geolocation/blob/master/package.json#L34-L37

* Update dependencies in package-lock.json
2023-11-10 10:16:06 +01:00
Niklas Merz
51959ec268 chore(lint): update eslint config and apply fixes (#1032) 2023-11-06 22:14:27 +01:00
jcesarmobile
4b3c0f126d fix!: remove deprecated platforms windows & osx (#1030) 2023-11-04 19:51:11 +01:00
jcesarmobile
44ead0fb34 fix(ios): Remove deprecation warnings and old code (#1031)
* remove restoring status bar style code
2023-11-04 19:45:56 +01:00
alekop
31860cf6c3 fix: explicitly import dependencies, instead of relying on PCH files. This is important in Swift projects, where you cannot use prefix headers. (#927)
Co-authored-by: Aleko Petkov <apetkov@spideroak-inc.com>
2023-11-03 19:15:52 +01:00
joanbat
d735e136cd GH-706 android: Allow permissions requests (#968)
Co-authored-by: joanb-moncasoft <55381916+joanb-moncasoft@users.noreply.github.com>
2023-10-27 10:36:16 -03:00
エリス
65e86c7e1b chore: update asf config (#1029) 2023-10-19 09:45:12 +09:00
Norman Breau
d533f2a953 chore: 5.1.0-dev (#1021) 2023-09-15 00:34:39 -03:00
Norman Breau
b18b9794a8 feat(android): Download event (#1019)
* feat(android): Added download event

* android typos, whitespaces and whiteline corrected

* Update README.md

* fix: removed added whitespace trail

---------

Co-authored-by: Shaikh Amaan FM <thisisamaan.s@gmail.com>
Co-authored-by: Shaikh Amaan FM <53618794+shaikh-amaan-fm@users.noreply.github.com>
2023-09-15 00:23:22 -03:00
Norman Breau
ac16f78b15 ci(gh-action): Paramedic CI sync (#1020) 2023-09-14 21:06:14 -03:00
jcesarmobile
ec16fee79f feat(ios): Make WebView inspectable (#1015) 2023-09-11 14:20:53 +02:00
jcesarmobile
178f2d3e59 chore: use https urls in tests and README (#1016) 2023-09-07 23:36:52 +02:00
jcesarmobile
1e8599a32a chore: Update SUPPORT_QUESTION.md template (#1017) 2023-08-25 11:07:57 +02:00
DAnn2012
8ee1d38821 fix(docs): missing xml indicator in code block (#977) 2022-09-25 18:04:14 -03:00
エリス
405468cb2d ci: sync workflow with paramedic (#971) 2022-08-13 00:41:39 +09:00
エリス
a877f62d62 dep(npm): bump package-lock v2 w/ rebuild (#964) 2022-08-10 16:49:34 +09:00
エリス
bd02f45383 ci(android): update java requirement for cordova-android@11 (#957) 2022-07-16 16:44:21 +09:00
エリス
dfcffb4812 fix(android): increase toolbar to 48dp (#946)
Material Design Guidelines says "For most platforms, consider making touch targets at least 48 x 48dp."
2022-07-12 21:17:49 +09:00
エリス
1718efa138 ci(ios): update workflow w/ iOS 15 (#912) 2021-10-18 21:13:18 +09:00
エリス
0f468c7393 ci: add action-badge (#907) 2021-09-25 01:03:30 +09:00
エリス
2043109c16 ci: remove travis & appveyor (#906) 2021-09-25 00:07:33 +09:00
エリス
89c5a6a21b ci: add gh-actions workflows (#903) 2021-09-16 22:19:15 +09:00
Niklas Merz
9bc8f7629e fix(android): add space between default useragent and custom AppendUserAgent (#861)
cordova-android adds a space between the default user agent and the custom one:
c144c08112/framework/src/org/apache/cordova/engine/SystemWebViewEngine.java (L214)

With this change cordova-androids and the IAB user agent are exactly the same.
2021-06-23 12:09:27 +02:00
jcesarmobile
2fef3046fc fix(ios): make system open tel, sms, mailto and geo links (#881) 2021-06-11 14:25:43 +02:00
Niklas Merz
3b6757fc44 Incremented plugin version. (cordova-plugin-inappbrowser-5.0.0) 2021-02-10 18:11:21 +01:00
Niklas Merz
10f2ad72a0 Updated version and RELEASENOTES.md for release 5.0.0 (cordova-plugin-inappbrowser-5.0.0) 2021-02-10 17:56:58 +01:00
Niklas Merz
6b920849cc feat(ios): add InAppBrowserStatusBarStyle 'darkcontent' configuration option (#828)
Co-authored-by: Tim Brust <github@timbrust.de>
2021-02-09 08:24:56 +01:00
jcesarmobile
07862603eb chore: bump engines requirements (#823)
* chore: bump engines requirements

* bump cordova-ios to >=6.0.0
2021-02-09 08:24:17 +01:00
jcesarmobile
b496e03169 breaking: cleanup code for old android versions (#824) 2021-01-20 17:43:28 +01:00
jcesarmobile
80720a0850 chore: bump version to 5.0.0-dev (#822) 2021-01-20 17:30:10 +01:00
Niklas Merz
de31942e6c (ios): rename CDVWKProcessPoolFactory (#825)
* (ios): rename CDVWKProcessPoolFactory

CDVWKProcessPoolFactory was integrated from the WKWebView plugin with
the new name: CDVWebViewProcessPoolFactory

* (ios): Allow both processpool imports
2021-01-07 19:21:57 +01:00
エリス
8bdbd18d16 ci: add node-14.x to workflow (#826) 2020-11-28 19:50:04 +09:00
jcesarmobile
11b1347812 breaking(android): replace magic numbers with android.os.Build constants (#821) 2020-11-24 15:49:09 +01:00
Niklas Merz
85acc2a12a ci(ios): remove wkwebview plugin (#717)
cordova-ios@6.x makes the WKWebView plugin obsolete.

Co-authored-by: Erisu <ellis.bryan@gmail.com>
2020-11-23 10:21:18 +01:00
Niklas Merz
02909a7f16 Incremented plugin version. (cordova-plugin-inappbrowser-4.1.0) 2020-11-17 19:22:20 +01:00
Niklas Merz
8a29d884c3 Updated version and RELEASENOTES.md for release 4.1.0 2020-11-17 19:09:22 +01:00
Niklas Merz
af8d268ce4 chore(npm): fix npm audit issues automatically (#819) 2020-11-17 18:57:37 +01:00
Carl Poole
e1d0777ea0 fix(android): Add mitigation strategy for CVE-2020-6506 (#792) 2020-11-17 17:32:05 +01:00
wrightsonm
2e6d63751f Updated typings (#817)
Co-authored-by: Tim Brust <github@timbrust.de>
Co-authored-by: Mark <mark.wrightson@spreadex.com>
2020-11-17 14:37:32 +00:00
jcesarmobile
1020b8f642 fix(android): allow compilation in old cordova-android versions (#803) 2020-10-21 16:17:14 +02:00
Niklas Merz
46c080f59a (ios): allow to set "preferredContentMode" (#688)
PreferredContentMode can now be set with preference config. Since iPadOS came out iPads get a desktop Safari useragent by default.

see #687 

Co-authored-by: Tim Brust <github@timbrust.de>
2020-09-20 01:48:32 +02:00
エリス
2a1c0c0591 ci(travis): update osx xcode image (#768)
* ci(travis): update osx xcode image
* ci: use travis's latest supported osx_image xcode11.6
2020-09-03 19:34:47 +09:00
Dave Alden
043f96a47e Merge pull request #765 from mrbberra/master
(ios) Add InAppBrowserStatusBarStyle preference. Resolves #728
2020-09-01 16:41:53 +01:00
Tim Brust
b7ea751ba9 ci(travis): updates Android API level (#767) 2020-08-22 21:33:50 +09:00
Moses Berra
edd7250c83 add documentation for InAppBrowserStatusBarStyle preference 2020-08-18 13:22:48 -05:00
Moses Berra
deb8fbe776 undo whitespace changes due to editor preferrences 2020-08-18 12:45:52 -05:00
Moses Berra
2a28e09a70 ios: added InAppBrowserStatusBarStyle preference (#728) 2020-08-18 12:40:13 -05:00
Dave Alden
91ebdf2776 Merge pull request #738 from lazydan/master
(ios): Fix incorrect view height from the second open time
2020-07-23 12:50:21 +01:00
Tim Brust
ab8fb4417c chore: adds package-lock file (#748) 2020-07-03 18:50:02 +00:00
Tim Brust
2fb0a368ed chore(npm): use short notation in package.json (#746) 2020-07-03 13:31:23 +00:00
Tim Brust
7c2810e885 refactor(eslint): use cordova-eslint /w fix (#747) 2020-07-02 15:41:21 +00:00
jcesarmobile
bdbb1df44c fix(ios): exit event not fired on swipe down (#737) 2020-06-22 11:44:39 +02:00
lazydan
6d60e4c6eb (ios): Fix incorrect view height from the second open time 2020-06-20 00:56:52 +08:00
Niklas Merz
d5fba787d4 Incremented plugin version. (cordova-plugin-inappbrowser-4.0.0) 2020-06-09 18:57:10 +02:00
Niklas Merz
d2b512ed04 Updated version and RELEASENOTES.md for release 4.0.0 (cordova-plugin-inappbrowser-4.0.0) 2020-06-09 18:54:58 +02:00
Niklas Merz
090345248c (ios): fix regression in 2706f34 (#715)
Fix merging issue from #656

Closes #714
2020-06-05 15:23:10 +02:00
jcesarmobile
04ce789724 chore: update install engines (#685) 2020-06-04 16:48:03 +02:00
PDLMobileApps
2706f3460d (ios) Remove fake status bar with hardcoded height to fix issues in iOS devices with a notch (#656)
* (ios) Removed fake statusbar with hardcoded height to fix issues in iOS devices with a notch

* (ios) Removed no longer needed bgToolbar

* (ios) Fixed issue with rotation in landscape mode and refactored/simplified the code

Co-authored-by: Alessandro Basso <Alessandro.Basso@PeapodDigitalLabs.com>
2020-06-04 16:32:07 +02:00
Dani Palou
dcfe692ccd fix(ios): Allow loading local html files (#693) 2020-05-17 00:24:36 +02:00
Nicolas HENRY
8aaae5b3f7 GH-292 android: SSL errors handling in Android (#293) 2020-05-08 12:02:39 +00:00
jcesarmobile
2793e16ab4 fix(ios): prevent statusbar rotation after closing InAppBrowser (#672) 2020-04-27 17:54:02 +02:00
Erisu
cbe345689b chore(asf): update git notification settings 2020-04-22 13:41:11 +09:00
csware
9b6b229509 Allow App using inappbrowser to be hosted in a cross-origin ifra… (#669)
Signed-off-by: Sven Strickroth <email@cs-ware.de>
2020-04-14 17:22:08 +00:00
Niklas Merz
074d4d03ea (all platforms): remove "window.open" overwrite (#600)
Closes #599
2020-04-14 15:25:54 +02:00
Tim Brust
548f19ca90 chore: bump version to 4.0.0-dev (#670) 2020-04-14 12:56:53 +00:00
Niklas Merz
4227fe8211 Update CONTRIBUTING.md 2020-04-13 14:29:50 +02:00
Tim Brust
df4615dea4 docs: replaces outdated transition and presentation style links (#662) 2020-04-07 13:20:36 +00:00
jcesarmobile
396c085ba3 chore: remove deprecated orientation methods (#666) 2020-04-06 15:21:22 +02:00
Kamil Burek
c01f037c8a Fix incorrect TypeScript typings (#515)
* fix #514

* Update based on conversation in #514

* Fixed whitespace
2020-04-03 12:08:32 +00:00
Jim Wright
11ba4c4e7e [GH-652] add check for openInSystem postNotification (#654)
Co-authored-by: Jim Wright <jim.wright@masabi.com>
2020-03-30 10:47:30 +00:00
Tim Brust
7a856bec60 ci: updates Node.js versions (#659) 2020-03-27 18:24:32 +00:00
Tim Brust
4129f11e24 chore(npm): improve ignore list (#658) 2020-03-27 18:24:22 +00:00
Jesse MacFadyen
290841dea6 fix(android): Reset lefttoright if not set (#442)
This fixes #441
2020-03-25 18:08:04 +00:00
Mosab A
0e5f05c938 [android] Correcting the documentation regarding lefttoright opt… (#648) 2020-03-25 17:18:41 +00:00
PDLMobileApps
e78ffe7fc2 (android) Added option to turn on/off fullscreen mode in Android (#634)
* (android) Added option to turn on/off fullscreen mode in Android

* (android) Reverted version changes as requested

* (android) Changing default option value to enabled as per request

Co-authored-by: Alessandro Basso <Alessandro.Basso@PeapodDigitalLabs.com>
2020-03-24 13:24:14 +00:00
Slayterik
e658c8c201 Android GH-470 InAppBrowser: java.lang.IllegalArgumentException (#616)
Fix interacting with views when Activity destroyed
Bug description https://stackoverflow.com/questions/22924825/view-not-attached-to-window-manager-crash

Co-authored-by: Sarafanov Valeriy <sarafanov_v@firma-gamma.ru>
2020-03-20 14:07:48 +00:00
jcesarmobile
6c55e6172c breaking(ios): remove UIWebView (#635) 2020-03-05 15:51:31 +01:00
Niklas Merz
09ad59f7ef chore(release): 3.2.1-dev 2020-01-06 07:23:15 +01:00
Niklas Merz
81aa8ba5a9 (ios) fix regression in injectScriptFile
Fixes issue introduced in #584
2020-01-06 07:20:07 +01:00
Niklas Merz
2cd868e99f chore(release): release notes for 3.2.0 2020-01-04 09:43:11 +01:00
Niklas Merz
6aca3f7fb4 chore(release): 3.2.0 (version string) 2020-01-04 09:24:36 +01:00
Niklas Merz
7b42f3e105 Merge pull request #503 from alexyazvinsky/def-fix
(android) Defensive code to prevent NULL reference exceptions for async
2020-01-04 08:57:52 +01:00
Maik Hummel
82bbe29986 (ios) add compile-time decision for disabling UIWebView (#584) 2020-01-04 08:55:28 +01:00
Niklas Merz
785fc4c83d chore(release): 3.2.0-dev 2020-01-02 21:27:59 +01:00
Niklas Merz
d4338bd64a (android) improve defensive code for NULL check 2020-01-02 19:53:36 +01:00
Alex Yaz
0411a287b8 (android) defensive code to prevent NULL reference exceptions for async
Signed-off-by: Niklas Merz <niklasmerz@apache.org>
2020-01-02 19:50:26 +01:00
Lorenzo B
416b05c1e5 Replace "beforeload" with BEFORELOAD (#524)
Improve code formatting
2019-12-30 10:47:37 +01:00
mosababubakr
9a15737577 Update missing closed brace to the insert.CSS (#568) 2019-11-04 15:23:44 +00:00
Norman Breau
7b6f95964a Merge pull request #567 from mosababubakr/patch-1
Update missing closed brace to the insert.CSS
2019-11-03 11:09:54 -04:00
mosababubakr
1e16c50b1a Update missing closed brace to the insert.CSS 2019-11-03 16:56:59 +02:00
Dave Alden
80feff6cf8 Merge pull request #401 from GEDYSIntraWare/bridge
Move bridge creation to injectDeferredObject
2019-09-24 16:21:19 +01:00
Dave Alden
ba345b0159 Merge pull request #534 from GEDYSIntraWare/fix-show-ios13
Fix inappbrowser not opening on iOS 13 by using reusable window. Resolves #492
2019-09-24 15:43:48 +01:00
Niklas Merz
855394628e Fix unresponsive main window after hide 2019-09-24 16:28:07 +02:00
Niklas Merz
79b1bb61a0 Move window hiding to 'browserExit'
Fixes close, hide and toolbar 'done' and makes cordova window responsive
2019-09-23 10:29:31 +02:00
Niklas Merz
4376ddabcd New fix attempt 2019-09-20 15:48:27 +02:00
Niklas Merz
82d496ae5c Use tmpWindow and hide on close 2019-09-20 13:43:57 +02:00
Niklas Merz
81bec09526 (ios) Fix iOS 13 show not working
Removed tmpWindow and controller.
This was introduced to fix IAB with WKWebView before WKIAB existed.
2019-09-06 14:14:51 +02:00
Niklas Merz
8805f5d46a Finish revert and correct Xcode warnings 2019-09-06 13:53:36 +02:00
Niklas Merz
8810c6a8a0 (ios) Fix inappbrowser not opening on iOS 13 by using reusable window
Closes #492
2019-09-06 13:49:44 +02:00
Jan Piotrowski
2b59941514 ci(travis): upgrade to node8 2019-07-01 20:26:57 +02:00
Jan Piotrowski
84dfb09edd chore(release): 3.1.1-dev 2019-06-28 23:12:38 +02:00
Niklas Merz
e3db974080 (ios) Move createIframeBridge to injectDeferredObject
Avoid failed script injections for pages which did not finish loading.
2019-01-16 14:22:51 +01:00
39 changed files with 5958 additions and 3143 deletions

View File

@@ -1,30 +0,0 @@
# appveyor file
# http://www.appveyor.com/docs/appveyor-yml
max_jobs: 1
shallow_clone: true
init:
- git config --global core.autocrlf true
image:
- Visual Studio 2017
environment:
nodejs_version: "4"
matrix:
- PLATFORM: windows-10-store
JUST_BUILD: --justBuild
install:
- npm cache clean -f
- node --version
- npm install -g cordova-paramedic@https://github.com/apache/cordova-paramedic.git
- npm install -g cordova
- npm install
build: off
test_script:
- npm run eslint
- cordova-paramedic --config pr\%PLATFORM% --plugin . %JUST_BUILD%

48
.asf.yaml Normal file
View File

@@ -0,0 +1,48 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
github:
description: Apache Cordova InAppBrowser Plugin
homepage: https://cordova.apache.org/
labels:
- android
- cordova
- hacktoberfest
- ios
- java
- javascript
- library
- mobile
- nodejs
- objective-c
features:
wiki: false
issues: true
projects: true
enabled_merge_buttons:
squash: true
merge: false
rebase: false
notifications:
commits: commits@cordova.apache.org
issues: issues@cordova.apache.org
pullrequests_status: issues@cordova.apache.org
pullrequests_comment: issues@cordova.apache.org

View File

@@ -1,10 +1,23 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
root: true
extends: semistandard
rules:
indent:
- error
- 4
camelcase: off
padded-blocks: off
operator-linebreak: off
no-throw-literal: off
extends: '@cordova/eslint-config/browser'
overrides:
- files: [tests/**/*.js]
extends: '@cordova/eslint-config/node-tests'

View File

@@ -13,7 +13,8 @@ For usage and support questions, please check out the resources below. Thanks!
You can get answers to your usage and support questions about **Apache Cordova** on:
* Slack Community Chat: https://cordova.slack.com (you can sign-up at http://slack.cordova.io/)
* GitHub Discussions: https://github.com/apache/cordova/discussions
* Slack Community Chat: https://cordova.slack.com (you can sign-up at https://s.apache.org/cordova-slack)
* StackOverflow: https://stackoverflow.com/questions/tagged/cordova using the tag `cordova`
---
@@ -22,6 +23,4 @@ If you are using a tool that uses Cordova internally, like e.g. Ionic, check the
* **Ionic Framework**
* [Ionic Community Forum](https://forum.ionicframework.com/)
* [Ionic Worldwide Slack](https://ionicworldwide.herokuapp.com/)
* **PhoneGap**
* [PhoneGap Developer Community](https://forums.adobe.com/community/phonegap)
* [Ionic Discord](https://ionic.link/discord)

137
.github/workflows/android.yml vendored Normal file
View File

@@ -0,0 +1,137 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
name: Android Testsuite
on:
push:
paths-ignore:
- '**.md'
- 'LICENSE'
- '.eslint*'
pull_request:
paths-ignore:
- '**.md'
- 'LICENSE'
- '.eslint*'
jobs:
test:
name: Android ${{ matrix.versions.android }} Test
runs-on: macos-latest
continue-on-error: true
# hoist configurations to top that are expected to be updated
env:
# Storing a copy of the repo
repo: ${{ github.event.pull_request.head.repo.full_name || github.repository }}
node-version: 16
# These are the default Java configurations used by most tests.
# To customize these options, add "java-distro" or "java-version" to the strategy matrix with its overriding value.
default_java-distro: temurin
default_java-version: 11
# These are the default Android System Image configurations used by most tests.
# To customize these options, add "system-image-arch" or "system-image-target" to the strategy matrix with its overriding value.
default_system-image-arch: x86_64
default_system-image-target: google_apis # Most system images have a google_api option. Set this as default.
# configurations for each testing strategy (test matrix)
strategy:
matrix:
versions:
# Test the lowest minimum supported APIs
- android: 7
android-api: 24
# Test the last 3-4 supported APIs
- android: 10
android-api: 29
- android: 11
android-api: 30
- android: 12L
android-api: 32
- android: 13
android-api: 33
timeout-minutes: 60
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ env.node-version }}
- uses: actions/setup-java@v3
env:
java-version: ${{ matrix.versions.java-version == '' && env.default_java-version || matrix.versions.java-version }}
java-distro: ${{ matrix.versions.java-distro == '' && env.default_java-distro || matrix.versions.java-distro }}
with:
distribution: ${{ env.java-distro }}
java-version: ${{ env.java-version }}
- name: Run Environment Information
run: |
node --version
npm --version
java -version
- name: Run npm install
run: |
export PATH="/usr/local/lib/android/sdk/platform-tools":$PATH
export JAVA_HOME=$JAVA_HOME_11_X64
npm i -g cordova@latest
npm ci
- name: Run paramedic install
if: ${{ endswith(env.repo, '/cordova-paramedic') != true }}
run: npm i -g github:apache/cordova-paramedic
- uses: reactivecircus/android-emulator-runner@d94c3fbe4fe6a29e4a5ba47c12fb47677c73656b
env:
system-image-arch: ${{ matrix.versions.system-image-arch == '' && env.default_system-image-arch || matrix.versions.system-image-arch }}
system-image-target: ${{ matrix.versions.system-image-target == '' && env.default_system-image-target || matrix.versions.system-image-target }}
with:
api-level: ${{ matrix.versions.android-api }}
target: ${{ env.system-image-target }}
arch: ${{ env.system-image-arch }}
force-avd-creation: false
disable-animations: false
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim
script: echo "Pregenerate the AVD before running Paramedic"
- name: Run paramedic tests
uses: reactivecircus/android-emulator-runner@d94c3fbe4fe6a29e4a5ba47c12fb47677c73656b
env:
system-image-arch: ${{ matrix.versions.system-image-arch == '' && env.default_system-image-arch || matrix.versions.system-image-arch }}
system-image-target: ${{ matrix.versions.system-image-target == '' && env.default_system-image-target || matrix.versions.system-image-target }}
test_config: 'android-${{ matrix.versions.android }}.config.json'
# Generally, this should automatically work for cordova-paramedic & plugins. If the path is unique, this can be manually changed.
test_plugin_path: ${{ endswith(env.repo, '/cordova-paramedic') && './spec/testable-plugin/' || './' }}
paramedic: ${{ endswith(env.repo, '/cordova-paramedic') && 'node main.js' || 'cordova-paramedic' }}
with:
api-level: ${{ matrix.versions.android-api }}
target: ${{ env.system-image-target }}
arch: ${{ env.system-image-arch }}
force-avd-creation: false
disable-animations: false
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim
script: ${{ env.paramedic }} --config ./pr/local/${{ env.test_config }} --plugin ${{ env.test_plugin_path }}

73
.github/workflows/chrome.yml vendored Normal file
View File

@@ -0,0 +1,73 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
name: Chrome Testsuite
on:
push:
paths-ignore:
- '**.md'
- 'LICENSE'
- '.eslint*'
pull_request:
paths-ignore:
- '**.md'
- 'LICENSE'
- '.eslint*'
jobs:
test:
name: Chrome Latest Test
runs-on: ubuntu-latest
# hoist configurations to top that are expected to be updated
env:
# Storing a copy of the repo
repo: ${{ github.event.pull_request.head.repo.full_name || github.repository }}
node-version: 16
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ env.node-version }}
- name: Run install xvfb
run: sudo apt-get install xvfb
- name: Run Environment Information
run: |
node --version
npm --version
- name: Run npm install
run: |
npm i -g cordova@latest
npm ci
- name: Run paramedic install
if: ${{ endswith(env.repo, '/cordova-paramedic') != true }}
run: npm i -g github:apache/cordova-paramedic
- name: Run paramedic tests
env:
test_config: 'browser.config.json'
# Generally, this should automatically work for cordova-paramedic & plugins. If the path is unique, this can be manually changed.
test_plugin_path: ${{ endswith(env.repo, '/cordova-paramedic') && './spec/testable-plugin/' || './' }}
paramedic: ${{ endswith(env.repo, '/cordova-paramedic') && 'node main.js' || 'cordova-paramedic' }}
run: xvfb-run --auto-servernum ${{ env.paramedic }} --config ./pr/local/${{ env.test_config }} --plugin ${{ env.test_plugin_path }}

101
.github/workflows/ios.yml vendored Normal file
View File

@@ -0,0 +1,101 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
name: iOS Testsuite
on:
push:
paths-ignore:
- '**.md'
- 'LICENSE'
- '.eslint*'
pull_request:
paths-ignore:
- '**.md'
- 'LICENSE'
- '.eslint*'
jobs:
test:
name: iOS ${{ matrix.versions.ios-version }} Test
runs-on: ${{ matrix.versions.os-version }}
continue-on-error: true
# hoist configurations to top that are expected to be updated
env:
# Storing a copy of the repo
repo: ${{ github.event.pull_request.head.repo.full_name || github.repository }}
node-version: 16
# > Starting April 26, 2021, all iOS and iPadOS apps submitted to the App Store must be built with Xcode 12 and the iOS 14 SDK.
# Because of Apple's requirement, listed above, We will only be using the latest Xcode release for testing.
# To customize these options, add "xcode-version" to the strategy matrix with its overriding value.
default_xcode-version: latest-stable
strategy:
matrix:
versions:
- os-version: macos-11
ios-version: 13.x
xcode-version: 11.x
- os-version: macos-11
ios-version: 14.x
xcode-version: 12.x
- os-version: macos-11
ios-version: 15.x
xcode-version: 13.x
- os-version: macos-12
ios-version: 16.x
xcode-version: 14.x
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: ${{ env.node-version }}
- uses: maxim-lobanov/setup-xcode@9a697e2b393340c3cacd97468baa318e4c883d98
env:
xcode-version: ${{ matrix.versions.xcode-version == '' && env.default_xcode-version || matrix.versions.xcode-version }}
with:
xcode-version: ${{ env.xcode-version }}
- name: Run Environment Information
run: |
node --version
npm --version
xcodebuild -version
- name: Run npm install
run: |
npm i -g cordova@latest ios-deploy@latest
npm ci
- name: Run paramedic install
if: ${{ endswith(env.repo, '/cordova-paramedic') != true }}
run: npm i -g github:apache/cordova-paramedic
- name: Run paramedic tests
env:
test_config: 'ios-${{ matrix.versions.ios-version }}.config.json'
# Generally, this should automatically work for cordova-paramedic & plugins. If the path is unique, this can be manually changed.
test_plugin_path: ${{ endswith(env.repo, '/cordova-paramedic') && './spec/testable-plugin/' || './' }}
paramedic: ${{ endswith(env.repo, '/cordova-paramedic') && 'node main.js' || 'cordova-paramedic' }}
run: ${{ env.paramedic }} --config ./pr/local/${{ env.test_config }} --plugin ${{ env.test_plugin_path }}

56
.github/workflows/lint.yml vendored Normal file
View File

@@ -0,0 +1,56 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
name: Lint Test
on:
push:
paths:
- '**.js'
- '.eslint*'
- '.github/workflow/lint.yml'
pull_request:
paths:
- '**.js'
- '.eslint*'
- '.github/workflow/lint.yml'
jobs:
test:
name: Lint Test
runs-on: ubuntu-latest
env:
node-version: 16
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ env.node-version }}
- name: Run Environment Information
run: |
node --version
npm --version
- name: Run npm install
run: |
npm ci
- name: Run lint test
run: |
npm run lint

View File

@@ -1,16 +1,2 @@
# CI service configurations
.travis.yml
.appveyor.yml
appveyor.yml
# Testing, code coverage, and linting
.eslintignore
.eslintrc.yml
# Git
.git
.gitattributes
.gitignore
# Github
.github
.*
tests

View File

@@ -1,117 +0,0 @@
# This Travis configuration file is built after a Cordova Paramedic
# specific template with minimal modifications and adaptations:
# https://github.com/apache/cordova-paramedic/blob/master/.travis.yml
sudo: false
addons:
jwt:
# SAUCE_ACCESS_KEY
secure: TZ88IEvAw1bsWPWxvDzXdpi2NK0i3PN4hG15+vDpIt6wXGVPknjxuXWJeLj7TqBpAIvP7XDfS8ZvHVPLe7fe8oOchZPLuiDw9VVIk6cnHjE6wpoavdGc/1mDJ3Bi4PDcHwRUr5ng5spYQqqlTwcECkH/q7iPgudiFM6rlOlGRyA=
env:
global:
- SAUCE_USERNAME=snay
- TRAVIS_NODE_VERSION=6
- ANDROID_API_LEVEL=28
- ANDROID_BUILD_TOOLS_VERSION=28.0.3
language: node_js
node_js: 6
# yaml anchor/alias: https://medium.com/@tommyvn/travis-yml-dry-with-anchors-8b6a3ac1b027
_ios: &_ios
os: osx
osx_image: xcode10.2
_android: &_android
language: android
os: linux
jdk: oraclejdk8
android:
components:
- tools
- build-tools-$ANDROID_BUILD_TOOLS_VERSION
- android-$ANDROID_API_LEVEL
licenses:
- 'android-sdk-preview-license-.+'
- 'android-sdk-license-.+'
- 'google-gdk-license-.+'
matrix:
include:
# local tests, without saucelabs
- env: PLATFORM=local/browser
<<: *_ios
- env: PLATFORM=local/ios-10.0
<<: *_ios
# many tests with saucelabs
- env: PLATFORM=browser-chrome
- env: PLATFORM=browser-firefox
- env: PLATFORM=browser-safari
- env: PLATFORM=browser-edge
- env: PLATFORM=ios-11.3
<<: *_ios
- env: PLATFORM=ios-12.0
<<: *_ios
- env: PLATFORM=android-5.1
<<: *_android
- env: PLATFORM=android-6.0
<<: *_android
- env: PLATFORM=android-7.0
<<: *_android
- env: PLATFORM=android-7.1
<<: *_android
- env: PLATFORM=android-8.0
<<: *_android
- env: PLATFORM=android-8.1
<<: *_android
- env: PLATFORM=android-9.0
<<: *_android
before_install:
# manually install Node for `language: android`
- if [[ "$PLATFORM" =~ android ]]; then nvm install $TRAVIS_NODE_VERSION; fi
- node --version
- if [[ "$PLATFORM" =~ android ]]; then gradle --version; fi
- if [[ "$PLATFORM" =~ ios ]]; then npm install -g ios-deploy; fi
- npm install -g cordova
# install paramedic if not running on paramedic repo
- if ! [[ "$TRAVIS_REPO_SLUG" =~ cordova-paramedic ]]; then npm install -g github:apache/cordova-paramedic; fi
install:
- npm install
before_script:
- |
if [[ "$TRAVIS_REPO_SLUG" =~ cordova-paramedic ]]; then
# when used in the cordova-paramedic repo
TEST_COMMAND="npm run eslint"
PARAMEDIC_PLUGIN_TO_TEST="./spec/testable-plugin/"
PARAMEDIC_COMMAND="node main.js"
else
# when used in any other (plugin) repo
TEST_COMMAND="npm test"
PARAMEDIC_PLUGIN_TO_TEST=$(pwd)
PARAMEDIC_COMMAND="cordova-paramedic"
fi
- PARAMEDIC_BUILDNAME=travis-$TRAVIS_REPO_SLUG-$TRAVIS_JOB_NUMBER
- |
echo "Variables now are set to:"
echo "TEST_COMMAND=$TEST_COMMAND"
echo "ADDITIONAL_TESTS=$ADDITIONAL_TESTS"
echo "PARAMEDIC_COMMAND=$PARAMEDIC_COMMAND"
echo "PLATFORM=$PLATFORM"
echo "PARAMEDIC_PLUGIN_TO_TEST=$PARAMEDIC_PLUGIN_TO_TEST"
echo "PARAMEDIC_BUILDNAME=$PARAMEDIC_BUILDNAME"
script:
- $TEST_COMMAND
- if [[ "$ADDITIONAL_TESTS_DIR" != "" ]]; then
cd $ADDITIONAL_TESTS_DIR && npm install && npm test;
else
$PARAMEDIC_COMMAND --config ./pr/$PLATFORM --plugin $PARAMEDIC_PLUGIN_TO_TEST --buildName $PARAMEDIC_BUILDNAME;
fi

View File

@@ -25,40 +25,13 @@ Anyone can contribute to Cordova. And we need your contributions.
There are multiple ways to contribute: report bugs, improve the docs, and
contribute code.
For instructions on this, start with the
[contribution overview](http://cordova.apache.org/contribute/).
The details are explained there, but the important items are:
- Sign and submit an Apache ICLA (Contributor License Agreement).
- Have a Jira issue open that corresponds to your contribution.
- Check for Github issues that corresponds to your contribution and link or create them if necessary.
- 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
```
<meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com http://cordova.apache.org http://google.co.uk https://google.co.uk 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *">
```
* 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 ```<content src="index.html" />``` with ```<content src="cdvtests/index.html" />```
* run application
```
cordova run
```

166
README.md
View File

@@ -21,19 +21,18 @@ description: Open an in-app browser window.
# under the License.
-->
|AppVeyor|Travis CI|
|:-:|:-:|
|[![Build status](https://ci.appveyor.com/api/projects/status/github/apache/cordova-plugin-inappbrowser?branch=master)](https://ci.appveyor.com/project/ApacheSoftwareFoundation/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
[![Android Testsuite](https://github.com/apache/cordova-plugin-inappbrowser/actions/workflows/android.yml/badge.svg)](https://github.com/apache/cordova-plugin-inappbrowser/actions/workflows/android.yml) [![Chrome Testsuite](https://github.com/apache/cordova-plugin-inappbrowser/actions/workflows/chrome.yml/badge.svg)](https://github.com/apache/cordova-plugin-inappbrowser/actions/workflows/chrome.yml) [![iOS Testsuite](https://github.com/apache/cordova-plugin-inappbrowser/actions/workflows/ios.yml/badge.svg)](https://github.com/apache/cordova-plugin-inappbrowser/actions/workflows/ios.yml) [![Lint Test](https://github.com/apache/cordova-plugin-inappbrowser/actions/workflows/lint.yml/badge.svg)](https://github.com/apache/cordova-plugin-inappbrowser/actions/workflows/lint.yml)
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');
var ref = cordova.InAppBrowser.open('https://apache.org', '_blank', 'location=yes');
### `window.open`
@@ -43,6 +42,10 @@ InAppBrowser window, by replacing window.open:
window.open = cordova.InAppBrowser.open;
If you change the browsers `window.open` function this way, it can have unintended side
effects (especially if this plugin is included only as a dependency of another
plugin).
The InAppBrowser window behaves like a standard web browser,
and can't access Cordova APIs. For this reason, the InAppBrowser is recommended
if you need to load third-party (untrusted) content, instead of loading that
@@ -52,22 +55,6 @@ whitelist, nor is opening links in the system browser.
The InAppBrowser provides by default its own GUI controls for the user (back,
forward, done).
For backwards compatibility, this plugin also hooks `window.open`.
However, the plugin-installed hook of `window.open` can have unintended side
effects (especially if this plugin is included only as a dependency of another
plugin). The hook of `window.open` will be removed in a future major release.
Until the hook is removed from the plugin, apps can manually restore the default
behaviour:
delete window.open // Reverts the call back to its prototype's default
Although `window.open` is in the global scope, InAppBrowser is not available until after the `deviceready` event.
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
console.log("window.open works well");
}
## Installation
cordova plugin add cordova-plugin-inappbrowser
@@ -80,6 +67,14 @@ simply hook `window.open` during initialization. For example:
window.open = cordova.InAppBrowser.open;
}
### Preferences
#### <b>config.xml</b>
- <b>InAppBrowserStatusBarStyle [iOS only]</b>: (string, options 'lightcontent', 'darkcontent' or 'default'. Defaults to 'default') set text color style for iOS. 'lightcontent' is intended for use on dark backgrounds. 'darkcontent' is only available since iOS 13 and intended for use on light backgrounds.
```xml
<preference name="InAppBrowserStatusBarStyle" value="lightcontent" />
```
## cordova.InAppBrowser.open
Opens a URL in a new `InAppBrowser` instance, the current browser
@@ -123,15 +118,15 @@ instance, or the system browser.
- __hideurlbar__: set to `yes` to hide the url bar on the location toolbar, only has effect if user has location set to `yes`. The default value is `no`.
- __navigationbuttoncolor__: set to a valid hex color string, for example: `#00ff00`, and it will change the color of both navigation buttons from default. Only has effect if user has location set to `yes` and not hidenavigationbuttons set to `yes`.
- __toolbarcolor__: set to a valid hex color string, for example: `#00ff00`, and it will change the color the toolbar from default. Only has effect if user has location set to `yes`.
- __lefttoright__: Set to `yes` to swap positions of the navigation buttons and the close button. Specifically, navigation buttons go to the left and close button to the right.
- __lefttoright__: Set to `yes` to swap positions of the navigation buttons and the close button. Specifically, navigation buttons go to the right and close button to the left. Default value is `no`.
- __zoom__: set to `yes` to show Android browser's zoom controls, set to `no` to hide them. Default value is `yes`.
- __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)).
- __useWideViewPort__: Sets whether the WebView should enable support for the "viewport" HTML meta tag or should use a wide viewport. When the value of the setting is `no`, the layout width is always set to the width of the WebView control in device-independent (CSS) pixels. When the value is `yes` and the page contains the viewport meta tag, the value of the width specified in the tag is used. If the page does not contain the tag or does not provide a width, then a wide viewport will be used. (defaults to `yes`).
- __fullscreen__: Sets whether the InappBrowser WebView is displayed fullscreen or not. In fullscreen mode, the status bar is hidden. Default value is `yes`.
iOS supports these additional options:
- __usewkwebview__: set to `yes` to use WKWebView engine for the InappBrowser. Omit or set to `no` (default) to use UIWebView. Note: Using `usewkwebview=yes` requires that a WKWebView engine plugin be installed in the Cordova project (e.g. [cordova-plugin-wkwebview-engine](https://github.com/apache/cordova-plugin-wkwebview-engine) or [cordova-plugin-ionic-webview](https://github.com/ionic-team/cordova-plugin-ionic-webview)).
- __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.
- __beforeload__: set to enable the `beforeload` event to modify which pages are actually loaded in the browser. Accepted values are `get` to intercept only GET requests, `post` to intercept on POST requests or `yes` to intercept both GET & POST requests. Note that POST requests are not currently supported and will be ignored (if you set `beforeload=post` it will raise an error).
- __clearcache__: set to `yes` to have the browser's cookie cache cleared before the new window is opened
@@ -139,41 +134,31 @@ instance, or the system browser.
- __cleardata__: set to `yes` to have the browser's entire local storage cleared (cookies, HTML5 local storage, IndexedDB, etc.) before the new window is opened
- __closebuttoncolor__: set as a valid hex color string, for example: `#00ff00`, to change from the default __Done__ button's color. Only applicable if toolbar is not disabled.
- __closebuttoncaption__: set to a string to use as the __Done__ button's caption. Note that you need to localize this value yourself.
- __disallowoverscroll__: Set to `yes` or `no` (default is `no`). Turns on/off the UIWebViewBounce property.
- __disallowoverscroll__: Set to `yes` or `no` (default is `no`). Turns on/off the the bounce of the WKWebView's UIScrollView.
- __hidenavigationbuttons__: set to `yes` or `no` to turn the toolbar navigation buttons on or off (defaults to `no`). Only applicable if toolbar is not disabled.
- __navigationbuttoncolor__: set as a valid hex color string, for example: `#00ff00`, to change from the default color. Only applicable if navigation buttons are visible.
- __toolbar__: set to `yes` or `no` to turn the toolbar on or off for the InAppBrowser (defaults to `yes`)
- __toolbarcolor__: set as a valid hex color string, for example: `#00ff00`, to change from the default color of the toolbar. Only applicable if toolbar is not disabled.
- __toolbartranslucent__: set to `yes` or `no` to make the toolbar translucent(semi-transparent) (defaults to `yes`). Only applicable if toolbar is not disabled.
- __lefttoright__: Set to `yes` to swap positions of the navigation buttons and the close button. Specifically, close button goes to the right and navigation buttons to the left.
- __enableViewportScale__: Set to `yes` or `no` to prevent viewport scaling through a meta tag (defaults to `no`). Only applicable to UIWebView (`usewkwebview=no`) and WKWebView (`usewkwebview=yes`) on iOS 10+.
- __mediaPlaybackRequiresUserAction__: Set to `yes` to prevent HTML5 audio or video from autoplaying (defaults to `no`). Applicable to UIWebView (`usewkwebview=no`) and WKWebView (`usewkwebview=yes`).
- __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`). Applicable to UIWebView (`usewkwebview=no`) and WKWebView (`usewkwebview=yes`).
- __keyboardDisplayRequiresUserAction__: Set to `yes` or `no` to open the keyboard when form elements receive focus via JavaScript's `focus()` call (defaults to `yes`). Only applicable to UIWebView (`usewkwebview=no`).
- __suppressesIncrementalRendering__: Set to `yes` or `no` to wait until all new view content is received before being rendered (defaults to `no`). Only applicable to UIWebView (`usewkwebview=no`).
- __presentationstyle__: Set to `pagesheet`, `formsheet` or `fullscreen` to set the [presentation style](http://developer.apple.com/library/ios/documentation/UIKit/Reference/UIViewController_Class/Reference/Reference.html#//apple_ref/occ/instp/UIViewController/modalPresentationStyle) (defaults to `fullscreen`).
- __transitionstyle__: Set to `fliphorizontal`, `crossdissolve` or `coververtical` to set the [transition style](http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIViewController_Class/Reference/Reference.html#//apple_ref/occ/instp/UIViewController/modalTransitionStyle) (defaults to `coververtical`).
- __enableViewportScale__: Set to `yes` or `no` to prevent viewport scaling through a meta tag (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`).
- __presentationstyle__: Set to `pagesheet`, `formsheet` or `fullscreen` to set the [presentation style](https://developer.apple.com/documentation/uikit/uimodalpresentationstyle) (defaults to `fullscreen`).
- __transitionstyle__: Set to `fliphorizontal`, `crossdissolve` or `coververtical` to set the [transition style](https://developer.apple.com/documentation/uikit/uimodaltransitionstyle) (defaults to `coververtical`).
- __toolbarposition__: Set to `top` or `bottom` (default is `bottom`). Causes the toolbar to be at the top or bottom of the window.
- __hidespinner__: Set to `yes` or `no` to change the visibility of the loading indicator (defaults to `no`).
Windows supports these additional options:
- __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.
- __hardwareback__: works the same way as on Android platform.
- __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.
### Supported Platforms
- Android
- Browser
- iOS
- OSX
- Windows
### Example
var ref = cordova.InAppBrowser.open('http://apache.org', '_blank', 'location=yes');
var ref = cordova.InAppBrowser.open('https://apache.org', '_blank', 'location=yes');
var ref2 = cordova.InAppBrowser.open(encodeURI('http://ja.m.wikipedia.org/wiki/ハングル'), '_blank', 'location=yes');
### OSX Quirks
@@ -182,6 +167,16 @@ At the moment the only supported target in OSX is `_system`.
`_blank` and `_self` targets are not yet implemented and are ignored silently. Pull requests and patches to get these to work are greatly appreciated.
### iOS Quirks
Since the introduction of iPadOS 13, iPads try to adapt their content mode / user agent for the optimal browsing experience. This may result in iPads having their user agent set to Macintosh, making it hard to detect them as mobile devices using user agent string sniffing. You can change this with the `PreferredContentMode` preference in `config.xml`.
```xml
<preference name="PreferredContentMode" value="mobile" />
```
The example above forces the user agent to contain `iPad`. The other option is to use the value `desktop` to turn the user agent to `Macintosh`.
### Browser Quirks
- Plugin is implemented via iframe,
@@ -218,6 +213,7 @@ The object returned from a call to `cordova.InAppBrowser.open` when the target i
- __exit__: event fires when the `InAppBrowser` window is closed.
- __beforeload__: event fires when the `InAppBrowser` decides whether to load an URL or not (only with option `beforeload` set).
- __message__: event fires when the `InAppBrowser` receives a message posted from the page loaded inside the `InAppBrowser` Webview.
- __download__: _(Android Only)_ event fires when the `InAppBrowser` loads a URL that leads in downloading of a file.
- __callback__: the function that executes when the event fires. The function is passed an `InAppBrowserEvent` object as a parameter.
@@ -256,7 +252,7 @@ function loadStopCallBack() {
if (inAppBrowserRef != undefined) {
inAppBrowserRef.insertCSS({ code: "body{font-size: 25px;" });
inAppBrowserRef.insertCSS({ code: "body{font-size: 25px;}" });
inAppBrowserRef.executeScript({ code: "\
var message = 'this is the message';\
@@ -318,39 +314,56 @@ function messageCallBack(params){
}
```
#### Download event Example
Whenever the InAppBrowser receives or locates to a url which leads in downloading a file, the callback assigned to the "download" event is called. The parameter passed to this callback is an object with the the following properties
- **type** _it contains the String value "download" always_
- **url** _The url that leaded to the downloading of file. Basically, the download link of file_
- **userAgent** _User Agent of the webview_
- **contentDisposition** _If the url contains "content-disposition" header, then this property holds the value of that field else this field is empty_
- **contentLength** _If the link of the file allows to obtain file size then this property holds the file size else it contains int value 0_
- **mimetype** _The MIME type of the file_
```
function downloadListener(params){
var url = params.url;
var mimetype = params.mimetype;
var xhr = new XMLHttpRequest();
xhr.open("GET", params.url);
xhr.onload = function() {
var content = xhr.responseText;
};
xhr.send();
}
```
### InAppBrowserEvent Properties
- __type__: the eventname, either `loadstart`, `loadstop`, `loaderror`, `message` or `exit`. _(String)_
- __url__: the URL that was loaded. _(String)_
- __code__: the error code, only in the case of `loaderror`. _(Number)_
- __message__: the error message, only in the case of `loaderror`. _(String)_
- __data__: the message contents , only in the case of `message`. A stringified JSON object. _(String)_
### Supported Platforms
- Android
- Browser
- iOS
- Windows
- OSX
### Browser Quirks
`loadstart`, `loaderror`, `message` events are not fired.
### Windows Quirks
`message` event is not fired.
### Quick Example
var ref = cordova.InAppBrowser.open('http://apache.org', '_blank', 'location=yes');
var ref = cordova.InAppBrowser.open('https://apache.org', '_blank', 'location=yes');
ref.addEventListener('loadstart', function(event) { alert(event.url); });
## InAppBrowser.removeEventListener
@@ -368,6 +381,7 @@ function messageCallBack(params){
- __loaderror__: event fires when the `InAppBrowser` encounters an error loading a URL.
- __exit__: event fires when the `InAppBrowser` window is closed.
- __message__: event fires when the `InAppBrowser` receives a message posted from the page loaded inside the `InAppBrowser` Webview.
- __download__: _(Android only)_ event fires when the `InAppBrowser` loads a URL that leads in downloading of a file.
- __callback__: the function to execute when the event fires.
The function is passed an `InAppBrowserEvent` object.
@@ -377,11 +391,10 @@ The function is passed an `InAppBrowserEvent` object.
- Android
- Browser
- iOS
- Windows
### Quick Example
var ref = cordova.InAppBrowser.open('http://apache.org', '_blank', 'location=yes');
var ref = cordova.InAppBrowser.open('https://apache.org', '_blank', 'location=yes');
var myCallback = function(event) { alert(event.url); }
ref.addEventListener('loadstart', myCallback);
ref.removeEventListener('loadstart', myCallback);
@@ -399,11 +412,10 @@ The function is passed an `InAppBrowserEvent` object.
- Android
- Browser
- iOS
- Windows
### Quick Example
var ref = cordova.InAppBrowser.open('http://apache.org', '_blank', 'location=yes');
var ref = cordova.InAppBrowser.open('https://apache.org', '_blank', 'location=yes');
ref.close();
## InAppBrowser.show
@@ -419,11 +431,10 @@ The function is passed an `InAppBrowserEvent` object.
- Android
- Browser
- iOS
- Windows
### Quick Example
var ref = cordova.InAppBrowser.open('http://apache.org', '_blank', 'hidden=yes');
var ref = cordova.InAppBrowser.open('https://apache.org', '_blank', 'hidden=yes');
// some time later...
ref.show();
@@ -439,11 +450,10 @@ The function is passed an `InAppBrowserEvent` object.
- Android
- iOS
- Windows
### Quick Example
var ref = cordova.InAppBrowser.open('http://apache.org', '_blank');
var ref = cordova.InAppBrowser.open('https://apache.org', '_blank');
// some time later...
ref.hide();
@@ -471,11 +481,10 @@ The function is passed an `InAppBrowserEvent` object.
- Android
- Browser
- iOS
- Windows
### Quick Example
var ref = cordova.InAppBrowser.open('http://apache.org', '_blank', 'location=yes');
var ref = cordova.InAppBrowser.open('https://apache.org', '_blank', 'location=yes');
ref.addEventListener('loadstop', function() {
ref.executeScript({file: "myscript.js"});
});
@@ -484,10 +493,6 @@ The function is passed an `InAppBrowserEvent` object.
- only __code__ key is supported.
### Windows Quirks
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]`.
## InAppBrowser.insertCSS
> Injects CSS into the `InAppBrowser` window. (Only available when the target is set to `'_blank'`)
@@ -506,11 +511,10 @@ Due to [MSDN docs](https://msdn.microsoft.com/en-us/library/windows.ui.xaml.cont
- Android
- iOS
- Windows
### Quick Example
var ref = cordova.InAppBrowser.open('http://apache.org', '_blank', 'location=yes');
var ref = cordova.InAppBrowser.open('https://apache.org', '_blank', 'location=yes');
ref.addEventListener('loadstop', function() {
ref.insertCSS({file: "mystyles.css"});
});
@@ -621,7 +625,7 @@ function loadStopCallBack() {
if (inAppBrowserRef != undefined) {
inAppBrowserRef.insertCSS({ code: "body{font-size: 25px;" });
inAppBrowserRef.insertCSS({ code: "body{font-size: 25px;}" });
$('#status-message').text("");
@@ -692,13 +696,13 @@ iab.open('local-url.html', 'random_string', 'location=no'); // loads in the InAp
```
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('https://whitelisted-url.com'); // loads in the Cordova WebView
iab.open('https://whitelisted-url.com', '_self'); // loads in the Cordova WebView
iab.open('https://whitelisted-url.com', '_system'); // loads in the system browser
iab.open('https://whitelisted-url.com', '_blank'); // loads in the InAppBrowser
iab.open('https://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
iab.open('https://whitelisted-url.com', 'random_string', 'location=no'); // loads in the InAppBrowser, no location bar
```
@@ -707,11 +711,11 @@ iab.open('http://whitelisted-url.com', 'random_string', 'location=no'); // loads
```
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
iab.open('https://url-that-fails-whitelist.com'); // loads in the InAppBrowser
iab.open('https://url-that-fails-whitelist.com', '_self'); // loads in the InAppBrowser
iab.open('https://url-that-fails-whitelist.com', '_system'); // loads in the system browser
iab.open('https://url-that-fails-whitelist.com', '_blank'); // loads in the InAppBrowser
iab.open('https://url-that-fails-whitelist.com', 'random_string'); // loads in the InAppBrowser
iab.open('https://url-that-fails-whitelist.com', 'random_string', 'location=no'); // loads in the InAppBrowser, no location bar
```

View File

@@ -20,6 +20,89 @@
-->
# Release Notes
### 6.0.0 (Nov 10, 2023)
* [GH-1033](https://github.com/apache/cordova-plugin-inappbrowser/pull/1033) chore: bump to next major release 6.0.0 & update deependencies
* [GH-1032](https://github.com/apache/cordova-plugin-inappbrowser/pull/1032) chore(lint): update eslint config and apply fixes
* [GH-1030](https://github.com/apache/cordova-plugin-inappbrowser/pull/1030) fix!: remove deprecated platforms **Windows** & osx
* [GH-1031](https://github.com/apache/cordova-plugin-inappbrowser/pull/1031) fix(ios): Remove deprecation warnings and old code
* [GH-927](https://github.com/apache/cordova-plugin-inappbrowser/pull/927) fix: explicitly import dependencies, instead of relying on PCH files. This is important in Swift projects, where you cannot use prefix headers.
* [GH-968](https://github.com/apache/cordova-plugin-inappbrowser/pull/968) GH-706 **Android**: Allow permissions requests
* [GH-1029](https://github.com/apache/cordova-plugin-inappbrowser/pull/1029) chore: update asf config
* [GH-1019](https://github.com/apache/cordova-plugin-inappbrowser/pull/1019) feat(android): Download event
* [GH-1020](https://github.com/apache/cordova-plugin-inappbrowser/pull/1020) ci(gh-action): Paramedic CI sync
* [GH-1015](https://github.com/apache/cordova-plugin-inappbrowser/pull/1015) feat(ios): Make WebView inspectable
* [GH-1016](https://github.com/apache/cordova-plugin-inappbrowser/pull/1016) chore: use https urls in tests and `README`
* [GH-1017](https://github.com/apache/cordova-plugin-inappbrowser/pull/1017) chore: Update SUPPORT_QUESTION.md template
* [GH-977](https://github.com/apache/cordova-plugin-inappbrowser/pull/977) fix(docs): missing xml indicator in code block
* [GH-971](https://github.com/apache/cordova-plugin-inappbrowser/pull/971) ci: sync workflow with paramedic
* [GH-964](https://github.com/apache/cordova-plugin-inappbrowser/pull/964) dep(npm): bump package-lock v2 w/ rebuild
* [GH-957](https://github.com/apache/cordova-plugin-inappbrowser/pull/957) ci(android): update java requirement for `cordova-android`@11
* [GH-946](https://github.com/apache/cordova-plugin-inappbrowser/pull/946) fix(android): increase toolbar to 48dp
* [GH-912](https://github.com/apache/cordova-plugin-inappbrowser/pull/912) ci(ios): update workflow w/ **iOS** 15
* [GH-907](https://github.com/apache/cordova-plugin-inappbrowser/pull/907) ci: add action-badge
* [GH-906](https://github.com/apache/cordova-plugin-inappbrowser/pull/906) ci: remove travis & appveyor
* [GH-903](https://github.com/apache/cordova-plugin-inappbrowser/pull/903) ci: add gh-actions workflows
* [GH-861](https://github.com/apache/cordova-plugin-inappbrowser/pull/861) fix(android): add space between default useragent and custom AppendUserAgent
* [GH-881](https://github.com/apache/cordova-plugin-inappbrowser/pull/881) fix(ios): make system open tel, sms, mailto and geo links
### 5.0.0 (Feb 10, 2021)
* [GH-828](https://github.com/apache/cordova-plugin-inappbrowser/pull/828) feat(ios): add `InAppBrowser`StatusBarStyle 'darkcontent' configuration option
* [GH-823](https://github.com/apache/cordova-plugin-inappbrowser/pull/823) chore: bump engines requirements
* [GH-824](https://github.com/apache/cordova-plugin-inappbrowser/pull/824) breaking: cleanup code for old **Android** versions
* [GH-825](https://github.com/apache/cordova-plugin-inappbrowser/pull/825) (ios): rename CDVWKProcessPoolFactory
* [GH-826](https://github.com/apache/cordova-plugin-inappbrowser/pull/826) ci: add node-14.x to workflow
* [GH-821](https://github.com/apache/cordova-plugin-inappbrowser/pull/821) breaking(android): replace magic numbers with **Android**.os.Build constants
* [GH-717](https://github.com/apache/cordova-plugin-inappbrowser/pull/717) ci(ios): remove wkwebview plugin
### 4.1.0 (Nov 17, 2020)
* [GH-792](https://github.com/apache/cordova-plugin-inappbrowser/pull/792) fix(android): Add mitigation strategy for CVE-2020-6506
* [GH-817](https://github.com/apache/cordova-plugin-inappbrowser/pull/817) Updated typings
* [GH-803](https://github.com/apache/cordova-plugin-inappbrowser/pull/803) fix(android): allow compilation in old `cordova-android` versions
* [GH-688](https://github.com/apache/cordova-plugin-inappbrowser/pull/688) (ios): allow to set "preferredContentMode"
* [GH-768](https://github.com/apache/cordova-plugin-inappbrowser/pull/768) ci(travis): update osx xcode image
* add documentation for `InAppBrowser`StatusBarStyle preference
* undo whitespace changes due to editor preferrences
* [GH-728](https://github.com/apache/cordova-plugin-inappbrowser/pull/728) **iOS**: added `InAppBrowser`StatusBarStyle preference
* [GH-767](https://github.com/apache/cordova-plugin-inappbrowser/pull/767) ci(travis): updates **Android** API level
* (ios): Fix incorrect view height from the second open time
* [GH-748](https://github.com/apache/cordova-plugin-inappbrowser/pull/748) chore: adds package-lock file
* [GH-746](https://github.com/apache/cordova-plugin-inappbrowser/pull/746) chore(npm): use short notation in `package.json`
* [GH-747](https://github.com/apache/cordova-plugin-inappbrowser/pull/747) refactor(eslint): use cordova-eslint /w fix
* [GH-737](https://github.com/apache/cordova-plugin-inappbrowser/pull/737) fix(ios): exit event not fired on swipe down
### 4.0.0 (Jun 09, 2020)
* [GH-715](https://github.com/apache/cordova-plugin-inappbrowser/pull/715) (ios): fix regression in 2706f34
* [GH-685](https://github.com/apache/cordova-plugin-inappbrowser/pull/685) chore: update install engines
* [GH-656](https://github.com/apache/cordova-plugin-inappbrowser/pull/656) (ios) Remove fake status bar with hardcoded height to fix issues in **iOS** devices with a notch
* [GH-693](https://github.com/apache/cordova-plugin-inappbrowser/pull/693) fix(ios): Allow loading local html files
* [GH-293](https://github.com/apache/cordova-plugin-inappbrowser/pull/293) **Android**: SSL errors handling in **Android**
* [GH-672](https://github.com/apache/cordova-plugin-inappbrowser/pull/672) fix(ios): prevent statusbar rotation after closing `InAppBrowser`
* chore(asf): update git notification settings
* [GH-669](https://github.com/apache/cordova-plugin-inappbrowser/pull/669) Allow App using `InAppBrowser` to be hosted in a cross-origin iframe
* [GH-600](https://github.com/apache/cordova-plugin-inappbrowser/pull/600) (all platforms): remove "window.open" overwrite
* [GH-670](https://github.com/apache/cordova-plugin-inappbrowser/pull/670) chore: bump version to 4.0.0-dev
* Update CONTRIBUTING.md
* [GH-662](https://github.com/apache/cordova-plugin-inappbrowser/pull/662) docs: replaces outdated transition and presentation style links
* [GH-666](https://github.com/apache/cordova-plugin-inappbrowser/pull/666) chore: remove deprecated orientation methods
* [GH-515](https://github.com/apache/cordova-plugin-inappbrowser/pull/515) Fix incorrect TypeScript typings
* [GH-654](https://github.com/apache/cordova-plugin-inappbrowser/pull/654) add check for openInSystem postNotification
* [GH-659](https://github.com/apache/cordova-plugin-inappbrowser/pull/659) ci: updates Node.js versions
* [GH-658](https://github.com/apache/cordova-plugin-inappbrowser/pull/658) chore(npm): improve ignore list
* [GH-442](https://github.com/apache/cordova-plugin-inappbrowser/pull/442) fix(android): Reset lefttoright if not set
* [GH-648](https://github.com/apache/cordova-plugin-inappbrowser/pull/648) (android) Correcting the documentation regarding lefttoright opt…
* [GH-634](https://github.com/apache/cordova-plugin-inappbrowser/pull/634) (android) Added option to turn on/off fullscreen mode in **Android**
* [GH-616](https://github.com/apache/cordova-plugin-inappbrowser/pull/616) (android) `InAppBrowser`: java.lang.IllegalArgumentException
* [GH-635](https://github.com/apache/cordova-plugin-inappbrowser/pull/635) breaking(ios): remove UIWebView
### 3.2.0 (Jan 04, 2020)
* [GH-503](https://github.com/apache/cordova-plugin-inappbrowser/pull/503) Defensive code to prevent NULL reference exceptions for async
* [GH-584](https://github.com/apache/cordova-plugin-inappbrowser/pull/584) Add compile-time decision for disabling UIWebView
* [GH-524](https://github.com/apache/cordova-plugin-inappbrowser/pull/524) Replace "beforeload" with BEFORELOAD
* [GH-568](https://github.com/apache/cordova-plugin-inappbrowser/pull/568) Update missing closed brace to the insert.CSS
* [GH-401](https://github.com/apache/cordova-plugin-inappbrowser/pull/401) Move createIframeBridge to injectDeferredObject
* [GH-534](https://github.com/apache/cordova-plugin-inappbrowser/pull/534) Fix `InAppBrowser` not opening on **iOS** 13
* ci(travis) Upgrade to node8
### 3.1.0 (Jun 27, 2019)
- chore: fix repo and issue urls and license in package.json and plugin.xml ([`8edfb9e`](https://github.com/apache/cordova-plugin-inappbrowser/commit/8edfb9e))

4349
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
{
"name": "cordova-plugin-inappbrowser",
"version": "3.1.0",
"version": "6.0.1-dev",
"description": "Cordova InAppBrowser Plugin",
"types": "./types/index.d.ts",
"cordova": {
@@ -8,18 +8,11 @@
"platforms": [
"android",
"browser",
"ios",
"osx",
"windows"
"ios"
]
},
"repository": {
"type": "git",
"url": "https://github.com/apache/cordova-plugin-inappbrowser"
},
"bugs": {
"url": "https://github.com/apache/cordova-plugin-inappbrowser/issues"
},
"repository": "github:apache/cordova-plugin-inappbrowser",
"bugs": "https://github.com/apache/cordova-plugin-inappbrowser/issues",
"keywords": [
"cordova",
"in",
@@ -29,13 +22,11 @@
"ecosystem:cordova",
"cordova-android",
"cordova-browser",
"cordova-ios",
"cordova-osx",
"cordova-windows"
"cordova-ios"
],
"scripts": {
"test": "npm run eslint",
"eslint": "node node_modules/eslint/bin/eslint www && node node_modules/eslint/bin/eslint src && node node_modules/eslint/bin/eslint tests"
"test": "npm run lint",
"lint": "eslint ."
},
"engines": {
"cordovaDependencies": {
@@ -43,6 +34,20 @@
"cordova": ">=3.1.0"
},
"4.0.0": {
"cordova": ">=3.1.0",
"cordova-ios": ">=4.0.0"
},
"5.0.0": {
"cordova-android": ">=9.0.0",
"cordova-ios": ">=6.0.0",
"cordova": ">=9.0.0"
},
"6.0.1-dev": {
"cordova-android": ">=10.0.0",
"cordova-ios": ">=6.0.0",
"cordova": ">=9.0.0"
},
"7.0.0": {
"cordova": ">100"
}
}
@@ -50,12 +55,6 @@
"author": "Apache Software Foundation",
"license": "Apache-2.0",
"devDependencies": {
"eslint": "^4.0.0",
"eslint-config-semistandard": "^11.0.0",
"eslint-config-standard": "^10.2.1",
"eslint-plugin-import": "^2.3.0",
"eslint-plugin-node": "^5.0.0",
"eslint-plugin-promise": "^3.5.0",
"eslint-plugin-standard": "^3.0.1"
"@cordova/eslint-config": "^5.0.0"
}
}

View File

@@ -20,7 +20,7 @@
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
id="cordova-plugin-inappbrowser"
version="3.1.0">
version="6.0.1-dev">
<name>InAppBrowser</name>
<description>Cordova InAppBrowser Plugin</description>
@@ -30,14 +30,15 @@
<issue>https://github.com/apache/cordova-plugin-inappbrowser/issues</issue>
<engines>
<engine name="cordova" version=">=3.1.0" /><!-- Needs cordova/urlutil -->
<engine name="cordova" version=">=9.0.0"/>
<engine name="cordova-android" version=">=9.0.0" />
<engine name="cordova-ios" version=">=6.0.0" />
</engines>
<!-- android -->
<platform name="android">
<js-module src="www/inappbrowser.js" name="inappbrowser">
<clobbers target="cordova.InAppBrowser.open" />
<clobbers target="window.open" />
</js-module>
<config-file target="res/xml/config.xml" parent="/*">
<feature name="InAppBrowser">
@@ -71,31 +72,17 @@
<platform name="ios">
<js-module src="www/inappbrowser.js" name="inappbrowser">
<clobbers target="cordova.InAppBrowser.open" />
<clobbers target="window.open" />
</js-module>
<config-file target="config.xml" parent="/*">
<feature name="InAppBrowser">
<param name="ios-package" value="CDVInAppBrowser" />
<param name="onload" value="true" />
</feature>
<feature name="UIInAppBrowser">
<param name="ios-package" value="CDVUIInAppBrowser" />
<param name="onload" value="true" />
</feature>
<feature name="WKInAppBrowser">
<param name="ios-package" value="CDVWKInAppBrowser" />
<param name="onload" value="true" />
</feature>
</config-file>
<header-file src="src/ios/CDVInAppBrowser.h" />
<source-file src="src/ios/CDVInAppBrowser.m" />
<header-file src="src/ios/CDVInAppBrowserOptions.h" />
<source-file src="src/ios/CDVInAppBrowserOptions.m" />
<header-file src="src/ios/CDVInAppBrowserNavigationController.h" />
<source-file src="src/ios/CDVInAppBrowserNavigationController.m" />
<header-file src="src/ios/CDVUIInAppBrowser.h" />
<source-file src="src/ios/CDVUIInAppBrowser.m" />
<header-file src="src/ios/CDVWKInAppBrowser.h" />
<source-file src="src/ios/CDVWKInAppBrowser.m" />
<header-file src="src/ios/CDVWKInAppBrowserUIDelegate.h" />
@@ -104,39 +91,10 @@
<framework src="CoreGraphics.framework" />
</platform>
<!-- osx -->
<platform name="osx">
<js-module src="www/inappbrowser.js" name="inappbrowser">
<clobbers target="cordova.InAppBrowser.open" />
<clobbers target="window.open" />
</js-module>
<config-file target="config.xml" parent="/*">
<feature name="InAppBrowser">
<param name="osx-package" value="CDVInAppBrowser" />
</feature>
</config-file>
<header-file src="src/osx/CDVInAppBrowser.h" />
<source-file src="src/osx/CDVInAppBrowser.m" />
</platform>
<!-- windows -->
<platform name="windows">
<js-module src="www/inappbrowser.js" name="inappbrowser">
<clobbers target="cordova.InAppBrowser.open" />
<clobbers target="window.open" />
</js-module>
<js-module src="src/windows/InAppBrowserProxy.js" name="InAppBrowserProxy">
<runs />
</js-module>
<asset src="www/inappbrowser.css" target="css/inappbrowser.css" />
</platform>
<!-- browser -->
<platform name="browser">
<js-module src="www/inappbrowser.js" name="inappbrowser">
<clobbers target="cordova.InAppBrowser.open" />
<clobbers target="window.open" />
</js-module>
<js-module src="src/browser/InAppBrowserProxy.js" name="InAppBrowserProxy">
<runs />

View File

@@ -20,7 +20,6 @@ package org.apache.cordova.inappbrowser;
import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
@@ -30,9 +29,8 @@ import android.provider.Browser;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;
import android.graphics.Color;
import android.net.http.SslError;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
@@ -47,15 +45,16 @@ 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.JavascriptInterface;
import android.webkit.SslErrorHandler;
import android.webkit.ValueCallback;
import android.webkit.WebChromeClient;
import android.webkit.WebResourceRequest;
import android.webkit.WebResourceResponse;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.DownloadListener;
import android.webkit.WebViewClient;
import android.widget.EditText;
import android.widget.ImageButton;
@@ -99,6 +98,7 @@ public class InAppBrowser extends CordovaPlugin {
private static final String LOAD_START_EVENT = "loadstart";
private static final String LOAD_STOP_EVENT = "loadstop";
private static final String LOAD_ERROR_EVENT = "loaderror";
private static final String DOWNLOAD_EVENT = "download";
private static final String MESSAGE_EVENT = "message";
private static final String CLEAR_ALL_CACHE = "clearcache";
private static final String CLEAR_SESSION_CACHE = "clearsessioncache";
@@ -117,6 +117,9 @@ public class InAppBrowser extends CordovaPlugin {
private static final String FOOTER = "footer";
private static final String FOOTER_COLOR = "footercolor";
private static final String BEFORELOAD = "beforeload";
private static final String FULLSCREEN = "fullscreen";
private static final int TOOLBAR_HEIGHT = 48;
private static final List customizableOptions = Arrays.asList(CLOSE_BUTTON_CAPTION, TOOLBAR_COLOR, NAVIGATION_COLOR, CLOSE_BUTTON_COLOR, FOOTER_COLOR);
@@ -133,10 +136,8 @@ public class InAppBrowser extends CordovaPlugin {
private boolean mediaPlaybackRequiresUserGesture = false;
private boolean shouldPauseInAppBrowser = false;
private boolean useWideViewPort = true;
private ValueCallback<Uri> mUploadCallback;
private ValueCallback<Uri[]> mUploadCallbackLollipop;
private ValueCallback<Uri[]> mUploadCallback;
private final static int FILECHOOSER_REQUESTCODE = 1;
private final static int FILECHOOSER_REQUESTCODE_LOLLIPOP = 2;
private String closeButtonCaption = "";
private String closeButtonColor = "";
private boolean leftToRight = false;
@@ -147,6 +148,7 @@ public class InAppBrowser extends CordovaPlugin {
private boolean showFooter = false;
private String footerColor = "";
private String beforeload = "";
private boolean fullscreen = true;
private String[] allowedSchemes;
private InAppBrowserClient currentClient;
@@ -272,6 +274,7 @@ public class InAppBrowser extends CordovaPlugin {
((InAppBrowserClient)inAppWebView.getWebViewClient()).waitForBeforeload = false;
}
inAppWebView.loadUrl(url);
}
});
}
@@ -313,7 +316,9 @@ public class InAppBrowser extends CordovaPlugin {
this.cordova.getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
dialog.show();
if (dialog != null && !cordova.getActivity().isFinishing()) {
dialog.show();
}
}
});
PluginResult pluginResult = new PluginResult(PluginResult.Status.OK);
@@ -324,7 +329,9 @@ public class InAppBrowser extends CordovaPlugin {
this.cordova.getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
dialog.hide();
if (dialog != null && !cordova.getActivity().isFinishing()) {
dialog.hide();
}
}
});
PluginResult pluginResult = new PluginResult(PluginResult.Status.OK);
@@ -406,12 +413,7 @@ public class InAppBrowser extends CordovaPlugin {
@SuppressLint("NewApi")
@Override
public void run() {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
// This action will have the side-effect of blurring the currently focused element
inAppWebView.loadUrl("javascript:" + finalScriptToInject);
} else {
inAppWebView.evaluateJavascript(finalScriptToInject, null);
}
inAppWebView.evaluateJavascript(finalScriptToInject, null);
}
});
} else {
@@ -437,7 +439,7 @@ public class InAppBrowser extends CordovaPlugin {
if (option.hasMoreElements()) {
String key = option.nextToken();
String value = option.nextToken();
if (!customizableOptions.contains(key)){
if (!customizableOptions.contains(key)) {
value = value.equals("yes") || value.equals("no") ? value : "yes";
}
map.put(key, value);
@@ -533,7 +535,7 @@ public class InAppBrowser extends CordovaPlugin {
childView.setWebViewClient(new WebViewClient() {
// NB: wait for about:blank before dismissing
public void onPageFinished(WebView view, String url) {
if (dialog != null) {
if (dialog != null && !cordova.getActivity().isFinishing()) {
dialog.dismiss();
dialog = null;
}
@@ -616,7 +618,7 @@ public class InAppBrowser extends CordovaPlugin {
return this.showLocationBar;
}
private InAppBrowser getInAppBrowser(){
private InAppBrowser getInAppBrowser() {
return this;
}
@@ -688,9 +690,8 @@ public class InAppBrowser extends CordovaPlugin {
closeButtonColor = closeButtonColorSet;
}
String leftToRightSet = features.get(LEFT_TO_RIGHT);
if (leftToRightSet != null) {
leftToRight = leftToRightSet.equals("yes") ? true : false;
}
leftToRight = leftToRightSet != null && leftToRightSet.equals("yes");
String toolbarColorSet = features.get(TOOLBAR_COLOR);
if (toolbarColorSet != null) {
toolbarColor = android.graphics.Color.parseColor(toolbarColorSet);
@@ -710,6 +711,10 @@ public class InAppBrowser extends CordovaPlugin {
if (features.get(BEFORELOAD) != null) {
beforeload = features.get(BEFORELOAD);
}
String fullscreenSet = features.get(FULLSCREEN);
if (fullscreenSet != null) {
fullscreen = fullscreenSet.equals("yes") ? true : false;
}
}
final CordovaWebView thatWebView = this.webView;
@@ -730,7 +735,7 @@ public class InAppBrowser extends CordovaPlugin {
return value;
}
private View createCloseButton(int id){
private View createCloseButton(int id) {
View _close;
Resources activityRes = cordova.getActivity().getResources();
@@ -751,8 +756,7 @@ public class InAppBrowser extends CordovaPlugin {
if (closeButtonColor != "") close.setColorFilter(android.graphics.Color.parseColor(closeButtonColor));
close.setImageDrawable(closeIcon);
close.setScaleType(ImageView.ScaleType.FIT_CENTER);
if (Build.VERSION.SDK_INT >= 16)
close.getAdjustViewBounds();
close.getAdjustViewBounds();
_close = close;
}
@@ -761,11 +765,7 @@ public class InAppBrowser extends CordovaPlugin {
if (leftToRight) closeLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
else closeLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
_close.setLayoutParams(closeLayoutParams);
if (Build.VERSION.SDK_INT >= 16)
_close.setBackground(null);
else
_close.setBackgroundDrawable(null);
_close.setBackground(null);
_close.setContentDescription("Close Button");
_close.setId(Integer.valueOf(id));
@@ -790,7 +790,9 @@ public class InAppBrowser extends CordovaPlugin {
dialog = new InAppBrowserDialog(cordova.getActivity(), android.R.style.Theme_NoTitleBar);
dialog.getWindow().getAttributes().windowAnimations = android.R.style.Animation_Dialog;
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
if (fullscreen) {
dialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
dialog.setCancelable(true);
dialog.setInAppBroswer(getInAppBrowser());
@@ -802,7 +804,7 @@ public class InAppBrowser extends CordovaPlugin {
RelativeLayout toolbar = new RelativeLayout(cordova.getActivity());
//Please, no more black!
toolbar.setBackgroundColor(toolbarColor);
toolbar.setLayoutParams(new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, this.dpToPixels(44)));
toolbar.setLayoutParams(new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, this.dpToPixels(TOOLBAR_HEIGHT)));
toolbar.setPadding(this.dpToPixels(2), this.dpToPixels(2), this.dpToPixels(2), this.dpToPixels(2));
if (leftToRight) {
toolbar.setHorizontalGravity(Gravity.LEFT);
@@ -832,15 +834,11 @@ public class InAppBrowser extends CordovaPlugin {
int backResId = activityRes.getIdentifier("ic_action_previous_item", "drawable", cordova.getActivity().getPackageName());
Drawable backIcon = activityRes.getDrawable(backResId);
if (navigationButtonColor != "") back.setColorFilter(android.graphics.Color.parseColor(navigationButtonColor));
if (Build.VERSION.SDK_INT >= 16)
back.setBackground(null);
else
back.setBackgroundDrawable(null);
back.setBackground(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.getAdjustViewBounds();
back.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
@@ -858,15 +856,11 @@ public class InAppBrowser extends CordovaPlugin {
int fwdResId = activityRes.getIdentifier("ic_action_next_item", "drawable", cordova.getActivity().getPackageName());
Drawable fwdIcon = activityRes.getDrawable(fwdResId);
if (navigationButtonColor != "") forward.setColorFilter(android.graphics.Color.parseColor(navigationButtonColor));
if (Build.VERSION.SDK_INT >= 16)
forward.setBackground(null);
else
forward.setBackgroundDrawable(null);
forward.setBackground(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.getAdjustViewBounds();
forward.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
@@ -906,13 +900,13 @@ public class InAppBrowser extends CordovaPlugin {
// Footer
RelativeLayout footer = new RelativeLayout(cordova.getActivity());
int _footerColor;
if(footerColor != ""){
if(footerColor != "") {
_footerColor = Color.parseColor(footerColor);
}else{
} else {
_footerColor = android.graphics.Color.LTGRAY;
}
footer.setBackgroundColor(_footerColor);
RelativeLayout.LayoutParams footerLayout = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, this.dpToPixels(44));
RelativeLayout.LayoutParams footerLayout = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, this.dpToPixels(TOOLBAR_HEIGHT));
footerLayout.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
footer.setLayoutParams(footerLayout);
if (closeButtonCaption != "") footer.setPadding(this.dpToPixels(8), this.dpToPixels(8), this.dpToPixels(8), this.dpToPixels(8));
@@ -922,22 +916,20 @@ public class InAppBrowser extends CordovaPlugin {
View footerClose = createCloseButton(7);
footer.addView(footerClose);
// WebView
inAppWebView = new WebView(cordova.getActivity());
inAppWebView.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
inAppWebView.setId(Integer.valueOf(6));
// File Chooser Implemented ChromeClient
inAppWebView.setWebChromeClient(new InAppChromeClient(thatWebView) {
// For Android 5.0+
public boolean onShowFileChooser (WebView webView, ValueCallback<Uri[]> filePathCallback, WebChromeClient.FileChooserParams fileChooserParams)
{
LOG.d(LOG_TAG, "File Chooser 5.0+");
// If callback exists, finish it.
if(mUploadCallbackLollipop != null) {
mUploadCallbackLollipop.onReceiveValue(null);
if(mUploadCallback != null) {
mUploadCallback.onReceiveValue(null);
}
mUploadCallbackLollipop = filePathCallback;
mUploadCallback = filePathCallback;
// Create File Chooser Intent
Intent content = new Intent(Intent.ACTION_GET_CONTENT);
@@ -945,30 +937,9 @@ public class InAppBrowser extends CordovaPlugin {
content.setType("*/*");
// Run cordova startActivityForResult
cordova.startActivityForResult(InAppBrowser.this, Intent.createChooser(content, "Select File"), FILECHOOSER_REQUESTCODE_LOLLIPOP);
cordova.startActivityForResult(InAppBrowser.this, Intent.createChooser(content, "Select File"), FILECHOOSER_REQUESTCODE);
return true;
}
// For Android 4.1+
public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType, String capture)
{
LOG.d(LOG_TAG, "File Chooser 4.1+");
// Call file chooser for Android 3.0+
openFileChooser(uploadMsg, acceptType);
}
// For Android 3.0+
public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType)
{
LOG.d(LOG_TAG, "File Chooser 3.0+");
mUploadCallback = uploadMsg;
Intent content = new Intent(Intent.ACTION_GET_CONTENT);
content.addCategory(Intent.CATEGORY_OPENABLE);
// run startActivityForResult
cordova.startActivityForResult(InAppBrowser.this, Intent.createChooser(content, "Select File"), FILECHOOSER_REQUESTCODE);
}
});
currentClient = new InAppBrowserClient(thatWebView, edittext, beforeload);
inAppWebView.setWebViewClient(currentClient);
@@ -977,6 +948,30 @@ public class InAppBrowser extends CordovaPlugin {
settings.setJavaScriptCanOpenWindowsAutomatically(true);
settings.setBuiltInZoomControls(showZoomControls);
settings.setPluginState(android.webkit.WebSettings.PluginState.ON);
// download event
inAppWebView.setDownloadListener(
new DownloadListener(){
public void onDownloadStart(
String url, String userAgent, String contentDisposition, String mimetype, long contentLength
){
try{
JSONObject succObj = new JSONObject();
succObj.put("type", DOWNLOAD_EVENT);
succObj.put("url",url);
succObj.put("userAgent",userAgent);
succObj.put("contentDisposition",contentDisposition);
succObj.put("mimetype",mimetype);
succObj.put("contentLength",contentLength);
sendUpdate(succObj, true);
}
catch(Exception e){
LOG.e(LOG_TAG,e.getMessage());
}
}
}
);
// Add postMessage interface
class JsObject {
@@ -993,10 +988,8 @@ public class InAppBrowser extends CordovaPlugin {
}
}
if(android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR1) {
settings.setMediaPlaybackRequiresUserGesture(mediaPlaybackRequiresUserGesture);
inAppWebView.addJavascriptInterface(new JsObject(), "cordova_iab");
}
settings.setMediaPlaybackRequiresUserGesture(mediaPlaybackRequiresUserGesture);
inAppWebView.addJavascriptInterface(new JsObject(), "cordova_iab");
String overrideUserAgent = preferences.getString("OverrideUserAgent", null);
String appendUserAgent = preferences.getString("AppendUserAgent", null);
@@ -1005,7 +998,7 @@ public class InAppBrowser extends CordovaPlugin {
settings.setUserAgentString(overrideUserAgent);
}
if (appendUserAgent != null) {
settings.setUserAgentString(settings.getUserAgentString() + appendUserAgent);
settings.setUserAgentString(settings.getUserAgentString() + " " + appendUserAgent);
}
//Toggle whether this is enabled or not!
@@ -1024,15 +1017,16 @@ public class InAppBrowser extends CordovaPlugin {
CookieManager.getInstance().removeSessionCookie();
}
// Enable Thirdparty Cookies on >=Android 5.0 device
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
CookieManager.getInstance().setAcceptThirdPartyCookies(inAppWebView,true);
}
// Enable Thirdparty Cookies
CookieManager.getInstance().setAcceptThirdPartyCookies(inAppWebView,true);
inAppWebView.loadUrl(url);
inAppWebView.setId(Integer.valueOf(6));
inAppWebView.getSettings().setLoadWithOverviewMode(true);
inAppWebView.getSettings().setUseWideViewPort(useWideViewPort);
// Multiple Windows set to true to mitigate Chromium security bug.
// See: https://bugs.chromium.org/p/chromium/issues/detail?id=1083819
inAppWebView.getSettings().setSupportMultipleWindows(true);
inAppWebView.requestFocus();
inAppWebView.requestFocusFromTouch();
@@ -1065,12 +1059,14 @@ public class InAppBrowser extends CordovaPlugin {
lp.width = WindowManager.LayoutParams.MATCH_PARENT;
lp.height = WindowManager.LayoutParams.MATCH_PARENT;
dialog.setContentView(main);
dialog.show();
dialog.getWindow().setAttributes(lp);
if (dialog != null) {
dialog.setContentView(main);
dialog.show();
dialog.getWindow().setAttributes(lp);
}
// the goal of openhidden is to load the url and not display it
// Show() needs to be called to cause the URL to be loaded
if(openWindowHidden) {
if (openWindowHidden && dialog != null) {
dialog.hide();
}
}
@@ -1113,32 +1109,14 @@ public class InAppBrowser extends CordovaPlugin {
* @param intent the data from android file chooser
*/
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
// For Android >= 5.0
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
LOG.d(LOG_TAG, "onActivityResult (For Android >= 5.0)");
// If RequestCode or Callback is Invalid
if(requestCode != FILECHOOSER_REQUESTCODE_LOLLIPOP || mUploadCallbackLollipop == null) {
super.onActivityResult(requestCode, resultCode, intent);
return;
}
mUploadCallbackLollipop.onReceiveValue(WebChromeClient.FileChooserParams.parseResult(resultCode, intent));
mUploadCallbackLollipop = null;
}
// For Android < 5.0
else {
LOG.d(LOG_TAG, "onActivityResult (For Android < 5.0)");
// If RequestCode or Callback is Invalid
if(requestCode != FILECHOOSER_REQUESTCODE || mUploadCallback == null) {
super.onActivityResult(requestCode, resultCode, intent);
return;
}
if (null == mUploadCallback) return;
Uri result = intent == null || resultCode != cordova.getActivity().RESULT_OK ? null : intent.getData();
mUploadCallback.onReceiveValue(result);
mUploadCallback = null;
LOG.d(LOG_TAG, "onActivityResult");
// If RequestCode or Callback is Invalid
if(requestCode != FILECHOOSER_REQUESTCODE || mUploadCallback == null) {
super.onActivityResult(requestCode, resultCode, intent);
return;
}
mUploadCallback.onReceiveValue(WebChromeClient.FileChooserParams.parseResult(resultCode, intent));
mUploadCallback = null;
}
/**
@@ -1208,26 +1186,26 @@ public class InAppBrowser extends CordovaPlugin {
if (beforeload.equals("yes") && method == null) {
useBeforeload = true;
}else if(beforeload.equals("yes")
} else if(beforeload.equals("yes")
//TODO handle POST requests then this condition can be removed:
&& !method.equals("POST"))
{
useBeforeload = true;
}else if(beforeload.equals("get") && (method == null || method.equals("GET"))){
} else if(beforeload.equals("get") && (method == null || method.equals("GET"))) {
useBeforeload = true;
}else if(beforeload.equals("post") && (method == null || method.equals("POST"))){
} else if(beforeload.equals("post") && (method == null || method.equals("POST"))) {
//TODO handle POST requests
errorMessage = "beforeload doesn't yet support POST requests";
}
// On first URL change, initiate JS callback. Only after the beforeload event, continue.
if (useBeforeload && this.waitForBeforeload) {
if(sendBeforeLoad(url, method)){
if(sendBeforeLoad(url, method)) {
return true;
}
}
if(errorMessage != null){
if(errorMessage != null) {
try {
LOG.e(LOG_TAG, errorMessage);
JSONObject obj = new JSONObject();
@@ -1236,7 +1214,7 @@ public class InAppBrowser extends CordovaPlugin {
obj.put("code", -1);
obj.put("message", errorMessage);
sendUpdate(obj, true, PluginResult.Status.ERROR);
}catch(Exception e){
} catch(Exception e) {
LOG.e(LOG_TAG, "Error sending loaderror for " + url + ": " + e.toString());
}
}
@@ -1322,12 +1300,12 @@ public class InAppBrowser extends CordovaPlugin {
return override;
}
private boolean sendBeforeLoad(String url, String method){
private boolean sendBeforeLoad(String url, String method) {
try {
JSONObject obj = new JSONObject();
obj.put("type", "beforeload");
obj.put("type", BEFORELOAD);
obj.put("url", url);
if(method != null){
if(method != null) {
obj.put("method", method);
}
sendUpdate(obj, true);
@@ -1338,34 +1316,19 @@ public class InAppBrowser extends CordovaPlugin {
return false;
}
/**
* Legacy (deprecated in API 21)
* For Android 4.4 and below.
* @param view
* @param url
* @return
*/
@SuppressWarnings("deprecation")
@Override
public WebResourceResponse shouldInterceptRequest (final WebView view, String url) {
return shouldInterceptRequest(url, super.shouldInterceptRequest(view, url), null);
}
/**
* New (added in API 21)
* For Android 5.0 and above.
*
* @param webView
* @param view
* @param request
*/
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override
public WebResourceResponse shouldInterceptRequest(WebView view, WebResourceRequest request) {
return shouldInterceptRequest(request.getUrl().toString(), super.shouldInterceptRequest(view, request), request.getMethod());
}
public WebResourceResponse shouldInterceptRequest(String url, WebResourceResponse response, String method){
public WebResourceResponse shouldInterceptRequest(String url, WebResourceResponse response, String method) {
return response;
}
@@ -1406,22 +1369,14 @@ public class InAppBrowser extends CordovaPlugin {
}
}
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
// Set the namespace for postMessage()
if (Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR1){
injectDeferredObject("window.webkit={messageHandlers:{cordova_iab:cordova_iab}}", null);
}
injectDeferredObject("window.webkit={messageHandlers:{cordova_iab:cordova_iab}}", null);
// 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();
}
CookieManager.getInstance().flush();
// https://issues.apache.org/jira/browse/CB-11248
view.clearFocus();
@@ -1454,6 +1409,46 @@ public class InAppBrowser extends CordovaPlugin {
}
}
@Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
super.onReceivedSslError(view, handler, error);
try {
JSONObject obj = new JSONObject();
obj.put("type", LOAD_ERROR_EVENT);
obj.put("url", error.getUrl());
obj.put("code", 0);
obj.put("sslerror", error.getPrimaryError());
String message;
switch (error.getPrimaryError()) {
case SslError.SSL_DATE_INVALID:
message = "The date of the certificate is invalid";
break;
case SslError.SSL_EXPIRED:
message = "The certificate has expired";
break;
case SslError.SSL_IDMISMATCH:
message = "Hostname mismatch";
break;
default:
case SslError.SSL_INVALID:
message = "A generic error occurred";
break;
case SslError.SSL_NOTYETVALID:
message = "The certificate is not yet valid";
break;
case SslError.SSL_UNTRUSTED:
message = "The certificate authority is not trusted";
break;
}
obj.put("message", message);
sendUpdate(obj, true, PluginResult.Status.ERROR);
} catch (JSONException ex) {
LOG.d(LOG_TAG, "Should never happen");
}
handler.cancel();
}
/**
* On received http auth request.
*/

View File

@@ -24,12 +24,17 @@ import org.apache.cordova.PluginResult;
import org.json.JSONArray;
import org.json.JSONException;
import android.annotation.TargetApi;
import android.os.Build;
import android.os.Message;
import android.webkit.JsPromptResult;
import android.webkit.WebChromeClient;
import android.webkit.WebResourceRequest;
import android.webkit.WebStorage;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.webkit.GeolocationPermissions.Callback;
import android.webkit.PermissionRequest;
public class InAppChromeClient extends WebChromeClient {
@@ -41,6 +46,13 @@ public class InAppChromeClient extends WebChromeClient {
super();
this.webView = webView;
}
public void onPermissionRequest(final PermissionRequest request) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
request.grant(request.getResources());
}
}
/**
* Handle database quota exceeded notification.
*
@@ -135,4 +147,44 @@ public class InAppChromeClient extends WebChromeClient {
return false;
}
/**
* The InAppWebBrowser WebView is configured to MultipleWindow mode to mitigate a security
* bug found in Chromium prior to version 83.0.4103.106.
* See https://bugs.chromium.org/p/chromium/issues/detail?id=1083819
*
* Valid Urls set to open in new window will be routed back to load in the original WebView.
*
* @param view
* @param isDialog
* @param isUserGesture
* @param resultMsg
* @return
*/
@Override
public boolean onCreateWindow(WebView view, boolean isDialog, boolean isUserGesture, Message resultMsg) {
WebView inAppWebView = view;
final WebViewClient webViewClient =
new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
inAppWebView.loadUrl(request.getUrl().toString());
return true;
}
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
inAppWebView.loadUrl(url);
return true;
}
};
final WebView newWebView = new WebView(view.getContext());
newWebView.setWebViewClient(webViewClient);
final WebView.WebViewTransport transport = (WebView.WebViewTransport) resultMsg.obj;
transport.setWebView(newWebView);
resultMsg.sendToTarget();
return true;
}
}

View File

@@ -17,43 +17,37 @@
* specific language governing permissions and limitations
* under the License.
*
*/
*/
var modulemapper = require('cordova/modulemapper');
const modulemapper = require('cordova/modulemapper');
var browserWrap,
popup,
navigationButtonsDiv,
navigationButtonsDivInner,
backButton,
forwardButton,
closeButton;
let browserWrap, popup, navigationButtonsDiv, navigationButtonsDivInner, backButton, forwardButton, closeButton;
function attachNavigationEvents (element, callback) {
var onError = function () {
const onError = function () {
try {
callback({ type: 'loaderror', url: this.contentWindow.location.href }, {keepCallback: true}); // eslint-disable-line standard/no-callback-literal
callback({ type: 'loaderror', url: this.contentWindow.location.href }, { keepCallback: true }); // eslint-disable-line n/no-callback-literal
} catch (err) {
// blocked by CORS :\
callback({ type: 'loaderror', url: null }, {keepCallback: true}); // eslint-disable-line standard/no-callback-literal
callback({ type: 'loaderror', url: null }, { keepCallback: true }); // eslint-disable-line n/no-callback-literal
}
};
element.addEventListener('pageshow', function () {
try {
callback({ type: 'loadstart', url: this.contentWindow.location.href }, {keepCallback: true}); // eslint-disable-line standard/no-callback-literal
callback({ type: 'loadstart', url: this.contentWindow.location.href }, { keepCallback: true }); // eslint-disable-line n/no-callback-literal
} catch (err) {
// blocked by CORS :\
callback({ type: 'loadstart', url: null }, {keepCallback: true}); // eslint-disable-line standard/no-callback-literal
callback({ type: 'loadstart', url: null }, { keepCallback: true }); // eslint-disable-line n/no-callback-literal
}
});
element.addEventListener('load', function () {
try {
callback({ type: 'loadstop', url: this.contentWindow.location.href }, {keepCallback: true}); // eslint-disable-line standard/no-callback-literal
callback({ type: 'loadstop', url: this.contentWindow.location.href }, { keepCallback: true }); // eslint-disable-line n/no-callback-literal
} catch (err) {
// blocked by CORS :\
callback({ type: 'loadstop', url: null }, {keepCallback: true}); // eslint-disable-line standard/no-callback-literal
callback({ type: 'loadstop', url: null }, { keepCallback: true }); // eslint-disable-line n/no-callback-literal
}
});
@@ -61,7 +55,7 @@ function attachNavigationEvents (element, callback) {
element.addEventListener('abort', onError);
}
var IAB = {
const IAB = {
close: function (win, lose) {
if (browserWrap) {
// use the "open" function callback so that the exit event is fired properly
@@ -80,9 +74,9 @@ var IAB = {
},
open: function (win, lose, args) {
var strUrl = args[0];
var target = args[1];
var features = args[2];
const strUrl = args[0];
const target = args[1];
const features = args[2];
IAB._win = win;
@@ -153,7 +147,9 @@ var IAB = {
backButton.innerHTML = '←';
backButton.addEventListener('click', function (e) {
if (popup.canGoBack) { popup.goBack(); }
if (popup.canGoBack) {
popup.goBack();
}
});
forwardButton = document.createElement('button');
@@ -164,7 +160,9 @@ var IAB = {
forwardButton.innerHTML = '→';
forwardButton.addEventListener('click', function (e) {
if (popup.canGoForward) { popup.goForward(); }
if (popup.canGoForward) {
popup.goForward();
}
});
closeButton = document.createElement('button');
@@ -202,8 +200,8 @@ var IAB = {
},
injectScriptCode: function (win, fail, args) {
var code = args[0];
var hasCallback = args[1];
const code = args[0];
const hasCallback = args[1];
if (browserWrap && popup) {
try {
@@ -218,7 +216,7 @@ var IAB = {
},
injectScriptFile: function (win, fail, args) {
var msg = 'Browser cordova-plugin-inappbrowser injectScriptFile is not yet implemented';
const msg = 'Browser cordova-plugin-inappbrowser injectScriptFile is not yet implemented';
console.warn(msg);
if (fail) {
fail(msg);
@@ -226,7 +224,7 @@ var IAB = {
},
injectStyleCode: function (win, fail, args) {
var msg = 'Browser cordova-plugin-inappbrowser injectStyleCode is not yet implemented';
const msg = 'Browser cordova-plugin-inappbrowser injectStyleCode is not yet implemented';
console.warn(msg);
if (fail) {
fail(msg);
@@ -234,7 +232,7 @@ var IAB = {
},
injectStyleFile: function (win, fail, args) {
var msg = 'Browser cordova-plugin-inappbrowser injectStyleFile is not yet implemented';
const msg = 'Browser cordova-plugin-inappbrowser injectStyleFile is not yet implemented';
console.warn(msg);
if (fail) {
fail(msg);

View File

@@ -1,36 +0,0 @@
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
#import <Cordova/CDVPlugin.h>
#import <Cordova/CDVInvokedUrlCommand.h>
@interface CDVInAppBrowser : CDVPlugin {}
@property (nonatomic, assign) BOOL wkwebviewavailable;
@property (nonatomic, assign) BOOL usewkwebview;
- (void)open:(CDVInvokedUrlCommand*)command;
- (void)close:(CDVInvokedUrlCommand*)command;
- (void)injectScriptCode:(CDVInvokedUrlCommand*)command;
- (void)show:(CDVInvokedUrlCommand*)command;
- (void)hide:(CDVInvokedUrlCommand*)command;
- (void)loadAfterBeforeload:(CDVInvokedUrlCommand*)command;
@end

View File

@@ -1,134 +0,0 @@
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
#import "CDVInAppBrowser.h"
#import "CDVInAppBrowserOptions.h"
#import "CDVUIInAppBrowser.h"
#import "CDVWKInAppBrowser.h"
#import <Cordova/CDVPluginResult.h>
#pragma mark CDVInAppBrowser
@implementation CDVInAppBrowser
- (void)pluginInitialize
{
// default values
self.usewkwebview = NO;
#if __has_include("CDVWKWebViewEngine.h")
self.wkwebviewavailable = YES;
#else
self.wkwebviewavailable = NO;
#endif
}
- (void)open:(CDVInvokedUrlCommand*)command
{
NSString* options = [command argumentAtIndex:2 withDefault:@"" andClass:[NSString class]];
CDVInAppBrowserOptions* browserOptions = [CDVInAppBrowserOptions parseOptions:options];
if(browserOptions.usewkwebview && !self.wkwebviewavailable){
[self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:@{@"type":@"loaderror", @"message": @"usewkwebview option specified but but no plugin that supplies a WKWebView engine is present"}] callbackId:command.callbackId];
return;
}
self.usewkwebview = browserOptions.usewkwebview;
if(self.usewkwebview){
[[CDVWKInAppBrowser getInstance] open:command];
}else{
[[CDVUIInAppBrowser getInstance] open:command];
}
}
- (void)close:(CDVInvokedUrlCommand*)command
{
if(self.usewkwebview){
[[CDVWKInAppBrowser getInstance] close:command];
}else{
[[CDVUIInAppBrowser getInstance] close:command];
}
}
- (void)show:(CDVInvokedUrlCommand*)command
{
if(self.usewkwebview){
[[CDVWKInAppBrowser getInstance] show:command];
}else{
[[CDVUIInAppBrowser getInstance] show:command];
}
}
- (void)hide:(CDVInvokedUrlCommand*)command
{
if(self.usewkwebview){
[[CDVWKInAppBrowser getInstance] hide:command];
}else{
[[CDVUIInAppBrowser getInstance] hide:command];
}
}
- (void)injectScriptCode:(CDVInvokedUrlCommand*)command
{
if(self.usewkwebview){
[[CDVWKInAppBrowser getInstance] injectScriptCode:command];
}else{
[[CDVUIInAppBrowser getInstance] injectScriptCode:command];
}
}
- (void)injectScriptFile:(CDVInvokedUrlCommand*)command
{
if(self.usewkwebview){
[[CDVWKInAppBrowser getInstance] injectScriptFile:command];
}else{
[[CDVUIInAppBrowser getInstance] injectScriptFile:command];
}
}
- (void)injectStyleCode:(CDVInvokedUrlCommand*)command
{
if(self.usewkwebview){
[[CDVWKInAppBrowser getInstance] injectStyleCode:command];
}else{
[[CDVUIInAppBrowser getInstance] injectStyleCode:command];
}
}
- (void)injectStyleFile:(CDVInvokedUrlCommand*)command
{
if(self.usewkwebview){
[[CDVWKInAppBrowser getInstance] injectStyleFile:command];
}else{
[[CDVUIInAppBrowser getInstance] injectStyleFile:command];
}
}
- (void)loadAfterBeforeload:(CDVInvokedUrlCommand*)command
{
if(self.usewkwebview){
[[CDVWKInAppBrowser getInstance] loadAfterBeforeload:command];
}else{
[[CDVUIInAppBrowser getInstance] loadAfterBeforeload:command];
}
}
@end

View File

@@ -17,6 +17,7 @@
under the License.
*/
#import <UIKit/UINavigationController.h>
#import <Cordova/CDVScreenOrientationDelegate.h>

View File

@@ -19,8 +19,6 @@
#import "CDVInAppBrowserNavigationController.h"
#define STATUSBAR_HEIGHT 20.0
@implementation CDVInAppBrowserNavigationController : UINavigationController
- (void) dismissViewControllerAnimated:(BOOL)flag completion:(void (^)(void))completion {
@@ -30,16 +28,6 @@
}
- (void) viewDidLoad {
CGRect statusBarFrame = [self invertFrameIfNeeded:[UIApplication sharedApplication].statusBarFrame];
statusBarFrame.size.height = STATUSBAR_HEIGHT;
// simplified from: http://stackoverflow.com/a/25669695/219684
UIToolbar* bgToolbar = [[UIToolbar alloc] initWithFrame:statusBarFrame];
bgToolbar.barStyle = UIBarStyleDefault;
[bgToolbar setAutoresizingMask:UIViewAutoresizingFlexibleWidth];
[self.view addSubview:bgToolbar];
[super viewDidLoad];
}
@@ -63,7 +51,7 @@
return YES;
}
- (NSUInteger)supportedInterfaceOrientations
- (UIInterfaceOrientationMask)supportedInterfaceOrientations
{
if ((self.orientationDelegate != nil) && [self.orientationDelegate respondsToSelector:@selector(supportedInterfaceOrientations)]) {
return [self.orientationDelegate supportedInterfaceOrientations];
@@ -72,14 +60,4 @@
return 1 << UIInterfaceOrientationPortrait;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
if ((self.orientationDelegate != nil) && [self.orientationDelegate respondsToSelector:@selector(shouldAutorotateToInterfaceOrientation:)]) {
return [self.orientationDelegate shouldAutorotateToInterfaceOrientation:interfaceOrientation];
}
return YES;
}
@end

View File

@@ -17,10 +17,10 @@
under the License.
*/
#import <Foundation/Foundation.h>
@interface CDVInAppBrowserOptions : NSObject {}
@property (nonatomic, assign) BOOL usewkwebview;
@property (nonatomic, assign) BOOL location;
@property (nonatomic, assign) BOOL toolbar;
@property (nonatomic, copy) NSString* closebuttoncaption;
@@ -42,8 +42,6 @@
@property (nonatomic, assign) BOOL enableviewportscale;
@property (nonatomic, assign) BOOL mediaplaybackrequiresuseraction;
@property (nonatomic, assign) BOOL allowinlinemediaplayback;
@property (nonatomic, assign) BOOL keyboarddisplayrequiresuseraction;
@property (nonatomic, assign) BOOL suppressesincrementalrendering;
@property (nonatomic, assign) BOOL hidden;
@property (nonatomic, assign) BOOL disallowoverscroll;
@property (nonatomic, copy) NSString* beforeload;

View File

@@ -25,7 +25,6 @@
{
if (self = [super init]) {
// default values
self.usewkwebview = NO;
self.location = YES;
self.toolbar = YES;
self.closebuttoncaption = nil;
@@ -38,8 +37,6 @@
self.enableviewportscale = NO;
self.mediaplaybackrequiresuseraction = NO;
self.allowinlinemediaplayback = NO;
self.keyboarddisplayrequiresuseraction = YES;
self.suppressesincrementalrendering = NO;
self.hidden = NO;
self.disallowoverscroll = NO;
self.hidenavigationbuttons = NO;

View File

@@ -1,91 +0,0 @@
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
#import <Cordova/CDVPlugin.h>
#import <Cordova/CDVInvokedUrlCommand.h>
#import <Cordova/CDVScreenOrientationDelegate.h>
#import "CDVInAppBrowserOptions.h"
#import "CDVInAppBrowserNavigationController.h"
#ifdef __CORDOVA_4_0_0
#import <Cordova/CDVUIWebViewDelegate.h>
#else
#import <Cordova/CDVWebViewDelegate.h>
#endif
@class CDVUIInAppBrowserViewController;
@interface CDVUIInAppBrowser : CDVPlugin {
UIWindow * tmpWindow;
@private
NSString* _beforeload;
BOOL _waitForBeforeload;
}
@property (nonatomic, retain) CDVUIInAppBrowserViewController* inAppBrowserViewController;
@property (nonatomic, copy) NSString* callbackId;
@property (nonatomic, copy) NSRegularExpression *callbackIdPattern;
+ (id) getInstance;
- (void)open:(CDVInvokedUrlCommand*)command;
- (void)close:(CDVInvokedUrlCommand*)command;
- (void)injectScriptCode:(CDVInvokedUrlCommand*)command;
- (void)show:(CDVInvokedUrlCommand*)command;
- (void)hide:(CDVInvokedUrlCommand*)command;
- (void)loadAfterBeforeload:(CDVInvokedUrlCommand*)command;
@end
@interface CDVUIInAppBrowserViewController : UIViewController <UIWebViewDelegate, CDVScreenOrientationDelegate>{
@private
NSString* _userAgent;
NSString* _prevUserAgent;
NSInteger _userAgentLockToken;
CDVInAppBrowserOptions *_browserOptions;
#ifdef __CORDOVA_4_0_0
CDVUIWebViewDelegate* _webViewDelegate;
#else
CDVWebViewDelegate* _webViewDelegate;
#endif
}
@property (nonatomic, strong) IBOutlet UIWebView* webView;
@property (nonatomic, strong) IBOutlet UIBarButtonItem* closeButton;
@property (nonatomic, strong) IBOutlet UILabel* addressLabel;
@property (nonatomic, strong) IBOutlet UIBarButtonItem* backButton;
@property (nonatomic, strong) IBOutlet UIBarButtonItem* forwardButton;
@property (nonatomic, strong) IBOutlet UIActivityIndicatorView* spinner;
@property (nonatomic, strong) IBOutlet UIToolbar* toolbar;
@property (nonatomic, weak) id <CDVScreenOrientationDelegate> orientationDelegate;
@property (nonatomic, weak) CDVUIInAppBrowser* navigationDelegate;
@property (nonatomic) NSURL* currentURL;
- (void)close;
- (void)navigateTo:(NSURL*)url;
- (void)showLocationBar:(BOOL)show;
- (void)showToolBar:(BOOL)show : (NSString *) toolbarPosition;
- (void)setCloseButtonTitle:(NSString*)title : (NSString*) colorString : (int) buttonIndex;
- (id)initWithUserAgent:(NSString*)userAgent prevUserAgent:(NSString*)prevUserAgent browserOptions: (CDVInAppBrowserOptions*) browserOptions;
@end

File diff suppressed because it is too large Load Diff

View File

@@ -27,6 +27,8 @@
@class CDVWKInAppBrowserViewController;
@interface CDVWKInAppBrowser : CDVPlugin {
UIWindow * tmpWindow;
@private
NSString* _beforeload;
BOOL _waitForBeforeload;
@@ -47,12 +49,10 @@
@end
@interface CDVWKInAppBrowserViewController : UIViewController <CDVScreenOrientationDelegate,WKNavigationDelegate,WKUIDelegate,WKScriptMessageHandler>{
@interface CDVWKInAppBrowserViewController : UIViewController <CDVScreenOrientationDelegate,WKNavigationDelegate,WKUIDelegate,WKScriptMessageHandler,UIAdaptivePresentationControllerDelegate>{
@private
NSString* _userAgent;
NSString* _prevUserAgent;
NSInteger _userAgentLockToken;
CDVInAppBrowserOptions *_browserOptions;
NSDictionary *_settings;
}
@property (nonatomic, strong) IBOutlet WKWebView* webView;
@@ -75,6 +75,6 @@
- (void)showToolBar:(BOOL)show : (NSString *) toolbarPosition;
- (void)setCloseButtonTitle:(NSString*)title : (NSString*) colorString : (int) buttonIndex;
- (id)initWithUserAgent:(NSString*)userAgent prevUserAgent:(NSString*)prevUserAgent browserOptions: (CDVInAppBrowserOptions*) browserOptions;
- (id)initWithBrowserOptions: (CDVInAppBrowserOptions*) browserOptions andSettings:(NSDictionary*) settings;
@end

View File

@@ -18,13 +18,9 @@
*/
#import "CDVWKInAppBrowser.h"
#if __has_include("CDVWKProcessPoolFactory.h")
#import "CDVWKProcessPoolFactory.h"
#endif
#import <Cordova/NSDictionary+CordovaPreferences.h>
#import <Cordova/CDVWebViewProcessPoolFactory.h>
#import <Cordova/CDVPluginResult.h>
#import <Cordova/CDVUserAgentUtil.h>
#define kInAppBrowserTargetSelf @"_self"
#define kInAppBrowserTargetSystem @"_system"
@@ -36,17 +32,11 @@
#define IAB_BRIDGE_NAME @"cordova_iab"
#define TOOLBAR_HEIGHT 44.0
#define STATUSBAR_HEIGHT 20.0
#define LOCATIONBAR_HEIGHT 21.0
#define FOOTER_HEIGHT ((TOOLBAR_HEIGHT) + (LOCATIONBAR_HEIGHT))
#pragma mark CDVWKInAppBrowser
@interface CDVWKInAppBrowser () {
NSInteger _previousStatusBarStyle;
}
@end
@implementation CDVWKInAppBrowser
static CDVWKInAppBrowser* instance = nil;
@@ -58,17 +48,11 @@ static CDVWKInAppBrowser* instance = nil;
- (void)pluginInitialize
{
instance = self;
_previousStatusBarStyle = -1;
_callbackIdPattern = nil;
_beforeload = @"";
_waitForBeforeload = NO;
}
- (id)settingForKey:(NSString*)key
{
return [self.commandDelegate.settings objectForKey:[key lowercaseString]];
}
- (void)onReset
{
[self close:nil];
@@ -80,6 +64,7 @@ static CDVWKInAppBrowser* instance = nil;
NSLog(@"IAB.close() called but it was already closed.");
return;
}
// Things are cleaned up in browserExit.
[self.inAppBrowserViewController close];
}
@@ -104,11 +89,7 @@ static CDVWKInAppBrowser* instance = nil;
self.callbackId = command.callbackId;
if (url != nil) {
#ifdef __CORDOVA_4_0_0
NSURL* baseUrl = [self.webViewEngine URL];
#else
NSURL* baseUrl = [self.webView.request URL];
#endif
NSURL* absoluteUrl = [[NSURL URLWithString:url relativeToURL:baseUrl] absoluteURL];
if ([self isSystemUrl:absoluteUrl]) {
@@ -147,77 +128,31 @@ static CDVWKInAppBrowser* instance = nil;
}
if (browserOptions.clearcache) {
bool isAtLeastiOS11 = false;
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000
if (@available(iOS 11.0, *)) {
isAtLeastiOS11 = true;
}
#endif
if(isAtLeastiOS11){
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000
// Deletes all cookies
WKHTTPCookieStore* cookieStore = dataStore.httpCookieStore;
[cookieStore getAllCookies:^(NSArray* cookies) {
NSHTTPCookie* cookie;
for(cookie in cookies){
[cookieStore deleteCookie:cookie completionHandler:nil];
}
}];
#endif
}else{
// https://stackoverflow.com/a/31803708/777265
// Only deletes domain cookies (not session cookies)
[dataStore fetchDataRecordsOfTypes:[WKWebsiteDataStore allWebsiteDataTypes]
completionHandler:^(NSArray<WKWebsiteDataRecord *> * __nonnull records) {
for (WKWebsiteDataRecord *record in records){
NSSet<NSString*>* dataTypes = record.dataTypes;
if([dataTypes containsObject:WKWebsiteDataTypeCookies]){
[[WKWebsiteDataStore defaultDataStore] removeDataOfTypes:record.dataTypes
forDataRecords:@[record]
completionHandler:^{}];
}
}
}];
}
// Deletes all cookies
WKHTTPCookieStore* cookieStore = dataStore.httpCookieStore;
[cookieStore getAllCookies:^(NSArray* cookies) {
NSHTTPCookie* cookie;
for(cookie in cookies){
[cookieStore deleteCookie:cookie completionHandler:nil];
}
}];
}
if (browserOptions.clearsessioncache) {
bool isAtLeastiOS11 = false;
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000
if (@available(iOS 11.0, *)) {
isAtLeastiOS11 = true;
}
#endif
if (isAtLeastiOS11) {
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000
// Deletes session cookies
WKHTTPCookieStore* cookieStore = dataStore.httpCookieStore;
[cookieStore getAllCookies:^(NSArray* cookies) {
NSHTTPCookie* cookie;
for(cookie in cookies){
if(cookie.sessionOnly){
[cookieStore deleteCookie:cookie completionHandler:nil];
}
// Deletes session cookies
WKHTTPCookieStore* cookieStore = dataStore.httpCookieStore;
[cookieStore getAllCookies:^(NSArray* cookies) {
NSHTTPCookie* cookie;
for(cookie in cookies){
if(cookie.sessionOnly){
[cookieStore deleteCookie:cookie completionHandler:nil];
}
}];
#endif
}else{
NSLog(@"clearsessioncache not available below iOS 11.0");
}
}
}];
}
if (self.inAppBrowserViewController == nil) {
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 = [[CDVWKInAppBrowserViewController alloc] initWithUserAgent:userAgent prevUserAgent:[self.commandDelegate userAgent] browserOptions: browserOptions];
self.inAppBrowserViewController = [[CDVWKInAppBrowserViewController alloc] initWithBrowserOptions: browserOptions andSettings:self.commandDelegate.settings];
self.inAppBrowserViewController.navigationDelegate = self;
if ([self.viewController conformsToProtocol:@protocol(CDVScreenOrientationDelegate)]) {
@@ -275,7 +210,9 @@ static CDVWKInAppBrowser* instance = nil;
_waitForBeforeload = ![_beforeload isEqualToString:@""];
[self.inAppBrowserViewController navigateTo:url];
[self show:nil withNoAnimate:browserOptions.hidden];
if (!browserOptions.hidden) {
[self show:nil withNoAnimate:browserOptions.hidden];
}
}
- (void)show:(CDVInvokedUrlCommand*)command{
@@ -293,20 +230,13 @@ static CDVWKInAppBrowser* instance = nil;
NSLog(@"Tried to show IAB after it was closed.");
return;
}
if (_previousStatusBarStyle != -1) {
NSLog(@"Tried to show IAB while already shown");
return;
}
if(!initHidden){
_previousStatusBarStyle = [UIApplication sharedApplication].statusBarStyle;
}
__block CDVInAppBrowserNavigationController* nav = [[CDVInAppBrowserNavigationController alloc]
initWithRootViewController:self.inAppBrowserViewController];
nav.orientationDelegate = self.inAppBrowserViewController;
nav.navigationBarHidden = YES;
nav.modalPresentationStyle = self.inAppBrowserViewController.modalPresentationStyle;
nav.presentationController.delegate = self.inAppBrowserViewController;
__weak CDVWKInAppBrowser* weakSelf = self;
@@ -314,19 +244,20 @@ static CDVWKInAppBrowser* instance = nil;
dispatch_async(dispatch_get_main_queue(), ^{
if (weakSelf.inAppBrowserViewController != nil) {
float osVersion = [[[UIDevice currentDevice] systemVersion] floatValue];
CGRect frame = [[UIScreen mainScreen] bounds];
if(initHidden && osVersion < 11){
frame.origin.x = -10000;
__strong __typeof(weakSelf) strongSelf = weakSelf;
if (!strongSelf->tmpWindow) {
CGRect frame = [[UIScreen mainScreen] bounds];
if(initHidden && osVersion < 11){
frame.origin.x = -10000;
}
strongSelf->tmpWindow = [[UIWindow alloc] initWithFrame:frame];
}
UIWindow *tmpWindow = [[UIWindow alloc] initWithFrame:frame];
UIViewController *tmpController = [[UIViewController alloc] init];
[tmpWindow setRootViewController:tmpController];
[tmpWindow setWindowLevel:UIWindowLevelNormal];
[strongSelf->tmpWindow setRootViewController:tmpController];
[strongSelf->tmpWindow setWindowLevel:UIWindowLevelNormal];
if(!initHidden || osVersion < 11){
[tmpWindow makeKeyAndVisible];
[self->tmpWindow makeKeyAndVisible];
}
[tmpController presentViewController:nav animated:!noAnimate completion:nil];
}
@@ -335,23 +266,21 @@ static CDVWKInAppBrowser* instance = nil;
- (void)hide:(CDVInvokedUrlCommand*)command
{
// Set tmpWindow to hidden to make main webview responsive to touch again
// https://stackoverflow.com/questions/4544489/how-to-remove-a-uiwindow
self->tmpWindow.hidden = YES;
self->tmpWindow = nil;
if (self.inAppBrowserViewController == nil) {
NSLog(@"Tried to hide IAB after it was closed.");
return;
}
if (_previousStatusBarStyle == -1) {
NSLog(@"Tried to hide IAB while already hidden");
return;
}
_previousStatusBarStyle = [UIApplication sharedApplication].statusBarStyle;
// Run later to avoid the "took a long time" log message.
dispatch_async(dispatch_get_main_queue(), ^{
if (self.inAppBrowserViewController != nil) {
_previousStatusBarStyle = -1;
[self.inAppBrowserViewController.presentingViewController dismissViewControllerAnimated:YES completion:nil];
}
});
@@ -360,24 +289,18 @@ static CDVWKInAppBrowser* instance = nil;
- (void)openInCordovaWebView:(NSURL*)url withOptions:(NSString*)options
{
NSURLRequest* request = [NSURLRequest requestWithURL:url];
#ifdef __CORDOVA_4_0_0
// the webview engine itself will filter for this according to <allow-navigation> policy
// in config.xml for cordova-ios-4.0
// in config.xml
[self.webViewEngine loadRequest:request];
#else
if ([self.commandDelegate URLIsWhitelisted:url]) {
[self.webView loadRequest:request];
} else { // this assumes the InAppBrowser can be excepted from the white-list
[self openInInAppBrowser:url withOptions:options];
}
#endif
}
- (void)openInSystem:(NSURL*)url
{
[[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:CDVPluginHandleOpenURLNotification object:url]];
[[UIApplication sharedApplication] openURL:url];
[[UIApplication sharedApplication] openURL:url options:@{} completionHandler:^(BOOL success) {
if (!success) {
[[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:CDVPluginHandleOpenURLNotification object:url]];
}
}];
}
- (void)loadAfterBeforeload:(CDVInvokedUrlCommand*)command
@@ -554,8 +477,9 @@ static CDVWKInAppBrowser* instance = nil;
[self.commandDelegate sendPluginResult:pluginResult callbackId:self.callbackId];
}
//if is an app store link, let the system handle it, otherwise it fails to load it
if ([[ url scheme] isEqualToString:@"itms-appss"] || [[ url scheme] isEqualToString:@"itms-apps"]) {
//if is an app store, tel, sms, mailto or geo link, let the system handle it, otherwise it fails to load it
NSArray * allowedSchemes = @[@"itms-appss", @"itms-apps", @"tel", @"sms", @"mailto", @"geo"];
if ([allowedSchemes containsObject:[url scheme]]) {
[theWebView stopLoading];
[self openInSystem:url];
shouldStart = NO;
@@ -690,15 +614,11 @@ static CDVWKInAppBrowser* instance = nil;
// Set navigationDelegate to nil to ensure no callbacks are received from it.
self.inAppBrowserViewController.navigationDelegate = nil;
self.inAppBrowserViewController = nil;
if (IsAtLeastiOSVersion(@"7.0")) {
if (_previousStatusBarStyle != -1) {
[[UIApplication sharedApplication] setStatusBarStyle:_previousStatusBarStyle];
}
}
_previousStatusBarStyle = -1; // this value was reset before reapplying it. caused statusbar to stay black on ios7
// Set tmpWindow to hidden to make main webview responsive to touch again
// Based on https://stackoverflow.com/questions/4544489/how-to-remove-a-uiwindow
self->tmpWindow.hidden = YES;
self->tmpWindow = nil;
}
@end //CDVWKInAppBrowser
@@ -709,16 +629,15 @@ static CDVWKInAppBrowser* instance = nil;
@synthesize currentURL;
BOOL viewRenderedAtLeastOnce = FALSE;
CGFloat lastReducedStatusBarHeight = 0.0;
BOOL isExiting = FALSE;
- (id)initWithUserAgent:(NSString*)userAgent prevUserAgent:(NSString*)prevUserAgent browserOptions: (CDVInAppBrowserOptions*) browserOptions
- (id)initWithBrowserOptions: (CDVInAppBrowserOptions*) browserOptions andSettings:(NSDictionary *)settings
{
self = [super init];
if (self != nil) {
_userAgent = userAgent;
_prevUserAgent = prevUserAgent;
_browserOptions = browserOptions;
_settings = settings;
self.webViewUIDelegate = [[CDVWKInAppBrowserUIDelegate alloc] initWithTitle:[[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleDisplayName"]];
[self.webViewUIDelegate setViewController:self];
@@ -742,28 +661,59 @@ BOOL isExiting = FALSE;
WKUserContentController* userContentController = [[WKUserContentController alloc] init];
WKWebViewConfiguration* configuration = [[WKWebViewConfiguration alloc] init];
NSString *userAgent = configuration.applicationNameForUserAgent;
if (
[self settingForKey:@"OverrideUserAgent"] == nil &&
[self settingForKey:@"AppendUserAgent"] != nil
) {
userAgent = [NSString stringWithFormat:@"%@ %@", userAgent, [self settingForKey:@"AppendUserAgent"]];
}
configuration.applicationNameForUserAgent = userAgent;
configuration.userContentController = userContentController;
#if __has_include("CDVWKProcessPoolFactory.h")
#if __has_include(<Cordova/CDVWebViewProcessPoolFactory.h>)
configuration.processPool = [[CDVWebViewProcessPoolFactory sharedFactory] sharedProcessPool];
#elif __has_include("CDVWKProcessPoolFactory.h")
configuration.processPool = [[CDVWKProcessPoolFactory sharedFactory] sharedProcessPool];
#endif
[configuration.userContentController addScriptMessageHandler:self name:IAB_BRIDGE_NAME];
//WKWebView options
configuration.allowsInlineMediaPlayback = _browserOptions.allowinlinemediaplayback;
if (IsAtLeastiOSVersion(@"10.0")) {
configuration.ignoresViewportScaleLimits = _browserOptions.enableviewportscale;
if(_browserOptions.mediaplaybackrequiresuseraction == YES){
configuration.mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeAll;
}else{
configuration.mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeNone;
}
}else{ // iOS 9
configuration.mediaPlaybackRequiresUserAction = _browserOptions.mediaplaybackrequiresuseraction;
configuration.ignoresViewportScaleLimits = _browserOptions.enableviewportscale;
if(_browserOptions.mediaplaybackrequiresuseraction == YES){
configuration.mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeAll;
}else{
configuration.mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeNone;
}
if (@available(iOS 13.0, *)) {
NSString *contentMode = [self settingForKey:@"PreferredContentMode"];
if ([contentMode isEqual: @"mobile"]) {
configuration.defaultWebpagePreferences.preferredContentMode = WKContentModeMobile;
} else if ([contentMode isEqual: @"desktop"]) {
configuration.defaultWebpagePreferences.preferredContentMode = WKContentModeDesktop;
}
}
self.webView = [[WKWebView alloc] initWithFrame:webViewBounds configuration:configuration];
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 160400
// With the introduction of iOS 16.4 the webview is no longer inspectable by default.
// We'll honor that change for release builds, but will still allow inspection on debug builds by default.
// We also introduce an override option, so consumers can influence this decision in their own build.
if (@available(iOS 16.4, *)) {
#ifdef DEBUG
BOOL allowWebviewInspectionDefault = YES;
#else
BOOL allowWebviewInspectionDefault = NO;
#endif
self.webView.inspectable = [_settings cordovaBoolSettingForKey:@"InspectableWebview" defaultValue:allowWebviewInspectionDefault];
}
#endif
[self.view addSubview:self.webView];
[self.view sendSubviewToBack:self.webView];
@@ -772,6 +722,9 @@ BOOL isExiting = FALSE;
self.webView.navigationDelegate = self;
self.webView.UIDelegate = self.webViewUIDelegate;
self.webView.backgroundColor = [UIColor whiteColor];
if ([self settingForKey:@"OverrideUserAgent"] != nil) {
self.webView.customUserAgent = [self settingForKey:@"OverrideUserAgent"];
}
self.webView.clearsContextBeforeDrawing = YES;
self.webView.clipsToBounds = YES;
@@ -784,11 +737,7 @@ BOOL isExiting = FALSE;
self.webView.allowsLinkPreview = NO;
self.webView.allowsBackForwardNavigationGestures = NO;
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000
if (@available(iOS 11.0, *)) {
[self.webView.scrollView setContentInsetAdjustmentBehavior:UIScrollViewContentInsetAdjustmentNever];
}
#endif
[self.webView.scrollView setContentInsetAdjustmentBehavior:UIScrollViewContentInsetAdjustmentNever];
self.spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
self.spinner.alpha = 1.000;
@@ -896,12 +845,17 @@ BOOL isExiting = FALSE;
[self.toolbar setItems:@[self.closeButton, flexibleSpaceButton, self.backButton, fixedSpaceButton, self.forwardButton]];
}
self.view.backgroundColor = [UIColor grayColor];
self.view.backgroundColor = [UIColor clearColor];
[self.view addSubview:self.toolbar];
[self.view addSubview:self.addressLabel];
[self.view addSubview:self.spinner];
}
- (id)settingForKey:(NSString*)key
{
return [_settings objectForKey:[key lowercaseString]];
}
- (void) setWebViewFrame : (CGRect) frame {
NSLog(@"Setting the WebView's frame to %@", NSStringFromCGRect(frame));
[self.webView setFrame:frame];
@@ -913,7 +867,7 @@ BOOL isExiting = FALSE;
// but, if you want to set this yourself, knock yourself out (we can't set the title for a system Done button, so we have to create a new one)
self.closeButton = nil;
// Initialize with title if title is set, otherwise the title will be 'Done' localized
self.closeButton = title != nil ? [[UIBarButtonItem alloc] initWithTitle:title style:UIBarButtonItemStyleBordered target:self action:@selector(close)] : [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(close)];
self.closeButton = title != nil ? [[UIBarButtonItem alloc] initWithTitle:title style:UIBarButtonItemStylePlain target:self action:@selector(close)] : [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(close)];
self.closeButton.enabled = YES;
// If color on closebutton is requested then initialize with that that color, otherwise use initialize with default
self.closeButton.tintColor = colorString != nil ? [self colorFromHexString:colorString] : [UIColor colorWithRed:60.0 / 255.0 green:136.0 / 255.0 blue:230.0 / 255.0 alpha:1];
@@ -1037,7 +991,6 @@ BOOL isExiting = FALSE;
- (void)viewDidLoad
{
viewRenderedAtLeastOnce = FALSE;
[super viewDidLoad];
}
@@ -1052,7 +1005,18 @@ BOOL isExiting = FALSE;
- (UIStatusBarStyle)preferredStatusBarStyle
{
return UIStatusBarStyleDefault;
NSString* statusBarStylePreference = [self settingForKey:@"InAppBrowserStatusBarStyle"];
if (statusBarStylePreference && [statusBarStylePreference isEqualToString:@"lightcontent"]) {
return UIStatusBarStyleLightContent;
} else if (statusBarStylePreference && [statusBarStylePreference isEqualToString:@"darkcontent"]) {
if (@available(iOS 13.0, *)) {
return UIStatusBarStyleDarkContent;
} else {
return UIStatusBarStyleDefault;
}
} else {
return UIStatusBarStyleDefault;
}
}
- (BOOL)prefersStatusBarHidden {
@@ -1061,7 +1025,6 @@ BOOL isExiting = FALSE;
- (void)close
{
[CDVUserAgentUtil releaseLock:&_userAgentLockToken];
self.currentURL = nil;
__weak UIViewController* weakSelf = self;
@@ -1069,6 +1032,7 @@ BOOL isExiting = FALSE;
// Run later to avoid the "took a long time" log message.
dispatch_async(dispatch_get_main_queue(), ^{
isExiting = TRUE;
lastReducedStatusBarHeight = 0.0;
if ([weakSelf respondsToSelector:@selector(presentingViewController)]) {
[[weakSelf presentingViewController] dismissViewControllerAnimated:YES completion:nil];
} else {
@@ -1079,17 +1043,11 @@ BOOL isExiting = FALSE;
- (void)navigateTo:(NSURL*)url
{
NSURLRequest* request = [NSURLRequest requestWithURL:url];
if (_userAgentLockToken != 0) {
[self.webView loadRequest:request];
if ([url.scheme isEqualToString:@"file"]) {
[self.webView loadFileURL:url allowingReadAccessToURL:url];
} else {
__weak CDVWKInAppBrowserViewController* weakSelf = self;
[CDVUserAgentUtil acquireLock:^(NSInteger lockToken) {
_userAgentLockToken = lockToken;
[CDVUserAgentUtil setUserAgent:_userAgent lockToken:lockToken];
[weakSelf.webView loadRequest:request];
}];
NSURLRequest* request = [NSURLRequest requestWithURL:url];
[self.webView loadRequest:request];
}
}
@@ -1105,35 +1063,34 @@ BOOL isExiting = FALSE;
- (void)viewWillAppear:(BOOL)animated
{
if (IsAtLeastiOSVersion(@"7.0") && !viewRenderedAtLeastOnce) {
viewRenderedAtLeastOnce = TRUE;
CGRect viewBounds = [self.webView bounds];
viewBounds.origin.y = STATUSBAR_HEIGHT;
viewBounds.size.height = viewBounds.size.height - STATUSBAR_HEIGHT;
self.webView.frame = viewBounds;
[[UIApplication sharedApplication] setStatusBarStyle:[self preferredStatusBarStyle]];
}
[self rePositionViews];
[super viewWillAppear:animated];
}
//
// On iOS 7 the status bar is part of the view's dimensions, therefore it's height has to be taken into account.
// The height of it could be hardcoded as 20 pixels, but that would assume that the upcoming releases of iOS won't
// change that value.
//
- (float) getStatusBarOffset {
CGRect statusBarFrame = [[UIApplication sharedApplication] statusBarFrame];
float statusBarOffset = IsAtLeastiOSVersion(@"7.0") ? MIN(statusBarFrame.size.width, statusBarFrame.size.height) : 0.0;
return statusBarOffset;
return (float) [[UIApplication sharedApplication] statusBarFrame].size.height;
}
- (void) rePositionViews {
if ([_browserOptions.toolbarposition isEqualToString:kInAppBrowserToolbarBarPositionTop]) {
[self.webView setFrame:CGRectMake(self.webView.frame.origin.x, TOOLBAR_HEIGHT, self.webView.frame.size.width, self.webView.frame.size.height)];
[self.toolbar setFrame:CGRectMake(self.toolbar.frame.origin.x, [self getStatusBarOffset], self.toolbar.frame.size.width, self.toolbar.frame.size.height)];
CGRect viewBounds = [self.webView bounds];
CGFloat statusBarHeight = [self getStatusBarOffset];
// orientation portrait or portraitUpsideDown: status bar is on the top and web view is to be aligned to the bottom of the status bar
// orientation landscapeLeft or landscapeRight: status bar height is 0 in but lets account for it in case things ever change in the future
viewBounds.origin.y = statusBarHeight;
// account for web view height portion that may have been reduced by a previous call to this method
viewBounds.size.height = viewBounds.size.height - statusBarHeight + lastReducedStatusBarHeight;
lastReducedStatusBarHeight = statusBarHeight;
if ((_browserOptions.toolbar) && ([_browserOptions.toolbarposition isEqualToString:kInAppBrowserToolbarBarPositionTop])) {
// if we have to display the toolbar on top of the web view, we need to account for its height
viewBounds.origin.y += TOOLBAR_HEIGHT;
self.toolbar.frame = CGRectMake(self.toolbar.frame.origin.x, statusBarHeight, self.toolbar.frame.size.width, self.toolbar.frame.size.height);
}
self.webView.frame = viewBounds;
}
// Helper function to convert hex color string to UIColor
@@ -1190,24 +1147,6 @@ BOOL isExiting = FALSE;
[self.spinner stopAnimating];
// Work around a bug where the first time a PDF is opened, all UIWebViews
// reload their User-Agent from NSUserDefaults.
// This work-around makes the following assumptions:
// 1. The app has only a single Cordova Webview. If not, then the app should
// take it upon themselves to load a PDF in the background as a part of
// their start-up flow.
// 2. That the PDF does not require any additional network requests. We change
// the user-agent here back to that of the CDVViewController, so requests
// from it must pass through its white-list. This *does* break PDFs that
// contain links to other remote PDF/websites.
// More info at https://issues.apache.org/jira/browse/CB-2225
BOOL isPDF = NO;
//TODO webview class
//BOOL isPDF = [@"true" isEqualToString :[theWebView evaluateJavaScript:@"document.body==null"]];
if (isPDF) {
[CDVUserAgentUtil setUserAgent:_prevUserAgent lockToken:_userAgentLockToken];
}
[self.navigationDelegate didFinishNavigation:theWebView];
}
@@ -1253,7 +1192,7 @@ BOOL isExiting = FALSE;
return YES;
}
- (NSUInteger)supportedInterfaceOrientations
- (UIInterfaceOrientationMask)supportedInterfaceOrientations
{
if ((self.orientationDelegate != nil) && [self.orientationDelegate respondsToSelector:@selector(supportedInterfaceOrientations)]) {
return [self.orientationDelegate supportedInterfaceOrientations];
@@ -1262,14 +1201,23 @@ BOOL isExiting = FALSE;
return 1 << UIInterfaceOrientationPortrait;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator
{
if ((self.orientationDelegate != nil) && [self.orientationDelegate respondsToSelector:@selector(shouldAutorotateToInterfaceOrientation:)]) {
return [self.orientationDelegate shouldAutorotateToInterfaceOrientation:interfaceOrientation];
}
return YES;
[coordinator animateAlongsideTransition:^(id<UIViewControllerTransitionCoordinatorContext> context)
{
[self rePositionViews];
} completion:^(id<UIViewControllerTransitionCoordinatorContext> context)
{
}];
[super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
}
#pragma mark UIAdaptivePresentationControllerDelegate
- (void)presentationControllerWillDismiss:(UIPresentationController *)presentationController {
isExiting = TRUE;
}
@end //CDVWKInAppBrowserViewController

View File

@@ -1,30 +0,0 @@
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
#import <Cordova/CDVPlugin.h>
@interface CDVInAppBrowser : CDVPlugin {
}
@property (nonatomic, copy) NSString* callbackId;
- (void)open:(CDVInvokedUrlCommand*)command;
@end

View File

@@ -1,89 +0,0 @@
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
#import "CDVInAppBrowser.h"
#import <Cordova/CDVPluginResult.h>
#define kInAppBrowserTargetSelf @"_self"
#define kInAppBrowserTargetSystem @"_system"
#define kInAppBrowserTargetBlank @"_blank"
@interface CDVInAppBrowser () {
}
@end
@implementation CDVInAppBrowser
- (void)pluginInitialize
{
}
- (BOOL) isSystemUrl:(NSURL*)url
{
if ([[url host] isEqualToString:@"itunes.apple.com"]) {
return YES;
}
return NO;
}
- (void)open:(CDVInvokedUrlCommand*)command
{
CDVPluginResult* pluginResult;
NSString* url = [command argumentAtIndex:0];
NSString* target = [command argumentAtIndex:1 withDefault:kInAppBrowserTargetSelf];
self.callbackId = command.callbackId;
if (url != nil) {
NSURL* baseUrl = [NSURL URLWithString:url];
NSURL* absoluteUrl = [[NSURL URLWithString:url relativeToURL:baseUrl] absoluteURL];
if ([self isSystemUrl:absoluteUrl]) {
target = kInAppBrowserTargetSystem;
}
if ([target isEqualToString:kInAppBrowserTargetSelf]) {
//[self openInCordovaWebView:absoluteUrl withOptions:options];
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Not Yet Implemented for OSX: [self openInCordovaWebView:absoluteUrl withOptions:options]"];
} else if ([target isEqualToString:kInAppBrowserTargetSystem]) {
[self openInSystem:absoluteUrl];
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
} else { // _blank or anything else
//[self openInInAppBrowser:absoluteUrl withOptions:options];
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Not Yet Implemented for OSX: [self openInInAppBrowser:absoluteUrl withOptions:options]"];
}
} else {
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"incorrect number of arguments"];
}
[pluginResult setKeepCallback:[NSNumber numberWithBool:YES]];
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
}
- (void)openInSystem:(NSURL*)url
{
[[NSWorkspace sharedWorkspace] openURL:url];
}
@end

View File

@@ -1,385 +0,0 @@
/*
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*/
/* jslint sloppy:true */
/* global Windows:true, setImmediate */
/* eslint standard/no-callback-literal : 0 */
var cordova = require('cordova');
var urlutil = require('cordova/urlutil');
var browserWrap,
popup,
navigationButtonsDiv,
navigationButtonsDivInner,
backButton,
forwardButton,
closeButton,
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';
function attachNavigationEvents (element, callback) {
if (isWebViewAvailable) {
element.addEventListener('MSWebViewNavigationStarting', function (e) {
callback({ type: 'loadstart', url: e.uri }, {keepCallback: true});
});
element.addEventListener('MSWebViewNavigationCompleted', function (e) {
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, code: e.webErrorStatus, message: 'Navigation failed with error code ' + e.webErrorStatus }, { keepCallback: true });
});
element.addEventListener('MSWebViewContentLoading', function (e) {
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 {
var onError = function () {
callback({ type: 'loaderror', url: this.contentWindow.location }, {keepCallback: true});
};
element.addEventListener('unload', function () {
callback({ type: 'loadstart', url: this.contentWindow.location }, {keepCallback: true});
});
element.addEventListener('load', function () {
callback({ type: 'loadstop', url: this.contentWindow.location }, {keepCallback: true});
});
element.addEventListener('error', onError);
element.addEventListener('abort', onError);
}
}
var IAB = {
close: function (win, lose) {
setImmediate(function () {
if (browserWrap) {
if (navigationEventsCallback) {
navigationEventsCallback({ type: 'exit' });
}
browserWrap.parentNode.removeChild(browserWrap);
// Reset body overflow style to initial value
document.body.style.msOverflowStyle = bodyOverflowStyle;
browserWrap = null;
popup = null;
document.removeEventListener('backbutton', hardwareBackCallback, false);
}
});
},
show: function (win, lose) {
setImmediate(function () {
if (browserWrap) {
browserWrap.style.display = 'block';
}
});
},
hide: function (win, lose) {
if (browserWrap) {
browserWrap.style.display = 'none';
}
},
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];
var target = args[1];
var features = args[2];
var 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');
document.head.appendChild(browserWrapStyle);
browserWrap = document.createElement('div');
browserWrap.className = 'inAppBrowserWrap';
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;
browserWrap.onclick = function () {
setTimeout(function () {
IAB.close(navigationEventsCallback);
}, 0);
};
document.body.appendChild(browserWrap);
// Hide scrollbars for the whole body while inappbrowser's window is open
document.body.style.msOverflowStyle = 'none';
}
if (features.indexOf('hidden=yes') !== -1) {
browserWrap.style.display = 'none';
}
popup = document.createElement(isWebViewAvailable ? 'x-ms-webview' : 'iframe');
if (popup instanceof HTMLIFrameElement) { // eslint-disable-line no-undef
// 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 = '-5px';
browserWrap.appendChild(popup);
var closeHandler = function (e) {
setTimeout(function () {
IAB.close(navigationEventsCallback);
}, 0);
};
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'; // eslint-disable-line no-throw-literal
}
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'; // eslint-disable-line no-throw-literal
}
closeHandler();
};
}
document.addEventListener('backbutton', hardwareBackCallback, false);
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;
};
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://');
}
popup.src = strUrl;
}
});
},
injectScriptCode: function (win, fail, args) {
setImmediate(function () {
var code = args[0];
var 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) {
setImmediate(function () {
var filePath = args[0];
var hasCallback = args[1];
if (filePath) {
filePath = urlutil.makeAbsolute(filePath);
}
if (isWebViewAvailable && browserWrap && popup) {
// CB-12364 getFileFromApplicationUriAsync does not support ms-appx-web
var uri = new Windows.Foundation.Uri(filePath.replace('ms-appx-web:', 'ms-appx:'));
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) {
setImmediate(function () {
var code = args[0];
var hasCallback = args[1];
if (isWebViewAvailable && browserWrap && popup) {
injectCSS(popup, code, hasCallback && win);
}
});
},
injectStyleFile: function (win, fail, args) {
setImmediate(function () {
var filePath = args[0];
var hasCallback = args[1];
filePath = filePath && urlutil.makeAbsolute(filePath);
if (isWebViewAvailable && browserWrap && popup) {
// CB-12364 getFileFromApplicationUriAsync does not support ms-appx-web
var uri = new Windows.Foundation.Uri(filePath.replace('ms-appx-web:', 'ms-appx:'));
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
});
}
});
}
};
function injectCSS (webView, cssCode, callback) {
// This will automatically escape all thing that we need (quotes, slashes, etc.)
var escapedCode = JSON.stringify(cssCode);
var evalWrapper = '(function(d){var c=d.createElement(\'style\');c.innerHTML=%s;d.head.appendChild(c);})(document)'
.replace('%s', escapedCode);
var op = webView.invokeScriptAsync('eval', evalWrapper);
op.oncomplete = function () {
if (callback) {
callback([]);
}
};
op.onerror = function () { };
op.start();
}
module.exports = IAB;
require('cordova/exec/proxy').add('InAppBrowser', module.exports);

View File

@@ -1,6 +1,6 @@
{
"name": "cordova-plugin-inappbrowser-tests",
"version": "3.1.0",
"version": "6.0.1-dev",
"description": "",
"cordova": {
"id": "cordova-plugin-inappbrowser-tests",

View File

@@ -20,7 +20,7 @@
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
id="cordova-plugin-inappbrowser-tests"
version="3.1.0">
version="6.0.1-dev">
<name>Cordova InAppBrowser Plugin Tests</name>
<license>Apache 2.0</license>
@@ -29,12 +29,5 @@
<js-module src="tests.js" name="tests">
</js-module>
<platform name="ios">
<!-- The WKWebView implementation for inappbrowser requires the presence of this plugin -->
<dependency id="cordova-plugin-wkwebview-engine" />
<dependency id="cordova-plugin-wkwebview-engine-allowfileaccess" url="https://github.com/knight9999/cordova-plugin-wkwebview-engine-allowfileaccess.git" />
</platform>
<asset src="resources" target="cdvtests/iab-resources" />
</plugin>

View File

@@ -15,6 +15,7 @@
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
var d = document.getElementById('header');
*/
const d = document.getElementById('header');
d.innerHTML = 'Script file successfully injected';

File diff suppressed because it is too large Load Diff

22
types/index.d.ts vendored
View File

@@ -6,9 +6,14 @@
// Copyright (c) Microsoft Open Technologies Inc
// Licensed under the MIT license.
// TypeScript Version: 2.3
type channel = "loadstart" | "loadstop" | "loaderror" | "exit" | "message";
type channel = "loadstart" | "loadstop" | "loaderror" | "exit" | "message" | "customscheme";
/**
* The object returned from a call to cordova.InAppBrowser.open.
* NOTE: The InAppBrowser window behaves like a standard web browser, and can't access Cordova APIs.
*/
interface InAppBrowser {
interface Window {
/**
* Opens a URL in a new InAppBrowser instance, the current browser instance, or the system browser.
* @param url The URL to load.
@@ -18,13 +23,7 @@ interface Window {
* name/value pairs must be separated by a comma. Feature names are case insensitive.
*/
open(url: string, target?: string, options?: string): InAppBrowser;
}
/**
* The object returned from a call to window.open.
* NOTE: The InAppBrowser window behaves like a standard web browser, and can't access Cordova APIs.
*/
interface InAppBrowser extends Window {
onloadstart(type: Event): void;
onloadstop(type: InAppBrowserEvent): void;
onloaderror(type: InAppBrowserEvent): void;
@@ -40,6 +39,13 @@ interface InAppBrowser extends Window {
* passed an InAppBrowserEvent object as a parameter.
*/
addEventListener(type: channel, callback: InAppBrowserEventListenerOrEventListenerObject): void;
/**
* Adds a listener for an event from the InAppBrowser.
* @param type any custom event that might occur.
* @param callback the function that executes when the event fires. The function is
* passed an InAppBrowserEvent object as a parameter.
*/
addEventListener(type: string, callback: InAppBrowserEventListenerOrEventListenerObject): void;
// removeEventListener overloads
/**
* Removes a listener for an event from the InAppBrowser.

View File

@@ -1,114 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
.inAppBrowserWrap {
margin: 0;
padding: 0;
outline: 0;
font-size: 100%;
vertical-align: baseline;
background: 0 0;
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 9999999;
box-sizing: border-box;
border: 40px solid #bfbfbf;
border: 40px solid rgba(0, 0, 0, 0.25);
}
.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";
}

View File

@@ -17,35 +17,30 @@
* specific language governing permissions and limitations
* under the License.
*
*/
*/
(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');
const exec = require('cordova/exec');
const channel = require('cordova/channel');
const modulemapper = require('cordova/modulemapper');
const urlutil = require('cordova/urlutil');
function InAppBrowser () {
this.channels = {
'beforeload': channel.create('beforeload'),
'loadstart': channel.create('loadstart'),
'loadstop': channel.create('loadstop'),
'loaderror': channel.create('loaderror'),
'exit': channel.create('exit'),
'customscheme': channel.create('customscheme'),
'message': channel.create('message')
beforeload: channel.create('beforeload'),
loadstart: channel.create('loadstart'),
loadstop: channel.create('loadstop'),
loaderror: channel.create('loaderror'),
exit: channel.create('exit'),
customscheme: channel.create('customscheme'),
message: channel.create('message'),
download: channel.create('download')
};
}
InAppBrowser.prototype = {
_eventHandler: function (event) {
if (event && (event.type in this.channels)) {
if (event && event.type in this.channels) {
if (event.type === 'beforeload') {
this.channels[event.type].fire(event, this._loadAfterBeforeload);
} else {
@@ -95,25 +90,29 @@
} else {
throw new Error('insertCSS requires exactly one of code or file to be specified');
}
},
addDownloadListener: function (success, error) {
exec(success, error, 'InAppBrowser', 'downloadListener');
}
};
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');
const origOpenFunc = modulemapper.getOriginalSymbol(window, 'open');
return origOpenFunc.apply(window, arguments);
}
strUrl = urlutil.makeAbsolute(strUrl);
var iab = new InAppBrowser();
const iab = new InAppBrowser();
callbacks = callbacks || {};
for (var callbackName in callbacks) {
for (const callbackName in callbacks) {
iab.addEventListener(callbackName, callbacks[callbackName]);
}
var cb = function (eventname) {
const cb = function (eventname) {
iab._eventHandler(eventname);
};