Compare commits
523 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
df623882c2 | ||
|
|
b84203970f | ||
|
|
e9dad636d2 | ||
|
|
f3b695fde5 | ||
|
|
5741d4af6d | ||
|
|
c2bb6c1409 | ||
|
|
cc5ee007c6 | ||
|
|
94fec84d5c | ||
|
|
a162bd9076 | ||
|
|
af44235a61 | ||
|
|
2500b08946 | ||
|
|
d01bd25a88 | ||
|
|
eb3acc04cc | ||
|
|
5f1afbdf05 | ||
|
|
2f74d677b7 | ||
|
|
7b16ee88a4 | ||
|
|
c95dbcbaea | ||
|
|
686108484e | ||
|
|
f861655382 | ||
|
|
9c7c2f31d8 | ||
|
|
3c0a42e2ae | ||
|
|
5359f6cf18 | ||
|
|
df84ddabd2 | ||
|
|
2bcec40213 | ||
|
|
fc0c560bff | ||
|
|
5ead1e6a7e | ||
|
|
c7931faa7e | ||
|
|
e2adf1b285 | ||
|
|
4adf4c7230 | ||
|
|
74ccef1226 | ||
|
|
92243cdcc2 | ||
|
|
388e3f6ae7 | ||
|
|
ae329bc4c2 | ||
|
|
9f4b72982a | ||
|
|
6db2f2d324 | ||
|
|
a890e606eb | ||
|
|
632a395b3d | ||
|
|
c54d10052a | ||
|
|
ba3a440491 | ||
|
|
0fd43ae644 | ||
|
|
3b82c160d9 | ||
|
|
978b147598 | ||
|
|
3eadde65ab | ||
|
|
27fe8ec8d4 | ||
|
|
c24bb46965 | ||
|
|
10a06691f9 | ||
|
|
3927b8f2fe | ||
|
|
82482158c5 | ||
|
|
61014dd877 | ||
|
|
c41f5b5131 | ||
|
|
19c6dfe197 | ||
|
|
7f5fa2a28f | ||
|
|
5d2df218d8 | ||
|
|
86cc778c4a | ||
|
|
d9cafcdb14 | ||
|
|
eafaedaec4 | ||
|
|
cbfa195f7d | ||
|
|
52e3534ca7 | ||
|
|
8165232a5a | ||
|
|
a0c267fe36 | ||
|
|
228703a63b | ||
|
|
0ed0bf543b | ||
|
|
f8ad52894b | ||
|
|
e2210bdbcc | ||
|
|
dc7fa34bbe | ||
|
|
b48e02fcd5 | ||
|
|
27e6c67909 | ||
|
|
a0783378fc | ||
|
|
cf58b04097 | ||
|
|
dc5329d157 | ||
|
|
de86501026 | ||
|
|
07d9a9939b | ||
|
|
81f1437b6d | ||
|
|
a464ea6875 | ||
|
|
e75fe14c4b | ||
|
|
eb245ecaf7 | ||
|
|
9cc7f69625 | ||
|
|
dac06aa3f3 | ||
|
|
26cf6e488c | ||
|
|
33aff11f45 | ||
|
|
f57ede9be2 | ||
|
|
57eda786e0 | ||
|
|
ec6af56fbd | ||
|
|
5581957078 | ||
|
|
757022d85a | ||
|
|
49a23e34ba | ||
|
|
4a5608a7a0 | ||
|
|
220cb39f93 | ||
|
|
200f7c1923 | ||
|
|
974ca3309a | ||
|
|
50db5c498c | ||
|
|
013a861493 | ||
|
|
42df297724 | ||
|
|
27500c2990 | ||
|
|
4c4bee528e | ||
|
|
019ec3963f | ||
|
|
2d69afcd7c | ||
|
|
a6c7b54998 | ||
|
|
44d9bb0f6a | ||
|
|
65a825a193 | ||
|
|
b06ad8ed97 | ||
|
|
cbe3a428f4 | ||
|
|
313e0ae6f9 | ||
|
|
a3fca87ee5 | ||
|
|
3f0528c380 | ||
|
|
7eb2e1ea03 | ||
|
|
98ee2e148c | ||
|
|
b73ba93884 | ||
|
|
c80c338e51 | ||
|
|
8e3f2f2c53 | ||
|
|
8f66f075dd | ||
|
|
1876869a05 | ||
|
|
260542d13c | ||
|
|
b9e0a80837 | ||
|
|
7c1ea3b5c2 | ||
|
|
3a2c4ef5c0 | ||
|
|
5f072a752d | ||
|
|
e428556e25 | ||
|
|
d85991accb | ||
|
|
309cdef070 | ||
|
|
695e1b0f02 | ||
|
|
2c547a1a1e | ||
|
|
84a4644cd1 | ||
|
|
0f2f14a563 | ||
|
|
b9c577044c | ||
|
|
cc2299e1c3 | ||
|
|
7fb19f6bdc | ||
|
|
d46f5d45d5 | ||
|
|
ff230d429a | ||
|
|
ec2f12c872 | ||
|
|
6c2a8f4576 | ||
|
|
55b02285f9 | ||
|
|
4af420c592 | ||
|
|
e691212c96 | ||
|
|
8711ee3f21 | ||
|
|
05e37a1ff1 | ||
|
|
0c6189e1a2 | ||
|
|
d940b596b6 | ||
|
|
f3d7f72c9e | ||
|
|
71201b10a6 | ||
|
|
50ac05ca41 | ||
|
|
dcc00fc3bd | ||
|
|
e9878ddecd | ||
|
|
aee699a0e5 | ||
|
|
d78cfdc4d4 | ||
|
|
bf6945feb0 | ||
|
|
ad4a0a3120 | ||
|
|
3882924c4a | ||
|
|
6eb9bbbf75 | ||
|
|
7ac56842aa | ||
|
|
dbf3316df3 | ||
|
|
171e7dfea7 | ||
|
|
6ea100a9fe | ||
|
|
bfe8763918 | ||
|
|
902427525f | ||
|
|
7611645469 | ||
|
|
72ac4d7eca | ||
|
|
32d867f8e4 | ||
|
|
6e058624d6 | ||
|
|
ed139eeb34 | ||
|
|
aa82a5d6c8 | ||
|
|
15685d7a21 | ||
|
|
4f144d9e82 | ||
|
|
b6ed0bbaca | ||
|
|
711c605212 | ||
|
|
c630159c22 | ||
|
|
ff6a765fac | ||
|
|
531a508c0d | ||
|
|
bfb33988be | ||
|
|
b923e88b23 | ||
|
|
c9ff78abfd | ||
|
|
0f5de8524f | ||
|
|
0ddc31d3f4 | ||
|
|
a74510ba00 | ||
|
|
c6ffd69e9c | ||
|
|
783c23b663 | ||
|
|
d842693889 | ||
|
|
92ca973b3d | ||
|
|
771bcb54cf | ||
|
|
6671608a3f | ||
|
|
fe686b3c1f | ||
|
|
c53be403e2 | ||
|
|
26f7ef3c67 | ||
|
|
2a383a66c5 | ||
|
|
1c49092205 | ||
|
|
680971316d | ||
|
|
ad28a0ec68 | ||
|
|
fa70a64af9 | ||
|
|
f32917df31 | ||
|
|
d735649fcd | ||
|
|
d26ccd1f4d | ||
|
|
b6e575be32 | ||
|
|
5cb9df188e | ||
|
|
fdf953c704 | ||
|
|
1c1d14a9fc | ||
|
|
cfbd3845a8 | ||
|
|
009e662c82 | ||
|
|
ca323ea952 | ||
|
|
d73ec0b796 | ||
|
|
8ab07277cd | ||
|
|
1b4859c175 | ||
|
|
5cbbc8e26e | ||
|
|
f8747a700d | ||
|
|
2a71258b98 | ||
|
|
e8533996d0 | ||
|
|
20c21f39df | ||
|
|
df8bcaf751 | ||
|
|
ab696f6ebd | ||
|
|
32253b96a6 | ||
|
|
d4156fb19e | ||
|
|
2df0e72c36 | ||
|
|
c81a64a21c | ||
|
|
6c8106a706 | ||
|
|
032c804937 | ||
|
|
ccfbe7b8cd | ||
|
|
d08a730990 | ||
|
|
cc2ec22695 | ||
|
|
57b50b1d65 | ||
|
|
4a0442b95a | ||
|
|
60d27b8d8d | ||
|
|
22d466a050 | ||
|
|
a77b289f01 | ||
|
|
698648f15d | ||
|
|
2776b14db6 | ||
|
|
3f63aaee58 | ||
|
|
83c5e749f0 | ||
|
|
56dca03de7 | ||
|
|
2a3a0cecab | ||
|
|
fc7452c445 | ||
|
|
64928480e9 | ||
|
|
e9734667c6 | ||
|
|
6bdd538096 | ||
|
|
4ef6106259 | ||
|
|
768f886c6a | ||
|
|
bcdc0b9da0 | ||
|
|
aef8b9947b | ||
|
|
f42226dddb | ||
|
|
066ba4c286 | ||
|
|
4543dec138 | ||
|
|
fc66109f93 | ||
|
|
37b3d249da | ||
|
|
56bb457c5e | ||
|
|
c6ff803113 | ||
|
|
21f4de0e2a | ||
|
|
68054819d8 | ||
|
|
0db344327c | ||
|
|
ea1253963b | ||
|
|
555d55ac8a | ||
|
|
2d836eea0f | ||
|
|
5cbd28edb0 | ||
|
|
98b63cc37e | ||
|
|
4f3b4df7d1 | ||
|
|
234cca4e5b | ||
|
|
bb69b79ca3 | ||
|
|
80c8e56fb0 | ||
|
|
b51a4dc54e | ||
|
|
be1f6076c2 | ||
|
|
f04f37a617 | ||
|
|
df94a6c157 | ||
|
|
1f190d517f | ||
|
|
163f7c5a8f | ||
|
|
b024104a54 | ||
|
|
73ed40fe07 | ||
|
|
4d9e4884dd | ||
|
|
04c05a5e52 | ||
|
|
2e0dc26eaa | ||
|
|
8da5e25eee | ||
|
|
15a57485c6 | ||
|
|
c3ccb694d3 | ||
|
|
212e0a34d8 | ||
|
|
518596a96f | ||
|
|
f326121590 | ||
|
|
fa7c46a316 | ||
|
|
9540f11fcc | ||
|
|
3a1fea5d8b | ||
|
|
2fc2658830 | ||
|
|
ce285e8e06 | ||
|
|
65821f907d | ||
|
|
290ea0ac9c | ||
|
|
542536f790 | ||
|
|
9b576f303b | ||
|
|
52cfd3216a | ||
|
|
8142c73c84 | ||
|
|
bc9036d90a | ||
|
|
1cd9205eb5 | ||
|
|
5451427c98 | ||
|
|
e32b95ccf9 | ||
|
|
682703aa24 | ||
|
|
6815a48408 | ||
|
|
620d92e5c0 | ||
|
|
2c002f0f8d | ||
|
|
214763c76b | ||
|
|
8fb2244432 | ||
|
|
1bc51f9381 | ||
|
|
49757716f5 | ||
|
|
6b99fb96f8 | ||
|
|
1912d12697 | ||
|
|
5a558344fd | ||
|
|
e89f602633 | ||
|
|
790771bb00 | ||
|
|
1afd42aabb | ||
|
|
32743e0eb9 | ||
|
|
89c5ee54e7 | ||
|
|
fee0d4e2d8 | ||
|
|
c08e239143 | ||
|
|
2279aee4ff | ||
|
|
368cbcbc41 | ||
|
|
5c7a9d95a8 | ||
|
|
74aa099b7e | ||
|
|
cb1c6b4d24 | ||
|
|
47e332fc92 | ||
|
|
3413453d86 | ||
|
|
de9f3e35b4 | ||
|
|
77d0c99998 | ||
|
|
ba7cbe58d5 | ||
|
|
7d1b584306 | ||
|
|
f614dc3193 | ||
|
|
05fa172116 | ||
|
|
aacf70f888 | ||
|
|
8175122c03 | ||
|
|
11a2acfd7b | ||
|
|
ea7e7674f8 | ||
|
|
e2865db2ea | ||
|
|
dfd0999581 | ||
|
|
461d9e9c4c | ||
|
|
16353c3466 | ||
|
|
c85cab15b7 | ||
|
|
2c1ded2c43 | ||
|
|
eb59809c34 | ||
|
|
805d43d61d | ||
|
|
9901d62248 | ||
|
|
57f942670c | ||
|
|
ed1227f61a | ||
|
|
4c8f58d87c | ||
|
|
1774ceafae | ||
|
|
00809a3c51 | ||
|
|
b96c4a7d9a | ||
|
|
a45dbc80b4 | ||
|
|
9de15ac8bf | ||
|
|
f4879e9e50 | ||
|
|
4a4164c6f6 | ||
|
|
fb8574abde | ||
|
|
f8a80ce27d | ||
|
|
0293771e14 | ||
|
|
ad263a1b53 | ||
|
|
6604d54e12 | ||
|
|
90d41e87ce | ||
|
|
19a2179d1d | ||
|
|
bfff56aef4 | ||
|
|
e5d6d6f69a | ||
|
|
88b71b3a57 | ||
|
|
a40a10f1ea | ||
|
|
d9900ba783 | ||
|
|
514469ab24 | ||
|
|
abbbcc2461 | ||
|
|
b9653af691 | ||
|
|
2c4bef1f97 | ||
|
|
e785533ab4 | ||
|
|
3056997c78 | ||
|
|
3f80b0b59c | ||
|
|
71b43d39a4 | ||
|
|
d2eaa089f8 | ||
|
|
1bf42c9e3b | ||
|
|
70d74e5273 | ||
|
|
2818011249 | ||
|
|
80e4831a7f | ||
|
|
7a816d8454 | ||
|
|
50a78baf22 | ||
|
|
216ed8ae57 | ||
|
|
8012ae709b | ||
|
|
80010ae309 | ||
|
|
927e7a8e98 | ||
|
|
003f0fd3cd | ||
|
|
0d79919aa5 | ||
|
|
a0785deff8 | ||
|
|
e9eb234683 | ||
|
|
32c0e41c43 | ||
|
|
43592a4789 | ||
|
|
4b3a838704 | ||
|
|
ac0bdee8e6 | ||
|
|
22b3f0ccd4 | ||
|
|
6e0ea336fc | ||
|
|
f47f5449c2 | ||
|
|
8ce6b497fa | ||
|
|
df90a6acc4 | ||
|
|
720123718e | ||
|
|
f90e571430 | ||
|
|
ec8c4527b9 | ||
|
|
faf37db5da | ||
|
|
5fc1beed0d | ||
|
|
832ff5f2e9 | ||
|
|
4f957919c7 | ||
|
|
81161ebe66 | ||
|
|
683937872d | ||
|
|
2c018a3460 | ||
|
|
315a0e30db | ||
|
|
69ca780772 | ||
|
|
79f73fbe62 | ||
|
|
c37b08e038 | ||
|
|
0900f5cc62 | ||
|
|
97e0eac603 | ||
|
|
c2c94f315b | ||
|
|
8cb876c63a | ||
|
|
cc2f8966ba | ||
|
|
f620b64035 | ||
|
|
d828197de4 | ||
|
|
6e38667320 | ||
|
|
ea6a4fc80a | ||
|
|
ac9c64964e | ||
|
|
61239c12e8 | ||
|
|
9fe291ce7a | ||
|
|
225bde271b | ||
|
|
e5d07f14e8 | ||
|
|
f866e0ed9f | ||
|
|
ae5e01ef04 | ||
|
|
91b84579e8 | ||
|
|
89ae9dbd53 | ||
|
|
c011fe2d9d | ||
|
|
992306bbc5 | ||
|
|
384d3fb8a6 | ||
|
|
f9c235caf5 | ||
|
|
df001e2765 | ||
|
|
393524a3ea | ||
|
|
eb704f8212 | ||
|
|
75cadab5ee | ||
|
|
846190a6f8 | ||
|
|
cd7916d025 | ||
|
|
03e1715cfe | ||
|
|
8fea6be60a | ||
|
|
9fc6654b89 | ||
|
|
1953356fd2 | ||
|
|
687ce60470 | ||
|
|
8e2db096ae | ||
|
|
abf757edff | ||
|
|
fea1f9827c | ||
|
|
5270462611 | ||
|
|
a6cd0a16ba | ||
|
|
7b24dcb3dd | ||
|
|
282fdb7a40 | ||
|
|
6ee35a09ca | ||
|
|
be9034ff6c | ||
|
|
e2a0bb8715 | ||
|
|
907bba6cf6 | ||
|
|
ab7494faa0 | ||
|
|
8f2ad211ad | ||
|
|
40778ba239 | ||
|
|
c25bc30d7d | ||
|
|
b9f8fcd8a9 | ||
|
|
11f833b46d | ||
|
|
1c98bc5b3f | ||
|
|
c5061ec333 | ||
|
|
932f078e2d | ||
|
|
1c32236353 | ||
|
|
34c29dc2ec | ||
|
|
aa6c1519d2 | ||
|
|
2fc9f3da1f | ||
|
|
bddf86c3ce | ||
|
|
cc5b0ce5a3 | ||
|
|
88f330abd8 | ||
|
|
25f306d11e | ||
|
|
04de070dcd | ||
|
|
c14871da95 | ||
|
|
51879d8e2f | ||
|
|
22c7a0e51e | ||
|
|
bdf4ade2bb | ||
|
|
6b25158e07 | ||
|
|
9399ed3955 | ||
|
|
749d55c676 | ||
|
|
fceea502a3 | ||
|
|
aa9a5db941 | ||
|
|
e282cc9e38 | ||
|
|
392a73c2cd | ||
|
|
7dbad601f0 | ||
|
|
5680f18bb4 | ||
|
|
a5dedae631 | ||
|
|
d0dd10103c | ||
|
|
34653ce393 | ||
|
|
497a23efc7 | ||
|
|
6f373f7ed9 | ||
|
|
300f1e782e | ||
|
|
4d3c7b17d2 | ||
|
|
a5201cc1e3 | ||
|
|
942d17981e | ||
|
|
17ba417572 | ||
|
|
77085aa547 | ||
|
|
4a3c134be1 | ||
|
|
dbf54d2d09 | ||
|
|
26702cb072 | ||
|
|
39e64c988a | ||
|
|
cd31b3a64d | ||
|
|
4c07917c0a | ||
|
|
24e6a1feeb | ||
|
|
b62b9edde3 | ||
|
|
985d94ee00 | ||
|
|
e807bc3dc0 | ||
|
|
0ce0eed585 | ||
|
|
736c8ddec0 | ||
|
|
9206d82df4 | ||
|
|
bc554fdf95 | ||
|
|
43f8935541 | ||
|
|
2136cad49a | ||
|
|
9795b2e9dc | ||
|
|
255c5269c3 | ||
|
|
21fe13e809 | ||
|
|
3f9af4fd88 | ||
|
|
57d14da151 | ||
|
|
21a1638ccf | ||
|
|
b0bdb1088b | ||
|
|
6163f17aeb | ||
|
|
176890f305 | ||
|
|
2bd006b71e | ||
|
|
aac2db29b5 | ||
|
|
97c6f2ba8a | ||
|
|
f75b30857b | ||
|
|
25d152b578 | ||
|
|
4aeaf81e1e | ||
|
|
20611efe67 | ||
|
|
e819041fd4 | ||
|
|
034b599315 | ||
|
|
f448ce88ab | ||
|
|
ea239151d2 | ||
|
|
863386398e | ||
|
|
ef9ca5ad3e |
30
.appveyor.yml
Normal file
@@ -0,0 +1,30 @@
|
||||
# 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%
|
||||
10
.eslintrc.yml
Normal file
@@ -0,0 +1,10 @@
|
||||
root: true
|
||||
extends: semistandard
|
||||
rules:
|
||||
indent:
|
||||
- error
|
||||
- 4
|
||||
camelcase: off
|
||||
padded-blocks: off
|
||||
operator-linebreak: off
|
||||
no-throw-literal: off
|
||||
26
.gitattributes
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
* text eol=lf
|
||||
|
||||
#
|
||||
## These files are binary and should be left untouched
|
||||
#
|
||||
|
||||
# (binary is a macro for -text -diff)
|
||||
*.png binary
|
||||
*.jpg binary
|
||||
*.jpeg binary
|
||||
*.gif binary
|
||||
*.ico binary
|
||||
*.mov binary
|
||||
*.mp4 binary
|
||||
*.mp3 binary
|
||||
*.flv binary
|
||||
*.fla binary
|
||||
*.swf binary
|
||||
*.gz binary
|
||||
*.zip binary
|
||||
*.7z binary
|
||||
*.ttf binary
|
||||
*.eot binary
|
||||
*.woff binary
|
||||
*.pyc binary
|
||||
*.pdf binary
|
||||
42
.github/ISSUE_TEMPLATE.md
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
<!--
|
||||
Please have a look at the issue templates you get when you click "New issue" in the GitHub UI.
|
||||
We very much prefer issues created by using one of these templates.
|
||||
-->
|
||||
|
||||
### Issue Type
|
||||
<!-- Please check the boxes by putting an x in the [ ] like so: [x] -->
|
||||
|
||||
- [ ] Bug Report
|
||||
- [ ] Feature Request
|
||||
- [ ] Support Question
|
||||
|
||||
## Description
|
||||
|
||||
## Information
|
||||
<!-- Include all relevant information that might help understand and reproduce the problem -->
|
||||
|
||||
### Command or Code
|
||||
<!-- What command or code is needed to reproduce the problem? -->
|
||||
|
||||
### Environment, Platform, Device
|
||||
<!-- In what environment, on what platform or on which device are you experiencing the issue? -->
|
||||
|
||||
|
||||
|
||||
### Version information
|
||||
<!--
|
||||
What are relevant versions you are using?
|
||||
For example:
|
||||
Cordova: Cordova CLI, Cordova Platforms, Cordova Plugins
|
||||
Other Frameworks: Ionic Framework and CLI version
|
||||
Operating System, Android Studio, Xcode etc.
|
||||
-->
|
||||
|
||||
|
||||
|
||||
## Checklist
|
||||
<!-- Please check the boxes by putting an `x` in the `[ ]` like so: `[x]` -->
|
||||
|
||||
- [ ] I searched for already existing GitHub issues about this
|
||||
- [ ] I updated all Cordova tooling to their most recent version
|
||||
- [ ] I included all the necessary information above
|
||||
50
.github/ISSUE_TEMPLATE/BUG_REPORT.md
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
---
|
||||
name: 🐛 Bug Report
|
||||
about: If something isn't working as expected.
|
||||
|
||||
---
|
||||
|
||||
# Bug Report
|
||||
|
||||
## Problem
|
||||
|
||||
### What is expected to happen?
|
||||
|
||||
|
||||
|
||||
### What does actually happen?
|
||||
|
||||
|
||||
|
||||
## Information
|
||||
<!-- Include all relevant information that might help understand and reproduce the problem -->
|
||||
|
||||
|
||||
|
||||
### Command or Code
|
||||
<!-- What command or code is needed to reproduce the problem? -->
|
||||
|
||||
|
||||
|
||||
### Environment, Platform, Device
|
||||
<!-- In what environment, on what platform or on which device are you experiencing the issue? -->
|
||||
|
||||
|
||||
|
||||
### Version information
|
||||
<!--
|
||||
What are relevant versions you are using?
|
||||
For example:
|
||||
Cordova: Cordova CLI, Cordova Platforms, Cordova Plugins
|
||||
Other Frameworks: Ionic Framework and CLI version
|
||||
Operating System, Android Studio, Xcode etc.
|
||||
-->
|
||||
|
||||
|
||||
|
||||
## Checklist
|
||||
<!-- Please check the boxes by putting an x in the [ ] like so: [x] -->
|
||||
|
||||
- [ ] I searched for existing GitHub issues
|
||||
- [ ] I updated all Cordova tooling to most recent version
|
||||
- [ ] I included all the necessary information above
|
||||
29
.github/ISSUE_TEMPLATE/FEATURE_REQUEST.md
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
---
|
||||
name: 🚀 Feature Request
|
||||
about: A suggestion for a new functionality
|
||||
|
||||
---
|
||||
|
||||
# Feature Request
|
||||
|
||||
## Motivation Behind Feature
|
||||
<!-- Why should this feature be implemented? What problem does it solve? -->
|
||||
|
||||
|
||||
|
||||
## Feature Description
|
||||
<!--
|
||||
Describe your feature request in detail
|
||||
Please provide any code examples or screenshots of what this feature would look like
|
||||
Are there any drawbacks? Will this break anything for existing users?
|
||||
-->
|
||||
|
||||
|
||||
|
||||
## Alternatives or Workarounds
|
||||
<!--
|
||||
Describe alternatives or workarounds you are currently using
|
||||
Are there ways to do this with existing functionality?
|
||||
-->
|
||||
|
||||
|
||||
27
.github/ISSUE_TEMPLATE/SUPPORT_QUESTION.md
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
---
|
||||
name: 💬 Support Question
|
||||
about: If you have a question, please check out our Slack or StackOverflow!
|
||||
|
||||
---
|
||||
|
||||
<!------------^ Click "Preview" for a nicer view! -->
|
||||
|
||||
Apache Cordova uses GitHub Issues as a feature request and bug tracker _only_.
|
||||
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/)
|
||||
* StackOverflow: https://stackoverflow.com/questions/tagged/cordova using the tag `cordova`
|
||||
|
||||
---
|
||||
|
||||
If you are using a tool that uses Cordova internally, like e.g. Ionic, check their support channels:
|
||||
|
||||
* **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)
|
||||
35
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
<!--
|
||||
Please make sure the checklist boxes are all checked before submitting the PR. The checklist is intended as a quick reference, for complete details please see our Contributor Guidelines:
|
||||
|
||||
http://cordova.apache.org/contribute/contribute_guidelines.html
|
||||
|
||||
Thanks!
|
||||
-->
|
||||
|
||||
### Platforms affected
|
||||
|
||||
|
||||
|
||||
### Motivation and Context
|
||||
<!-- Why is this change required? What problem does it solve? -->
|
||||
<!-- If it fixes an open issue, please link to the issue here. -->
|
||||
|
||||
|
||||
|
||||
### Description
|
||||
<!-- Describe your changes in detail -->
|
||||
|
||||
|
||||
|
||||
### Testing
|
||||
<!-- Please describe in detail how you tested your changes. -->
|
||||
|
||||
|
||||
|
||||
### Checklist
|
||||
|
||||
- [ ] I've run the tests to see all new and existing tests pass
|
||||
- [ ] I added automated test coverage as appropriate for this change
|
||||
- [ ] Commit is prefixed with `(platform)` if this change only applies to one platform (e.g. `(android)`)
|
||||
- [ ] If this Pull Request resolves an issue, I linked to the issue in the text above (and used the correct [keyword to close issues using keywords](https://help.github.com/articles/closing-issues-using-keywords/))
|
||||
- [ ] I've updated the documentation if necessary
|
||||
5
.gitignore
vendored
@@ -11,6 +11,9 @@ Thumbs.db
|
||||
*.log
|
||||
*.swp
|
||||
*.user
|
||||
*.idea
|
||||
|
||||
node_modules
|
||||
|
||||
|
||||
|
||||
@@ -19,5 +22,3 @@ Thumbs.db
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
16
.npmignore
Normal file
@@ -0,0 +1,16 @@
|
||||
# CI service configurations
|
||||
.travis.yml
|
||||
.appveyor.yml
|
||||
appveyor.yml
|
||||
|
||||
# Testing, code coverage, and linting
|
||||
.eslintignore
|
||||
.eslintrc.yml
|
||||
|
||||
# Git
|
||||
.git
|
||||
.gitattributes
|
||||
.gitignore
|
||||
|
||||
# Github
|
||||
.github
|
||||
117
.travis.yml
Normal file
@@ -0,0 +1,117 @@
|
||||
# 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
|
||||
64
CONTRIBUTING.md
Normal file
@@ -0,0 +1,64 @@
|
||||
<!--
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
-->
|
||||
|
||||
# Contributing to Apache Cordova
|
||||
|
||||
Anyone can contribute to Cordova. And we need your contributions.
|
||||
|
||||
There are multiple ways to contribute: report bugs, improve the docs, and
|
||||
contribute code.
|
||||
|
||||
For instructions on this, start with the
|
||||
[contribution overview](http://cordova.apache.org/contribute/).
|
||||
|
||||
The details are explained there, but the important items are:
|
||||
- Sign and submit an Apache ICLA (Contributor License Agreement).
|
||||
- Have a Jira issue open that corresponds to your contribution.
|
||||
- Run the tests so your patch doesn't break existing functionality.
|
||||
|
||||
We look forward to your contributions!
|
||||
|
||||
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
|
||||
```
|
||||
5
NOTICE
Normal file
@@ -0,0 +1,5 @@
|
||||
Apache Cordova
|
||||
Copyright 2012 The Apache Software Foundation
|
||||
|
||||
This product includes software developed at
|
||||
The Apache Software Foundation (http://www.apache.org/).
|
||||
720
README.md
@@ -1,5 +1,717 @@
|
||||
cordova-plugin-inappbrowser
|
||||
-----------------------------
|
||||
To install this plugin, follow the [Command-line Interface Guide](http://cordova.apache.org/docs/en/edge/guide_cli_index.md.html#The%20Command-line%20Interface).
|
||||
---
|
||||
title: Inappbrowser
|
||||
description: Open an in-app browser window.
|
||||
---
|
||||
<!--
|
||||
# license: Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
-->
|
||||
|
||||
If you are not using the Cordova Command-line Interface, follow [Using Plugman to Manage Plugins](http://cordova.apache.org/docs/en/edge/plugin_ref_plugman.md.html).
|
||||
|AppVeyor|Travis CI|
|
||||
|:-:|:-:|
|
||||
|[](https://ci.appveyor.com/project/ApacheSoftwareFoundation/cordova-plugin-inappbrowser)|[](https://travis-ci.org/apache/cordova-plugin-inappbrowser)|
|
||||
|
||||
# cordova-plugin-inappbrowser
|
||||
|
||||
You can show helpful articles, videos, and web resources inside of your app. Users can view web pages without leaving your app.
|
||||
|
||||
> To get a few ideas, check out the [sample](#sample) at the bottom of this page or go straight to the [reference](#reference) content.
|
||||
|
||||
This plugin provides a web browser view that displays when calling `cordova.InAppBrowser.open()`.
|
||||
|
||||
var ref = cordova.InAppBrowser.open('http://apache.org', '_blank', 'location=yes');
|
||||
|
||||
### `window.open`
|
||||
|
||||
The `cordova.InAppBrowser.open()` function is defined to be a drop-in replacement
|
||||
for the `window.open()` function. Existing `window.open()` calls can use the
|
||||
InAppBrowser window, by replacing window.open:
|
||||
|
||||
window.open = cordova.InAppBrowser.open;
|
||||
|
||||
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
|
||||
into the main Cordova webview. The InAppBrowser is not subject to the
|
||||
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
|
||||
|
||||
If you want all page loads in your app to go through the InAppBrowser, you can
|
||||
simply hook `window.open` during initialization. For example:
|
||||
|
||||
document.addEventListener("deviceready", onDeviceReady, false);
|
||||
function onDeviceReady() {
|
||||
window.open = cordova.InAppBrowser.open;
|
||||
}
|
||||
|
||||
## cordova.InAppBrowser.open
|
||||
|
||||
Opens a URL in a new `InAppBrowser` instance, the current browser
|
||||
instance, or the system browser.
|
||||
|
||||
var ref = cordova.InAppBrowser.open(url, target, options);
|
||||
|
||||
- __ref__: Reference to the `InAppBrowser` window when the target is set to `'_blank'`. _(InAppBrowser)_
|
||||
|
||||
- __url__: The URL to load _(String)_. Call `encodeURI()` on this if the URL contains Unicode characters.
|
||||
|
||||
- __target__: The target in which to load the URL, an optional parameter that defaults to `_self`. _(String)_
|
||||
|
||||
- `_self`: Opens in the Cordova WebView if the URL is in the white list, otherwise it opens in the `InAppBrowser`.
|
||||
- `_blank`: Opens in the `InAppBrowser`.
|
||||
- `_system`: Opens in the system's web browser.
|
||||
|
||||
- __options__: Options for the `InAppBrowser`. Optional, defaulting to: `location=yes`. _(String)_
|
||||
|
||||
The `options` string must not contain any blank space, and each feature's name/value pairs must be separated by a comma. Feature names are case insensitive.
|
||||
|
||||
All platforms support:
|
||||
|
||||
- __location__: Set to `yes` or `no` to turn the `InAppBrowser`'s location bar on or off.
|
||||
|
||||
Android 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.
|
||||
- __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
|
||||
- __clearsessioncache__: set to `yes` to have the session cookie cache cleared before the new window is opened
|
||||
- __closebuttoncaption__: set to a string to use as the close button's caption instead of a X. Note that you need to localize this value yourself.
|
||||
- __closebuttoncolor__: set to a valid hex color string, for example: `#00ff00`, and it will change the
|
||||
close button color from default, regardless of being a text or default X. Only has effect if user has location set to `yes`.
|
||||
- __footer__: set to `yes` to show a close button in the footer similar to the iOS __Done__ button.
|
||||
The close button will appear the same as for the header hence use __closebuttoncaption__ and __closebuttoncolor__ to set its properties.
|
||||
- __footercolor__: set to a valid hex color string, for example `#00ff00` or `#CC00ff00` (`#aarrggbb`) , and it will change the footer color from default.
|
||||
Only has effect if user has __footer__ set to `yes`.
|
||||
- __hardwareback__: set to `yes` to use the hardware back button to navigate backwards through the `InAppBrowser`'s history. If there is no previous page, the `InAppBrowser` will close. The default value is `yes`, so you must set it to `no` if you want the back button to simply close the InAppBrowser.
|
||||
- __hidenavigationbuttons__: set to `yes` to hide the navigation buttons on the location toolbar, only has effect if user has location set to `yes`. The default value is `no`.
|
||||
- __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.
|
||||
- __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`).
|
||||
|
||||
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
|
||||
- __clearsessioncache__: set to `yes` to have the session cookie cache cleared before the new window is opened. For WKWebView, requires iOS 11+ on target device.
|
||||
- __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.
|
||||
- __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`).
|
||||
- __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 ref2 = cordova.InAppBrowser.open(encodeURI('http://ja.m.wikipedia.org/wiki/ハングル'), '_blank', 'location=yes');
|
||||
|
||||
### OSX Quirks
|
||||
|
||||
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.
|
||||
|
||||
### Browser Quirks
|
||||
|
||||
- Plugin is implemented via iframe,
|
||||
|
||||
- Navigation history (`back` and `forward` buttons in LocationBar) is not implemented.
|
||||
|
||||
## InAppBrowser
|
||||
|
||||
The object returned from a call to `cordova.InAppBrowser.open` when the target is set to `'_blank'`.
|
||||
|
||||
### Methods
|
||||
|
||||
- addEventListener
|
||||
- removeEventListener
|
||||
- close
|
||||
- show
|
||||
- hide
|
||||
- executeScript
|
||||
- insertCSS
|
||||
|
||||
## InAppBrowser.addEventListener
|
||||
|
||||
> Adds a listener for an event from the `InAppBrowser`. (Only available when the target is set to `'_blank'`)
|
||||
|
||||
ref.addEventListener(eventname, callback);
|
||||
|
||||
- __ref__: reference to the `InAppBrowser` window _(InAppBrowser)_
|
||||
|
||||
- __eventname__: the event to listen for _(String)_
|
||||
|
||||
- __loadstart__: event fires when the `InAppBrowser` starts to load a URL.
|
||||
- __loadstop__: event fires when the `InAppBrowser` finishes loading a URL.
|
||||
- __loaderror__: event fires when the `InAppBrowser` encounters an error when loading a URL.
|
||||
- __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.
|
||||
|
||||
- __callback__: the function that executes when the event fires. The function is passed an `InAppBrowserEvent` object as a parameter.
|
||||
|
||||
## Example
|
||||
|
||||
```javascript
|
||||
|
||||
var inAppBrowserRef;
|
||||
|
||||
function showHelp(url) {
|
||||
|
||||
var target = "_blank";
|
||||
|
||||
var options = "location=yes,hidden=yes,beforeload=yes";
|
||||
|
||||
inAppBrowserRef = cordova.InAppBrowser.open(url, target, options);
|
||||
|
||||
inAppBrowserRef.addEventListener('loadstart', loadStartCallBack);
|
||||
|
||||
inAppBrowserRef.addEventListener('loadstop', loadStopCallBack);
|
||||
|
||||
inAppBrowserRef.addEventListener('loaderror', loadErrorCallBack);
|
||||
|
||||
inAppBrowserRef.addEventListener('beforeload', beforeloadCallBack);
|
||||
|
||||
inAppBrowserRef.addEventListener('message', messageCallBack);
|
||||
}
|
||||
|
||||
function loadStartCallBack() {
|
||||
|
||||
$('#status-message').text("loading please wait ...");
|
||||
|
||||
}
|
||||
|
||||
function loadStopCallBack() {
|
||||
|
||||
if (inAppBrowserRef != undefined) {
|
||||
|
||||
inAppBrowserRef.insertCSS({ code: "body{font-size: 25px;" });
|
||||
|
||||
inAppBrowserRef.executeScript({ code: "\
|
||||
var message = 'this is the message';\
|
||||
var messageObj = {my_message: message};\
|
||||
var stringifiedMessageObj = JSON.stringify(messageObj);\
|
||||
webkit.messageHandlers.cordova_iab.postMessage(stringifiedMessageObj);"
|
||||
});
|
||||
|
||||
$('#status-message').text("");
|
||||
|
||||
inAppBrowserRef.show();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function loadErrorCallBack(params) {
|
||||
|
||||
$('#status-message').text("");
|
||||
|
||||
var scriptErrorMesssage =
|
||||
"alert('Sorry we cannot open that page. Message from the server is : "
|
||||
+ params.message + "');"
|
||||
|
||||
inAppBrowserRef.executeScript({ code: scriptErrorMesssage }, executeScriptCallBack);
|
||||
|
||||
inAppBrowserRef.close();
|
||||
|
||||
inAppBrowserRef = undefined;
|
||||
|
||||
}
|
||||
|
||||
function executeScriptCallBack(params) {
|
||||
|
||||
if (params[0] == null) {
|
||||
|
||||
$('#status-message').text(
|
||||
"Sorry we couldn't open that page. Message from the server is : '"
|
||||
+ params.message + "'");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function beforeloadCallBack(params, callback) {
|
||||
|
||||
if (params.url.startsWith("http://www.example.com/")) {
|
||||
|
||||
// Load this URL in the inAppBrowser.
|
||||
callback(params.url);
|
||||
} else {
|
||||
|
||||
// The callback is not invoked, so the page will not be loaded.
|
||||
$('#status-message').text("This browser only opens pages on http://www.example.com/");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function messageCallBack(params){
|
||||
$('#status-message').text("message received: "+params.data.my_message);
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
### 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');
|
||||
ref.addEventListener('loadstart', function(event) { alert(event.url); });
|
||||
|
||||
## InAppBrowser.removeEventListener
|
||||
|
||||
> Removes a listener for an event from the `InAppBrowser`. (Only available when the target is set to `'_blank'`)
|
||||
|
||||
ref.removeEventListener(eventname, callback);
|
||||
|
||||
- __ref__: reference to the `InAppBrowser` window. _(InAppBrowser)_
|
||||
|
||||
- __eventname__: the event to stop listening for. _(String)_
|
||||
|
||||
- __loadstart__: event fires when the `InAppBrowser` starts to load a URL.
|
||||
- __loadstop__: event fires when the `InAppBrowser` finishes loading a URL.
|
||||
- __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.
|
||||
|
||||
- __callback__: the function to execute when the event fires.
|
||||
The function is passed an `InAppBrowserEvent` object.
|
||||
|
||||
### Supported Platforms
|
||||
|
||||
- Android
|
||||
- Browser
|
||||
- iOS
|
||||
- Windows
|
||||
|
||||
### Quick Example
|
||||
|
||||
var ref = cordova.InAppBrowser.open('http://apache.org', '_blank', 'location=yes');
|
||||
var myCallback = function(event) { alert(event.url); }
|
||||
ref.addEventListener('loadstart', myCallback);
|
||||
ref.removeEventListener('loadstart', myCallback);
|
||||
|
||||
## InAppBrowser.close
|
||||
|
||||
> Closes the `InAppBrowser` window.
|
||||
|
||||
ref.close();
|
||||
|
||||
- __ref__: reference to the `InAppBrowser` window _(InAppBrowser)_
|
||||
|
||||
### Supported Platforms
|
||||
|
||||
- Android
|
||||
- Browser
|
||||
- iOS
|
||||
- Windows
|
||||
|
||||
### Quick Example
|
||||
|
||||
var ref = cordova.InAppBrowser.open('http://apache.org', '_blank', 'location=yes');
|
||||
ref.close();
|
||||
|
||||
## InAppBrowser.show
|
||||
|
||||
> Displays an InAppBrowser window that was opened hidden. Calling this has no effect if the InAppBrowser was already visible.
|
||||
|
||||
ref.show();
|
||||
|
||||
- __ref__: reference to the InAppBrowser window (`InAppBrowser`)
|
||||
|
||||
### Supported Platforms
|
||||
|
||||
- Android
|
||||
- Browser
|
||||
- iOS
|
||||
- Windows
|
||||
|
||||
### Quick Example
|
||||
|
||||
var ref = cordova.InAppBrowser.open('http://apache.org', '_blank', 'hidden=yes');
|
||||
// some time later...
|
||||
ref.show();
|
||||
|
||||
## InAppBrowser.hide
|
||||
|
||||
> Hides the InAppBrowser window. Calling this has no effect if the InAppBrowser was already hidden.
|
||||
|
||||
ref.hide();
|
||||
|
||||
- __ref__: reference to the InAppBrowser window (`InAppBrowser`)
|
||||
|
||||
### Supported Platforms
|
||||
|
||||
- Android
|
||||
- iOS
|
||||
- Windows
|
||||
|
||||
### Quick Example
|
||||
|
||||
var ref = cordova.InAppBrowser.open('http://apache.org', '_blank');
|
||||
// some time later...
|
||||
ref.hide();
|
||||
|
||||
## InAppBrowser.executeScript
|
||||
|
||||
> Injects JavaScript code into the `InAppBrowser` window. (Only available when the target is set to `'_blank'`)
|
||||
|
||||
ref.executeScript(details, callback);
|
||||
|
||||
- __ref__: reference to the `InAppBrowser` window. _(InAppBrowser)_
|
||||
|
||||
- __injectDetails__: details of the script to run, specifying either a `file` or `code` key. _(Object)_
|
||||
- __file__: URL of the script to inject.
|
||||
- __code__: Text of the script to inject.
|
||||
|
||||
- __callback__: the function that executes after the JavaScript code is injected.
|
||||
- If the injected script is of type `code`, the callback executes
|
||||
with a single parameter, which is the return value of the
|
||||
script, wrapped in an `Array`. For multi-line scripts, this is
|
||||
the return value of the last statement, or the last expression
|
||||
evaluated.
|
||||
|
||||
### Supported Platforms
|
||||
|
||||
- Android
|
||||
- Browser
|
||||
- iOS
|
||||
- Windows
|
||||
|
||||
### Quick Example
|
||||
|
||||
var ref = cordova.InAppBrowser.open('http://apache.org', '_blank', 'location=yes');
|
||||
ref.addEventListener('loadstop', function() {
|
||||
ref.executeScript({file: "myscript.js"});
|
||||
});
|
||||
|
||||
### Browser Quirks
|
||||
|
||||
- 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'`)
|
||||
|
||||
ref.insertCSS(details, callback);
|
||||
|
||||
- __ref__: reference to the `InAppBrowser` window _(InAppBrowser)_
|
||||
|
||||
- __injectDetails__: details of the script to run, specifying either a `file` or `code` key. _(Object)_
|
||||
- __file__: URL of the stylesheet to inject.
|
||||
- __code__: Text of the stylesheet to inject.
|
||||
|
||||
- __callback__: the function that executes after the CSS is injected.
|
||||
|
||||
### Supported Platforms
|
||||
|
||||
- Android
|
||||
- iOS
|
||||
- Windows
|
||||
|
||||
### Quick Example
|
||||
|
||||
var ref = cordova.InAppBrowser.open('http://apache.org', '_blank', 'location=yes');
|
||||
ref.addEventListener('loadstop', function() {
|
||||
ref.insertCSS({file: "mystyles.css"});
|
||||
});
|
||||
__
|
||||
|
||||
## <a id="sample"></a>Sample: Show help pages with an InAppBrowser
|
||||
|
||||
You can use this plugin to show helpful documentation pages within your app. Users can view online help documents and then close them without leaving the app.
|
||||
|
||||
Here's a few snippets that show how you do this.
|
||||
|
||||
* [Give users a way to ask for help](#give).
|
||||
* [Load a help page](#load).
|
||||
* [Let users know that you're getting their page ready](#let).
|
||||
* [Show the help page](#show).
|
||||
* [Handle page errors](#handle).
|
||||
|
||||
### <a id="give"></a>Give users a way to ask for help
|
||||
|
||||
There's lots of ways to do this in your app. A drop down list is a simple way to do that.
|
||||
|
||||
```html
|
||||
|
||||
<select id="help-select">
|
||||
<option value="default">Need help?</option>
|
||||
<option value="article">Show me a helpful article</option>
|
||||
<option value="video">Show me a helpful video</option>
|
||||
<option value="search">Search for other topics</option>
|
||||
</select>
|
||||
|
||||
```
|
||||
|
||||
Gather the users choice in the ``onDeviceReady`` function of the page and then send an appropriate URL to a helper function in some shared library file. Our helper function is named ``showHelp()`` and we'll write that function next.
|
||||
|
||||
```javascript
|
||||
|
||||
$('#help-select').on('change', function (e) {
|
||||
|
||||
var url;
|
||||
|
||||
switch (this.value) {
|
||||
|
||||
case "article":
|
||||
url = "https://cordova.apache.org/docs/en/latest/"
|
||||
+ "reference/cordova-plugin-inappbrowser/index.html";
|
||||
break;
|
||||
|
||||
case "video":
|
||||
url = "https://youtu.be/F-GlVrTaeH0";
|
||||
break;
|
||||
|
||||
case "search":
|
||||
url = "https://www.google.com/#q=inAppBrowser+plugin";
|
||||
break;
|
||||
}
|
||||
|
||||
showHelp(url);
|
||||
|
||||
});
|
||||
|
||||
```
|
||||
|
||||
### <a id="load"></a>Load a help page
|
||||
|
||||
We'll use the ``open`` function to load the help page. We're setting the ``hidden`` property to ``yes`` so that we can show the browser only after the page content has loaded. That way, users don't see a blank browser while they wait for content to appear. When the ``loadstop`` event is raised, we'll know when the content has loaded. We'll handle that event shortly.
|
||||
|
||||
```javascript
|
||||
|
||||
function showHelp(url) {
|
||||
|
||||
var target = "_blank";
|
||||
|
||||
var options = "location=yes,hidden=yes";
|
||||
|
||||
inAppBrowserRef = cordova.InAppBrowser.open(url, target, options);
|
||||
|
||||
inAppBrowserRef.addEventListener('loadstart', loadStartCallBack);
|
||||
|
||||
inAppBrowserRef.addEventListener('loadstop', loadStopCallBack);
|
||||
|
||||
inAppBrowserRef.addEventListener('loaderror', loadErrorCallBack);
|
||||
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
### <a id="let"></a>Let users know that you're getting their page ready
|
||||
|
||||
Because the browser doesn't immediately appear, we can use the ``loadstart`` event to show a status message, progress bar, or other indicator. This assures users that content is on the way.
|
||||
|
||||
```javascript
|
||||
|
||||
function loadStartCallBack() {
|
||||
|
||||
$('#status-message').text("loading please wait ...");
|
||||
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
### <a id="show"></a>Show the help page
|
||||
|
||||
When the ``loadstopcallback`` event is raised, we know that the content has loaded and we can make the browser visible. This sort of trick can create the impression of better performance. The truth is that whether you show the browser before content loads or not, the load times are exactly the same.
|
||||
|
||||
```javascript
|
||||
|
||||
function loadStopCallBack() {
|
||||
|
||||
if (inAppBrowserRef != undefined) {
|
||||
|
||||
inAppBrowserRef.insertCSS({ code: "body{font-size: 25px;" });
|
||||
|
||||
$('#status-message').text("");
|
||||
|
||||
inAppBrowserRef.show();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
```
|
||||
You might have noticed the call to the ``insertCSS`` function. This serves no particular purpose in our scenario. But it gives you an idea of why you might use it. In this case, we're just making sure that the font size of your pages have a certain size. You can use this function to insert any CSS style elements. You can even point to a CSS file in your project.
|
||||
|
||||
### <a id="handle"></a>Handle page errors
|
||||
|
||||
Sometimes a page no longer exists, a script error occurs, or a user lacks permission to view the resource. How or if you handle that situation is completely up to you and your design. You can let the browser show that message or you can present it in another way.
|
||||
|
||||
We'll try to show that error in a message box. We can do that by injecting a script that calls the ``alert`` function. That said, this won't work in browsers on Windows devices so we'll have to look at the parameter of the ``executeScript`` callback function to see if our attempt worked. If it didn't work out for us, we'll just show the error message in a ``<div>`` on the page.
|
||||
|
||||
```javascript
|
||||
|
||||
function loadErrorCallBack(params) {
|
||||
|
||||
$('#status-message').text("");
|
||||
|
||||
var scriptErrorMesssage =
|
||||
"alert('Sorry we cannot open that page. Message from the server is : "
|
||||
+ params.message + "');"
|
||||
|
||||
inAppBrowserRef.executeScript({ code: scriptErrorMesssage }, executeScriptCallBack);
|
||||
|
||||
inAppBrowserRef.close();
|
||||
|
||||
inAppBrowserRef = undefined;
|
||||
|
||||
}
|
||||
|
||||
function executeScriptCallBack(params) {
|
||||
|
||||
if (params[0] == null) {
|
||||
|
||||
$('#status-message').text(
|
||||
"Sorry we couldn't open that page. Message from the server is : '"
|
||||
+ params.message + "'");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
## More Usage Info
|
||||
|
||||
### Local Urls ( source is in the app package )
|
||||
```
|
||||
var iab = cordova.InAppBrowser;
|
||||
|
||||
iab.open('local-url.html'); // loads in the Cordova WebView
|
||||
iab.open('local-url.html', '_self'); // loads in the Cordova WebView
|
||||
iab.open('local-url.html', '_system'); // Security error: system browser, but url will not load (iOS)
|
||||
iab.open('local-url.html', '_blank'); // loads in the InAppBrowser
|
||||
iab.open('local-url.html', 'random_string'); // loads in the InAppBrowser
|
||||
iab.open('local-url.html', 'random_string', 'location=no'); // loads in the InAppBrowser, no location bar
|
||||
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Whitelisted Content
|
||||
|
||||
```
|
||||
var iab = cordova.InAppBrowser;
|
||||
|
||||
iab.open('http://whitelisted-url.com'); // loads in the Cordova WebView
|
||||
iab.open('http://whitelisted-url.com', '_self'); // loads in the Cordova WebView
|
||||
iab.open('http://whitelisted-url.com', '_system'); // loads in the system browser
|
||||
iab.open('http://whitelisted-url.com', '_blank'); // loads in the InAppBrowser
|
||||
iab.open('http://whitelisted-url.com', 'random_string'); // loads in the InAppBrowser
|
||||
|
||||
iab.open('http://whitelisted-url.com', 'random_string', 'location=no'); // loads in the InAppBrowser, no location bar
|
||||
|
||||
```
|
||||
|
||||
### Urls that are not white-listed
|
||||
|
||||
```
|
||||
var iab = cordova.InAppBrowser;
|
||||
|
||||
iab.open('http://url-that-fails-whitelist.com'); // loads in the InAppBrowser
|
||||
iab.open('http://url-that-fails-whitelist.com', '_self'); // loads in the InAppBrowser
|
||||
iab.open('http://url-that-fails-whitelist.com', '_system'); // loads in the system browser
|
||||
iab.open('http://url-that-fails-whitelist.com', '_blank'); // loads in the InAppBrowser
|
||||
iab.open('http://url-that-fails-whitelist.com', 'random_string'); // loads in the InAppBrowser
|
||||
iab.open('http://url-that-fails-whitelist.com', 'random_string', 'location=no'); // loads in the InAppBrowser, no location bar
|
||||
|
||||
```
|
||||
|
||||
711
RELEASENOTES.md
@@ -20,38 +20,699 @@
|
||||
-->
|
||||
# Release Notes
|
||||
|
||||
### 0.2.2 (Sept 25, 2013)
|
||||
* CB-4889 bumping&resetting version
|
||||
* CB-4788: Modified the onJsPrompt to warn against Cordova calls
|
||||
### 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))
|
||||
- chore: unknown changes because of linebreak change in binary files ([`e44ad91`](https://github.com/apache/cordova-plugin-inappbrowser/commit/e44ad91))
|
||||
- build: add `.npmignore` to remove unneeded files from npm package ([`0ec4a11`](https://github.com/apache/cordova-plugin-inappbrowser/commit/0ec4a11))
|
||||
- build: add `.gitattributes` to force LF (instead of possible CRLF on Windows) ([`2751255`](https://github.com/apache/cordova-plugin-inappbrowser/commit/2751255))
|
||||
- ci(travis): Update Travis CI configuration for new paramedic ([#478](https://github.com/apache/cordova-plugin-inappbrowser/issues/478)) ([`c2bb6c1`](https://github.com/apache/cordova-plugin-inappbrowser/commit/c2bb6c1))
|
||||
- docs: remove outdated translations ([`cc5ee00`](https://github.com/apache/cordova-plugin-inappbrowser/commit/cc5ee00))
|
||||
- fix(android): Fix beforeload for Android <= 7 ([#427](https://github.com/apache/cordova-plugin-inappbrowser/issues/427)) ([`94fec84`](https://github.com/apache/cordova-plugin-inappbrowser/commit/94fec84))
|
||||
- ci(travis) Fix failing CI tests ([#460](https://github.com/apache/cordova-plugin-inappbrowser/issues/460)) ([`a162bd9`](https://github.com/apache/cordova-plugin-inappbrowser/commit/a162bd9))
|
||||
- test: Fix test spec.5 to close inappbrowser after loadstop event ([#440](https://github.com/apache/cordova-plugin-inappbrowser/issues/440)) ([`5f1afbd`](https://github.com/apache/cordova-plugin-inappbrowser/commit/5f1afbd), [`af44235`](https://github.com/apache/cordova-plugin-inappbrowser/commit/af44235))
|
||||
- fix(android): Prevent malformed callbackId from reaching app cordova view ([#436](https://github.com/apache/cordova-plugin-inappbrowser/issues/436)) ([`6861084`](https://github.com/apache/cordova-plugin-inappbrowser/commit/6861084), [`c95dbcb`](https://github.com/apache/cordova-plugin-inappbrowser/commit/c95dbcb))
|
||||
- feat: [CB-13969](https://issues.apache.org/jira/browse/CB-13969): Allow close button and navigation buttons positions to be swapped ([#262](https://github.com/apache/cordova-plugin-inappbrowser/issues/262)) ([`d01bd25`](https://github.com/apache/cordova-plugin-inappbrowser/commit/d01bd25), [`f861655`](https://github.com/apache/cordova-plugin-inappbrowser/commit/f861655), [`9c7c2f3`](https://github.com/apache/cordova-plugin-inappbrowser/commit/9c7c2f3), [`3c0a42e`](https://github.com/apache/cordova-plugin-inappbrowser/commit/3c0a42e), [`5359f6c`](https://github.com/apache/cordova-plugin-inappbrowser/commit/5359f6c), [`df84dda`](https://github.com/apache/cordova-plugin-inappbrowser/commit/df84dda), [`2bcec40`](https://github.com/apache/cordova-plugin-inappbrowser/commit/2bcec40), [`fc0c560`](https://github.com/apache/cordova-plugin-inappbrowser/commit/fc0c560), [`5ead1e6`](https://github.com/apache/cordova-plugin-inappbrowser/commit/5ead1e6), [`c7931fa`](https://github.com/apache/cordova-plugin-inappbrowser/commit/c7931fa), [`e2adf1b`](https://github.com/apache/cordova-plugin-inappbrowser/commit/e2adf1b), [`4adf4c7`](https://github.com/apache/cordova-plugin-inappbrowser/commit/4adf4c7), [`cbe3a42`](https://github.com/apache/cordova-plugin-inappbrowser/commit/cbe3a42), [`74ccef1`](https://github.com/apache/cordova-plugin-inappbrowser/commit/74ccef1), [`ec6af56`](https://github.com/apache/cordova-plugin-inappbrowser/commit/ec6af56), [`b06ad8e`](https://github.com/apache/cordova-plugin-inappbrowser/commit/b06ad8e), [`313e0ae`](https://github.com/apache/cordova-plugin-inappbrowser/commit/313e0ae), [`05e37a1`](https://github.com/apache/cordova-plugin-inappbrowser/commit/05e37a1), [`0c6189e`](https://github.com/apache/cordova-plugin-inappbrowser/commit/0c6189e), [`d940b59`](https://github.com/apache/cordova-plugin-inappbrowser/commit/d940b59), [`f3d7f72`](https://github.com/apache/cordova-plugin-inappbrowser/commit/f3d7f72))
|
||||
- docs: Add headline to window.open documentation ([#406](https://github.com/apache/cordova-plugin-inappbrowser/issues/406)) ([`92243cd`](https://github.com/apache/cordova-plugin-inappbrowser/commit/92243cd))
|
||||
- fix(ios): Fix iframes in iOS/WKWebView which were broken by [#418](https://github.com/apache/cordova-plugin-inappbrowser/issues/418) ([#425](https://github.com/apache/cordova-plugin-inappbrowser/issues/425)) ([`388e3f6`](https://github.com/apache/cordova-plugin-inappbrowser/commit/388e3f6))
|
||||
- chore(github): Add or update GitHub pull request and issue template ([`ae329bc`](https://github.com/apache/cordova-plugin-inappbrowser/commit/ae329bc))
|
||||
- fix(ios): Handle non-default target attribute values (e.g. target=on links in WKWebView implementation on iOS ([#418](https://github.com/apache/cordova-plugin-inappbrowser/issues/418)) ([`9f4b729`](https://github.com/apache/cordova-plugin-inappbrowser/commit/9f4b729))
|
||||
- fix(types): remove unused replace parameter ([#410](https://github.com/apache/cordova-plugin-inappbrowser/issues/410)) ([`6db2f2d`](https://github.com/apache/cordova-plugin-inappbrowser/commit/6db2f2d))
|
||||
- documentation: Example documentation - Fix callBack function name ([#383](https://github.com/apache/cordova-plugin-inappbrowser/issues/383)) ([`a890e60`](https://github.com/apache/cordova-plugin-inappbrowser/commit/a890e60), [`2500b08`](https://github.com/apache/cordova-plugin-inappbrowser/commit/2500b08))
|
||||
- fix: Fix beforeload to work with POST requests ([#367](https://github.com/apache/cordova-plugin-inappbrowser/issues/367)) ([`632a395`](https://github.com/apache/cordova-plugin-inappbrowser/commit/632a395))
|
||||
- feat: (iOS & Android) Add postMessage API support ([#362](https://github.com/apache/cordova-plugin-inappbrowser/issues/362)) ([`c54d100`](https://github.com/apache/cordova-plugin-inappbrowser/commit/c54d100))
|
||||
- fix(ios): Fixes loadAfterBeforeload on iOS. ([#350](https://github.com/apache/cordova-plugin-inappbrowser/issues/350)) ([`0fd43ae`](https://github.com/apache/cordova-plugin-inappbrowser/commit/0fd43ae))
|
||||
- fix(ios): Fix crashes when using WKWebView implementation on iOS 9. ([#337](https://github.com/apache/cordova-plugin-inappbrowser/issues/337)) ([`3b82c16`](https://github.com/apache/cordova-plugin-inappbrowser/commit/3b82c16))
|
||||
- fix(ios): Fix iOS CDVWKInAppBrowser evaluateJavascript method randomly gets blocked on ios 12 ([#341](https://github.com/apache/cordova-plugin-inappbrowser/issues/341)) ([`978b147`](https://github.com/apache/cordova-plugin-inappbrowser/commit/978b147))
|
||||
- docs: remove unwanted information in README table ([#308](https://github.com/apache/cordova-plugin-inappbrowser/issues/308)) ([`3eadde6`](https://github.com/apache/cordova-plugin-inappbrowser/commit/3eadde6))
|
||||
- fix(ios): This lets the default window layering do it's thing. ([#336](https://github.com/apache/cordova-plugin-inappbrowser/issues/336)) ([`c24bb46`](https://github.com/apache/cordova-plugin-inappbrowser/commit/c24bb46), [`27fe8ec`](https://github.com/apache/cordova-plugin-inappbrowser/commit/27fe8ec))
|
||||
- feat(ios): [CB-7179](https://issues.apache.org/jira/browse/CB-7179) (iOS): Add optional WKWebView support for iOS ([#271](https://github.com/apache/cordova-plugin-inappbrowser/issues/271)) ([`10a0669`](https://github.com/apache/cordova-plugin-inappbrowser/commit/10a0669), [`3927b8f`](https://github.com/apache/cordova-plugin-inappbrowser/commit/3927b8f), [`8248215`](https://github.com/apache/cordova-plugin-inappbrowser/commit/8248215), [`61014dd`](https://github.com/apache/cordova-plugin-inappbrowser/commit/61014dd), [`c41f5b5`](https://github.com/apache/cordova-plugin-inappbrowser/commit/c41f5b5), [`19c6dfe`](https://github.com/apache/cordova-plugin-inappbrowser/commit/19c6dfe), [`7f5fa2a`](https://github.com/apache/cordova-plugin-inappbrowser/commit/7f5fa2a), [`5d2df21`](https://github.com/apache/cordova-plugin-inappbrowser/commit/5d2df21), [`86cc778`](https://github.com/apache/cordova-plugin-inappbrowser/commit/86cc778), [`cbfa195`](https://github.com/apache/cordova-plugin-inappbrowser/commit/cbfa195), [`52e3534`](https://github.com/apache/cordova-plugin-inappbrowser/commit/52e3534), [`8165232`](https://github.com/apache/cordova-plugin-inappbrowser/commit/8165232), [`e2210bd`](https://github.com/apache/cordova-plugin-inappbrowser/commit/e2210bd), [`dc7fa34`](https://github.com/apache/cordova-plugin-inappbrowser/commit/dc7fa34), [`b48e02f`](https://github.com/apache/cordova-plugin-inappbrowser/commit/b48e02f), [`27e6c67`](https://github.com/apache/cordova-plugin-inappbrowser/commit/27e6c67))
|
||||
- docs: remove JIRA link ([`d9cafcd`](https://github.com/apache/cordova-plugin-inappbrowser/commit/d9cafcd))
|
||||
- chore(types): [CB-12941](https://issues.apache.org/jira/browse/CB-12941): update typings ([#267](https://github.com/apache/cordova-plugin-inappbrowser/issues/267)) ([`a0c267f`](https://github.com/apache/cordova-plugin-inappbrowser/commit/a0c267f))
|
||||
- feat: [CB-14188](https://issues.apache.org/jira/browse/CB-14188): add beforeload event, catching navigation before it happens ([#276](https://github.com/apache/cordova-plugin-inappbrowser/issues/276)) ([`228703a`](https://github.com/apache/cordova-plugin-inappbrowser/commit/228703a), [`eafaeda`](https://github.com/apache/cordova-plugin-inappbrowser/commit/eafaeda))
|
||||
- ci(travis): reenable testing on all platforms ([`0ed0bf5`](https://github.com/apache/cordova-plugin-inappbrowser/commit/0ed0bf5))
|
||||
- ci(travis): also accept terms for android sdk `android-27` ([`f8ad528`](https://github.com/apache/cordova-plugin-inappbrowser/commit/f8ad528))
|
||||
- fix(android): [CB-10795](https://issues.apache.org/jira/browse/CB-10795): Exclude current app from external intent list ([#154](https://github.com/apache/cordova-plugin-inappbrowser/issues/154)) ([`a078337`](https://github.com/apache/cordova-plugin-inappbrowser/commit/a078337))
|
||||
- fix(ios): [CB-14234](https://issues.apache.org/jira/browse/CB-14234): Don't call handleOpenURL for system URLs ([#278](https://github.com/apache/cordova-plugin-inappbrowser/issues/278)) ([`cf58b04`](https://github.com/apache/cordova-plugin-inappbrowser/commit/cf58b04))
|
||||
- fix(ios): [CB-12875](https://issues.apache.org/jira/browse/CB-12875): (iOS) Pushes the inappbrowser window to a higher ui level than the existing apps window. ([#284](https://github.com/apache/cordova-plugin-inappbrowser/issues/284)) ([`dc5329d`](https://github.com/apache/cordova-plugin-inappbrowser/commit/dc5329d))
|
||||
- ci: Quick CI fixes ([#277](https://github.com/apache/cordova-plugin-inappbrowser/issues/277)) ([`de86501`](https://github.com/apache/cordova-plugin-inappbrowser/commit/de86501), [`07d9a99`](https://github.com/apache/cordova-plugin-inappbrowser/commit/07d9a99), [`81f1437`](https://github.com/apache/cordova-plugin-inappbrowser/commit/81f1437), [`a464ea6`](https://github.com/apache/cordova-plugin-inappbrowser/commit/a464ea6), [`e75fe14`](https://github.com/apache/cordova-plugin-inappbrowser/commit/e75fe14), [`eb245ec`](https://github.com/apache/cordova-plugin-inappbrowser/commit/eb245ec))
|
||||
- fix(ios): [CB-12922](https://issues.apache.org/jira/browse/CB-12922) (ios): fix In-app browser does not cede control ([#272](https://github.com/apache/cordova-plugin-inappbrowser/issues/272)) ([`dac06aa`](https://github.com/apache/cordova-plugin-inappbrowser/commit/dac06aa), [`9cc7f69`](https://github.com/apache/cordova-plugin-inappbrowser/commit/9cc7f69))
|
||||
- fix(android): [CB-14061](https://issues.apache.org/jira/browse/CB-14061): (android) comply with RFC 3986 for custom URL scheme handling ([#269](https://github.com/apache/cordova-plugin-inappbrowser/issues/269)) ([`f57ede9`](https://github.com/apache/cordova-plugin-inappbrowser/commit/f57ede9), [`26cf6e4`](https://github.com/apache/cordova-plugin-inappbrowser/commit/26cf6e4))
|
||||
- fix(android): [CB-14048](https://issues.apache.org/jira/browse/CB-14048): (android) allowedSchemes check empty string fix ([#268](https://github.com/apache/cordova-plugin-inappbrowser/issues/268)) ([`57eda78`](https://github.com/apache/cordova-plugin-inappbrowser/commit/57eda78), [`33aff11`](https://github.com/apache/cordova-plugin-inappbrowser/commit/33aff11))
|
||||
|
||||
|
||||
### 3.0.0 (Apr 12, 2018)
|
||||
* [CB-13659](https://issues.apache.org/jira/browse/CB-13659) **iOS** Add hidespinner option
|
||||
* In file `AppBrowser.java`: New code within `shouldOverrideUrlLoading()` to check for whitelisting custom schemes via a new `AllowedSchemes` preference configuration item. Allows custom schemes like `mycoolapp://` or `wevotetwitterscheme://`
|
||||
* `InAppBrowser.java`: New method `isURLWhileListed` to check for whitelisting of `AllowedSchemes` in a new preference configuration item. There is a new check in `shouldOverrideUrlLoading`, to allow whitelisted custom schemes like "mycoolapp://"
|
||||
* Add customisation of the navigation buttons for **iOS**
|
||||
* Fix navigation buttons on **iOS**
|
||||
|
||||
### 2.0.2 (Jan 24, 2018)
|
||||
* [CB-13791](https://issues.apache.org/jira/browse/CB-13791) Add **Android** support for a footer close button
|
||||
* [CB-13409](https://issues.apache.org/jira/browse/CB-13409) restore gitignore to default
|
||||
* [CB-13409](https://issues.apache.org/jira/browse/CB-13409) restore gitignore to default
|
||||
* [CB-13409](https://issues.apache.org/jira/browse/CB-13409) restore gitignore to default
|
||||
* [CB-13409](https://issues.apache.org/jira/browse/CB-13409) restore gitignore to default
|
||||
* [CB-13409](https://issues.apache.org/jira/browse/CB-13409) ignore idea folder
|
||||
* [CB-13409](https://issues.apache.org/jira/browse/CB-13409) change hidetoolbarnavigationbuttons to hidenavigationbuttons in iso
|
||||
* [CB-13409](https://issues.apache.org/jira/browse/CB-13409) **Android** works well now, all changes are now documented
|
||||
* [CB-13409](https://issues.apache.org/jira/browse/CB-13409) Lets user adjust color of toolbar, hide navigation buttons and set custom text on close button
|
||||
* [CB-13746](https://issues.apache.org/jira/browse/CB-13746) Add build-tools-26.0.2 to travis
|
||||
|
||||
### 2.0.1 (Dec 27, 2017)
|
||||
* [CB-13699](https://issues.apache.org/jira/browse/CB-13699) Fix to allow 2.0.0 version install
|
||||
|
||||
### 2.0.0 (Dec 15, 2017)
|
||||
* [CB-13662](https://issues.apache.org/jira/browse/CB-13662) remove deprecated platforms
|
||||
|
||||
### 1.7.2 (Nov 06, 2017)
|
||||
* [CB-13473](https://issues.apache.org/jira/browse/CB-13473) (CI) Removed **Browser** builds from AppVeyor
|
||||
* [CB-13472](https://issues.apache.org/jira/browse/CB-13472) (CI) Fixed Travis **Android** builds again
|
||||
* [CB-13347](https://issues.apache.org/jira/browse/CB-13347) Enable thirdparty cookies on `>=Android 5.0` device
|
||||
* [CB-12895](https://issues.apache.org/jira/browse/CB-12895) added `eslint` and removed `jshint`
|
||||
* [CB-12975](https://issues.apache.org/jira/browse/CB-12975) (docs) Resort and reword `cordova.InAppBrowser.open` `options` lists
|
||||
* [CB-12586](https://issues.apache.org/jira/browse/CB-12586) (iOS) fix method `hide` doesn't work
|
||||
* [CB-12847](https://issues.apache.org/jira/browse/CB-12847) added `bugs` entry to `package.json`.
|
||||
|
||||
### 1.7.1 (Apr 27, 2017)
|
||||
* [CB-12622](https://issues.apache.org/jira/browse/CB-12622) Added **Android 6.0** build badges to `README`
|
||||
* [CB-12266](https://issues.apache.org/jira/browse/CB-12266) (browser platform) loadstop event.url is now a string instead of an object, aligning it with the other platforms.
|
||||
* [CB-12685](https://issues.apache.org/jira/browse/CB-12685) added `package.json` to tests folder
|
||||
* [CB-11248](https://issues.apache.org/jira/browse/CB-11248) `InAppBrowser` no focus on input text fields
|
||||
|
||||
### 1.7.0 (Feb 28, 2017)
|
||||
* [CB-12366](https://issues.apache.org/jira/browse/CB-12366) **iOS:** Reduce `tmpWindow` level to prevent overlapping statusbar
|
||||
* [CB-12364](https://issues.apache.org/jira/browse/CB-12364) **Windows:** `Inappbrowser` inject file manual tests are not working
|
||||
* [CB-12353](https://issues.apache.org/jira/browse/CB-12353) Corrected merges usage in `plugin.xml`
|
||||
* [CB-12369](https://issues.apache.org/jira/browse/CB-12369) Add plugin typings from `DefinitelyTyped`
|
||||
* [CB-12363](https://issues.apache.org/jira/browse/CB-12363) Added build badges for **iOS 9.3** and **iOS 10.0**
|
||||
* [CB-9148](https://issues.apache.org/jira/browse/CB-9148) **Android:** Add Support for `input[type=file]` File Chooser
|
||||
* [CB-11136](https://issues.apache.org/jira/browse/CB-11136) (ios) Fix `InAppBrowser` when closing with `WKWebView`
|
||||
* [CB-10799](https://issues.apache.org/jira/browse/CB-10799) **iOS:** fix toolbar is shown in incorrect position when in-call status bar
|
||||
|
||||
### 1.6.1 (Dec 14, 2016)
|
||||
* [CB-12237](https://issues.apache.org/jira/browse/CB-12237) - Update version in package.json to correct 1.6.1-dev
|
||||
* [CB-12236](https://issues.apache.org/jira/browse/CB-12236) - Fixed RELEASENOTES for cordova-plugin-inappbrowser
|
||||
* [CB-12230](https://issues.apache.org/jira/browse/CB-12230) Removed Windows 8.1 build badges
|
||||
* [CB-12224](https://issues.apache.org/jira/browse/CB-12224) Incremented plugin version.
|
||||
|
||||
### 1.6.0 (Dec 07, 2016)
|
||||
* [CB-12224](https://issues.apache.org/jira/browse/CB-12224) Updated version and RELEASENOTES.md for release 1.6.0
|
||||
* [CB-7608](https://issues.apache.org/jira/browse/CB-7608) (android) document useWidthViewPort
|
||||
* add option useWidthViewPort
|
||||
* [CB-12184](https://issues.apache.org/jira/browse/CB-12184) executeScript leads to a null pointer on exception on Android.
|
||||
* fix(close button): Set correct content description
|
||||
* [CB-9274](https://issues.apache.org/jira/browse/CB-9274) Adds missing methods to InAppBrowser to allow compilation for Amazon FireOS.
|
||||
* [CB-10973](https://issues.apache.org/jira/browse/CB-10973) inAppBrowser for Windows Platform: wrong height of webview with location=yes
|
||||
* Increment plugin minor version because of new hide feature
|
||||
* removed duplicate hide method in ios source and add jasmine test cases
|
||||
* [CB-8467](https://issues.apache.org/jira/browse/CB-8467)
|
||||
* [CB-12010](https://issues.apache.org/jira/browse/CB-12010) (android) Catch FileUriExposedException
|
||||
* [CB-11955](https://issues.apache.org/jira/browse/CB-11955) Added Initial OSX platform support
|
||||
* [CB-11917](https://issues.apache.org/jira/browse/CB-11917) - Remove pull request template checklist item: "iCLA has been signed and submitted to secretary@apache.org."
|
||||
* [CB-11694](https://issues.apache.org/jira/browse/CB-11694) Android: Set hadwareBackButton value according option in cordova.InAppBrowser.open
|
||||
* [CB-11832](https://issues.apache.org/jira/browse/CB-11832) Incremented plugin version.
|
||||
|
||||
### 1.5.1 (Dec 07, 2016)
|
||||
* [CB-7608](https://issues.apache.org/jira/browse/CB-7608) (android) document useWidthViewPort
|
||||
* add option useWidthViewPort
|
||||
* [CB-12184](https://issues.apache.org/jira/browse/CB-12184) executeScript leads to a null pointer on exception on Android.
|
||||
* fix(close button): Set correct content description
|
||||
* [CB-9274](https://issues.apache.org/jira/browse/CB-9274) Adds missing methods to InAppBrowser to allow compilation for Amazon FireOS.
|
||||
* [CB-10973](https://issues.apache.org/jira/browse/CB-10973) inAppBrowser for Windows Platform: wrong height of webview with location=yes
|
||||
* Increment plugin minor version because of new hide feature
|
||||
* removed duplicate hide method in ios source and add jasmine test cases
|
||||
* [CB-8467](https://issues.apache.org/jira/browse/CB-8467)
|
||||
* [CB-12010](https://issues.apache.org/jira/browse/CB-12010) (android) Catch FileUriExposedException
|
||||
* [CB-11955](https://issues.apache.org/jira/browse/CB-11955) Added Initial OSX platform support
|
||||
* [CB-11917](https://issues.apache.org/jira/browse/CB-11917) - Remove pull request template checklist item: "iCLA has been signed and submitted to secretary@apache.org."
|
||||
* [CB-11694](https://issues.apache.org/jira/browse/CB-11694) Android: Set hadwareBackButton value according option in cordova.InAppBrowser.open
|
||||
* [CB-11832](https://issues.apache.org/jira/browse/CB-11832) Incremented plugin version.
|
||||
* [CB-11832](https://issues.apache.org/jira/browse/CB-11832) Updated version and RELEASENOTES.md for release 1.5.0
|
||||
* [CB-11795](https://issues.apache.org/jira/browse/CB-11795) Add 'protective' entry to cordovaDependencies
|
||||
* Closing invalid pull request: close #28
|
||||
* Closing invalid pull request: close #78
|
||||
* Add intent scheme to be handled by OS
|
||||
* Plugin uses Android Log class and not Cordova LOG class
|
||||
* Adding links to guide content and reference content at the top of the readme file Github: close #163
|
||||
* [CB-10973](https://issues.apache.org/jira/browse/CB-10973) inAppBrowser for Browser Platform: wrong height of webview with location=yes
|
||||
* Size and position in browser platform
|
||||
* [CB-10973](https://issues.apache.org/jira/browse/CB-10973) inAppBrowser for Windows Platform: wrong height of webview with location=yes
|
||||
* [CB-11013](https://issues.apache.org/jira/browse/CB-11013) IAB enabling background play of YouTube videos?
|
||||
* [CB-10467](https://issues.apache.org/jira/browse/CB-10467) Hardware back button, while InAppBrowser is opened, closes the app too in addition to closing InAppBrowser
|
||||
* [CB-11178](https://issues.apache.org/jira/browse/CB-11178) allow to open other apps on iOS 9
|
||||
* Closing stale pull request: close #152
|
||||
* fix some calls which used api level 16
|
||||
* [CB-5402](https://issues.apache.org/jira/browse/CB-5402) added extra content from wiki page
|
||||
* doc: do not use `with` in JS samples
|
||||
* Closing stale pull request: close #90
|
||||
* [CB-2063](https://issues.apache.org/jira/browse/CB-2063) (ios) Fixed presentation style
|
||||
* [CB-11012](https://issues.apache.org/jira/browse/CB-11012) added some clarifications about InAppBrowser object
|
||||
* [CB-3360](https://issues.apache.org/jira/browse/CB-3360) Set custom inappbrowser user agent for ios
|
||||
* Add badges for paramedic builds on Jenkins
|
||||
* [CB-11381](https://issues.apache.org/jira/browse/CB-11381) android: Does not pass sonarqube scan
|
||||
* Add pull request template.
|
||||
* [CB-10866](https://issues.apache.org/jira/browse/CB-10866) Adding engine requirements to package.json
|
||||
* [CB-110003](https://issues.apache.org/jira/browse/CB-110003) Adding samples to Readme.
|
||||
* [CB-10996](https://issues.apache.org/jira/browse/CB-10996) Adding front matter to README.md
|
||||
* [CB-11091](https://issues.apache.org/jira/browse/CB-11091) Incremented plugin version.
|
||||
* Updated version and RELEASENOTES.md for release 1.4.0
|
||||
* [CB-7679](https://issues.apache.org/jira/browse/CB-7679) add fix for iOS upload. This closes #139
|
||||
* [CB-10944](https://issues.apache.org/jira/browse/CB-10944) : NoSuchMethodError in InAppBrowser plugin
|
||||
* [CB-10937](https://issues.apache.org/jira/browse/CB-10937) fix stretched icons
|
||||
* [CB-10760](https://issues.apache.org/jira/browse/CB-10760) Fixing README for display on Cordova website
|
||||
* [CB-10636](https://issues.apache.org/jira/browse/CB-10636) Add JSHint for plugins
|
||||
* Fixes [CB-10607](https://issues.apache.org/jira/browse/CB-10607)
|
||||
* [CB-10557](https://issues.apache.org/jira/browse/CB-10557) Incremented plugin version.
|
||||
* [CB-10557](https://issues.apache.org/jira/browse/CB-10557) Updated version and RELEASENOTES.md for release 1.3.0
|
||||
* [CB-3360](https://issues.apache.org/jira/browse/CB-3360) Set custom inappbrowser user agent for android
|
||||
* [CB-10538](https://issues.apache.org/jira/browse/CB-10538) cordova-plugin-inappbrowser timeout issue
|
||||
* [CB-10395](https://issues.apache.org/jira/browse/CB-10395) InAppBrowser's WebView not storing cookies reliable on Android
|
||||
* chore: edit package.json license to match SPDX id
|
||||
* [CB-10305](https://issues.apache.org/jira/browse/CB-10305) Gray bar appears in the wrong place on iOS
|
||||
* [CB-7786](https://issues.apache.org/jira/browse/CB-7786) Support mediaPlaybackRequiresUserAction on Android
|
||||
* [CB-7500](https://issues.apache.org/jira/browse/CB-7500) executeScript with callback kills/blurs inAppBrowser window on Android
|
||||
* [CB-10505](https://issues.apache.org/jira/browse/CB-10505) Incremented plugin version.
|
||||
* [CB-10505](https://issues.apache.org/jira/browse/CB-10505) Updated version and RELEASENOTES.md for release 1.2.1
|
||||
* handle app store urls in system browser
|
||||
* Added missing plugin dependency for manual tests
|
||||
* [CB-10451](https://issues.apache.org/jira/browse/CB-10451) InAppBrowser: loadstart event is not triggered on Windows [CB-10452](https://issues.apache.org/jira/browse/CB-10452) InAppBrowser: 'exit' event is not triggered on Windows [CB-10454](https://issues.apache.org/jira/browse/CB-10454) InAppBrowser: 'loaderror' event does not have code and message on Windows [CB-10450](https://issues.apache.org/jira/browse/CB-10450) InAppBrowser: Unable to get property 'canGoBack' of undefined on Windows
|
||||
* [CB-6702](https://issues.apache.org/jira/browse/CB-6702) InAppBrowser hangs when opening more than one instance
|
||||
* [CB-10456](https://issues.apache.org/jira/browse/CB-10456) InAppBrowser is not closed if I close it programmatically on Android
|
||||
* [CB-10441](https://issues.apache.org/jira/browse/CB-10441) Add auto tests for InAppBrowser plugin
|
||||
* [CB-10428](https://issues.apache.org/jira/browse/CB-10428) Fix syntax error when browserifying inAppBrowser plugin
|
||||
* [CB-10407](https://issues.apache.org/jira/browse/CB-10407) Re-adding onPageStarted to re-add LOAD_START, even though it's in the wrong place
|
||||
* [CB-10368](https://issues.apache.org/jira/browse/CB-10368) Incremented plugin version.
|
||||
* [CB-10368](https://issues.apache.org/jira/browse/CB-10368) Updated version and RELEASENOTES.md for release 1.2.0
|
||||
* [CB-8180](https://issues.apache.org/jira/browse/CB-8180) Changing methods of interception in WebViewClient class
|
||||
* Fix lint warnings
|
||||
* [CB-10009](https://issues.apache.org/jira/browse/CB-10009) Improve InAppBrowser toolbar look and feel on Windows
|
||||
* Using modulemapper
|
||||
* Open a new window on the browser platform
|
||||
* [CB-10187](https://issues.apache.org/jira/browse/CB-10187) Incremented plugin version.
|
||||
* [CB-10187](https://issues.apache.org/jira/browse/CB-10187) Updated version and RELEASENOTES.md for release 1.1.1
|
||||
* [CB-9445](https://issues.apache.org/jira/browse/CB-9445) Improves executeScript callbacks on iOS
|
||||
* [CB-10035](https://issues.apache.org/jira/browse/CB-10035) Incremented plugin version.
|
||||
* [CB-10040](https://issues.apache.org/jira/browse/CB-10040) - re-fix: backwards compatible with cordova-ios < 4.0
|
||||
* [CB-8534](https://issues.apache.org/jira/browse/CB-8534) Allow plugins to respond to onReceivedHttpAuthRequest. This closes #82
|
||||
* [CB-3750](https://issues.apache.org/jira/browse/CB-3750) Fixes spinner on iOS. This closes #89
|
||||
* [CB-7696](https://issues.apache.org/jira/browse/CB-7696) Document target=_self behavior for Windows
|
||||
* [CB-10040](https://issues.apache.org/jira/browse/CB-10040) - Compile Error in InAppBrowser Plugin for iOS - No known instance method for selector 'URLIsWhitelisted:'
|
||||
* [CB-10035](https://issues.apache.org/jira/browse/CB-10035) linked issues in RELEASENOTES.md
|
||||
* [CB-10035](https://issues.apache.org/jira/browse/CB-10035) Updated version and RELEASENOTES.md for release 1.1.0
|
||||
* removed r prefix from tags
|
||||
* weak ref type was wrong
|
||||
* [CB-10035](https://issues.apache.org/jira/browse/CB-10035) Updated RELEASENOTES to be newest to oldest
|
||||
* Close #91
|
||||
* Close #85
|
||||
* Invoke webview if using local file
|
||||
* Fixed zIndex issue on Windows 8, 8.1 where InAppBrowser opens behind default app.
|
||||
* fix async self usage
|
||||
* [CB-9150](https://issues.apache.org/jira/browse/CB-9150) Fix InAppBrowser executeScript crash on Windows if no data returned
|
||||
* [CB-10008](https://issues.apache.org/jira/browse/CB-10008) Fix InAppBrowser popup layout on Windows
|
||||
* InAppBrowser, iOS: Setting setStatusBarStyle to -1 causes CGContextSaveGState.
|
||||
* Fix crash on browser window close (https://issues.apache.org/jira/browse/CB-9167)
|
||||
* Close #113
|
||||
* add JIRA issue tracker link
|
||||
* [CB-9799](https://issues.apache.org/jira/browse/CB-9799) Fixed javaDoc errors.. This closes #119
|
||||
* Actually fixing the contribute link.
|
||||
* Fixing contribute link.
|
||||
* [CB-9760](https://issues.apache.org/jira/browse/CB-9760) InAppBrowser: fallback to default window.open behavior on Ripple
|
||||
* Close #114
|
||||
* [CB-9378](https://issues.apache.org/jira/browse/CB-9378) Fix InAppBrowser not taking whole screen on Windows
|
||||
* remove travis-ci
|
||||
* [CB-9158](https://issues.apache.org/jira/browse/CB-9158) - InAppBrowser zoomControls are always set to true
|
||||
* [CB-9192](https://issues.apache.org/jira/browse/CB-9192) Incremented plugin version.
|
||||
* [CB-9202](https://issues.apache.org/jira/browse/CB-9202) updated repo url to github mirror in package.json
|
||||
* [CB-9192](https://issues.apache.org/jira/browse/CB-9192) Updated version and RELEASENOTES.md for release 1.0.1
|
||||
* [CB-9128](https://issues.apache.org/jira/browse/CB-9128) cordova-plugin-inappbrowser documentation translation: cordova-plugin-inappbrowser
|
||||
* fix npm md issue
|
||||
* [CB-8858](https://issues.apache.org/jira/browse/CB-8858) Incremented plugin version.
|
||||
* [CB-8858](https://issues.apache.org/jira/browse/CB-8858) Updated version in package.json for release 1.0.0
|
||||
* Revert "CB-8858 Incremented plugin version."
|
||||
* [CB-8858](https://issues.apache.org/jira/browse/CB-8858) Incremented plugin version.
|
||||
* [CB-8858](https://issues.apache.org/jira/browse/CB-8858) Updated version and RELEASENOTES.md for release 1.0.0
|
||||
* [CB-8746](https://issues.apache.org/jira/browse/CB-8746) gave plugin major version bump
|
||||
* [CB-7689](https://issues.apache.org/jira/browse/CB-7689) Adds insertCSS support for windows platform
|
||||
* [CB-4930](https://issues.apache.org/jira/browse/CB-4930) - (prefix) InAppBrowser should take into account the status bar
|
||||
* [CB-8635](https://issues.apache.org/jira/browse/CB-8635) Improves UX on windows platform
|
||||
* [CB-8661](https://issues.apache.org/jira/browse/CB-8661) Return executed script result on Windows
|
||||
* [CB-8683](https://issues.apache.org/jira/browse/CB-8683) updated wp and browser specific references of old id to new id
|
||||
* [CB-8683](https://issues.apache.org/jira/browse/CB-8683) changed plugin-id to pacakge-name
|
||||
* [CB-8653](https://issues.apache.org/jira/browse/CB-8653) properly updated translated docs to use new id
|
||||
* [CB-8653](https://issues.apache.org/jira/browse/CB-8653) updated translated docs to use new id
|
||||
* Use TRAVIS_BUILD_DIR, install paramedic by npm
|
||||
* [CB-8432](https://issues.apache.org/jira/browse/CB-8432) Correct styles for browser wrapper to display it correctly on some pages
|
||||
* [CB-8659](https://issues.apache.org/jira/browse/CB-8659) - Update InAppBrowser to support both cordova-ios 4.0.x and 3.x (closes #93)
|
||||
* [CB-7961](https://issues.apache.org/jira/browse/CB-7961) Add cordova-plugin-inappbrowser support for browser platform
|
||||
* [CB-8653](https://issues.apache.org/jira/browse/CB-8653) Updated Readme
|
||||
* Update docs for Android zoom=no option
|
||||
* Added option to disable/enable zoom controls
|
||||
* updated docs, set hardwareback default to true
|
||||
* Add a hardwareback option to allow for the hardware back button to go back.
|
||||
* [CB-8570](https://issues.apache.org/jira/browse/CB-8570) Integrate TravisCI
|
||||
* [CB-8438](https://issues.apache.org/jira/browse/CB-8438) cordova-plugin-inappbrowser documentation translation: cordova-plugin-inappbrowser
|
||||
* [CB-8538](https://issues.apache.org/jira/browse/CB-8538) Added package.json file
|
||||
* Keep external android pages in a single tab. (close #61)
|
||||
* [CB-8444](https://issues.apache.org/jira/browse/CB-8444) Add a clobber for `cordova.InAppBrowser.open` (close #80)
|
||||
* [CB-8444](https://issues.apache.org/jira/browse/CB-8444) Don't clobber `window.open` - Add new symbol/clobber to access open function (`cordova.InAppBrowser.open`) - Change existing tests to use new symbol (i.e. don't rely on plugin clobber of `window.open`) - Add tests to use `window.open` via manual replace with new symbol - Update docs to deprecate plugin clobber of `window.open`
|
||||
* [CB-8429](https://issues.apache.org/jira/browse/CB-8429) Incremented plugin version.
|
||||
* [CB-8429](https://issues.apache.org/jira/browse/CB-8429) Updated version and RELEASENOTES.md for release 0.6.0
|
||||
* Add missing license header for src/ubuntu/InAppBrowser_escapeScript.js
|
||||
* [CB-8270](https://issues.apache.org/jira/browse/CB-8270) Remove usage of `[arr JSONString]`, since it's been renamed to `cdv_JSONString`
|
||||
* ubuntu: implement inject* functions
|
||||
* ubuntu: port to oxide
|
||||
* [CB-7897](https://issues.apache.org/jira/browse/CB-7897) Update to work with whilelist plugins in Cordova 4.x
|
||||
* [CB-7897](https://issues.apache.org/jira/browse/CB-7897) Update to work with whilelist plugins in Cordova 4.x
|
||||
* [CB-8110](https://issues.apache.org/jira/browse/CB-8110) Incremented plugin version.
|
||||
* [CB-8110](https://issues.apache.org/jira/browse/CB-8110) Updated version and RELEASENOTES.md for release 0.5.4
|
||||
* Amazon specific changes: Removed reference to closebuttoncaption according to https://git-wip-us.apache.org/repos/asf?p=cordova-plugin-inappbrowser.git;a=commit;h=50a78baf22843b0df96ccb4ca83a45bd9ef3fc39
|
||||
* [CB-7784](https://issues.apache.org/jira/browse/CB-7784) Exit event is not fired after InAppBrowser closing
|
||||
* [CB-7697](https://issues.apache.org/jira/browse/CB-7697) Add locationBar support to InAppBrowser windows platform version
|
||||
* [CB-7690](https://issues.apache.org/jira/browse/CB-7690) InAppBrowser loadstart/loadstop events issues
|
||||
* [CB-7695](https://issues.apache.org/jira/browse/CB-7695) Fix InAppBrowser injectScriptFile for Windows 8.1 / Windows Phone 8.1
|
||||
* [CB-7692](https://issues.apache.org/jira/browse/CB-7692) InAppBrowser local url opening bug in 8.1
|
||||
* [CB-7688](https://issues.apache.org/jira/browse/CB-7688) Alert is not supported in InAppBrowser on Windows platform
|
||||
* [CB-7977](https://issues.apache.org/jira/browse/CB-7977) Mention deviceready in plugin docs
|
||||
* Dropping trailing whitespace
|
||||
* [CB-7876](https://issues.apache.org/jira/browse/CB-7876) change test target to avoid undesired redirects
|
||||
* [CB-7712](https://issues.apache.org/jira/browse/CB-7712) remove references to closebuttoncaption
|
||||
* [CB-7850](https://issues.apache.org/jira/browse/CB-7850) clarify role of whitelist
|
||||
* [CB-7720](https://issues.apache.org/jira/browse/CB-7720) check if event is null since OK string from success callback was removed
|
||||
* [CB-7700](https://issues.apache.org/jira/browse/CB-7700) cordova-plugin-inappbrowser documentation translation: cordova-plugin-inappbrowser
|
||||
* [CB-7471](https://issues.apache.org/jira/browse/CB-7471) cordova-plugin-inappbrowser documentation translation: cordova-plugin-inappbrowser
|
||||
* Incremented plugin version.
|
||||
* Updated version and RELEASENOTES.md for release 0.5.3
|
||||
* Amazon Specific changes: Added logs and corrected indentation according to 81161ebe668a14f87e1ef4b57f2d300a609b9a8b
|
||||
* Windows implementation fixes and improvements
|
||||
* zIndex fixed
|
||||
* renamed InAppBrowser back to inappbrowser for case sensitive operating systems
|
||||
* Clean plugin.xml
|
||||
* Update french translation
|
||||
* Update doc to add Windows 8
|
||||
* Update windows proxy to be both compatible with windows 8 and 8.1
|
||||
* Rename windows81 by windows8 in src directory
|
||||
* Append Windows 8.1 platform configuration in plugin.xml
|
||||
* Append Windows 8.1 proxy using x-ms-webview
|
||||
* [CB-7571](https://issues.apache.org/jira/browse/CB-7571) Bump version of nested plugin to match parent plugin
|
||||
* [CB-7571](https://issues.apache.org/jira/browse/CB-7571) Incremented plugin version.
|
||||
* [CB-7571](https://issues.apache.org/jira/browse/CB-7571) Updated version and RELEASENOTES.md for release 0.5.2
|
||||
* [CB-7471](https://issues.apache.org/jira/browse/CB-7471) cordova-plugin-inappbrowser documentation translation: cordova-plugin-inappbrowser
|
||||
* [CB-7490](https://issues.apache.org/jira/browse/CB-7490) Fixes InAppBrowser manual tests crash on windows platform
|
||||
* [CB-7249](https://issues.apache.org/jira/browse/CB-7249) cordova-plugin-inappbrowser documentation translation: cordova-plugin-inappbrowser
|
||||
* [CB-7424](https://issues.apache.org/jira/browse/CB-7424) - Wrong docs: anchor tags are not supported by the InAppBrowser
|
||||
* [CB-7133](https://issues.apache.org/jira/browse/CB-7133) clarify that anchor1 doesn't exist
|
||||
* [CB-7133](https://issues.apache.org/jira/browse/CB-7133) more fixup of tests on Android
|
||||
* [CB-7133](https://issues.apache.org/jira/browse/CB-7133) fix up the tests for Android
|
||||
* Add just a bit more logging
|
||||
* [CB-7133](https://issues.apache.org/jira/browse/CB-7133) port inappbrowser to plugin-test-framework
|
||||
* phonegap events supported for _blank target
|
||||
* inappbrowser _blank target position is fixed
|
||||
* amazon-fireos related changes.
|
||||
* [CB-7244](https://issues.apache.org/jira/browse/CB-7244) Incremented plugin version.
|
||||
* [CB-7244](https://issues.apache.org/jira/browse/CB-7244) Updated version and RELEASENOTES.md for release 0.5.1
|
||||
* ubuntu: support qt 5.2
|
||||
* CB-7249cordova-plugin-inappbrowser documentation translation: cordova-plugin-inappbrowser
|
||||
* update InAppBrowserProxy.js
|
||||
* app needs to be privileged
|
||||
* CB-6127lisa7cordova-plugin-consolecordova-plugin-inappbrowser documentation translation: cordova-plugin-inappbrowser
|
||||
* [CB-6769](https://issues.apache.org/jira/browse/CB-6769) ios: Fix statusbar color reset wasn't working on iOS7+
|
||||
* [CB-6877](https://issues.apache.org/jira/browse/CB-6877) Incremented plugin version.
|
||||
* [CB-6877](https://issues.apache.org/jira/browse/CB-6877) Updated version and RELEASENOTES.md for release 0.5.0
|
||||
* [CB-6127](https://issues.apache.org/jira/browse/CB-6127) Spanish and rench Translations added. Github close #23
|
||||
* Clean up whitespace (mainly due to no newline at eof warning)
|
||||
* after code review
|
||||
* default parameter added
|
||||
* doc updated
|
||||
* console.log removed
|
||||
* back/forward buttons added, iframe has no border
|
||||
* not forcing the look of the inAppBrowserWrap and buttons
|
||||
* Adding permission info
|
||||
* [CB-6806](https://issues.apache.org/jira/browse/CB-6806) Add license
|
||||
* documentation translation: cordova-plugin-inappbrowser
|
||||
* Lisa testing pulling in plugins for plugin: cordova-plugin-inappbrowser
|
||||
* Lisa testing pulling in plugins for plugin: cordova-plugin-inappbrowser
|
||||
* [CB-6491](https://issues.apache.org/jira/browse/CB-6491) add CONTRIBUTING.md
|
||||
* Add necessary capability so the plugin works on its own
|
||||
* [CB-6474](https://issues.apache.org/jira/browse/CB-6474) InAppBrowser. Add data urls support to WP8
|
||||
* [CB-6482](https://issues.apache.org/jira/browse/CB-6482) InAppBrowser calls incorrect callback on WP8
|
||||
* Fixed use of iOS 6 deprecated methods
|
||||
* [CB-6360](https://issues.apache.org/jira/browse/CB-6360) - improvement: feature detection instead of iOS version detection
|
||||
* [CB-5649](https://issues.apache.org/jira/browse/CB-5649) - InAppBrowser overrides App's orientation
|
||||
* [CB-6452](https://issues.apache.org/jira/browse/CB-6452) Incremented plugin version on dev branch.
|
||||
* [CB-6452](https://issues.apache.org/jira/browse/CB-6452) Updated version and RELEASENOTES.md for release 0.4.0
|
||||
* [CB-6460](https://issues.apache.org/jira/browse/CB-6460) Update license headers
|
||||
* [CB-6360](https://issues.apache.org/jira/browse/CB-6360) Fix for crash on iOS < 6.0 (closes #37)
|
||||
* [CB-3324](https://issues.apache.org/jira/browse/CB-3324) Add support for back-button inappbrowser [WP8] if there is no history -> InAppBrowser is closed
|
||||
* await async calls, resolve warnings
|
||||
* Make InAppBrowser work with embedded files, using system behavior
|
||||
* [CB-6402](https://issues.apache.org/jira/browse/CB-6402) [WP8] pass empty string instead of null for [optional] windowFeatures string
|
||||
* [CB-6422](https://issues.apache.org/jira/browse/CB-6422) [windows8] use cordova/exec/proxy
|
||||
* [CB-3617](https://issues.apache.org/jira/browse/CB-3617) Document clearcache and clearsessioncache for ios
|
||||
* [CB-6389](https://issues.apache.org/jira/browse/CB-6389) [CB-3617](https://issues.apache.org/jira/browse/CB-3617) Add clearcache and clearsessioncache options to iOS (like Android)
|
||||
* refactoring fixed
|
||||
* [CB-6396](https://issues.apache.org/jira/browse/CB-6396) [Firefox OS] Adding basic support
|
||||
* Doc update: event name and example param (closes #31)
|
||||
* [CB-6253](https://issues.apache.org/jira/browse/CB-6253) Add Network Capability to WMAppManifest.xml
|
||||
* [CB-6212](https://issues.apache.org/jira/browse/CB-6212) iOS: fix warnings compiled under arm64 64-bit
|
||||
* [CB-6218](https://issues.apache.org/jira/browse/CB-6218) Update docs for BB10
|
||||
* Tweak RELEASENOTES.md (missed a bug fix in last release)
|
||||
* Incremented plugin version on dev branch.
|
||||
* [CB-6218](https://issues.apache.org/jira/browse/CB-6218) Update docs for BB10
|
||||
* Updated version and RELEASENOTES.md for release 0.3.3
|
||||
* [CB-6172](https://issues.apache.org/jira/browse/CB-6172) Fix inappbrowser install failure on case-sensitive filesystems.
|
||||
* [CB-5534](https://issues.apache.org/jira/browse/CB-5534) Updating the plugin.xml with the new Dialog class
|
||||
* fix for [CB-5534](https://issues.apache.org/jira/browse/CB-5534)
|
||||
* Add NOTICE file
|
||||
* [CB-6114](https://issues.apache.org/jira/browse/CB-6114) Incremented plugin version on dev branch.
|
||||
* Add NOTICE file
|
||||
* [CB-6114](https://issues.apache.org/jira/browse/CB-6114) Updated version and RELEASENOTES.md for release 0.3.2
|
||||
* Validate that callbackId is correctly formed
|
||||
* [CB-6035](https://issues.apache.org/jira/browse/CB-6035) - Move js-module so it is not loaded on unsupported platforms
|
||||
* [CB-5980](https://issues.apache.org/jira/browse/CB-5980) Incremented plugin version on dev branch.
|
||||
* [CB-5980](https://issues.apache.org/jira/browse/CB-5980) Updated version and RELEASENOTES.md for release 0.3.1
|
||||
* Removed some iOS6 Deprecations
|
||||
* Lisa testing pulling in plugins for plugin: cordova-plugin-inappbrowser
|
||||
* Lisa testing pulling in plugins for plugin: cordova-plugin-inappbrowser
|
||||
* [CB-5980](https://issues.apache.org/jira/browse/CB-5980) Updated version and RELEASENOTES.md for release 0.3.1
|
||||
* Add missing import for previous commit
|
||||
* [CB-5756](https://issues.apache.org/jira/browse/CB-5756) Android: Use WebView.evaluateJavascript for script injection on Android 4.4+
|
||||
* Didn't test on ICS or lower, getDrawable isn't supported until Jellybean
|
||||
* WTF? ubuntu got automerged twice
|
||||
* add ubuntu platform
|
||||
* Adding CC-A-2.5 Notice for Assets, modifying plugins to use resources
|
||||
* Adding the buttons
|
||||
* Adding drawables to the inAppBrowser. This doesn't look quite right, but it's a HUGE improvement over the previous settings
|
||||
* [CB-5756](https://issues.apache.org/jira/browse/CB-5756) Add missing import
|
||||
* [CB-5756](https://issues.apache.org/jira/browse/CB-5756) Android: Use WebView.evaluateJavascript for script injection on Android 4.4+
|
||||
* Delete stale test/ directory
|
||||
* Remove _alive from InAppBrowser.js since it didn't catch the case where the browser is closed by the user.
|
||||
* [CB-5733](https://issues.apache.org/jira/browse/CB-5733) Fix IAB.close() not working if called before show() animation is done
|
||||
* [CB-5719](https://issues.apache.org/jira/browse/CB-5719) Incremented plugin version on dev branch.
|
||||
* [CB-5719](https://issues.apache.org/jira/browse/CB-5719) Updated version and RELEASENOTES.md for release 0.3.0
|
||||
* [CB-5592](https://issues.apache.org/jira/browse/CB-5592) Add a comment explaining why we set MIME only for file:
|
||||
* [CB-5592](https://issues.apache.org/jira/browse/CB-5592) Android - Add MIME type to Intent when opening file:/// URLs
|
||||
* [CB-5658](https://issues.apache.org/jira/browse/CB-5658) Update license comment formatting of doc/index.md
|
||||
* [CB-5658](https://issues.apache.org/jira/browse/CB-5658) Add doc.index.md for InAppBrowser plugin
|
||||
* [CB-5658](https://issues.apache.org/jira/browse/CB-5658) Delete stale snapshot of plugin docs
|
||||
* [CB-5594](https://issues.apache.org/jira/browse/CB-5594) Add disallowoverscroll option.
|
||||
* [CB-5595](https://issues.apache.org/jira/browse/CB-5595) Rename "toolbarbarpostion" -> "toolbarposition"
|
||||
* [CB-5595](https://issues.apache.org/jira/browse/CB-5595) Fixed the positioning and autoresizing for certain rotation scenarios.
|
||||
* [CB-5595](https://issues.apache.org/jira/browse/CB-5595) Add toolbarposition=top option.
|
||||
* Apply [CB-5193](https://issues.apache.org/jira/browse/CB-5193) to InAppBrowser
|
||||
* [CB-5593](https://issues.apache.org/jira/browse/CB-5593) iOS: Make InAppBrowser localizable
|
||||
* [CB-5591](https://issues.apache.org/jira/browse/CB-5591) Change window.escape to encodeURIComponent
|
||||
* [CB-5565](https://issues.apache.org/jira/browse/CB-5565) Incremented plugin version on dev branch.
|
||||
* [CB-5565](https://issues.apache.org/jira/browse/CB-5565) Updated version and RELEASENOTES.md for release 0.2.5
|
||||
* Remove merge conflict tag
|
||||
* [CB-4724](https://issues.apache.org/jira/browse/CB-4724) fixed UriFormatException
|
||||
* add ubuntu platform
|
||||
* [CB-3420](https://issues.apache.org/jira/browse/CB-3420) WP feature hidden=yes implemented
|
||||
* Added amazon-fireos platform. Change to use amazon-fireos as the platform if user agent string contains 'cordova-amazon-fireos'
|
||||
* [CB-5188](https://issues.apache.org/jira/browse/CB-5188)
|
||||
* [CB-5188](https://issues.apache.org/jira/browse/CB-5188) Updated version and RELEASENOTES.md for release 0.2.4
|
||||
* [CB-5128](https://issues.apache.org/jira/browse/CB-5128) added repo + issue tag to plugin.xml for inappbrowser plugin
|
||||
* [CB-4995](https://issues.apache.org/jira/browse/CB-4995) Fix crash when WebView is quickly opened then closed.
|
||||
* [CB-4930](https://issues.apache.org/jira/browse/CB-4930) - iOS - InAppBrowser should take into account the status bar
|
||||
* [CB-5010](https://issues.apache.org/jira/browse/CB-5010) Incremented plugin version on dev branch.
|
||||
* [CB-5010](https://issues.apache.org/jira/browse/CB-5010) Updated version and RELEASENOTES.md for release 0.2.3
|
||||
* [CB-4858](https://issues.apache.org/jira/browse/CB-4858) - Run IAB methods on the UI thread.
|
||||
* [CB-4858](https://issues.apache.org/jira/browse/CB-4858) Convert relative URLs to absolute URLs in JS
|
||||
* [CB-3747](https://issues.apache.org/jira/browse/CB-3747) Fix back button having different dismiss logic from the close button.
|
||||
* [CB-5021](https://issues.apache.org/jira/browse/CB-5021) Expose closeDialog() as a public function and make it safe to call multiple times.
|
||||
* [CB-5021](https://issues.apache.org/jira/browse/CB-5021) Make it safe to call close() multiple times
|
||||
* [CB-5010](https://issues.apache.org/jira/browse/CB-5010) Updated version and RELEASENOTES.md for release 0.2.3
|
||||
* [CB-4915](https://issues.apache.org/jira/browse/CB-4915) Incremented plugin version on dev branch.
|
||||
* [CB-4926](https://issues.apache.org/jira/browse/CB-4926) Fixes inappbrowser plugin loading for windows8
|
||||
* [CB-4915](https://issues.apache.org/jira/browse/CB-4915) Updated version and RELEASENOTES.md for release 0.2.2
|
||||
* [CB-4889](https://issues.apache.org/jira/browse/CB-4889) bumping&resetting version
|
||||
* [CB-4788](https://issues.apache.org/jira/browse/CB-4788) Modified the onJsPrompt to warn against Cordova calls
|
||||
* [windows8] commandProxy was moved
|
||||
* CB-4788: Modified the onJsPrompt to warn against Cordova calls
|
||||
* [CB-4788](https://issues.apache.org/jira/browse/CB-4788) Modified the onJsPrompt to warn against Cordova calls
|
||||
* [windows8] commandProxy was moved
|
||||
* CB-4889 renaming core references
|
||||
* CB-4889 renaming org.apache.cordova.core.inappbrowser to org.apache.cordova.inappbrowser
|
||||
* CB-4864, CB-4865: Minor improvements to InAppBrowser
|
||||
* [CB-4889](https://issues.apache.org/jira/browse/CB-4889) renaming core references
|
||||
* [CB-4889](https://issues.apache.org/jira/browse/CB-4889) renaming org.apache.cordova.core.inappbrowser to org.apache.cordova.inappbrowser
|
||||
* CB-4864, [CB-4865](https://issues.apache.org/jira/browse/CB-4865) Minor improvements to InAppBrowser
|
||||
* Rename CHANGELOG.md -> RELEASENOTES.md
|
||||
* [CB-4792] Added keepCallback to the show function.
|
||||
* [CB-4752] Incremented plugin version on dev branch.
|
||||
* [CB-4792](https://issues.apache.org/jira/browse/CB-4792) Added keepCallback to the show function.
|
||||
* [CB-4752](https://issues.apache.org/jira/browse/CB-4752) Incremented plugin version on dev branch.
|
||||
* Add empty CHANGELOG.md
|
||||
* [CB-4586](https://issues.apache.org/jira/browse/CB-4586) Making loadUrl run on the UI thread for close dialog to stop the WebView error
|
||||
* [Windows8] add support for Windows 8 ( limited )
|
||||
* [CB-3616](https://issues.apache.org/jira/browse/CB-3616) Change option name to "clearcache" to match original proposal
|
||||
* add "clearallcache" and "clearsessioncache" option to InAppbrowser
|
||||
* [CB-4595](https://issues.apache.org/jira/browse/CB-4595) updated version
|
||||
* [CB-4417](https://issues.apache.org/jira/browse/CB-4417) Move cordova-plugin-inappbrowser to its own Java package.
|
||||
* updated Readme, namespace and name tag
|
||||
* [plugin.xml] standardizing license + meta
|
||||
* [license] adding apache license file
|
||||
* [CB-4399](https://issues.apache.org/jira/browse/CB-4399) removed blackberry entry in plugin xml. Installation of plugin interferes with natively supported childbrowser functionality. To support additional inappbrowser features, see [CB-4467.](https://issues.apache.org/jira/browse/CB-4467.)
|
||||
* updating plugin.xml with registry data
|
||||
* [CB-4368](https://issues.apache.org/jira/browse/CB-4368) Explicit CoreGraphics.framework dependency should be specified for some core plugins
|
||||
|
||||
### 0.2.3 (Oct 9, 2013)
|
||||
* [CB-4915] Incremented plugin version on dev branch.
|
||||
* [CB-4926] Fixes inappbrowser plugin loading for windows8
|
||||
### 1.5.0 (Sep 08, 2016)
|
||||
* [CB-11795](https://issues.apache.org/jira/browse/CB-11795) Add 'protective' entry to cordovaDependencies
|
||||
* Add intent scheme to be handled by OS
|
||||
* Plugin uses `Android Log class` and not `Cordova LOG class`
|
||||
* Adding links to guide content and reference content at the top of the readme file Github: close #163
|
||||
* [CB-10973](https://issues.apache.org/jira/browse/CB-10973) **Browser**: wrong height of webview with `location=yes`
|
||||
* Size and position in browser platform
|
||||
* [CB-10973](https://issues.apache.org/jira/browse/CB-10973) **Windows**: wrong height of webview with `location=yes`
|
||||
* [CB-11013](https://issues.apache.org/jira/browse/CB-11013) IAB enabling background play of YouTube videos?
|
||||
* [CB-10467](https://issues.apache.org/jira/browse/CB-10467) Hardware back button, while `InAppBrowser` is opened, closes the app too in addition to closing `InAppBrowser`
|
||||
* [CB-11178](https://issues.apache.org/jira/browse/CB-11178) allow to open other apps on **iOS 9**
|
||||
* fix some calls which used api level 16
|
||||
* [CB-5402](https://issues.apache.org/jira/browse/CB-5402) added extra content from wiki page
|
||||
* [CB-2063](https://issues.apache.org/jira/browse/CB-2063) (**ios**) Fixed presentation style
|
||||
* [CB-11012](https://issues.apache.org/jira/browse/CB-11012) added some clarifications about `InAppBrowser` object
|
||||
* [CB-3360](https://issues.apache.org/jira/browse/CB-3360) Set custom `inappbrowser` user agent for **ios**
|
||||
* Add badges for paramedic builds on Jenkins
|
||||
* [CB-11381](https://issues.apache.org/jira/browse/CB-11381) android: Does not pass sonarqube scan
|
||||
* Add pull request template.
|
||||
* [CB-10866](https://issues.apache.org/jira/browse/CB-10866) Adding engine requirements to `package.json`
|
||||
* [CB-110003](https://issues.apache.org/jira/browse/CB-110003) Adding samples to Readme.
|
||||
* [CB-10996](https://issues.apache.org/jira/browse/CB-10996) Adding front matter to README.md
|
||||
|
||||
### 0.2.4 (Oct 28, 2013)
|
||||
* CB-5128: added repo + issue tag to plugin.xml for inappbrowser plugin
|
||||
* CB-4995 Fix crash when WebView is quickly opened then closed.
|
||||
* CB-4930 - iOS - InAppBrowser should take into account the status bar
|
||||
* [CB-5010] Incremented plugin version on dev branch.
|
||||
* [CB-5010] Updated version and RELEASENOTES.md for release 0.2.3
|
||||
* CB-4858 - Run IAB methods on the UI thread.
|
||||
* CB-4858 Convert relative URLs to absolute URLs in JS
|
||||
* CB-3747 Fix back button having different dismiss logic from the close button.
|
||||
* CB-5021 Expose closeDialog() as a public function and make it safe to call multiple times.
|
||||
* CB-5021 Make it safe to call close() multiple times
|
||||
### 1.4.0 (Apr 15, 2016)
|
||||
* [CB-7679](https://issues.apache.org/jira/browse/CB-7679) add fix for **iOS** upload.
|
||||
* [CB-10944](https://issues.apache.org/jira/browse/CB-10944) `NoSuchMethodError` in `InAppBrowser` plugin
|
||||
* [CB-10937](https://issues.apache.org/jira/browse/CB-10937) fix stretched icons
|
||||
* [CB-10760](https://issues.apache.org/jira/browse/CB-10760) Fixing README for display on Cordova website
|
||||
* [CB-10636](https://issues.apache.org/jira/browse/CB-10636) Add `JSHint` for plugins
|
||||
|
||||
### 1.3.0 (Feb 09, 2016)
|
||||
* [CB-3360](https://issues.apache.org/jira/browse/CB-3360) Set custom inappbrowser user agent for android
|
||||
* [CB-10538](https://issues.apache.org/jira/browse/CB-10538) cordova-plugin-inappbrowser timeout issue
|
||||
* [CB-10395](https://issues.apache.org/jira/browse/CB-10395) InAppBrowser's WebView not storing cookies reliable on Android
|
||||
* Edit package.json license to match SPDX id
|
||||
* [CB-10305](https://issues.apache.org/jira/browse/CB-10305) Gray bar appears in the wrong place on iOS
|
||||
* [CB-7786](https://issues.apache.org/jira/browse/CB-7786) Support mediaPlaybackRequiresUserAction on Android
|
||||
* [CB-7500](https://issues.apache.org/jira/browse/CB-7500) executeScript with callback kills/blurs inAppBrowser window on Android
|
||||
|
||||
### 1.2.1 (Feb 02, 2016)
|
||||
* [CB-10407](https://issues.apache.org/jira/browse/CB-10407) InAppBrowser not firing loadstart event on android
|
||||
* [CB-10428](https://issues.apache.org/jira/browse/CB-10428) Fix syntax error when browserifying inAppBrowser plugin
|
||||
* handle app store urls in system browser
|
||||
* [CB-6702](https://issues.apache.org/jira/browse/CB-6702) InAppBrowser hangs when opening more than one instance
|
||||
* [CB-10456](https://issues.apache.org/jira/browse/CB-10456) InAppBrowser is not closed if I close it programmatically on Android
|
||||
* [CB-10451](https://issues.apache.org/jira/browse/CB-10451) InAppBrowser: loadstart event is not triggered on Windows
|
||||
* [CB-10452](https://issues.apache.org/jira/browse/CB-10452) InAppBrowser: 'exit' event is not triggered on Windows
|
||||
* [CB-10454](https://issues.apache.org/jira/browse/CB-10454) InAppBrowser: 'loaderror' event does not have code and message on Windows
|
||||
* [CB-10450](https://issues.apache.org/jira/browse/CB-10450) InAppBrowser: Unable to get property 'canGoBack' of undefined on Windows
|
||||
* [CB-10441](https://issues.apache.org/jira/browse/CB-10441) Add auto tests for InAppBrowser plugin
|
||||
|
||||
### 1.2.0 (Jan 15, 2016)
|
||||
* [CB-8180](https://issues.apache.org/jira/browse/CB-8180) Changing methods of interception in `WebViewClient` class
|
||||
* [CB-10009](https://issues.apache.org/jira/browse/CB-10009) Improve `InAppBrowser` toolbar look and feel on **Windows**
|
||||
* Open a new window on the **Browser** platform
|
||||
|
||||
### 1.1.1 (Dec 10, 2015)
|
||||
|
||||
* [CB-9445](https://issues.apache.org/jira/browse/CB-9445) Improves executeScript callbacks on iOS
|
||||
* [CB-10035](https://issues.apache.org/jira/browse/CB-10035) Incremented plugin version.
|
||||
* [CB-10040](https://issues.apache.org/jira/browse/CB-10040) - re-fix: backwards compatible with cordova-ios < 4.0
|
||||
* [CB-8534](https://issues.apache.org/jira/browse/CB-8534) Allow plugins to respond to onReceivedHttpAuthRequest. This closes #82
|
||||
* [CB-3750](https://issues.apache.org/jira/browse/CB-3750) Fixes spinner on iOS. This closes #89
|
||||
* [CB-7696](https://issues.apache.org/jira/browse/CB-7696) Document target=_self behavior for Windows
|
||||
* [CB-10040](https://issues.apache.org/jira/browse/CB-10040) - Compile Error in InAppBrowser Plugin for iOS - No known instance method for selector 'URLIsWhitelisted:'
|
||||
|
||||
### 1.1.0 (Nov 18, 2015)
|
||||
* [CB-10035](https://issues.apache.org/jira/browse/CB-10035) Updated `RELEASENOTES` to be newest to oldest
|
||||
* Invoke webview if using local file
|
||||
* Fixed `zIndex` issue on **Windows 8**, **8.188 where InAppBrowser opens behind default app.
|
||||
* fix `async` self usage
|
||||
* [CB-9150](https://issues.apache.org/jira/browse/CB-9150) Fix InAppBrowser `executeScript` crash on **Windows** if no data returned
|
||||
* [CB-10008](https://issues.apache.org/jira/browse/CB-10008) Fix InAppBrowser popup layout on **Windows**
|
||||
* Setting `setStatusBarStyle` to `-1` causes `CGContextSaveGState`.
|
||||
* [CB-9167](https://issues.apache.org/jira/browse/CB-9167) Fix crash on **browser** window close
|
||||
* [CB-9799](https://issues.apache.org/jira/browse/CB-9799) Fixed `javaDoc` errors.
|
||||
* Fixing contribute link.
|
||||
* [CB-9760](https://issues.apache.org/jira/browse/CB-9760) InAppBrowser: fallback to default `window.open` behavior on **Ripple**
|
||||
* [CB-9378](https://issues.apache.org/jira/browse/CB-9378) Fix InAppBrowser not taking whole screen on **Windows**
|
||||
* [CB-9158](https://issues.apache.org/jira/browse/CB-9158) - InAppBrowser `zoomControls` are always set to true
|
||||
|
||||
### 1.0.1 (Jun 17, 2015)
|
||||
* [CB-9128](https://issues.apache.org/jira/browse/CB-9128) cordova-plugin-inappbrowser documentation translation: cordova-plugin-inappbrowser
|
||||
* fix npm md issue
|
||||
|
||||
### 1.0.0 (Apr 15, 2015)
|
||||
* [CB-8746](https://issues.apache.org/jira/browse/CB-8746) gave plugin major version bump
|
||||
* [CB-7689](https://issues.apache.org/jira/browse/CB-7689) Adds insertCSS support for windows platform
|
||||
* [CB-4930](https://issues.apache.org/jira/browse/CB-4930) - (prefix) InAppBrowser should take into account the status bar
|
||||
* [CB-8635](https://issues.apache.org/jira/browse/CB-8635) Improves UX on windows platform
|
||||
* [CB-8661](https://issues.apache.org/jira/browse/CB-8661) Return executed script result on Windows
|
||||
* [CB-8683](https://issues.apache.org/jira/browse/CB-8683) updated wp and browser specific references of old id to new id
|
||||
* [CB-8683](https://issues.apache.org/jira/browse/CB-8683) changed plugin-id to pacakge-name
|
||||
* [CB-8653](https://issues.apache.org/jira/browse/CB-8653) properly updated translated docs to use new id
|
||||
* [CB-8653](https://issues.apache.org/jira/browse/CB-8653) updated translated docs to use new id
|
||||
* Use TRAVIS_BUILD_DIR, install paramedic by npm
|
||||
* [CB-8432](https://issues.apache.org/jira/browse/CB-8432) Correct styles for browser wrapper to display it correctly on some pages
|
||||
* [CB-8659](https://issues.apache.org/jira/browse/CB-8659) - Update InAppBrowser to support both cordova-ios 4.0.x and 3.x (closes #93)
|
||||
* [CB-7961](https://issues.apache.org/jira/browse/CB-7961) Add cordova-plugin-inappbrowser support for browser platform
|
||||
* [CB-8653](https://issues.apache.org/jira/browse/CB-8653) Updated Readme
|
||||
* Update docs for Android zoom=no option
|
||||
* Added option to disable/enable zoom controls
|
||||
* updated docs, set hardwareback default to true
|
||||
* Add a hardwareback option to allow for the hardware back button to go back.
|
||||
* [CB-8570](https://issues.apache.org/jira/browse/CB-8570) Integrate TravisCI
|
||||
* [CB-8438](https://issues.apache.org/jira/browse/CB-8438) cordova-plugin-inappbrowser documentation translation: cordova-plugin-inappbrowser
|
||||
* [CB-8538](https://issues.apache.org/jira/browse/CB-8538) Added package.json file
|
||||
* Keep external android pages in a single tab. (close #61)
|
||||
* [CB-8444](https://issues.apache.org/jira/browse/CB-8444) Add a clobber for `cordova.InAppBrowser.open` (close #80)
|
||||
* [CB-8444](https://issues.apache.org/jira/browse/CB-8444) Don't clobber `window.open` - Add new symbol/clobber to access open function (`cordova.InAppBrowser.open`) - Change existing tests to use new symbol (i.e. don't rely on plugin clobber of `window.open`) - Add tests to use `window.open` via manual replace with new symbol - Update docs to deprecate plugin clobber of `window.open`
|
||||
|
||||
### 0.6.0 (Feb 04, 2015)
|
||||
* [CB-8270](https://issues.apache.org/jira/browse/CB-8270) ios: Remove usage of `[arr JSONString]`, since it's been renamed to `cdv_JSONString`
|
||||
* ubuntu: implement `inject*` functions
|
||||
* ubuntu: port to oxide
|
||||
* [CB-7897](https://issues.apache.org/jira/browse/CB-7897) ios, android: Update to work with whilelist plugins in Cordova 4.x
|
||||
|
||||
### 0.5.4 (Dec 02, 2014)
|
||||
* [CB-7784](https://issues.apache.org/jira/browse/CB-7784) Exit event is not fired after `InAppBrowser` closing
|
||||
* [CB-7697](https://issues.apache.org/jira/browse/CB-7697) Add `locationBar` support to `InAppBrowser` **Windows** platform version
|
||||
* [CB-7690](https://issues.apache.org/jira/browse/CB-7690) `InAppBrowser` `loadstart/loadstop` events issues
|
||||
* [CB-7695](https://issues.apache.org/jira/browse/CB-7695) Fix `InAppBrowser` `injectScriptFile` for **Windows 8.1** / **Windows Phone 8.1**
|
||||
* [CB-7692](https://issues.apache.org/jira/browse/CB-7692) `InAppBrowser` local url opening bug in 8.1
|
||||
* [CB-7688](https://issues.apache.org/jira/browse/CB-7688) `Alert` is not supported in `InAppBrowser` on **Windows** platform
|
||||
* [CB-7977](https://issues.apache.org/jira/browse/CB-7977) Mention `deviceready` in plugin docs
|
||||
* [CB-7876](https://issues.apache.org/jira/browse/CB-7876) change test target to avoid undesired redirects
|
||||
* [CB-7712](https://issues.apache.org/jira/browse/CB-7712) remove references to `closebuttoncaption`
|
||||
* [CB-7850](https://issues.apache.org/jira/browse/CB-7850) clarify role of whitelist
|
||||
* [CB-7720](https://issues.apache.org/jira/browse/CB-7720) check if event is null since OK string from success callback was removed
|
||||
* [CB-7471](https://issues.apache.org/jira/browse/CB-7471) cordova-plugin-inappbrowser documentation translation: cordova-plugin-inappbrowser
|
||||
|
||||
### 0.5.3 (Oct 03, 2014)
|
||||
* Windows implementation fixes and improvements
|
||||
* zIndex fixed
|
||||
* renamed InAppBrowser back to inappbrowser for case sensitive operating systems
|
||||
* Update french translation
|
||||
* Update doc to add Windows 8
|
||||
* Update windows proxy to be both compatible with windows 8 and 8.1
|
||||
* Rename windows81 by windows8 in src directory
|
||||
* Append Windows 8.1 platform configuration in plugin.xml
|
||||
* Append Windows 8.1 proxy using x-ms-webview
|
||||
|
||||
### 0.5.2 (Sep 17, 2014)
|
||||
* [CB-7471](https://issues.apache.org/jira/browse/CB-7471) cordova-plugin-inappbrowser documentation translation: cordova-plugin-inappbrowser
|
||||
* [CB-7490](https://issues.apache.org/jira/browse/CB-7490) Fixes InAppBrowser manual tests crash on windows platform
|
||||
* [CB-7249](https://issues.apache.org/jira/browse/CB-7249) cordova-plugin-inappbrowser documentation translation: cordova-plugin-inappbrowser
|
||||
* [CB-7424](https://issues.apache.org/jira/browse/CB-7424) Wrong docs: anchor tags are not supported by the InAppBrowser
|
||||
* [CB-7133](https://issues.apache.org/jira/browse/CB-7133) clarify that anchor1 doesn't exist
|
||||
* [CB-7133](https://issues.apache.org/jira/browse/CB-7133) more fixup of tests on Android
|
||||
* [CB-7133](https://issues.apache.org/jira/browse/CB-7133) fix up the tests for Android
|
||||
* Add just a bit more logging
|
||||
* [CB-7133](https://issues.apache.org/jira/browse/CB-7133) port inappbrowser to plugin-test-framework
|
||||
* phonegap events supported for \_blank target
|
||||
* inappbrowser \_blank target position is fixed
|
||||
* amazon-fireos related changes.
|
||||
|
||||
### 0.5.1 (Aug 06, 2014)
|
||||
* ubuntu: support qt 5.2
|
||||
* **FFOS** update InAppBrowserProxy.js
|
||||
* **FFOS** app needs to be privileged
|
||||
* [CB-6127](https://issues.apache.org/jira/browse/CB-6127) Updated translations for docs
|
||||
* [CB-6769](https://issues.apache.org/jira/browse/CB-6769) ios: Fix statusbar color reset wasn't working on iOS7+
|
||||
|
||||
### 0.5.0 (Jun 05, 2014)
|
||||
* [CB-6127](https://issues.apache.org/jira/browse/CB-6127) Spanish and rench Translations added. Github close #23
|
||||
* Clean up whitespace (mainly due to no newline at eof warning)
|
||||
* Adding permission info
|
||||
* [CB-6806](https://issues.apache.org/jira/browse/CB-6806) Add license
|
||||
* [CB-6491](https://issues.apache.org/jira/browse/CB-6491) add CONTRIBUTING.md
|
||||
* Add necessary capability so the plugin works on its own
|
||||
* [CB-6474](https://issues.apache.org/jira/browse/CB-6474) InAppBrowser. Add data urls support to WP8
|
||||
* [CB-6482](https://issues.apache.org/jira/browse/CB-6482) InAppBrowser calls incorrect callback on WP8
|
||||
* Fixed use of iOS 6 deprecated methods
|
||||
* [CB-6360](https://issues.apache.org/jira/browse/CB-6360) - improvement: feature detection instead of iOS version detection
|
||||
* [CB-5649](https://issues.apache.org/jira/browse/CB-5649) - InAppBrowser overrides App's orientation
|
||||
* refactoring fixed
|
||||
* [CB-6396](https://issues.apache.org/jira/browse/CB-6396) [Firefox OS] Adding basic support
|
||||
|
||||
### 0.4.0 (Apr 17, 2014)
|
||||
* [CB-6360](https://issues.apache.org/jira/browse/CB-6360): [ios] Fix for crash on iOS < 6.0 (closes #37)
|
||||
* [CB-3324](https://issues.apache.org/jira/browse/CB-3324): [WP8] Add support for back-button inappbrowser [WP8] if there is no history -> InAppBrowser is closed
|
||||
* [WP] await async calls, resolve warnings
|
||||
* [WP] Make InAppBrowser work with embedded files, using system behavior
|
||||
* [CB-6402](https://issues.apache.org/jira/browse/CB-6402): [WP8] pass empty string instead of null for [optional] windowFeatures string
|
||||
* [CB-6422](https://issues.apache.org/jira/browse/CB-6422): [windows8] use cordova/exec/proxy
|
||||
* [CB-6389](https://issues.apache.org/jira/browse/CB-6389) [CB-3617](https://issues.apache.org/jira/browse/CB-3617): Add clearcache and clearsessioncache options to iOS (like Android)
|
||||
* Doc update: event name and example param (closes #31)
|
||||
* [CB-6253](https://issues.apache.org/jira/browse/CB-6253): [WP] Add Network Capability to WMAppManifest.xml
|
||||
* [CB-6212](https://issues.apache.org/jira/browse/CB-6212): [iOS] fix warnings compiled under arm64 64-bit
|
||||
* [CB-6218](https://issues.apache.org/jira/browse/CB-6218): Update docs for BB10
|
||||
* [CB-6460](https://issues.apache.org/jira/browse/CB-6460): Update license headers
|
||||
|
||||
### 0.3.3 (Mar 5, 2014)
|
||||
* [CB-5534](https://issues.apache.org/jira/browse/CB-5534) Fix video/audio does not stop playing when browser is closed
|
||||
* [CB-6172](https://issues.apache.org/jira/browse/CB-6172) Fix broken install on case-sensitive file-systems
|
||||
|
||||
### 0.3.2 (Feb 26, 2014)
|
||||
* Validate that callbackId is correctly formed
|
||||
* [CB-6035](https://issues.apache.org/jira/browse/CB-6035) Move js-module so it is not loaded on unsupported platforms
|
||||
* Removed some iOS6 Deprecations
|
||||
|
||||
### 0.3.1 (Feb 05, 2014)
|
||||
* [CB-5756](https://issues.apache.org/jira/browse/CB-5756): Android: Use WebView.evaluateJavascript for script injection on Android 4.4+
|
||||
* Didn't test on ICS or lower, getDrawable isn't supported until Jellybean
|
||||
* add ubuntu platform
|
||||
* Adding drawables to the inAppBrowser. This doesn't look quite right, but it's a HUGE improvement over the previous settings
|
||||
* [CB-5756](https://issues.apache.org/jira/browse/CB-5756): Android: Use WebView.evaluateJavascript for script injection on Android 4.4+
|
||||
* Remove alive from InAppBrowser.js since it didn't catch the case where the browser is closed by the user.
|
||||
* [CB-5733](https://issues.apache.org/jira/browse/CB-5733) Fix IAB.close() not working if called before show() animation is done
|
||||
|
||||
### 0.2.5 (Dec 4, 2013)
|
||||
* Remove merge conflict tag
|
||||
* [CB-4724] fixed UriFormatException
|
||||
* [CB-4724](https://issues.apache.org/jira/browse/CB-4724) fixed UriFormatException
|
||||
* add ubuntu platform
|
||||
* CB-3420 WP feature hidden=yes implemented
|
||||
* [CB-3420](https://issues.apache.org/jira/browse/CB-3420) WP feature hidden=yes implemented
|
||||
* Added amazon-fireos platform. Change to use amazon-fireos as the platform if user agent string contains 'cordova-amazon-fireos'
|
||||
|
||||
### 0.2.4 (Oct 28, 2013)
|
||||
* [CB-5128](https://issues.apache.org/jira/browse/CB-5128): added repo + issue tag to plugin.xml for inappbrowser plugin
|
||||
* [CB-4995](https://issues.apache.org/jira/browse/CB-4995) Fix crash when WebView is quickly opened then closed.
|
||||
* [CB-4930](https://issues.apache.org/jira/browse/CB-4930) - iOS - InAppBrowser should take into account the status bar
|
||||
* [CB-5010](https://issues.apache.org/jira/browse/CB-5010) Incremented plugin version on dev branch.
|
||||
* [CB-5010](https://issues.apache.org/jira/browse/CB-5010) Updated version and RELEASENOTES.md for release 0.2.3
|
||||
* [CB-4858](https://issues.apache.org/jira/browse/CB-4858) - Run IAB methods on the UI thread.
|
||||
* [CB-4858](https://issues.apache.org/jira/browse/CB-4858) Convert relative URLs to absolute URLs in JS
|
||||
* [CB-3747](https://issues.apache.org/jira/browse/CB-3747) Fix back button having different dismiss logic from the close button.
|
||||
* [CB-5021](https://issues.apache.org/jira/browse/CB-5021) Expose closeDialog() as a public function and make it safe to call multiple times.
|
||||
* [CB-5021](https://issues.apache.org/jira/browse/CB-5021) Make it safe to call close() multiple times
|
||||
|
||||
### 0.2.3 (Oct 9, 2013)
|
||||
* [CB-4915](https://issues.apache.org/jira/browse/CB-4915) Incremented plugin version on dev branch.
|
||||
* [CB-4926](https://issues.apache.org/jira/browse/CB-4926) Fixes inappbrowser plugin loading for windows8
|
||||
|
||||
### 0.2.2 (Sept 25, 2013)
|
||||
* [CB-4889](https://issues.apache.org/jira/browse/CB-4889) bumping&resetting version
|
||||
* [CB-4788](https://issues.apache.org/jira/browse/CB-4788): Modified the onJsPrompt to warn against Cordova calls
|
||||
* [windows8] commandProxy was moved
|
||||
* [CB-4788](https://issues.apache.org/jira/browse/CB-4788): Modified the onJsPrompt to warn against Cordova calls
|
||||
* [windows8] commandProxy was moved
|
||||
* [CB-4889](https://issues.apache.org/jira/browse/CB-4889) renaming core references
|
||||
* [CB-4889](https://issues.apache.org/jira/browse/CB-4889) renaming org.apache.cordova.core.inappbrowser to org.apache.cordova.inappbrowser
|
||||
* [CB-4864](https://issues.apache.org/jira/browse/CB-4864), [CB-4865](https://issues.apache.org/jira/browse/CB-4865): Minor improvements to InAppBrowser
|
||||
* Rename CHANGELOG.md -> RELEASENOTES.md
|
||||
* [CB-4792](https://issues.apache.org/jira/browse/CB-4792) Added keepCallback to the show function.
|
||||
* [CB-4752](https://issues.apache.org/jira/browse/CB-4752) Incremented plugin version on dev branch.
|
||||
|
||||
@@ -1,427 +0,0 @@
|
||||
---
|
||||
license: Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
---
|
||||
|
||||
InAppBrowser
|
||||
============
|
||||
|
||||
> The `InAppBrowser` is a web browser that displays in the app when calling `window.open`.
|
||||
|
||||
var ref = window.open('http://apache.org', '_blank', 'location=yes');
|
||||
|
||||
Description
|
||||
-----------
|
||||
|
||||
The object returned from a call to `window.open`.
|
||||
|
||||
Methods
|
||||
----------
|
||||
|
||||
- addEventListener
|
||||
- removeEventListener
|
||||
- close
|
||||
|
||||
Permissions
|
||||
-----------
|
||||
|
||||
### Android
|
||||
|
||||
#### app/res/xml/config.xml
|
||||
|
||||
<plugin name="InAppBrowser" value="org.apache.cordova.InAppBrowser" />
|
||||
|
||||
### iOS
|
||||
|
||||
#### config.xml
|
||||
|
||||
<plugin name="InAppBrowser" value="CDVInAppBrowser" />
|
||||
|
||||
### Windows Phone 7 + 8
|
||||
|
||||
#### config.xml
|
||||
|
||||
<plugin name="InAppBrowser" />
|
||||
|
||||
addEventListener
|
||||
================
|
||||
|
||||
> Adds a listener for an event from the `InAppBrowser`.
|
||||
|
||||
ref.addEventListener(eventname, callback);
|
||||
|
||||
- __ref__: reference to the `InAppBrowser` window _(InAppBrowser)_
|
||||
- __eventname__: the event to listen for _(String)_
|
||||
|
||||
- __loadstart__: event fires when the `InAppBrowser` starts to load a URL.
|
||||
- __loadstop__: event fires when the `InAppBrowser` finishes loading a URL.
|
||||
- __loaderror__: event fires when the `InAppBrowser` encounters an error when loading a URL.
|
||||
- __exit__: event fires when the `InAppBrowser` window is closed.
|
||||
|
||||
- __callback__: the function that executes when the event fires. The function is passed an `InAppBrowserEvent` object as a parameter.
|
||||
|
||||
Supported Platforms
|
||||
-------------------
|
||||
|
||||
- Android
|
||||
- iOS
|
||||
- Windows Phone 7 + 8
|
||||
|
||||
Quick Example
|
||||
-------------
|
||||
|
||||
var ref = window.open('http://apache.org', '_blank', 'location=yes');
|
||||
ref.addEventListener('loadstart', function() { alert(event.url); });
|
||||
|
||||
Full Example
|
||||
------------
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>InAppBrowser.addEventListener Example</title>
|
||||
|
||||
<script type="text/javascript" charset="utf-8" src="cordova-x.x.x.js"></script>
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
|
||||
// Wait for device API libraries to load
|
||||
//
|
||||
document.addEventListener("deviceready", onDeviceReady, false);
|
||||
|
||||
// device APIs are available
|
||||
//
|
||||
function onDeviceReady() {
|
||||
var ref = window.open('http://apache.org', '_blank', 'location=yes');
|
||||
ref.addEventListener('loadstart', function(event) { alert('start: ' + event.url); });
|
||||
ref.addEventListener('loadstop', function(event) { alert('stop: ' + event.url); });
|
||||
ref.addEventListener('loaderror', function(event) { alert('error: ' + event.message); });
|
||||
ref.addEventListener('exit', function(event) { alert(event.type); });
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
removeEventListener
|
||||
===================
|
||||
|
||||
> Removes a listener for an event from the `InAppBrowser`.
|
||||
|
||||
ref.removeEventListener(eventname, callback);
|
||||
|
||||
- __ref__: reference to the `InAppBrowser` window. _(InAppBrowser)_
|
||||
- __eventname__: the event to stop listening for. _(String)_
|
||||
|
||||
- __loadstart__: event fires when the `InAppBrowser` starts to load a URL.
|
||||
- __loadstop__: event fires when the `InAppBrowser` finishes loading a URL.
|
||||
- __loaderror__: event fires when the `InAppBrowser` encounters an error loading a URL.
|
||||
- __exit__: event fires when the `InAppBrowser` window is closed.
|
||||
|
||||
- __callback__: the function to execute when the event fires.
|
||||
The function is passed an `InAppBrowserEvent` object.
|
||||
|
||||
Supported Platforms
|
||||
-------------------
|
||||
|
||||
- Android
|
||||
- iOS
|
||||
- Windows Phone 7 + 8
|
||||
|
||||
Quick Example
|
||||
-------------
|
||||
|
||||
var ref = window.open('http://apache.org', '_blank', 'location=yes');
|
||||
var myCallback = function() { alert(event.url); }
|
||||
ref.addEventListener('loadstart', myCallback);
|
||||
ref.removeEventListener('loadstart', myCallback);
|
||||
|
||||
Full Example
|
||||
------------
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>InAppBrowser.removeEventListener Example</title>
|
||||
|
||||
<script type="text/javascript" charset="utf-8" src="cordova-x.x.x.js"></script>
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
|
||||
// Wait for device API libraries to load
|
||||
//
|
||||
document.addEventListener("deviceready", onDeviceReady, false);
|
||||
|
||||
// Global InAppBrowser reference
|
||||
var iabRef = null;
|
||||
|
||||
function iabLoadStart(event) {
|
||||
alert(event.type + ' - ' + event.url);
|
||||
}
|
||||
|
||||
function iabLoadStop(event) {
|
||||
alert(event.type + ' - ' + event.url);
|
||||
}
|
||||
|
||||
function iabLoadError(event) {
|
||||
alert(event.type + ' - ' + event.message);
|
||||
}
|
||||
|
||||
function iabClose(event) {
|
||||
alert(event.type);
|
||||
iabRef.removeEventListener('loadstart', iabLoadStart);
|
||||
iabRef.removeEventListener('loadstop', iabLoadStop);
|
||||
iabRef.removeEventListener('loaderror', iabLoadError);
|
||||
iabRef.removeEventListener('exit', iabClose);
|
||||
}
|
||||
|
||||
// device APIs are available
|
||||
//
|
||||
function onDeviceReady() {
|
||||
iabRef = window.open('http://apache.org', '_blank', 'location=yes');
|
||||
iabRef.addEventListener('loadstart', iabLoadStart);
|
||||
iabRef.addEventListener('loadstop', iabLoadStop);
|
||||
iabRef.removeEventListener('loaderror', iabLoadError);
|
||||
iabRef.addEventListener('exit', iabClose);
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
close
|
||||
=====
|
||||
|
||||
> Closes the `InAppBrowser` window.
|
||||
|
||||
ref.close();
|
||||
|
||||
- __ref__: reference to the `InAppBrowser` window _(InAppBrowser)_
|
||||
|
||||
Supported Platforms
|
||||
-------------------
|
||||
|
||||
- Android
|
||||
- iOS
|
||||
- Windows Phone 7 + 8
|
||||
- BlackBerry 10
|
||||
|
||||
Quick Example
|
||||
-------------
|
||||
|
||||
var ref = window.open('http://apache.org', '_blank', 'location=yes');
|
||||
ref.close();
|
||||
|
||||
Full Example
|
||||
------------
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>InAppBrowser.close Example</title>
|
||||
|
||||
<script type="text/javascript" charset="utf-8" src="cordova-x.x.x.js"></script>
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
|
||||
// Wait for device API libraries to load
|
||||
//
|
||||
document.addEventListener("deviceready", onDeviceReady, false);
|
||||
|
||||
// device APIs are available
|
||||
//
|
||||
function onDeviceReady() {
|
||||
var ref = window.open('http://apache.org', '_blank', 'location=yes');
|
||||
// close InAppBrowser after 5 seconds
|
||||
setTimeout(function() {
|
||||
ref.close();
|
||||
}, 5000);
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
executeScript
|
||||
=============
|
||||
|
||||
> Injects JavaScript code into the `InAppBrowser` window
|
||||
|
||||
ref.executeScript(details, callback);
|
||||
|
||||
- __ref__: reference to the `InAppBrowser` window. _(InAppBrowser)_
|
||||
- __injectDetails__: details of the script to run, specifying either a `file` or `code` key. _(Object)_
|
||||
- __file__: URL of the script to inject.
|
||||
- __code__: Text of the script to inject.
|
||||
- __callback__: the function that executes after the JavaScript code is injected.
|
||||
- If the injected script is of type `code`, the callback executes
|
||||
with a single parameter, which is the return value of the
|
||||
script, wrapped in an `Array`. For multi-line scripts, this is
|
||||
the return value of the last statement, or the last expression
|
||||
evaluated.
|
||||
|
||||
Supported Platforms
|
||||
-------------------
|
||||
|
||||
- Android
|
||||
- iOS
|
||||
|
||||
Quick Example
|
||||
-------------
|
||||
|
||||
var ref = window.open('http://apache.org', '_blank', 'location=yes');
|
||||
ref.addEventListener('loadstop', function() {
|
||||
ref.executeSript({file: "myscript.js"});
|
||||
});
|
||||
|
||||
Full Example
|
||||
------------
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>InAppBrowser.executeScript Example</title>
|
||||
|
||||
<script type="text/javascript" charset="utf-8" src="cordova-x.x.x.js"></script>
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
|
||||
// Wait for device API libraries to load
|
||||
//
|
||||
document.addEventListener("deviceready", onDeviceReady, false);
|
||||
|
||||
// Global InAppBrowser reference
|
||||
var iabRef = null;
|
||||
|
||||
// Inject our custom JavaScript into the InAppBrowser window
|
||||
//
|
||||
function replaceHeaderImage() {
|
||||
iabRef.executeScript({
|
||||
code: "var img=document.querySelector('#header img'); img.src='http://cordova.apache.org/images/cordova_bot.png';"
|
||||
}, function() {
|
||||
alert("Image Element Successfully Hijacked");
|
||||
}
|
||||
}
|
||||
|
||||
function iabClose(event) {
|
||||
iabRef.removeEventListener('loadstop', replaceHeaderImage);
|
||||
iabRef.removeEventListener('exit', iabClose);
|
||||
}
|
||||
|
||||
// device APIs are available
|
||||
//
|
||||
function onDeviceReady() {
|
||||
iabRef = window.open('http://apache.org', '_blank', 'location=yes');
|
||||
iabRef.addEventListener('loadstop', replaceHeaderImage);
|
||||
iabRef.addEventListener('exit', iabClose);
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
insertCSS
|
||||
=========
|
||||
|
||||
> Injects CSS into the `InAppBrowser` window.
|
||||
|
||||
ref.insertCSS(details, callback);
|
||||
|
||||
- __ref__: reference to the `InAppBrowser` window _(InAppBrowser)_
|
||||
- __injectDetails__: details of the script to run, specifying either a `file` or `code` key. _(Object)_
|
||||
- __file__: URL of the stylesheet to inject.
|
||||
- __code__: Text of the stylesheet to inject.
|
||||
- __callback__: the function that executes after the CSS is injected.
|
||||
|
||||
Supported Platforms
|
||||
-------------------
|
||||
|
||||
- Android
|
||||
- iOS
|
||||
|
||||
Quick Example
|
||||
-------------
|
||||
|
||||
var ref = window.open('http://apache.org', '_blank', 'location=yes');
|
||||
ref.addEventListener('loadstop', function() {
|
||||
ref.insertCSS({file: "mystyles.css"});
|
||||
});
|
||||
|
||||
Full Example
|
||||
------------
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>InAppBrowser.executeScript Example</title>
|
||||
|
||||
<script type="text/javascript" charset="utf-8" src="cordova-x.x.x.js"></script>
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
|
||||
// Wait for device API libraries to load
|
||||
//
|
||||
document.addEventListener("deviceready", onDeviceReady, false);
|
||||
|
||||
// Global InAppBrowser reference
|
||||
var iabRef = null;
|
||||
|
||||
// Inject our custom CSS into the InAppBrowser window
|
||||
//
|
||||
function changeBackgroundColor() {
|
||||
iabRef.executeScript({
|
||||
code: "body { background: #ffff00"
|
||||
}, function() {
|
||||
alert("Styles Altered");
|
||||
}
|
||||
}
|
||||
|
||||
function iabClose(event) {
|
||||
iabRef.removeEventListener('loadstop', changeBackgroundColor);
|
||||
iabRef.removeEventListener('exit', iabClose);
|
||||
}
|
||||
|
||||
// device APIs are available
|
||||
//
|
||||
function onDeviceReady() {
|
||||
iabRef = window.open('http://apache.org', '_blank', 'location=yes');
|
||||
iabRef.addEventListener('loadstop', changeBackgroundColor);
|
||||
iabRef.addEventListener('exit', iabClose);
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
InAppBrowserEvent
|
||||
=================
|
||||
|
||||
The object that is passed to the callback function from an
|
||||
`addEventListener` call on an `InAppBrowser` object.
|
||||
|
||||
Properties
|
||||
----------
|
||||
|
||||
- __type__: the eventname, either `loadstart`, `loadstop`, `loaderror`, 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)_
|
||||
@@ -1,100 +0,0 @@
|
||||
---
|
||||
license: Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
---
|
||||
|
||||
window.open
|
||||
===========
|
||||
|
||||
Opens a URL in a new `InAppBrowser` instance, the current browser
|
||||
instance, or the system browser.
|
||||
|
||||
var ref = window.open(url, target, options);
|
||||
|
||||
- __ref__: Reference to the `InAppBrowser` window. _(InAppBrowser)_
|
||||
- __url__: The URL to load _(String)_. Call `encodeURI()` on this if the URL contains Unicode characters.
|
||||
- __target__: The target in which to load the URL, an optional parameter that defaults to `_self`. _(String)_
|
||||
|
||||
- `_self`: Opens in the Cordova WebView if the URL is in the white list, otherwise it opens in the `InAppBrowser`.
|
||||
- `_blank`: Opens in the `InAppBrowser`.
|
||||
- `_system`: Opens in the system's web browser.
|
||||
|
||||
- __options__: Options for the `InAppBrowser`. Optional, defaulting to: `location=yes`. _(String)_
|
||||
|
||||
The `options` string must not contain any blank space, and each feature's name/value pairs must be separated by a comma. Feature names are case insensitive. All platforms support the value below:
|
||||
|
||||
- __location__: Set to `yes` or `no` to turn the `InAppBrowser`'s location bar on or off.
|
||||
|
||||
Android only
|
||||
------------
|
||||
- __closebuttoncaption__ - set to a string that will be the caption for the "Done" button.
|
||||
|
||||
iOS only
|
||||
--------
|
||||
- __closebuttoncaption__ - set to a string that will be the caption for the "Done" button. Note that you will have to localize this value yourself.
|
||||
- __toolbar__ - set to 'yes' or 'no' to turn the toolbar on or off for the InAppBrowser (defaults to 'yes')
|
||||
- __enableViewportScale__: Set to `yes` or `no` to prevent viewport scaling through a meta tag (defaults to `no`).
|
||||
- __mediaPlaybackRequiresUserAction__: Set to `yes` or `no` to prevent HTML5 audio or video from autoplaying (defaults to `no`).
|
||||
- __allowInlineMediaPlayback__: Set to `yes` or `no` to allow inline HTML5 media playback, displaying within the browser window rather than a device-specific playback interface. The HTML's `video` element must also include the `webkit-playsinline` attribute (defaults to `no`)
|
||||
- __keyboardDisplayRequiresUserAction__: Set to `yes` or `no` to open the keyboard when form elements receive focus via JavaScript's `focus()` call (defaults to `yes`).
|
||||
- __suppressesIncrementalRendering__: Set to `yes` or `no` to wait until all new view content is received before being rendered (defaults to `no`).
|
||||
- __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`).
|
||||
|
||||
Supported Platforms
|
||||
-------------------
|
||||
|
||||
- Android
|
||||
- iOS
|
||||
- BlackBerry 10
|
||||
- Windows Phone 7 + 8
|
||||
|
||||
Quick Example
|
||||
-------------
|
||||
|
||||
var ref = window.open('http://apache.org', '_blank', 'location=yes');
|
||||
var ref2 = window.open(encodeURI('http://ja.m.wikipedia.org/wiki/ハングル'), '_blank', 'location=yes');
|
||||
|
||||
Full Example
|
||||
------------
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>window.open Example</title>
|
||||
|
||||
<script type="text/javascript" charset="utf-8" src="cordova-x.x.x.js"></script>
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
|
||||
// Wait for device API libraries to load
|
||||
//
|
||||
document.addEventListener("deviceready", onDeviceReady, false);
|
||||
|
||||
// device APIs are available
|
||||
//
|
||||
function onDeviceReady() {
|
||||
// external url
|
||||
var ref = window.open(encodeURI('http://apache.org'), '_blank', 'location=yes');
|
||||
// relative document
|
||||
ref = window.open('next.html', '_self');
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
||||
61
package.json
Normal file
@@ -0,0 +1,61 @@
|
||||
{
|
||||
"name": "cordova-plugin-inappbrowser",
|
||||
"version": "3.1.0",
|
||||
"description": "Cordova InAppBrowser Plugin",
|
||||
"types": "./types/index.d.ts",
|
||||
"cordova": {
|
||||
"id": "cordova-plugin-inappbrowser",
|
||||
"platforms": [
|
||||
"android",
|
||||
"browser",
|
||||
"ios",
|
||||
"osx",
|
||||
"windows"
|
||||
]
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/apache/cordova-plugin-inappbrowser"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/apache/cordova-plugin-inappbrowser/issues"
|
||||
},
|
||||
"keywords": [
|
||||
"cordova",
|
||||
"in",
|
||||
"app",
|
||||
"browser",
|
||||
"inappbrowser",
|
||||
"ecosystem:cordova",
|
||||
"cordova-android",
|
||||
"cordova-browser",
|
||||
"cordova-ios",
|
||||
"cordova-osx",
|
||||
"cordova-windows"
|
||||
],
|
||||
"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"
|
||||
},
|
||||
"engines": {
|
||||
"cordovaDependencies": {
|
||||
"0.2.3": {
|
||||
"cordova": ">=3.1.0"
|
||||
},
|
||||
"4.0.0": {
|
||||
"cordova": ">100"
|
||||
}
|
||||
}
|
||||
},
|
||||
"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"
|
||||
}
|
||||
}
|
||||
152
plugin.xml
@@ -1,105 +1,145 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
-->
|
||||
|
||||
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
||||
id="org.apache.cordova.inappbrowser"
|
||||
version="0.2.5">
|
||||
id="cordova-plugin-inappbrowser"
|
||||
version="3.1.0">
|
||||
|
||||
<name>InAppBrowser</name>
|
||||
<description>Cordova InAppBrowser Plugin</description>
|
||||
<license>Apache 2.0</license>
|
||||
<keywords>cordova,in,app,browser,inappbrowser</keywords>
|
||||
<repo>https://git-wip-us.apache.org/repos/asf/cordova-plugin-inappbrowser.git</repo>
|
||||
<issue>https://issues.apache.org/jira/browse/CB/component/12320641</issue>
|
||||
<repo>https://github.com/apache/cordova-plugin-inappbrowser</repo>
|
||||
<issue>https://github.com/apache/cordova-plugin-inappbrowser/issues</issue>
|
||||
|
||||
<engines>
|
||||
<engine name="cordova" version=">=3.1.0" /><!-- Needs cordova/urlutil -->
|
||||
</engines>
|
||||
|
||||
<js-module src="www/InAppBrowser.js" name="InAppBrowser">
|
||||
<clobbers target="window.open" />
|
||||
</js-module>
|
||||
|
||||
<!-- 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">
|
||||
<feature name="InAppBrowser">
|
||||
<param name="android-package" value="org.apache.cordova.inappbrowser.InAppBrowser"/>
|
||||
</feature>
|
||||
</config-file>
|
||||
|
||||
<source-file src="src/android/InAppBrowser.java" target-dir="src/org/apache/cordova/inappbrowser" />
|
||||
<source-file src="src/android/InAppBrowserDialog.java" target-dir="src/org/apache/cordova/inappbrowser" />
|
||||
<source-file src="src/android/InAppChromeClient.java" target-dir="src/org/apache/cordova/inappbrowser" />
|
||||
</platform>
|
||||
|
||||
<!-- amazon-fireos -->
|
||||
<platform name="amazon-fireos">
|
||||
<config-file target="res/xml/config.xml" parent="/*">
|
||||
<feature name="InAppBrowser">
|
||||
<param name="android-package" value="org.apache.cordova.inappbrowser.InAppBrowser"/>
|
||||
</feature>
|
||||
</config-file>
|
||||
|
||||
<source-file src="src/amazon/InAppBrowser.java" target-dir="src/org/apache/cordova/inappbrowser" />
|
||||
<source-file src="src/amazon/InAppChromeClient.java" target-dir="src/org/apache/cordova/inappbrowser" />
|
||||
</platform>
|
||||
<!-- drawable src/android/resources -->
|
||||
<resource-file src="src/android/res/drawable-hdpi/ic_action_next_item.png" target="res/drawable-hdpi/ic_action_next_item.png" />
|
||||
<resource-file src="src/android/res/drawable-mdpi/ic_action_next_item.png" target="res/drawable-mdpi/ic_action_next_item.png" />
|
||||
<resource-file src="src/android/res/drawable-xhdpi/ic_action_next_item.png" target="res/drawable-xhdpi/ic_action_next_item.png" />
|
||||
<resource-file src="src/android/res/drawable-xxhdpi/ic_action_next_item.png" target="res/drawable-xxhdpi/ic_action_next_item.png" />
|
||||
|
||||
<resource-file src="src/android/res/drawable-hdpi/ic_action_previous_item.png" target="res/drawable-hdpi/ic_action_previous_item.png" />
|
||||
<resource-file src="src/android/res/drawable-mdpi/ic_action_previous_item.png" target="res/drawable-mdpi/ic_action_previous_item.png" />
|
||||
<resource-file src="src/android/res/drawable-xhdpi/ic_action_previous_item.png" target="res/drawable-xhdpi/ic_action_previous_item.png" />
|
||||
<resource-file src="src/android/res/drawable-xxhdpi/ic_action_previous_item.png" target="res/drawable-xxhdpi/ic_action_previous_item.png" />
|
||||
|
||||
<resource-file src="src/android/res/drawable-hdpi/ic_action_remove.png" target="res/drawable-hdpi/ic_action_remove.png" />
|
||||
<resource-file src="src/android/res/drawable-mdpi/ic_action_remove.png" target="res/drawable-mdpi/ic_action_remove.png" />
|
||||
<resource-file src="src/android/res/drawable-xhdpi/ic_action_remove.png" target="res/drawable-xhdpi/ic_action_remove.png" />
|
||||
<resource-file src="src/android/res/drawable-xxhdpi/ic_action_remove.png" target="res/drawable-xxhdpi/ic_action_remove.png" />
|
||||
|
||||
<!-- ubuntu -->
|
||||
<platform name="ubuntu">
|
||||
<header-file src="src/ubuntu/inappbrowser.h" />
|
||||
<source-file src="src/ubuntu/inappbrowser.cpp" />
|
||||
<resource-file src="src/ubuntu/InAppBrowser.qml" />
|
||||
<resource-file src="src/ubuntu/close.png" />
|
||||
</platform>
|
||||
|
||||
<!-- ios -->
|
||||
<platform name="ios">
|
||||
<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="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" />
|
||||
<source-file src="src/ios/CDVWKInAppBrowserUIDelegate.m" />
|
||||
|
||||
<framework src="CoreGraphics.framework" />
|
||||
</platform>
|
||||
|
||||
<!-- blackberry10 -->
|
||||
<!-- <platform name="blackberry10">
|
||||
<config-file target="www/config.xml" parent="/widget">
|
||||
<feature name="InAppBrowser" value="InAppBrowser"/>
|
||||
</config-file>
|
||||
</platform>
|
||||
-->
|
||||
<!-- wp7 -->
|
||||
<platform name="wp7">
|
||||
<!-- 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="wp-package" value="InAppBrowser"/>
|
||||
<param name="osx-package" value="CDVInAppBrowser" />
|
||||
</feature>
|
||||
</config-file>
|
||||
|
||||
<source-file src="src/wp/InAppBrowser.cs" />
|
||||
<header-file src="src/osx/CDVInAppBrowser.h" />
|
||||
<source-file src="src/osx/CDVInAppBrowser.m" />
|
||||
</platform>
|
||||
|
||||
<!-- wp8 -->
|
||||
<platform name="wp8">
|
||||
<config-file target="config.xml" parent="/*">
|
||||
<feature name="InAppBrowser">
|
||||
<param name="wp-package" value="InAppBrowser"/>
|
||||
</feature>
|
||||
</config-file>
|
||||
|
||||
<source-file src="src/wp/InAppBrowser.cs" />
|
||||
<!-- 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>
|
||||
|
||||
<!-- windows8 -->
|
||||
<platform name="windows8">
|
||||
<js-module src="www/windows8/InAppBrowserProxy.js" name="InAppBrowserProxy">
|
||||
<merges target="" />
|
||||
<!-- 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 />
|
||||
</js-module>
|
||||
</platform>
|
||||
|
||||
|
||||
</plugin>
|
||||
|
||||
@@ -1,769 +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.
|
||||
*/
|
||||
package org.apache.cordova.inappbrowser;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.text.InputType;
|
||||
import android.util.Log;
|
||||
import android.util.TypedValue;
|
||||
import android.view.Gravity;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.view.WindowManager.LayoutParams;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import com.amazon.android.webkit.AmazonWebChromeClient;
|
||||
import com.amazon.android.webkit.AmazonGeolocationPermissions.Callback;
|
||||
import com.amazon.android.webkit.AmazonJsPromptResult;
|
||||
import com.amazon.android.webkit.AmazonWebSettings;
|
||||
import com.amazon.android.webkit.AmazonWebStorage;
|
||||
import com.amazon.android.webkit.AmazonWebView;
|
||||
import com.amazon.android.webkit.AmazonWebViewClient;
|
||||
import com.amazon.android.webkit.AmazonCookieManager;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
import org.apache.cordova.CallbackContext;
|
||||
import org.apache.cordova.Config;
|
||||
import org.apache.cordova.CordovaArgs;
|
||||
import org.apache.cordova.CordovaPlugin;
|
||||
import org.apache.cordova.CordovaWebView;
|
||||
import org.apache.cordova.LOG;
|
||||
import org.apache.cordova.PluginResult;
|
||||
import org.apache.cordova.CordovaActivity;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
@SuppressLint("SetJavaScriptEnabled")
|
||||
public class InAppBrowser extends CordovaPlugin {
|
||||
|
||||
private static final String NULL = "null";
|
||||
protected static final String LOG_TAG = "InAppBrowser";
|
||||
private static final String SELF = "_self";
|
||||
private static final String SYSTEM = "_system";
|
||||
// private static final String BLANK = "_blank";
|
||||
private static final String EXIT_EVENT = "exit";
|
||||
private static final String LOCATION = "location";
|
||||
private static final String HIDDEN = "hidden";
|
||||
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 CLOSE_BUTTON_CAPTION = "closebuttoncaption";
|
||||
private static final String CLEAR_ALL_CACHE = "clearcache";
|
||||
private static final String CLEAR_SESSION_CACHE = "clearsessioncache";
|
||||
|
||||
private Dialog dialog;
|
||||
private AmazonWebView inAppWebView;
|
||||
private EditText edittext;
|
||||
private CallbackContext callbackContext;
|
||||
private boolean showLocationBar = true;
|
||||
private boolean openWindowHidden = false;
|
||||
private String buttonLabel = "Done";
|
||||
private boolean clearAllCache= false;
|
||||
private boolean clearSessionCache=false;
|
||||
|
||||
/**
|
||||
* Executes the request and returns PluginResult.
|
||||
*
|
||||
* @param action The action to execute.
|
||||
* @param args JSONArry of arguments for the plugin.
|
||||
* @param callbackId The callback id used when calling back into JavaScript.
|
||||
* @return A PluginResult object with a status and message.
|
||||
*/
|
||||
public boolean execute(String action, CordovaArgs args, final CallbackContext callbackContext) throws JSONException {
|
||||
if (action.equals("open")) {
|
||||
this.callbackContext = callbackContext;
|
||||
final String url = args.getString(0);
|
||||
String t = args.optString(1);
|
||||
if (t == null || t.equals("") || t.equals(NULL)) {
|
||||
t = SELF;
|
||||
}
|
||||
final String target = t;
|
||||
final HashMap<String, Boolean> features = parseFeature(args.optString(2));
|
||||
|
||||
Log.d(LOG_TAG, "target = " + target);
|
||||
|
||||
this.cordova.getActivity().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
String result = "";
|
||||
// SELF
|
||||
if (SELF.equals(target)) {
|
||||
Log.d(LOG_TAG, "in self");
|
||||
// load in webview
|
||||
if (url.startsWith("file://") || url.startsWith("javascript:")
|
||||
|| Config.isUrlWhiteListed(url)) {
|
||||
webView.loadUrl(url);
|
||||
}
|
||||
//Load the dialer
|
||||
else if (url.startsWith(AmazonWebView.SCHEME_TEL))
|
||||
{
|
||||
try {
|
||||
Intent intent = new Intent(Intent.ACTION_DIAL);
|
||||
intent.setData(Uri.parse(url));
|
||||
cordova.getActivity().startActivity(intent);
|
||||
} catch (android.content.ActivityNotFoundException e) {
|
||||
LOG.e(LOG_TAG, "Error dialing " + url + ": " + e.toString());
|
||||
}
|
||||
}
|
||||
// load in InAppBrowser
|
||||
else {
|
||||
result = showWebPage(url, features);
|
||||
}
|
||||
}
|
||||
// SYSTEM
|
||||
else if (SYSTEM.equals(target)) {
|
||||
Log.d(LOG_TAG, "in system");
|
||||
result = openExternal(url);
|
||||
}
|
||||
// BLANK - or anything else
|
||||
else {
|
||||
Log.d(LOG_TAG, "in blank");
|
||||
result = showWebPage(url, features);
|
||||
}
|
||||
|
||||
PluginResult pluginResult = new PluginResult(PluginResult.Status.OK, result);
|
||||
pluginResult.setKeepCallback(true);
|
||||
callbackContext.sendPluginResult(pluginResult);
|
||||
}
|
||||
});
|
||||
}
|
||||
else if (action.equals("close")) {
|
||||
closeDialog();
|
||||
}
|
||||
else if (action.equals("injectScriptCode")) {
|
||||
String jsWrapper = null;
|
||||
if (args.getBoolean(1)) {
|
||||
jsWrapper = String.format("prompt(JSON.stringify([eval(%%s)]), 'gap-iab://%s')", callbackContext.getCallbackId());
|
||||
}
|
||||
injectDeferredObject(args.getString(0), jsWrapper);
|
||||
}
|
||||
else if (action.equals("injectScriptFile")) {
|
||||
String jsWrapper;
|
||||
if (args.getBoolean(1)) {
|
||||
jsWrapper = String.format("(function(d) { var c = d.createElement('script'); c.src = %%s; c.onload = function() { prompt('', 'gap-iab://%s'); }; d.body.appendChild(c); })(document)", callbackContext.getCallbackId());
|
||||
} else {
|
||||
jsWrapper = "(function(d) { var c = d.createElement('script'); c.src = %s; d.body.appendChild(c); })(document)";
|
||||
}
|
||||
injectDeferredObject(args.getString(0), jsWrapper);
|
||||
}
|
||||
else if (action.equals("injectStyleCode")) {
|
||||
String jsWrapper;
|
||||
if (args.getBoolean(1)) {
|
||||
jsWrapper = String.format("(function(d) { var c = d.createElement('style'); c.innerHTML = %%s; d.body.appendChild(c); prompt('', 'gap-iab://%s');})(document)", callbackContext.getCallbackId());
|
||||
} else {
|
||||
jsWrapper = "(function(d) { var c = d.createElement('style'); c.innerHTML = %s; d.body.appendChild(c); })(document)";
|
||||
}
|
||||
injectDeferredObject(args.getString(0), jsWrapper);
|
||||
}
|
||||
else if (action.equals("injectStyleFile")) {
|
||||
String jsWrapper;
|
||||
if (args.getBoolean(1)) {
|
||||
jsWrapper = String.format("(function(d) { var c = d.createElement('link'); c.rel='stylesheet'; c.type='text/css'; c.href = %%s; d.head.appendChild(c); prompt('', 'gap-iab://%s');})(document)", callbackContext.getCallbackId());
|
||||
} else {
|
||||
jsWrapper = "(function(d) { var c = d.createElement('link'); c.rel='stylesheet'; c.type='text/css'; c.href = %s; d.head.appendChild(c); })(document)";
|
||||
}
|
||||
injectDeferredObject(args.getString(0), jsWrapper);
|
||||
}
|
||||
else if (action.equals("show")) {
|
||||
this.cordova.getActivity().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
dialog.show();
|
||||
}
|
||||
});
|
||||
PluginResult pluginResult = new PluginResult(PluginResult.Status.OK);
|
||||
pluginResult.setKeepCallback(true);
|
||||
this.callbackContext.sendPluginResult(pluginResult);
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the view navigates.
|
||||
*/
|
||||
@Override
|
||||
public void onReset() {
|
||||
closeDialog();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called by AccelBroker when listener is to be shut down.
|
||||
* Stop listener.
|
||||
*/
|
||||
public void onDestroy() {
|
||||
closeDialog();
|
||||
}
|
||||
|
||||
/**
|
||||
* Inject an object (script or style) into the InAppBrowser AmazonWebView.
|
||||
*
|
||||
* This is a helper method for the inject{Script|Style}{Code|File} API calls, which
|
||||
* provides a consistent method for injecting JavaScript code into the document.
|
||||
*
|
||||
* If a wrapper string is supplied, then the source string will be JSON-encoded (adding
|
||||
* quotes) and wrapped using string formatting. (The wrapper string should have a single
|
||||
* '%s' marker)
|
||||
*
|
||||
* @param source The source object (filename or script/style text) to inject into
|
||||
* the document.
|
||||
* @param jsWrapper A JavaScript string to wrap the source string in, so that the object
|
||||
* is properly injected, or null if the source string is JavaScript text
|
||||
* which should be executed directly.
|
||||
*/
|
||||
private void injectDeferredObject(String source, String jsWrapper) {
|
||||
final String scriptToInject;
|
||||
if (jsWrapper != null) {
|
||||
org.json.JSONArray jsonEsc = new org.json.JSONArray();
|
||||
jsonEsc.put(source);
|
||||
String jsonRepr = jsonEsc.toString();
|
||||
String jsonSourceString = jsonRepr.substring(1, jsonRepr.length()-1);
|
||||
scriptToInject = String.format(jsWrapper, jsonSourceString);
|
||||
} else {
|
||||
scriptToInject = source;
|
||||
}
|
||||
final String finalScriptToInject = scriptToInject;
|
||||
// This action will have the side-effect of blurring the currently focused element
|
||||
this.cordova.getActivity().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
inAppWebView.loadUrl("javascript:" + finalScriptToInject);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Put the list of features into a hash map
|
||||
*
|
||||
* @param optString
|
||||
* @return
|
||||
*/
|
||||
private HashMap<String, Boolean> parseFeature(String optString) {
|
||||
if (optString.equals(NULL)) {
|
||||
return null;
|
||||
} else {
|
||||
HashMap<String, Boolean> map = new HashMap<String, Boolean>();
|
||||
StringTokenizer features = new StringTokenizer(optString, ",");
|
||||
StringTokenizer option;
|
||||
while(features.hasMoreElements()) {
|
||||
option = new StringTokenizer(features.nextToken(), "=");
|
||||
if (option.hasMoreElements()) {
|
||||
String key = option.nextToken();
|
||||
if (key.equalsIgnoreCase(CLOSE_BUTTON_CAPTION)) {
|
||||
this.buttonLabel = option.nextToken();
|
||||
} else {
|
||||
Boolean value = option.nextToken().equals("no") ? Boolean.FALSE : Boolean.TRUE;
|
||||
map.put(key, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a new browser with the specified URL.
|
||||
*
|
||||
* @param url The url to load.
|
||||
* @param usePhoneGap Load url in PhoneGap webview
|
||||
* @return "" if ok, or error message.
|
||||
*/
|
||||
public String openExternal(String url) {
|
||||
try {
|
||||
Intent intent = null;
|
||||
intent = new Intent(Intent.ACTION_VIEW);
|
||||
intent.setData(Uri.parse(url));
|
||||
this.cordova.getActivity().startActivity(intent);
|
||||
return "";
|
||||
} catch (android.content.ActivityNotFoundException e) {
|
||||
Log.d(LOG_TAG, "InAppBrowser: Error loading url "+url+":"+ e.toString());
|
||||
return e.toString();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes the dialog
|
||||
*/
|
||||
public void closeDialog() {
|
||||
this.cordova.getActivity().runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
if (dialog != null) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if it is possible to go back one page in history, then does so.
|
||||
*/
|
||||
private void goBack() {
|
||||
this.cordova.getActivity().runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
if (InAppBrowser.this.inAppWebView.canGoBack()) {
|
||||
InAppBrowser.this.inAppWebView.goBack();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if it is possible to go forward one page in history, then does so.
|
||||
*/
|
||||
private void goForward() {
|
||||
this.cordova.getActivity().runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
if (InAppBrowser.this.inAppWebView.canGoForward()) {
|
||||
InAppBrowser.this.inAppWebView.goForward();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Navigate to the new page
|
||||
*
|
||||
* @param url to load
|
||||
*/
|
||||
private void navigate(final String url) {
|
||||
InputMethodManager imm = (InputMethodManager)this.cordova.getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
imm.hideSoftInputFromWindow(edittext.getWindowToken(), 0);
|
||||
|
||||
this.cordova.getActivity().runOnUiThread(new Runnable() {
|
||||
public void run() {
|
||||
if (!url.startsWith("http") && !url.startsWith("file:")) {
|
||||
InAppBrowser.this.inAppWebView.loadUrl("http://" + url);
|
||||
} else {
|
||||
InAppBrowser.this.inAppWebView.loadUrl(url);
|
||||
}
|
||||
InAppBrowser.this.inAppWebView.requestFocus();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Should we show the location bar?
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
private boolean getShowLocationBar() {
|
||||
return this.showLocationBar;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a new browser with the specified URL.
|
||||
*
|
||||
* @param url The url to load.
|
||||
* @param jsonObject
|
||||
*/
|
||||
public String showWebPage(final String url, HashMap<String, Boolean> features) {
|
||||
// Determine if we should hide the location bar.
|
||||
showLocationBar = true;
|
||||
openWindowHidden = false;
|
||||
if (features != null) {
|
||||
Boolean show = features.get(LOCATION);
|
||||
if (show != null) {
|
||||
showLocationBar = show.booleanValue();
|
||||
}
|
||||
Boolean hidden = features.get(HIDDEN);
|
||||
if (hidden != null) {
|
||||
openWindowHidden = hidden.booleanValue();
|
||||
}
|
||||
Boolean cache = features.get(CLEAR_ALL_CACHE);
|
||||
if (cache != null) {
|
||||
clearAllCache = cache.booleanValue();
|
||||
} else {
|
||||
cache = features.get(CLEAR_SESSION_CACHE);
|
||||
if (cache != null) {
|
||||
clearSessionCache = cache.booleanValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final CordovaWebView thatWebView = this.webView;
|
||||
|
||||
// Create dialog in new thread
|
||||
Runnable runnable = new Runnable() {
|
||||
/**
|
||||
* Convert our DIP units to Pixels
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
private int dpToPixels(int dipValue) {
|
||||
int value = (int) TypedValue.applyDimension( TypedValue.COMPLEX_UNIT_DIP,
|
||||
(float) dipValue,
|
||||
cordova.getActivity().getResources().getDisplayMetrics()
|
||||
);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
// Let's create the main dialog
|
||||
dialog = new Dialog(cordova.getActivity(), android.R.style.Theme_NoTitleBar);
|
||||
dialog.getWindow().getAttributes().windowAnimations = android.R.style.Animation_Dialog;
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
dialog.setCancelable(true);
|
||||
dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
|
||||
public void onDismiss(DialogInterface dialog) {
|
||||
closeDialog();
|
||||
}
|
||||
});
|
||||
|
||||
// Main container layout
|
||||
LinearLayout main = new LinearLayout(cordova.getActivity());
|
||||
main.setOrientation(LinearLayout.VERTICAL);
|
||||
|
||||
// Toolbar layout
|
||||
RelativeLayout toolbar = new RelativeLayout(cordova.getActivity());
|
||||
//Please, no more black!
|
||||
toolbar.setBackgroundColor(android.graphics.Color.LTGRAY);
|
||||
toolbar.setLayoutParams(new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, this.dpToPixels(44)));
|
||||
toolbar.setPadding(this.dpToPixels(2), this.dpToPixels(2), this.dpToPixels(2), this.dpToPixels(2));
|
||||
toolbar.setHorizontalGravity(Gravity.LEFT);
|
||||
toolbar.setVerticalGravity(Gravity.TOP);
|
||||
|
||||
// Action Button Container layout
|
||||
RelativeLayout actionButtonContainer = new RelativeLayout(cordova.getActivity());
|
||||
actionButtonContainer.setLayoutParams(new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
|
||||
actionButtonContainer.setHorizontalGravity(Gravity.LEFT);
|
||||
actionButtonContainer.setVerticalGravity(Gravity.CENTER_VERTICAL);
|
||||
actionButtonContainer.setId(1);
|
||||
|
||||
// Back button
|
||||
Button back = new Button(cordova.getActivity());
|
||||
RelativeLayout.LayoutParams backLayoutParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
|
||||
backLayoutParams.addRule(RelativeLayout.ALIGN_LEFT);
|
||||
back.setLayoutParams(backLayoutParams);
|
||||
back.setContentDescription("Back Button");
|
||||
back.setId(2);
|
||||
back.setText("<");
|
||||
back.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
goBack();
|
||||
}
|
||||
});
|
||||
|
||||
// Forward button
|
||||
Button forward = new Button(cordova.getActivity());
|
||||
RelativeLayout.LayoutParams forwardLayoutParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
|
||||
forwardLayoutParams.addRule(RelativeLayout.RIGHT_OF, 2);
|
||||
forward.setLayoutParams(forwardLayoutParams);
|
||||
forward.setContentDescription("Forward Button");
|
||||
forward.setId(3);
|
||||
forward.setText(">");
|
||||
forward.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
goForward();
|
||||
}
|
||||
});
|
||||
|
||||
// Edit Text Box
|
||||
edittext = new EditText(cordova.getActivity());
|
||||
RelativeLayout.LayoutParams textLayoutParams = new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
|
||||
textLayoutParams.addRule(RelativeLayout.RIGHT_OF, 1);
|
||||
textLayoutParams.addRule(RelativeLayout.LEFT_OF, 5);
|
||||
edittext.setLayoutParams(textLayoutParams);
|
||||
edittext.setId(4);
|
||||
edittext.setSingleLine(true);
|
||||
edittext.setText(url);
|
||||
edittext.setInputType(InputType.TYPE_TEXT_VARIATION_URI);
|
||||
edittext.setImeOptions(EditorInfo.IME_ACTION_GO);
|
||||
edittext.setInputType(InputType.TYPE_NULL); // Will not except input... Makes the text NON-EDITABLE
|
||||
edittext.setOnKeyListener(new View.OnKeyListener() {
|
||||
public boolean onKey(View v, int keyCode, KeyEvent event) {
|
||||
// If the event is a key-down event on the "enter" button
|
||||
if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) {
|
||||
navigate(edittext.getText().toString());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
// Close button
|
||||
Button close = new Button(cordova.getActivity());
|
||||
RelativeLayout.LayoutParams closeLayoutParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
|
||||
closeLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
|
||||
close.setLayoutParams(closeLayoutParams);
|
||||
forward.setContentDescription("Close Button");
|
||||
close.setId(5);
|
||||
close.setText(buttonLabel);
|
||||
close.setOnClickListener(new View.OnClickListener() {
|
||||
public void onClick(View v) {
|
||||
closeDialog();
|
||||
}
|
||||
});
|
||||
|
||||
// WebView
|
||||
inAppWebView = new AmazonWebView(cordova.getActivity());
|
||||
|
||||
CordovaActivity app = (CordovaActivity) cordova.getActivity();
|
||||
cordova.getFactory().initializeWebView(inAppWebView, 0x00FF00, false, null);
|
||||
|
||||
inAppWebView.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
|
||||
inAppWebView.setWebChromeClient(new InAppChromeClient(thatWebView));
|
||||
AmazonWebViewClient client = new InAppBrowserClient(thatWebView, edittext);
|
||||
inAppWebView.setWebViewClient(client);
|
||||
AmazonWebSettings settings = inAppWebView.getSettings();
|
||||
settings.setJavaScriptEnabled(true);
|
||||
settings.setJavaScriptCanOpenWindowsAutomatically(true);
|
||||
settings.setBuiltInZoomControls(true);
|
||||
settings.setPluginState(com.amazon.android.webkit.AmazonWebSettings.PluginState.ON);
|
||||
|
||||
//Toggle whether this is enabled or not!
|
||||
Bundle appSettings = cordova.getActivity().getIntent().getExtras();
|
||||
boolean enableDatabase = appSettings == null ? true : appSettings.getBoolean("InAppBrowserStorageEnabled", true);
|
||||
if (enableDatabase) {
|
||||
String databasePath = cordova.getActivity().getApplicationContext().getDir("inAppBrowserDB", Context.MODE_PRIVATE).getPath();
|
||||
settings.setDatabasePath(databasePath);
|
||||
settings.setDatabaseEnabled(true);
|
||||
}
|
||||
settings.setDomStorageEnabled(true);
|
||||
|
||||
if (clearAllCache) {
|
||||
AmazonCookieManager.getInstance().removeAllCookie();
|
||||
} else if (clearSessionCache) {
|
||||
AmazonCookieManager.getInstance().removeSessionCookie();
|
||||
}
|
||||
|
||||
inAppWebView.loadUrl(url);
|
||||
inAppWebView.setId(6);
|
||||
inAppWebView.getSettings().setLoadWithOverviewMode(true);
|
||||
inAppWebView.getSettings().setUseWideViewPort(true);
|
||||
inAppWebView.requestFocus();
|
||||
inAppWebView.requestFocusFromTouch();
|
||||
|
||||
// Add the back and forward buttons to our action button container layout
|
||||
actionButtonContainer.addView(back);
|
||||
actionButtonContainer.addView(forward);
|
||||
|
||||
// Add the views to our toolbar
|
||||
toolbar.addView(actionButtonContainer);
|
||||
toolbar.addView(edittext);
|
||||
toolbar.addView(close);
|
||||
|
||||
// Don't add the toolbar if its been disabled
|
||||
if (getShowLocationBar()) {
|
||||
// Add our toolbar to our main view/layout
|
||||
main.addView(toolbar);
|
||||
}
|
||||
|
||||
// Add our webview to our main view/layout
|
||||
main.addView(inAppWebView);
|
||||
|
||||
WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
|
||||
lp.copyFrom(dialog.getWindow().getAttributes());
|
||||
lp.width = WindowManager.LayoutParams.MATCH_PARENT;
|
||||
lp.height = WindowManager.LayoutParams.MATCH_PARENT;
|
||||
|
||||
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) {
|
||||
dialog.hide();
|
||||
}
|
||||
}
|
||||
};
|
||||
this.cordova.getActivity().runOnUiThread(runnable);
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new plugin success result and send it back to JavaScript
|
||||
*
|
||||
* @param obj a JSONObject contain event payload information
|
||||
*/
|
||||
private void sendUpdate(JSONObject obj, boolean keepCallback) {
|
||||
sendUpdate(obj, keepCallback, PluginResult.Status.OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new plugin result and send it back to JavaScript
|
||||
*
|
||||
* @param obj a JSONObject contain event payload information
|
||||
* @param status the status code to return to the JavaScript environment
|
||||
*/
|
||||
private void sendUpdate(JSONObject obj, boolean keepCallback, PluginResult.Status status) {
|
||||
if (callbackContext != null) {
|
||||
PluginResult result = new PluginResult(status, obj);
|
||||
result.setKeepCallback(keepCallback);
|
||||
callbackContext.sendPluginResult(result);
|
||||
if (!keepCallback) {
|
||||
callbackContext = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* The webview client receives notifications about appView
|
||||
*/
|
||||
public class InAppBrowserClient extends AmazonWebViewClient {
|
||||
EditText edittext;
|
||||
CordovaWebView webView;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param mContext
|
||||
* @param edittext
|
||||
*/
|
||||
public InAppBrowserClient(CordovaWebView webView, EditText mEditText) {
|
||||
this.webView = webView;
|
||||
this.edittext = mEditText;
|
||||
}
|
||||
|
||||
/**
|
||||
* Notify the host application that a page has started loading.
|
||||
*
|
||||
* @param view The webview initiating the callback.
|
||||
* @param url The url of the page.
|
||||
*/
|
||||
@Override
|
||||
public void onPageStarted(AmazonWebView view, String url, Bitmap favicon) {
|
||||
super.onPageStarted(view, url, favicon);
|
||||
String newloc = "";
|
||||
if (url.startsWith("http:") || url.startsWith("https:") || url.startsWith("file:")) {
|
||||
newloc = url;
|
||||
}
|
||||
// If dialing phone (tel:5551212)
|
||||
else if (url.startsWith(AmazonWebView.SCHEME_TEL)) {
|
||||
try {
|
||||
Intent intent = new Intent(Intent.ACTION_DIAL);
|
||||
intent.setData(Uri.parse(url));
|
||||
cordova.getActivity().startActivity(intent);
|
||||
} catch (android.content.ActivityNotFoundException e) {
|
||||
LOG.e(LOG_TAG, "Error dialing " + url + ": " + e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
else if (url.startsWith("geo:") || url.startsWith(AmazonWebView.SCHEME_MAILTO) || url.startsWith("market:")) {
|
||||
try {
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||
intent.setData(Uri.parse(url));
|
||||
cordova.getActivity().startActivity(intent);
|
||||
} catch (android.content.ActivityNotFoundException e) {
|
||||
LOG.e(LOG_TAG, "Error with " + url + ": " + e.toString());
|
||||
}
|
||||
}
|
||||
// If sms:5551212?body=This is the message
|
||||
else if (url.startsWith("sms:")) {
|
||||
try {
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||
|
||||
// Get address
|
||||
String address = null;
|
||||
int parmIndex = url.indexOf('?');
|
||||
if (parmIndex == -1) {
|
||||
address = url.substring(4);
|
||||
}
|
||||
else {
|
||||
address = url.substring(4, parmIndex);
|
||||
|
||||
// If body, then set sms body
|
||||
Uri uri = Uri.parse(url);
|
||||
String query = uri.getQuery();
|
||||
if (query != null) {
|
||||
if (query.startsWith("body=")) {
|
||||
intent.putExtra("sms_body", query.substring(5));
|
||||
}
|
||||
}
|
||||
}
|
||||
intent.setData(Uri.parse("sms:" + address));
|
||||
intent.putExtra("address", address);
|
||||
intent.setType("vnd.android-dir/mms-sms");
|
||||
cordova.getActivity().startActivity(intent);
|
||||
} catch (android.content.ActivityNotFoundException e) {
|
||||
LOG.e(LOG_TAG, "Error sending sms " + url + ":" + e.toString());
|
||||
}
|
||||
}
|
||||
else {
|
||||
newloc = "http://" + url;
|
||||
}
|
||||
|
||||
if (!newloc.equals(edittext.getText().toString())) {
|
||||
edittext.setText(newloc);
|
||||
}
|
||||
|
||||
try {
|
||||
JSONObject obj = new JSONObject();
|
||||
obj.put("type", LOAD_START_EVENT);
|
||||
obj.put("url", newloc);
|
||||
|
||||
sendUpdate(obj, true);
|
||||
} catch (JSONException ex) {
|
||||
Log.d(LOG_TAG, "Should never happen");
|
||||
}
|
||||
}
|
||||
|
||||
public void onPageFinished(AmazonWebView view, String url) {
|
||||
super.onPageFinished(view, url);
|
||||
|
||||
try {
|
||||
JSONObject obj = new JSONObject();
|
||||
obj.put("type", LOAD_STOP_EVENT);
|
||||
obj.put("url", url);
|
||||
|
||||
sendUpdate(obj, true);
|
||||
} catch (JSONException ex) {
|
||||
Log.d(LOG_TAG, "Should never happen");
|
||||
}
|
||||
}
|
||||
|
||||
public void onReceivedError(AmazonWebView view, int errorCode, String description, String failingUrl) {
|
||||
super.onReceivedError(view, errorCode, description, failingUrl);
|
||||
|
||||
try {
|
||||
JSONObject obj = new JSONObject();
|
||||
obj.put("type", LOAD_ERROR_EVENT);
|
||||
obj.put("url", failingUrl);
|
||||
obj.put("code", errorCode);
|
||||
obj.put("message", description);
|
||||
|
||||
sendUpdate(obj, true, PluginResult.Status.ERROR);
|
||||
} catch (JSONException ex) {
|
||||
Log.d(LOG_TAG, "Should never happen");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,128 +0,0 @@
|
||||
package org.apache.cordova.inappbrowser;
|
||||
|
||||
import org.apache.cordova.CordovaWebView;
|
||||
import org.apache.cordova.LOG;
|
||||
import org.apache.cordova.PluginResult;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
|
||||
import com.amazon.android.webkit.AmazonWebChromeClient;
|
||||
import com.amazon.android.webkit.AmazonGeolocationPermissions.Callback;
|
||||
import com.amazon.android.webkit.AmazonJsPromptResult;
|
||||
import com.amazon.android.webkit.AmazonWebStorage;
|
||||
import com.amazon.android.webkit.AmazonWebView;
|
||||
import com.amazon.android.webkit.AmazonWebViewClient;
|
||||
|
||||
public class InAppChromeClient extends AmazonWebChromeClient {
|
||||
|
||||
private CordovaWebView webView;
|
||||
private String LOG_TAG = "InAppChromeClient";
|
||||
private long MAX_QUOTA = 100 * 1024 * 1024;
|
||||
|
||||
public InAppChromeClient(CordovaWebView webView) {
|
||||
super();
|
||||
this.webView = webView;
|
||||
}
|
||||
/**
|
||||
* Handle database quota exceeded notification.
|
||||
*
|
||||
* @param url
|
||||
* @param databaseIdentifier
|
||||
* @param currentQuota
|
||||
* @param estimatedSize
|
||||
* @param totalUsedQuota
|
||||
* @param quotaUpdater
|
||||
*/
|
||||
@Override
|
||||
public void onExceededDatabaseQuota(String url, String databaseIdentifier, long currentQuota, long estimatedSize,
|
||||
long totalUsedQuota, AmazonWebStorage.QuotaUpdater quotaUpdater)
|
||||
{
|
||||
LOG.d(LOG_TAG, "onExceededDatabaseQuota estimatedSize: %d currentQuota: %d totalUsedQuota: %d", estimatedSize, currentQuota, totalUsedQuota);
|
||||
|
||||
if (estimatedSize < MAX_QUOTA)
|
||||
{
|
||||
//increase for 1Mb
|
||||
long newQuota = estimatedSize;
|
||||
LOG.d(LOG_TAG, "calling quotaUpdater.updateQuota newQuota: %d", newQuota);
|
||||
quotaUpdater.updateQuota(newQuota);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Set the quota to whatever it is and force an error
|
||||
// TODO: get docs on how to handle this properly
|
||||
quotaUpdater.updateQuota(currentQuota);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Instructs the client to show a prompt to ask the user to set the Geolocation permission state for the specified origin.
|
||||
*
|
||||
* @param origin
|
||||
* @param callback
|
||||
*/
|
||||
@Override
|
||||
public void onGeolocationPermissionsShowPrompt(String origin, Callback callback) {
|
||||
super.onGeolocationPermissionsShowPrompt(origin, callback);
|
||||
callback.invoke(origin, true, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tell the client to display a prompt dialog to the user.
|
||||
* If the client returns true, WebView will assume that the client will
|
||||
* handle the prompt dialog and call the appropriate JsPromptResult method.
|
||||
*
|
||||
* The prompt bridge provided for the InAppBrowser is capable of executing any
|
||||
* oustanding callback belonging to the InAppBrowser plugin. Care has been
|
||||
* taken that other callbacks cannot be triggered, and that no other code
|
||||
* execution is possible.
|
||||
*
|
||||
* To trigger the bridge, the prompt default value should be of the form:
|
||||
*
|
||||
* gap-iab://<callbackId>
|
||||
*
|
||||
* where <callbackId> is the string id of the callback to trigger (something
|
||||
* like "InAppBrowser0123456789")
|
||||
*
|
||||
* If present, the prompt message is expected to be a JSON-encoded value to
|
||||
* pass to the callback. A JSON_EXCEPTION is returned if the JSON is invalid.
|
||||
*
|
||||
* @param view
|
||||
* @param url
|
||||
* @param message
|
||||
* @param defaultValue
|
||||
* @param result
|
||||
*/
|
||||
@Override
|
||||
public boolean onJsPrompt(AmazonWebView view, String url, String message, String defaultValue, AmazonJsPromptResult result) {
|
||||
// See if the prompt string uses the 'gap-iab' protocol. If so, the remainder should be the id of a callback to execute.
|
||||
if (defaultValue != null && defaultValue.startsWith("gap")) {
|
||||
if(defaultValue.startsWith("gap-iab://")) {
|
||||
PluginResult scriptResult;
|
||||
String scriptCallbackId = defaultValue.substring(10);
|
||||
if (scriptCallbackId.startsWith("InAppBrowser")) {
|
||||
if(message == null || message.length() == 0) {
|
||||
scriptResult = new PluginResult(PluginResult.Status.OK, new JSONArray());
|
||||
} else {
|
||||
try {
|
||||
scriptResult = new PluginResult(PluginResult.Status.OK, new JSONArray(message));
|
||||
} catch(JSONException e) {
|
||||
scriptResult = new PluginResult(PluginResult.Status.JSON_EXCEPTION, e.getMessage());
|
||||
}
|
||||
}
|
||||
this.webView.sendPluginResult(scriptResult, scriptCallbackId);
|
||||
result.confirm("");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Anything else with a gap: prefix should get this message
|
||||
LOG.w(LOG_TAG, "InAppBrowser does not support Cordova API calls: " + url + " " + defaultValue);
|
||||
result.cancel();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
57
src/android/InAppBrowserDialog.java
Normal file
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
*/
|
||||
package org.apache.cordova.inappbrowser;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
/**
|
||||
* Created by Oliver on 22/11/2013.
|
||||
*/
|
||||
public class InAppBrowserDialog extends Dialog {
|
||||
Context context;
|
||||
InAppBrowser inAppBrowser = null;
|
||||
|
||||
public InAppBrowserDialog(Context context, int theme) {
|
||||
super(context, theme);
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
public void setInAppBroswer(InAppBrowser browser) {
|
||||
this.inAppBrowser = browser;
|
||||
}
|
||||
|
||||
public void onBackPressed () {
|
||||
if (this.inAppBrowser == null) {
|
||||
this.dismiss();
|
||||
} else {
|
||||
// better to go through the in inAppBrowser
|
||||
// because it does a clean up
|
||||
if (this.inAppBrowser.hardwareBack() && this.inAppBrowser.canGoBack()) {
|
||||
this.inAppBrowser.goBack();
|
||||
} else {
|
||||
this.inAppBrowser.closeDialog();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,21 @@
|
||||
/*
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
*/
|
||||
package org.apache.cordova.inappbrowser;
|
||||
|
||||
import org.apache.cordova.CordovaWebView;
|
||||
@@ -38,20 +56,7 @@ public class InAppChromeClient extends WebChromeClient {
|
||||
long totalUsedQuota, WebStorage.QuotaUpdater quotaUpdater)
|
||||
{
|
||||
LOG.d(LOG_TAG, "onExceededDatabaseQuota estimatedSize: %d currentQuota: %d totalUsedQuota: %d", estimatedSize, currentQuota, totalUsedQuota);
|
||||
|
||||
if (estimatedSize < MAX_QUOTA)
|
||||
{
|
||||
//increase for 1Mb
|
||||
long newQuota = estimatedSize;
|
||||
LOG.d(LOG_TAG, "calling quotaUpdater.updateQuota newQuota: %d", newQuota);
|
||||
quotaUpdater.updateQuota(newQuota);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Set the quota to whatever it is and force an error
|
||||
// TODO: get docs on how to handle this properly
|
||||
quotaUpdater.updateQuota(currentQuota);
|
||||
}
|
||||
quotaUpdater.updateQuota(MAX_QUOTA);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -99,7 +104,7 @@ public class InAppChromeClient extends WebChromeClient {
|
||||
if(defaultValue.startsWith("gap-iab://")) {
|
||||
PluginResult scriptResult;
|
||||
String scriptCallbackId = defaultValue.substring(10);
|
||||
if (scriptCallbackId.startsWith("InAppBrowser")) {
|
||||
if (scriptCallbackId.matches("^InAppBrowser[0-9]{1,10}$")) {
|
||||
if(message == null || message.length() == 0) {
|
||||
scriptResult = new PluginResult(PluginResult.Status.OK, new JSONArray());
|
||||
} else {
|
||||
@@ -113,9 +118,14 @@ public class InAppChromeClient extends WebChromeClient {
|
||||
result.confirm("");
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
// Anything else that doesn't look like InAppBrowser0123456789 should end up here
|
||||
LOG.w(LOG_TAG, "InAppBrowser callback called with invalid callbackId : "+ scriptCallbackId);
|
||||
result.cancel();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
// Anything else with a gap: prefix should get this message
|
||||
LOG.w(LOG_TAG, "InAppBrowser does not support Cordova API calls: " + url + " " + defaultValue);
|
||||
result.cancel();
|
||||
|
||||
BIN
src/android/res/drawable-hdpi/ic_action_next_item.png
Normal file
|
After Width: | Height: | Size: 593 B |
BIN
src/android/res/drawable-hdpi/ic_action_previous_item.png
Normal file
|
After Width: | Height: | Size: 599 B |
BIN
src/android/res/drawable-hdpi/ic_action_remove.png
Normal file
|
After Width: | Height: | Size: 438 B |
BIN
src/android/res/drawable-mdpi/ic_action_next_item.png
Normal file
|
After Width: | Height: | Size: 427 B |
BIN
src/android/res/drawable-mdpi/ic_action_previous_item.png
Normal file
|
After Width: | Height: | Size: 438 B |
BIN
src/android/res/drawable-mdpi/ic_action_remove.png
Normal file
|
After Width: | Height: | Size: 328 B |
BIN
src/android/res/drawable-xhdpi/ic_action_next_item.png
Normal file
|
After Width: | Height: | Size: 727 B |
BIN
src/android/res/drawable-xhdpi/ic_action_previous_item.png
Normal file
|
After Width: | Height: | Size: 744 B |
BIN
src/android/res/drawable-xhdpi/ic_action_remove.png
Normal file
|
After Width: | Height: | Size: 536 B |
BIN
src/android/res/drawable-xxhdpi/ic_action_next_item.png
Normal file
|
After Width: | Height: | Size: 1021 B |
BIN
src/android/res/drawable-xxhdpi/ic_action_previous_item.png
Normal file
|
After Width: | Height: | Size: 1.0 KiB |
BIN
src/android/res/drawable-xxhdpi/ic_action_remove.png
Normal file
|
After Width: | Height: | Size: 681 B |
@@ -1,25 +0,0 @@
|
||||
# BlackBerry 10 In-App-Browser Plugin
|
||||
|
||||
The in app browser functionality is entirely contained within common js. There is no native implementation required.
|
||||
To install this plugin, follow the [Command-line Interface Guide](http://cordova.apache.org/docs/en/edge/guide_cli_index.md.html#The%20Command-line%20Interface).
|
||||
|
||||
If you are not using the Cordova Command-line Interface, follow [Using Plugman to Manage Plugins](http://cordova.apache.org/docs/en/edge/guide_plugin_ref_plugman.md.html).
|
||||
./cordova-plugin-battery-status/README.md
|
||||
./cordova-plugin-camera/README.md
|
||||
./cordova-plugin-console/README.md
|
||||
./cordova-plugin-contacts/README.md
|
||||
./cordova-plugin-device/README.md
|
||||
./cordova-plugin-device-motion/README.md
|
||||
./cordova-plugin-device-orientation/README.md
|
||||
./cordova-plugin-device-orientation/src/blackberry10/README.md
|
||||
./cordova-plugin-file/README.md
|
||||
./cordova-plugin-file-transfer/README.md
|
||||
./cordova-plugin-geolocation/README.md
|
||||
./cordova-plugin-globalization/README.md
|
||||
./cordova-plugin-inappbrowser/README.md
|
||||
./cordova-plugin-inappbrowser/src/blackberry10/README.md
|
||||
./cordova-plugin-media/README.md
|
||||
./cordova-plugin-media-capture/README.md
|
||||
./cordova-plugin-network-information/README.md
|
||||
./cordova-plugin-splashscreen/README.md
|
||||
./cordova-plugin-vibration/README.md
|
||||
247
src/browser/InAppBrowserProxy.js
Normal file
@@ -0,0 +1,247 @@
|
||||
/*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
var modulemapper = require('cordova/modulemapper');
|
||||
|
||||
var browserWrap,
|
||||
popup,
|
||||
navigationButtonsDiv,
|
||||
navigationButtonsDivInner,
|
||||
backButton,
|
||||
forwardButton,
|
||||
closeButton;
|
||||
|
||||
function attachNavigationEvents (element, callback) {
|
||||
var onError = function () {
|
||||
try {
|
||||
callback({ type: 'loaderror', url: this.contentWindow.location.href }, {keepCallback: true}); // eslint-disable-line standard/no-callback-literal
|
||||
} catch (err) {
|
||||
// blocked by CORS :\
|
||||
callback({ type: 'loaderror', url: null }, {keepCallback: true}); // eslint-disable-line standard/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
|
||||
} catch (err) {
|
||||
// blocked by CORS :\
|
||||
callback({ type: 'loadstart', url: null }, {keepCallback: true}); // eslint-disable-line standard/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
|
||||
} catch (err) {
|
||||
// blocked by CORS :\
|
||||
callback({ type: 'loadstop', url: null }, {keepCallback: true}); // eslint-disable-line standard/no-callback-literal
|
||||
}
|
||||
});
|
||||
|
||||
element.addEventListener('error', onError);
|
||||
element.addEventListener('abort', onError);
|
||||
}
|
||||
|
||||
var IAB = {
|
||||
close: function (win, lose) {
|
||||
if (browserWrap) {
|
||||
// use the "open" function callback so that the exit event is fired properly
|
||||
if (IAB._win) IAB._win({ type: 'exit' });
|
||||
|
||||
browserWrap.parentNode.removeChild(browserWrap);
|
||||
browserWrap = null;
|
||||
popup = null;
|
||||
}
|
||||
},
|
||||
|
||||
show: function (win, lose) {
|
||||
if (browserWrap) {
|
||||
browserWrap.style.display = 'block';
|
||||
}
|
||||
},
|
||||
|
||||
open: function (win, lose, args) {
|
||||
var strUrl = args[0];
|
||||
var target = args[1];
|
||||
var features = args[2];
|
||||
|
||||
IAB._win = win;
|
||||
|
||||
if (target === '_self' || !target) {
|
||||
window.location = strUrl;
|
||||
} else if (target === '_system') {
|
||||
modulemapper.getOriginalSymbol(window, 'window.open').call(window, strUrl, '_blank');
|
||||
} else {
|
||||
// "_blank" or anything else
|
||||
if (!browserWrap) {
|
||||
browserWrap = document.createElement('div');
|
||||
browserWrap.style.position = 'absolute';
|
||||
browserWrap.style.top = '0';
|
||||
browserWrap.style.left = '0';
|
||||
browserWrap.style.boxSizing = 'border-box';
|
||||
browserWrap.style.borderWidth = '40px';
|
||||
browserWrap.style.width = '100vw';
|
||||
browserWrap.style.height = '100vh';
|
||||
browserWrap.style.borderStyle = 'solid';
|
||||
browserWrap.style.borderColor = 'rgba(0,0,0,0.25)';
|
||||
|
||||
browserWrap.onclick = function () {
|
||||
setTimeout(function () {
|
||||
IAB.close();
|
||||
}, 0);
|
||||
};
|
||||
|
||||
document.body.appendChild(browserWrap);
|
||||
}
|
||||
|
||||
if (features.indexOf('hidden=yes') !== -1) {
|
||||
browserWrap.style.display = 'none';
|
||||
}
|
||||
|
||||
popup = document.createElement('iframe');
|
||||
popup.style.borderWidth = '0px';
|
||||
popup.style.width = '100%';
|
||||
|
||||
browserWrap.appendChild(popup);
|
||||
|
||||
if (features.indexOf('location=yes') !== -1 || features.indexOf('location') === -1) {
|
||||
popup.style.height = 'calc(100% - 60px)';
|
||||
popup.style.marginBottom = '-4px';
|
||||
|
||||
navigationButtonsDiv = document.createElement('div');
|
||||
navigationButtonsDiv.style.height = '60px';
|
||||
navigationButtonsDiv.style.backgroundColor = '#404040';
|
||||
navigationButtonsDiv.style.zIndex = '999';
|
||||
navigationButtonsDiv.onclick = function (e) {
|
||||
e.cancelBubble = true;
|
||||
};
|
||||
|
||||
navigationButtonsDivInner = document.createElement('div');
|
||||
navigationButtonsDivInner.style.paddingTop = '10px';
|
||||
navigationButtonsDivInner.style.height = '50px';
|
||||
navigationButtonsDivInner.style.width = '160px';
|
||||
navigationButtonsDivInner.style.margin = '0 auto';
|
||||
navigationButtonsDivInner.style.backgroundColor = '#404040';
|
||||
navigationButtonsDivInner.style.zIndex = '999';
|
||||
navigationButtonsDivInner.onclick = function (e) {
|
||||
e.cancelBubble = true;
|
||||
};
|
||||
|
||||
backButton = document.createElement('button');
|
||||
backButton.style.width = '40px';
|
||||
backButton.style.height = '40px';
|
||||
backButton.style.borderRadius = '40px';
|
||||
|
||||
backButton.innerHTML = '←';
|
||||
backButton.addEventListener('click', function (e) {
|
||||
if (popup.canGoBack) { popup.goBack(); }
|
||||
});
|
||||
|
||||
forwardButton = document.createElement('button');
|
||||
forwardButton.style.marginLeft = '20px';
|
||||
forwardButton.style.width = '40px';
|
||||
forwardButton.style.height = '40px';
|
||||
forwardButton.style.borderRadius = '40px';
|
||||
|
||||
forwardButton.innerHTML = '→';
|
||||
forwardButton.addEventListener('click', function (e) {
|
||||
if (popup.canGoForward) { popup.goForward(); }
|
||||
});
|
||||
|
||||
closeButton = document.createElement('button');
|
||||
closeButton.style.marginLeft = '20px';
|
||||
closeButton.style.width = '40px';
|
||||
closeButton.style.height = '40px';
|
||||
closeButton.style.borderRadius = '40px';
|
||||
|
||||
closeButton.innerHTML = '✖';
|
||||
closeButton.addEventListener('click', function (e) {
|
||||
setTimeout(function () {
|
||||
IAB.close();
|
||||
}, 0);
|
||||
});
|
||||
|
||||
// iframe navigation is not yet supported
|
||||
backButton.disabled = true;
|
||||
forwardButton.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, win);
|
||||
|
||||
popup.src = strUrl;
|
||||
}
|
||||
},
|
||||
|
||||
injectScriptCode: function (win, fail, args) {
|
||||
var code = args[0];
|
||||
var hasCallback = args[1];
|
||||
|
||||
if (browserWrap && popup) {
|
||||
try {
|
||||
popup.contentWindow.eval(code);
|
||||
if (hasCallback) {
|
||||
win([]);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Error occured while trying to injectScriptCode: ' + JSON.stringify(e));
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
injectScriptFile: function (win, fail, args) {
|
||||
var msg = 'Browser cordova-plugin-inappbrowser injectScriptFile is not yet implemented';
|
||||
console.warn(msg);
|
||||
if (fail) {
|
||||
fail(msg);
|
||||
}
|
||||
},
|
||||
|
||||
injectStyleCode: function (win, fail, args) {
|
||||
var msg = 'Browser cordova-plugin-inappbrowser injectStyleCode is not yet implemented';
|
||||
console.warn(msg);
|
||||
if (fail) {
|
||||
fail(msg);
|
||||
}
|
||||
},
|
||||
|
||||
injectStyleFile: function (win, fail, args) {
|
||||
var msg = 'Browser cordova-plugin-inappbrowser injectStyleFile is not yet implemented';
|
||||
console.warn(msg);
|
||||
if (fail) {
|
||||
fail(msg);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = IAB;
|
||||
|
||||
require('cordova/exec/proxy').add('InAppBrowser', module.exports);
|
||||
@@ -19,71 +19,18 @@
|
||||
|
||||
#import <Cordova/CDVPlugin.h>
|
||||
#import <Cordova/CDVInvokedUrlCommand.h>
|
||||
#import <Cordova/CDVScreenOrientationDelegate.h>
|
||||
#import <Cordova/CDVWebViewDelegate.h>
|
||||
|
||||
@class CDVInAppBrowserViewController;
|
||||
@interface CDVInAppBrowser : CDVPlugin {}
|
||||
|
||||
@interface CDVInAppBrowser : CDVPlugin {
|
||||
BOOL _injectedIframeBridge;
|
||||
}
|
||||
|
||||
@property (nonatomic, retain) CDVInAppBrowserViewController* inAppBrowserViewController;
|
||||
@property (nonatomic, copy) NSString* callbackId;
|
||||
@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
|
||||
|
||||
@interface CDVInAppBrowserViewController : UIViewController <UIWebViewDelegate>{
|
||||
@private
|
||||
NSString* _userAgent;
|
||||
NSString* _prevUserAgent;
|
||||
NSInteger _userAgentLockToken;
|
||||
CDVWebViewDelegate* _webViewDelegate;
|
||||
}
|
||||
|
||||
@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) CDVInAppBrowser* navigationDelegate;
|
||||
@property (nonatomic) NSURL* currentURL;
|
||||
|
||||
- (void)close;
|
||||
- (void)navigateTo:(NSURL*)url;
|
||||
- (void)showLocationBar:(BOOL)show;
|
||||
- (void)showToolBar:(BOOL)show;
|
||||
- (void)setCloseButtonTitle:(NSString*)title;
|
||||
|
||||
- (id)initWithUserAgent:(NSString*)userAgent prevUserAgent:(NSString*)prevUserAgent;
|
||||
|
||||
@end
|
||||
|
||||
@interface CDVInAppBrowserOptions : NSObject {}
|
||||
|
||||
@property (nonatomic, assign) BOOL location;
|
||||
@property (nonatomic, assign) BOOL toolbar;
|
||||
@property (nonatomic, copy) NSString* closebuttoncaption;
|
||||
|
||||
@property (nonatomic, copy) NSString* presentationstyle;
|
||||
@property (nonatomic, copy) NSString* transitionstyle;
|
||||
|
||||
@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;
|
||||
|
||||
+ (CDVInAppBrowserOptions*)parseOptions:(NSString*)options;
|
||||
|
||||
@end
|
||||
|
||||
@@ -18,849 +18,117 @@
|
||||
*/
|
||||
|
||||
#import "CDVInAppBrowser.h"
|
||||
#import "CDVInAppBrowserOptions.h"
|
||||
#import "CDVUIInAppBrowser.h"
|
||||
#import "CDVWKInAppBrowser.h"
|
||||
#import <Cordova/CDVPluginResult.h>
|
||||
#import <Cordova/CDVUserAgentUtil.h>
|
||||
#import <Cordova/CDVJSON.h>
|
||||
|
||||
#define kInAppBrowserTargetSelf @"_self"
|
||||
#define kInAppBrowserTargetSystem @"_system"
|
||||
#define kInAppBrowserTargetBlank @"_blank"
|
||||
|
||||
#define TOOLBAR_HEIGHT 44.0
|
||||
#define LOCATIONBAR_HEIGHT 21.0
|
||||
#define FOOTER_HEIGHT ((TOOLBAR_HEIGHT) + (LOCATIONBAR_HEIGHT))
|
||||
|
||||
#pragma mark CDVInAppBrowser
|
||||
|
||||
@interface CDVInAppBrowser () {
|
||||
UIStatusBarStyle _previousStatusBarStyle;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation CDVInAppBrowser
|
||||
|
||||
- (CDVInAppBrowser*)initWithWebView:(UIWebView*)theWebView
|
||||
- (void)pluginInitialize
|
||||
{
|
||||
self = [super initWithWebView:theWebView];
|
||||
if (self != nil) {
|
||||
// your initialization here
|
||||
}
|
||||
// default values
|
||||
self.usewkwebview = NO;
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)onReset
|
||||
{
|
||||
[self close:nil];
|
||||
}
|
||||
|
||||
- (void)close:(CDVInvokedUrlCommand*)command
|
||||
{
|
||||
// Things are cleaned up in browserExit.
|
||||
[self.inAppBrowserViewController close];
|
||||
}
|
||||
|
||||
- (BOOL) isSystemUrl:(NSURL*)url
|
||||
{
|
||||
if ([[url host] isEqualToString:@"itunes.apple.com"]) {
|
||||
return YES;
|
||||
}
|
||||
|
||||
return NO;
|
||||
#if __has_include("CDVWKWebViewEngine.h")
|
||||
self.wkwebviewavailable = YES;
|
||||
#else
|
||||
self.wkwebviewavailable = NO;
|
||||
#endif
|
||||
}
|
||||
|
||||
- (void)open:(CDVInvokedUrlCommand*)command
|
||||
{
|
||||
CDVPluginResult* pluginResult;
|
||||
|
||||
NSString* url = [command argumentAtIndex:0];
|
||||
NSString* target = [command argumentAtIndex:1 withDefault:kInAppBrowserTargetSelf];
|
||||
NSString* options = [command argumentAtIndex:2 withDefault:@"" andClass:[NSString class]];
|
||||
|
||||
self.callbackId = command.callbackId;
|
||||
|
||||
if (url != nil) {
|
||||
NSURL* baseUrl = [self.webView.request URL];
|
||||
NSURL* absoluteUrl = [[NSURL URLWithString:url relativeToURL:baseUrl] absoluteURL];
|
||||
|
||||
if ([self isSystemUrl:absoluteUrl]) {
|
||||
target = kInAppBrowserTargetSystem;
|
||||
}
|
||||
|
||||
if ([target isEqualToString:kInAppBrowserTargetSelf]) {
|
||||
[self openInCordovaWebView:absoluteUrl withOptions:options];
|
||||
} else if ([target isEqualToString:kInAppBrowserTargetSystem]) {
|
||||
[self openInSystem:absoluteUrl];
|
||||
} else { // _blank or anything else
|
||||
[self openInInAppBrowser:absoluteUrl withOptions:options];
|
||||
}
|
||||
|
||||
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
||||
} else {
|
||||
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"incorrect number of arguments"];
|
||||
}
|
||||
|
||||
[pluginResult setKeepCallback:[NSNumber numberWithBool:YES]];
|
||||
[self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
|
||||
}
|
||||
|
||||
- (void)openInInAppBrowser:(NSURL*)url withOptions:(NSString*)options
|
||||
{
|
||||
if (self.inAppBrowserViewController == nil) {
|
||||
NSString* originalUA = [CDVUserAgentUtil originalUserAgent];
|
||||
self.inAppBrowserViewController = [[CDVInAppBrowserViewController alloc] initWithUserAgent:originalUA prevUserAgent:[self.commandDelegate userAgent]];
|
||||
self.inAppBrowserViewController.navigationDelegate = self;
|
||||
|
||||
if ([self.viewController conformsToProtocol:@protocol(CDVScreenOrientationDelegate)]) {
|
||||
self.inAppBrowserViewController.orientationDelegate = (UIViewController <CDVScreenOrientationDelegate>*)self.viewController;
|
||||
}
|
||||
}
|
||||
|
||||
_previousStatusBarStyle = [UIApplication sharedApplication].statusBarStyle;
|
||||
|
||||
CDVInAppBrowserOptions* browserOptions = [CDVInAppBrowserOptions parseOptions:options];
|
||||
[self.inAppBrowserViewController showLocationBar:browserOptions.location];
|
||||
[self.inAppBrowserViewController showToolBar:browserOptions.toolbar];
|
||||
if (browserOptions.closebuttoncaption != nil) {
|
||||
[self.inAppBrowserViewController setCloseButtonTitle:browserOptions.closebuttoncaption];
|
||||
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;
|
||||
}
|
||||
// Set Presentation Style
|
||||
UIModalPresentationStyle presentationStyle = UIModalPresentationFullScreen; // default
|
||||
if (browserOptions.presentationstyle != nil) {
|
||||
if ([[browserOptions.presentationstyle lowercaseString] isEqualToString:@"pagesheet"]) {
|
||||
presentationStyle = UIModalPresentationPageSheet;
|
||||
} else if ([[browserOptions.presentationstyle lowercaseString] isEqualToString:@"formsheet"]) {
|
||||
presentationStyle = UIModalPresentationFormSheet;
|
||||
}
|
||||
self.usewkwebview = browserOptions.usewkwebview;
|
||||
if(self.usewkwebview){
|
||||
[[CDVWKInAppBrowser getInstance] open:command];
|
||||
}else{
|
||||
[[CDVUIInAppBrowser getInstance] open:command];
|
||||
}
|
||||
self.inAppBrowserViewController.modalPresentationStyle = presentationStyle;
|
||||
|
||||
// Set Transition Style
|
||||
UIModalTransitionStyle transitionStyle = UIModalTransitionStyleCoverVertical; // default
|
||||
if (browserOptions.transitionstyle != nil) {
|
||||
if ([[browserOptions.transitionstyle lowercaseString] isEqualToString:@"fliphorizontal"]) {
|
||||
transitionStyle = UIModalTransitionStyleFlipHorizontal;
|
||||
} else if ([[browserOptions.transitionstyle lowercaseString] isEqualToString:@"crossdissolve"]) {
|
||||
transitionStyle = UIModalTransitionStyleCrossDissolve;
|
||||
}
|
||||
}
|
||||
self.inAppBrowserViewController.modalTransitionStyle = transitionStyle;
|
||||
|
||||
|
||||
// UIWebView options
|
||||
self.inAppBrowserViewController.webView.scalesPageToFit = browserOptions.enableviewportscale;
|
||||
self.inAppBrowserViewController.webView.mediaPlaybackRequiresUserAction = browserOptions.mediaplaybackrequiresuseraction;
|
||||
self.inAppBrowserViewController.webView.allowsInlineMediaPlayback = browserOptions.allowinlinemediaplayback;
|
||||
if (IsAtLeastiOSVersion(@"6.0")) {
|
||||
self.inAppBrowserViewController.webView.keyboardDisplayRequiresUserAction = browserOptions.keyboarddisplayrequiresuseraction;
|
||||
self.inAppBrowserViewController.webView.suppressesIncrementalRendering = browserOptions.suppressesincrementalrendering;
|
||||
}
|
||||
|
||||
if (! browserOptions.hidden) {
|
||||
|
||||
UINavigationController* nav = [[UINavigationController alloc]
|
||||
initWithRootViewController:self.inAppBrowserViewController];
|
||||
nav.navigationBarHidden = YES;
|
||||
|
||||
if (self.viewController.modalViewController != self.inAppBrowserViewController) {
|
||||
[self.viewController presentModalViewController:nav animated:YES];
|
||||
}
|
||||
}
|
||||
[self.inAppBrowserViewController navigateTo:url];
|
||||
}
|
||||
|
||||
- (void)close:(CDVInvokedUrlCommand*)command
|
||||
{
|
||||
if(self.usewkwebview){
|
||||
[[CDVWKInAppBrowser getInstance] close:command];
|
||||
}else{
|
||||
[[CDVUIInAppBrowser getInstance] close:command];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
- (void)show:(CDVInvokedUrlCommand*)command
|
||||
{
|
||||
if ([self.inAppBrowserViewController isViewLoaded] && self.inAppBrowserViewController.view.window)
|
||||
return;
|
||||
|
||||
_previousStatusBarStyle = [UIApplication sharedApplication].statusBarStyle;
|
||||
|
||||
UINavigationController* nav = [[UINavigationController alloc]
|
||||
initWithRootViewController:self.inAppBrowserViewController];
|
||||
nav.navigationBarHidden = YES;
|
||||
[self.viewController presentModalViewController:nav animated:YES];
|
||||
if(self.usewkwebview){
|
||||
[[CDVWKInAppBrowser getInstance] show:command];
|
||||
}else{
|
||||
[[CDVUIInAppBrowser getInstance] show:command];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)openInCordovaWebView:(NSURL*)url withOptions:(NSString*)options
|
||||
- (void)hide:(CDVInvokedUrlCommand*)command
|
||||
{
|
||||
if ([self.commandDelegate URLIsWhitelisted:url]) {
|
||||
NSURLRequest* request = [NSURLRequest requestWithURL:url];
|
||||
[self.webView loadRequest:request];
|
||||
} else { // this assumes the InAppBrowser can be excepted from the white-list
|
||||
[self openInInAppBrowser:url withOptions:options];
|
||||
if(self.usewkwebview){
|
||||
[[CDVWKInAppBrowser getInstance] hide:command];
|
||||
}else{
|
||||
[[CDVUIInAppBrowser getInstance] hide:command];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)openInSystem:(NSURL*)url
|
||||
{
|
||||
if ([[UIApplication sharedApplication] canOpenURL:url]) {
|
||||
[[UIApplication sharedApplication] openURL:url];
|
||||
} else { // handle any custom schemes to plugins
|
||||
[[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:CDVPluginHandleOpenURLNotification object:url]];
|
||||
}
|
||||
}
|
||||
|
||||
// This is a helper method for the inject{Script|Style}{Code|File} API calls, which
|
||||
// provides a consistent method for injecting JavaScript code into the document.
|
||||
//
|
||||
// If a wrapper string is supplied, then the source string will be JSON-encoded (adding
|
||||
// quotes) and wrapped using string formatting. (The wrapper string should have a single
|
||||
// '%@' marker).
|
||||
//
|
||||
// If no wrapper is supplied, then the source string is executed directly.
|
||||
|
||||
- (void)injectDeferredObject:(NSString*)source withWrapper:(NSString*)jsWrapper
|
||||
{
|
||||
if (!_injectedIframeBridge) {
|
||||
_injectedIframeBridge = YES;
|
||||
// Create an iframe bridge in the new document to communicate with the CDVInAppBrowserViewController
|
||||
[self.inAppBrowserViewController.webView stringByEvaluatingJavaScriptFromString:@"(function(d){var e = _cdvIframeBridge = d.createElement('iframe');e.style.display='none';d.body.appendChild(e);})(document)"];
|
||||
}
|
||||
|
||||
if (jsWrapper != nil) {
|
||||
NSString* sourceArrayString = [@[source] JSONString];
|
||||
if (sourceArrayString) {
|
||||
NSString* sourceString = [sourceArrayString substringWithRange:NSMakeRange(1, [sourceArrayString length] - 2)];
|
||||
NSString* jsToInject = [NSString stringWithFormat:jsWrapper, sourceString];
|
||||
[self.inAppBrowserViewController.webView stringByEvaluatingJavaScriptFromString:jsToInject];
|
||||
}
|
||||
} else {
|
||||
[self.inAppBrowserViewController.webView stringByEvaluatingJavaScriptFromString:source];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)injectScriptCode:(CDVInvokedUrlCommand*)command
|
||||
{
|
||||
NSString* jsWrapper = nil;
|
||||
|
||||
if ((command.callbackId != nil) && ![command.callbackId isEqualToString:@"INVALID"]) {
|
||||
jsWrapper = [NSString stringWithFormat:@"_cdvIframeBridge.src='gap-iab://%@/'+window.escape(JSON.stringify([eval(%%@)]));", command.callbackId];
|
||||
if(self.usewkwebview){
|
||||
[[CDVWKInAppBrowser getInstance] injectScriptCode:command];
|
||||
}else{
|
||||
[[CDVUIInAppBrowser getInstance] injectScriptCode:command];
|
||||
}
|
||||
[self injectDeferredObject:[command argumentAtIndex:0] withWrapper:jsWrapper];
|
||||
}
|
||||
|
||||
- (void)injectScriptFile:(CDVInvokedUrlCommand*)command
|
||||
{
|
||||
NSString* jsWrapper;
|
||||
|
||||
if ((command.callbackId != nil) && ![command.callbackId isEqualToString:@"INVALID"]) {
|
||||
jsWrapper = [NSString stringWithFormat:@"(function(d) { var c = d.createElement('script'); c.src = %%@; c.onload = function() { _cdvIframeBridge.src='gap-iab://%@'; }; d.body.appendChild(c); })(document)", command.callbackId];
|
||||
} else {
|
||||
jsWrapper = @"(function(d) { var c = d.createElement('script'); c.src = %@; d.body.appendChild(c); })(document)";
|
||||
if(self.usewkwebview){
|
||||
[[CDVWKInAppBrowser getInstance] injectScriptFile:command];
|
||||
}else{
|
||||
[[CDVUIInAppBrowser getInstance] injectScriptFile:command];
|
||||
}
|
||||
[self injectDeferredObject:[command argumentAtIndex:0] withWrapper:jsWrapper];
|
||||
}
|
||||
|
||||
- (void)injectStyleCode:(CDVInvokedUrlCommand*)command
|
||||
{
|
||||
NSString* jsWrapper;
|
||||
|
||||
if ((command.callbackId != nil) && ![command.callbackId isEqualToString:@"INVALID"]) {
|
||||
jsWrapper = [NSString stringWithFormat:@"(function(d) { var c = d.createElement('style'); c.innerHTML = %%@; c.onload = function() { _cdvIframeBridge.src='gap-iab://%@'; }; d.body.appendChild(c); })(document)", command.callbackId];
|
||||
} else {
|
||||
jsWrapper = @"(function(d) { var c = d.createElement('style'); c.innerHTML = %@; d.body.appendChild(c); })(document)";
|
||||
if(self.usewkwebview){
|
||||
[[CDVWKInAppBrowser getInstance] injectStyleCode:command];
|
||||
}else{
|
||||
[[CDVUIInAppBrowser getInstance] injectStyleCode:command];
|
||||
}
|
||||
[self injectDeferredObject:[command argumentAtIndex:0] withWrapper:jsWrapper];
|
||||
}
|
||||
|
||||
- (void)injectStyleFile:(CDVInvokedUrlCommand*)command
|
||||
{
|
||||
NSString* jsWrapper;
|
||||
|
||||
if ((command.callbackId != nil) && ![command.callbackId isEqualToString:@"INVALID"]) {
|
||||
jsWrapper = [NSString stringWithFormat:@"(function(d) { var c = d.createElement('link'); c.rel='stylesheet'; c.type='text/css'; c.href = %%@; c.onload = function() { _cdvIframeBridge.src='gap-iab://%@'; }; d.body.appendChild(c); })(document)", command.callbackId];
|
||||
} else {
|
||||
jsWrapper = @"(function(d) { var c = d.createElement('link'); c.rel='stylesheet', c.type='text/css'; c.href = %@; d.body.appendChild(c); })(document)";
|
||||
if(self.usewkwebview){
|
||||
[[CDVWKInAppBrowser getInstance] injectStyleFile:command];
|
||||
}else{
|
||||
[[CDVUIInAppBrowser getInstance] injectStyleFile:command];
|
||||
}
|
||||
[self injectDeferredObject:[command argumentAtIndex:0] withWrapper:jsWrapper];
|
||||
}
|
||||
|
||||
/**
|
||||
* The iframe bridge provided for the InAppBrowser is capable of executing any oustanding callback belonging
|
||||
* to the InAppBrowser plugin. Care has been taken that other callbacks cannot be triggered, and that no
|
||||
* other code execution is possible.
|
||||
*
|
||||
* To trigger the bridge, the iframe (or any other resource) should attempt to load a url of the form:
|
||||
*
|
||||
* gap-iab://<callbackId>/<arguments>
|
||||
*
|
||||
* where <callbackId> is the string id of the callback to trigger (something like "InAppBrowser0123456789")
|
||||
*
|
||||
* If present, the path component of the special gap-iab:// url is expected to be a URL-escaped JSON-encoded
|
||||
* value to pass to the callback. [NSURL path] should take care of the URL-unescaping, and a JSON_EXCEPTION
|
||||
* is returned if the JSON is invalid.
|
||||
*/
|
||||
- (BOOL)webView:(UIWebView*)theWebView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType
|
||||
- (void)loadAfterBeforeload:(CDVInvokedUrlCommand*)command
|
||||
{
|
||||
NSURL* url = request.URL;
|
||||
BOOL isTopLevelNavigation = [request.URL isEqual:[request mainDocumentURL]];
|
||||
|
||||
// See if the url uses the 'gap-iab' protocol. If so, the host should be the id of a callback to execute,
|
||||
// and the path, if present, should be a JSON-encoded value to pass to the callback.
|
||||
if ([[url scheme] isEqualToString:@"gap-iab"]) {
|
||||
NSString* scriptCallbackId = [url host];
|
||||
CDVPluginResult* pluginResult = nil;
|
||||
|
||||
if ([scriptCallbackId hasPrefix:@"InAppBrowser"]) {
|
||||
NSString* scriptResult = [url path];
|
||||
NSError* __autoreleasing error = nil;
|
||||
|
||||
// The message should be a JSON-encoded array of the result of the script which executed.
|
||||
if ((scriptResult != nil) && ([scriptResult length] > 1)) {
|
||||
scriptResult = [scriptResult substringFromIndex:1];
|
||||
NSData* decodedResult = [NSJSONSerialization JSONObjectWithData:[scriptResult dataUsingEncoding:NSUTF8StringEncoding] options:kNilOptions error:&error];
|
||||
if ((error == nil) && [decodedResult isKindOfClass:[NSArray class]]) {
|
||||
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsArray:(NSArray*)decodedResult];
|
||||
} else {
|
||||
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_JSON_EXCEPTION];
|
||||
}
|
||||
} else {
|
||||
pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsArray:@[]];
|
||||
}
|
||||
[self.commandDelegate sendPluginResult:pluginResult callbackId:scriptCallbackId];
|
||||
return NO;
|
||||
}
|
||||
} else if ((self.callbackId != nil) && isTopLevelNavigation) {
|
||||
// Send a loadstart event for each top-level navigation (includes redirects).
|
||||
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK
|
||||
messageAsDictionary:@{@"type":@"loadstart", @"url":[url absoluteString]}];
|
||||
[pluginResult setKeepCallback:[NSNumber numberWithBool:YES]];
|
||||
|
||||
[self.commandDelegate sendPluginResult:pluginResult callbackId:self.callbackId];
|
||||
}
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)webViewDidStartLoad:(UIWebView*)theWebView
|
||||
{
|
||||
_injectedIframeBridge = NO;
|
||||
}
|
||||
|
||||
- (void)webViewDidFinishLoad:(UIWebView*)theWebView
|
||||
{
|
||||
if (self.callbackId != nil) {
|
||||
// TODO: It would be more useful to return the URL the page is actually on (e.g. if it's been redirected).
|
||||
NSString* url = [self.inAppBrowserViewController.currentURL absoluteString];
|
||||
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK
|
||||
messageAsDictionary:@{@"type":@"loadstop", @"url":url}];
|
||||
[pluginResult setKeepCallback:[NSNumber numberWithBool:YES]];
|
||||
|
||||
[self.commandDelegate sendPluginResult:pluginResult callbackId:self.callbackId];
|
||||
if(self.usewkwebview){
|
||||
[[CDVWKInAppBrowser getInstance] loadAfterBeforeload:command];
|
||||
}else{
|
||||
[[CDVUIInAppBrowser getInstance] loadAfterBeforeload:command];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)webView:(UIWebView*)theWebView didFailLoadWithError:(NSError*)error
|
||||
{
|
||||
if (self.callbackId != nil) {
|
||||
NSString* url = [self.inAppBrowserViewController.currentURL absoluteString];
|
||||
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR
|
||||
messageAsDictionary:@{@"type":@"loaderror", @"url":url, @"code": [NSNumber numberWithInt:error.code], @"message": error.localizedDescription}];
|
||||
[pluginResult setKeepCallback:[NSNumber numberWithBool:YES]];
|
||||
|
||||
[self.commandDelegate sendPluginResult:pluginResult callbackId:self.callbackId];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)browserExit
|
||||
{
|
||||
if (self.callbackId != nil) {
|
||||
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK
|
||||
messageAsDictionary:@{@"type":@"exit"}];
|
||||
[self.commandDelegate sendPluginResult:pluginResult callbackId:self.callbackId];
|
||||
self.callbackId = nil;
|
||||
}
|
||||
// Set navigationDelegate to nil to ensure no callbacks are received from it.
|
||||
self.inAppBrowserViewController.navigationDelegate = nil;
|
||||
// Don't recycle the ViewController since it may be consuming a lot of memory.
|
||||
// Also - this is required for the PDF/User-Agent bug work-around.
|
||||
self.inAppBrowserViewController = nil;
|
||||
|
||||
if (IsAtLeastiOSVersion(@"7.0")) {
|
||||
[[UIApplication sharedApplication] setStatusBarStyle:_previousStatusBarStyle];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark CDVInAppBrowserViewController
|
||||
|
||||
@implementation CDVInAppBrowserViewController
|
||||
|
||||
@synthesize currentURL;
|
||||
|
||||
- (id)initWithUserAgent:(NSString*)userAgent prevUserAgent:(NSString*)prevUserAgent
|
||||
{
|
||||
self = [super init];
|
||||
if (self != nil) {
|
||||
_userAgent = userAgent;
|
||||
_prevUserAgent = prevUserAgent;
|
||||
_webViewDelegate = [[CDVWebViewDelegate alloc] initWithDelegate:self];
|
||||
[self createViews];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)createViews
|
||||
{
|
||||
// We create the views in code for primarily for ease of upgrades and not requiring an external .xib to be included
|
||||
|
||||
CGRect webViewBounds = self.view.bounds;
|
||||
|
||||
webViewBounds.size.height -= FOOTER_HEIGHT;
|
||||
|
||||
self.webView = [[UIWebView alloc] initWithFrame:webViewBounds];
|
||||
self.webView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
|
||||
|
||||
[self.view addSubview:self.webView];
|
||||
[self.view sendSubviewToBack:self.webView];
|
||||
|
||||
self.webView.delegate = _webViewDelegate;
|
||||
self.webView.backgroundColor = [UIColor whiteColor];
|
||||
|
||||
self.webView.clearsContextBeforeDrawing = YES;
|
||||
self.webView.clipsToBounds = YES;
|
||||
self.webView.contentMode = UIViewContentModeScaleToFill;
|
||||
self.webView.contentStretch = CGRectFromString(@"{{0, 0}, {1, 1}}");
|
||||
self.webView.multipleTouchEnabled = YES;
|
||||
self.webView.opaque = YES;
|
||||
self.webView.scalesPageToFit = NO;
|
||||
self.webView.userInteractionEnabled = YES;
|
||||
|
||||
self.spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
|
||||
self.spinner.alpha = 1.000;
|
||||
self.spinner.autoresizesSubviews = YES;
|
||||
self.spinner.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleTopMargin;
|
||||
self.spinner.clearsContextBeforeDrawing = NO;
|
||||
self.spinner.clipsToBounds = NO;
|
||||
self.spinner.contentMode = UIViewContentModeScaleToFill;
|
||||
self.spinner.contentStretch = CGRectFromString(@"{{0, 0}, {1, 1}}");
|
||||
self.spinner.frame = CGRectMake(454.0, 231.0, 20.0, 20.0);
|
||||
self.spinner.hidden = YES;
|
||||
self.spinner.hidesWhenStopped = YES;
|
||||
self.spinner.multipleTouchEnabled = NO;
|
||||
self.spinner.opaque = NO;
|
||||
self.spinner.userInteractionEnabled = NO;
|
||||
[self.spinner stopAnimating];
|
||||
|
||||
self.closeButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(close)];
|
||||
self.closeButton.enabled = YES;
|
||||
|
||||
UIBarButtonItem* flexibleSpaceButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
|
||||
|
||||
UIBarButtonItem* fixedSpaceButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
|
||||
fixedSpaceButton.width = 20;
|
||||
|
||||
self.toolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0.0, (self.view.bounds.size.height - TOOLBAR_HEIGHT), self.view.bounds.size.width, TOOLBAR_HEIGHT)];
|
||||
self.toolbar.alpha = 1.000;
|
||||
self.toolbar.autoresizesSubviews = YES;
|
||||
self.toolbar.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin;
|
||||
self.toolbar.barStyle = UIBarStyleBlackOpaque;
|
||||
self.toolbar.clearsContextBeforeDrawing = NO;
|
||||
self.toolbar.clipsToBounds = NO;
|
||||
self.toolbar.contentMode = UIViewContentModeScaleToFill;
|
||||
self.toolbar.contentStretch = CGRectFromString(@"{{0, 0}, {1, 1}}");
|
||||
self.toolbar.hidden = NO;
|
||||
self.toolbar.multipleTouchEnabled = NO;
|
||||
self.toolbar.opaque = NO;
|
||||
self.toolbar.userInteractionEnabled = YES;
|
||||
|
||||
CGFloat labelInset = 5.0;
|
||||
self.addressLabel = [[UILabel alloc] initWithFrame:CGRectMake(labelInset, (self.view.bounds.size.height - FOOTER_HEIGHT), self.view.bounds.size.width - labelInset, LOCATIONBAR_HEIGHT)];
|
||||
self.addressLabel.adjustsFontSizeToFitWidth = NO;
|
||||
self.addressLabel.alpha = 1.000;
|
||||
self.addressLabel.autoresizesSubviews = YES;
|
||||
self.addressLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin;
|
||||
self.addressLabel.backgroundColor = [UIColor clearColor];
|
||||
self.addressLabel.baselineAdjustment = UIBaselineAdjustmentAlignCenters;
|
||||
self.addressLabel.clearsContextBeforeDrawing = YES;
|
||||
self.addressLabel.clipsToBounds = YES;
|
||||
self.addressLabel.contentMode = UIViewContentModeScaleToFill;
|
||||
self.addressLabel.contentStretch = CGRectFromString(@"{{0, 0}, {1, 1}}");
|
||||
self.addressLabel.enabled = YES;
|
||||
self.addressLabel.hidden = NO;
|
||||
self.addressLabel.lineBreakMode = UILineBreakModeTailTruncation;
|
||||
self.addressLabel.minimumFontSize = 10.000;
|
||||
self.addressLabel.multipleTouchEnabled = NO;
|
||||
self.addressLabel.numberOfLines = 1;
|
||||
self.addressLabel.opaque = NO;
|
||||
self.addressLabel.shadowOffset = CGSizeMake(0.0, -1.0);
|
||||
self.addressLabel.text = @"Loading...";
|
||||
self.addressLabel.textAlignment = UITextAlignmentLeft;
|
||||
self.addressLabel.textColor = [UIColor colorWithWhite:1.000 alpha:1.000];
|
||||
self.addressLabel.userInteractionEnabled = NO;
|
||||
|
||||
NSString* frontArrowString = @"►"; // create arrow from Unicode char
|
||||
self.forwardButton = [[UIBarButtonItem alloc] initWithTitle:frontArrowString style:UIBarButtonItemStylePlain target:self action:@selector(goForward:)];
|
||||
self.forwardButton.enabled = YES;
|
||||
self.forwardButton.imageInsets = UIEdgeInsetsZero;
|
||||
|
||||
NSString* backArrowString = @"◄"; // create arrow from Unicode char
|
||||
self.backButton = [[UIBarButtonItem alloc] initWithTitle:backArrowString style:UIBarButtonItemStylePlain target:self action:@selector(goBack:)];
|
||||
self.backButton.enabled = YES;
|
||||
self.backButton.imageInsets = UIEdgeInsetsZero;
|
||||
|
||||
[self.toolbar setItems:@[self.closeButton, flexibleSpaceButton, self.backButton, fixedSpaceButton, self.forwardButton]];
|
||||
|
||||
self.view.backgroundColor = [UIColor grayColor];
|
||||
[self.view addSubview:self.toolbar];
|
||||
[self.view addSubview:self.addressLabel];
|
||||
[self.view addSubview:self.spinner];
|
||||
}
|
||||
|
||||
- (void)setCloseButtonTitle:(NSString*)title
|
||||
{
|
||||
// the advantage of using UIBarButtonSystemItemDone is the system will localize it for you automatically
|
||||
// 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;
|
||||
self.closeButton = [[UIBarButtonItem alloc] initWithTitle:title style:UIBarButtonItemStyleBordered target:self action:@selector(close)];
|
||||
self.closeButton.enabled = YES;
|
||||
self.closeButton.tintColor = [UIColor colorWithRed:60.0 / 255.0 green:136.0 / 255.0 blue:230.0 / 255.0 alpha:1];
|
||||
|
||||
NSMutableArray* items = [self.toolbar.items mutableCopy];
|
||||
[items replaceObjectAtIndex:0 withObject:self.closeButton];
|
||||
[self.toolbar setItems:items];
|
||||
}
|
||||
|
||||
- (void)showLocationBar:(BOOL)show
|
||||
{
|
||||
CGRect locationbarFrame = self.addressLabel.frame;
|
||||
|
||||
BOOL toolbarVisible = !self.toolbar.hidden;
|
||||
|
||||
// prevent double show/hide
|
||||
if (show == !(self.addressLabel.hidden)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (show) {
|
||||
self.addressLabel.hidden = NO;
|
||||
|
||||
if (toolbarVisible) {
|
||||
// toolBar at the bottom, leave as is
|
||||
// put locationBar on top of the toolBar
|
||||
|
||||
CGRect webViewBounds = self.view.bounds;
|
||||
webViewBounds.size.height -= FOOTER_HEIGHT;
|
||||
self.webView.frame = webViewBounds;
|
||||
|
||||
locationbarFrame.origin.y = webViewBounds.size.height;
|
||||
self.addressLabel.frame = locationbarFrame;
|
||||
} else {
|
||||
// no toolBar, so put locationBar at the bottom
|
||||
|
||||
CGRect webViewBounds = self.view.bounds;
|
||||
webViewBounds.size.height -= LOCATIONBAR_HEIGHT;
|
||||
self.webView.frame = webViewBounds;
|
||||
|
||||
locationbarFrame.origin.y = webViewBounds.size.height;
|
||||
self.addressLabel.frame = locationbarFrame;
|
||||
}
|
||||
} else {
|
||||
self.addressLabel.hidden = YES;
|
||||
|
||||
if (toolbarVisible) {
|
||||
// locationBar is on top of toolBar, hide locationBar
|
||||
|
||||
// webView take up whole height less toolBar height
|
||||
CGRect webViewBounds = self.view.bounds;
|
||||
webViewBounds.size.height -= TOOLBAR_HEIGHT;
|
||||
self.webView.frame = webViewBounds;
|
||||
} else {
|
||||
// no toolBar, expand webView to screen dimensions
|
||||
|
||||
CGRect webViewBounds = self.view.bounds;
|
||||
self.webView.frame = webViewBounds;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)showToolBar:(BOOL)show
|
||||
{
|
||||
CGRect toolbarFrame = self.toolbar.frame;
|
||||
CGRect locationbarFrame = self.addressLabel.frame;
|
||||
|
||||
BOOL locationbarVisible = !self.addressLabel.hidden;
|
||||
|
||||
// prevent double show/hide
|
||||
if (show == !(self.toolbar.hidden)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (show) {
|
||||
self.toolbar.hidden = NO;
|
||||
|
||||
if (locationbarVisible) {
|
||||
// locationBar at the bottom, move locationBar up
|
||||
// put toolBar at the bottom
|
||||
|
||||
CGRect webViewBounds = self.view.bounds;
|
||||
webViewBounds.size.height -= FOOTER_HEIGHT;
|
||||
self.webView.frame = webViewBounds;
|
||||
|
||||
locationbarFrame.origin.y = webViewBounds.size.height;
|
||||
self.addressLabel.frame = locationbarFrame;
|
||||
|
||||
toolbarFrame.origin.y = (webViewBounds.size.height + LOCATIONBAR_HEIGHT);
|
||||
self.toolbar.frame = toolbarFrame;
|
||||
} else {
|
||||
// no locationBar, so put toolBar at the bottom
|
||||
|
||||
CGRect webViewBounds = self.view.bounds;
|
||||
webViewBounds.size.height -= TOOLBAR_HEIGHT;
|
||||
self.webView.frame = webViewBounds;
|
||||
|
||||
toolbarFrame.origin.y = webViewBounds.size.height;
|
||||
self.toolbar.frame = toolbarFrame;
|
||||
}
|
||||
} else {
|
||||
self.toolbar.hidden = YES;
|
||||
|
||||
if (locationbarVisible) {
|
||||
// locationBar is on top of toolBar, hide toolBar
|
||||
// put locationBar at the bottom
|
||||
|
||||
// webView take up whole height less locationBar height
|
||||
CGRect webViewBounds = self.view.bounds;
|
||||
webViewBounds.size.height -= LOCATIONBAR_HEIGHT;
|
||||
self.webView.frame = webViewBounds;
|
||||
|
||||
// move locationBar down
|
||||
locationbarFrame.origin.y = webViewBounds.size.height;
|
||||
self.addressLabel.frame = locationbarFrame;
|
||||
} else {
|
||||
// no locationBar, expand webView to screen dimensions
|
||||
|
||||
CGRect webViewBounds = self.view.bounds;
|
||||
self.webView.frame = webViewBounds;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
}
|
||||
|
||||
- (void)viewDidUnload
|
||||
{
|
||||
[self.webView loadHTMLString:nil baseURL:nil];
|
||||
[CDVUserAgentUtil releaseLock:&_userAgentLockToken];
|
||||
[super viewDidUnload];
|
||||
}
|
||||
|
||||
- (UIStatusBarStyle)preferredStatusBarStyle
|
||||
{
|
||||
return UIStatusBarStyleDefault;
|
||||
}
|
||||
|
||||
- (void)close
|
||||
{
|
||||
[CDVUserAgentUtil releaseLock:&_userAgentLockToken];
|
||||
|
||||
if ([self respondsToSelector:@selector(presentingViewController)]) {
|
||||
[[self presentingViewController] dismissViewControllerAnimated:YES completion:nil];
|
||||
} else {
|
||||
[[self parentViewController] dismissModalViewControllerAnimated:YES];
|
||||
}
|
||||
|
||||
self.currentURL = nil;
|
||||
|
||||
if ((self.navigationDelegate != nil) && [self.navigationDelegate respondsToSelector:@selector(browserExit)]) {
|
||||
[self.navigationDelegate browserExit];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)navigateTo:(NSURL*)url
|
||||
{
|
||||
NSURLRequest* request = [NSURLRequest requestWithURL:url];
|
||||
|
||||
if (_userAgentLockToken != 0) {
|
||||
[self.webView loadRequest:request];
|
||||
} else {
|
||||
[CDVUserAgentUtil acquireLock:^(NSInteger lockToken) {
|
||||
_userAgentLockToken = lockToken;
|
||||
[CDVUserAgentUtil setUserAgent:_userAgent lockToken:lockToken];
|
||||
[self.webView loadRequest:request];
|
||||
}];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)goBack:(id)sender
|
||||
{
|
||||
[self.webView goBack];
|
||||
}
|
||||
|
||||
- (void)goForward:(id)sender
|
||||
{
|
||||
[self.webView goForward];
|
||||
}
|
||||
|
||||
- (void)viewWillAppear:(BOOL)animated
|
||||
{
|
||||
if (IsAtLeastiOSVersion(@"7.0")) {
|
||||
[[UIApplication sharedApplication] setStatusBarStyle:[self preferredStatusBarStyle]];
|
||||
}
|
||||
|
||||
[super viewWillAppear:animated];
|
||||
}
|
||||
|
||||
#pragma mark UIWebViewDelegate
|
||||
|
||||
- (void)webViewDidStartLoad:(UIWebView*)theWebView
|
||||
{
|
||||
// loading url, start spinner, update back/forward
|
||||
|
||||
self.addressLabel.text = @"Loading...";
|
||||
self.backButton.enabled = theWebView.canGoBack;
|
||||
self.forwardButton.enabled = theWebView.canGoForward;
|
||||
|
||||
[self.spinner startAnimating];
|
||||
|
||||
return [self.navigationDelegate webViewDidStartLoad:theWebView];
|
||||
}
|
||||
|
||||
- (BOOL)webView:(UIWebView*)theWebView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType
|
||||
{
|
||||
BOOL isTopLevelNavigation = [request.URL isEqual:[request mainDocumentURL]];
|
||||
|
||||
if (isTopLevelNavigation) {
|
||||
self.currentURL = request.URL;
|
||||
}
|
||||
return [self.navigationDelegate webView:theWebView shouldStartLoadWithRequest:request navigationType:navigationType];
|
||||
}
|
||||
|
||||
- (void)webViewDidFinishLoad:(UIWebView*)theWebView
|
||||
{
|
||||
// update url, stop spinner, update back/forward
|
||||
|
||||
self.addressLabel.text = [self.currentURL absoluteString];
|
||||
self.backButton.enabled = theWebView.canGoBack;
|
||||
self.forwardButton.enabled = theWebView.canGoForward;
|
||||
|
||||
[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 = [@"true" isEqualToString :[theWebView stringByEvaluatingJavaScriptFromString:@"document.body==null"]];
|
||||
if (isPDF) {
|
||||
[CDVUserAgentUtil setUserAgent:_prevUserAgent lockToken:_userAgentLockToken];
|
||||
}
|
||||
|
||||
[self.navigationDelegate webViewDidFinishLoad:theWebView];
|
||||
}
|
||||
|
||||
- (void)webView:(UIWebView*)theWebView didFailLoadWithError:(NSError*)error
|
||||
{
|
||||
// log fail message, stop spinner, update back/forward
|
||||
NSLog(@"webView:didFailLoadWithError - %@", [error localizedDescription]);
|
||||
|
||||
self.backButton.enabled = theWebView.canGoBack;
|
||||
self.forwardButton.enabled = theWebView.canGoForward;
|
||||
[self.spinner stopAnimating];
|
||||
|
||||
self.addressLabel.text = @"Load Error";
|
||||
|
||||
[self.navigationDelegate webView:theWebView didFailLoadWithError:error];
|
||||
}
|
||||
|
||||
#pragma mark CDVScreenOrientationDelegate
|
||||
|
||||
- (BOOL)shouldAutorotate
|
||||
{
|
||||
if ((self.orientationDelegate != nil) && [self.orientationDelegate respondsToSelector:@selector(shouldAutorotate)]) {
|
||||
return [self.orientationDelegate shouldAutorotate];
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (NSUInteger)supportedInterfaceOrientations
|
||||
{
|
||||
if ((self.orientationDelegate != nil) && [self.orientationDelegate respondsToSelector:@selector(supportedInterfaceOrientations)]) {
|
||||
return [self.orientationDelegate supportedInterfaceOrientations];
|
||||
}
|
||||
|
||||
return 1 << UIInterfaceOrientationPortrait;
|
||||
}
|
||||
|
||||
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
|
||||
{
|
||||
if ((self.orientationDelegate != nil) && [self.orientationDelegate respondsToSelector:@selector(shouldAutorotateToInterfaceOrientation:)]) {
|
||||
return [self.orientationDelegate shouldAutorotateToInterfaceOrientation:interfaceOrientation];
|
||||
}
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation CDVInAppBrowserOptions
|
||||
|
||||
- (id)init
|
||||
{
|
||||
if (self = [super init]) {
|
||||
// default values
|
||||
self.location = YES;
|
||||
self.toolbar = YES;
|
||||
self.closebuttoncaption = nil;
|
||||
|
||||
self.enableviewportscale = NO;
|
||||
self.mediaplaybackrequiresuseraction = NO;
|
||||
self.allowinlinemediaplayback = NO;
|
||||
self.keyboarddisplayrequiresuseraction = YES;
|
||||
self.suppressesincrementalrendering = NO;
|
||||
self.hidden = NO;
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
+ (CDVInAppBrowserOptions*)parseOptions:(NSString*)options
|
||||
{
|
||||
CDVInAppBrowserOptions* obj = [[CDVInAppBrowserOptions alloc] init];
|
||||
|
||||
// NOTE: this parsing does not handle quotes within values
|
||||
NSArray* pairs = [options componentsSeparatedByString:@","];
|
||||
|
||||
// parse keys and values, set the properties
|
||||
for (NSString* pair in pairs) {
|
||||
NSArray* keyvalue = [pair componentsSeparatedByString:@"="];
|
||||
|
||||
if ([keyvalue count] == 2) {
|
||||
NSString* key = [[keyvalue objectAtIndex:0] lowercaseString];
|
||||
NSString* value = [keyvalue objectAtIndex:1];
|
||||
NSString* value_lc = [value lowercaseString];
|
||||
|
||||
BOOL isBoolean = [value_lc isEqualToString:@"yes"] || [value_lc isEqualToString:@"no"];
|
||||
NSNumberFormatter* numberFormatter = [[NSNumberFormatter alloc] init];
|
||||
[numberFormatter setAllowsFloats:YES];
|
||||
BOOL isNumber = [numberFormatter numberFromString:value_lc] != nil;
|
||||
|
||||
// set the property according to the key name
|
||||
if ([obj respondsToSelector:NSSelectorFromString(key)]) {
|
||||
if (isNumber) {
|
||||
[obj setValue:[numberFormatter numberFromString:value_lc] forKey:key];
|
||||
} else if (isBoolean) {
|
||||
[obj setValue:[NSNumber numberWithBool:[value_lc isEqualToString:@"yes"]] forKey:key];
|
||||
} else {
|
||||
[obj setValue:value forKey:key];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
27
src/ios/CDVInAppBrowserNavigationController.h
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
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/CDVScreenOrientationDelegate.h>
|
||||
|
||||
|
||||
@interface CDVInAppBrowserNavigationController : UINavigationController
|
||||
|
||||
@property (nonatomic, weak) id <CDVScreenOrientationDelegate> orientationDelegate;
|
||||
|
||||
@end
|
||||
85
src/ios/CDVInAppBrowserNavigationController.m
Normal file
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
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 "CDVInAppBrowserNavigationController.h"
|
||||
|
||||
#define STATUSBAR_HEIGHT 20.0
|
||||
|
||||
@implementation CDVInAppBrowserNavigationController : UINavigationController
|
||||
|
||||
- (void) dismissViewControllerAnimated:(BOOL)flag completion:(void (^)(void))completion {
|
||||
if ( self.presentedViewController) {
|
||||
[super dismissViewControllerAnimated:flag completion:completion];
|
||||
}
|
||||
}
|
||||
|
||||
- (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];
|
||||
}
|
||||
|
||||
- (CGRect) invertFrameIfNeeded:(CGRect)rect {
|
||||
if (UIInterfaceOrientationIsLandscape([[UIApplication sharedApplication] statusBarOrientation])) {
|
||||
CGFloat temp = rect.size.width;
|
||||
rect.size.width = rect.size.height;
|
||||
rect.size.height = temp;
|
||||
}
|
||||
rect.origin = CGPointZero;
|
||||
return rect;
|
||||
}
|
||||
|
||||
#pragma mark CDVScreenOrientationDelegate
|
||||
|
||||
- (BOOL)shouldAutorotate
|
||||
{
|
||||
if ((self.orientationDelegate != nil) && [self.orientationDelegate respondsToSelector:@selector(shouldAutorotate)]) {
|
||||
return [self.orientationDelegate shouldAutorotate];
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (NSUInteger)supportedInterfaceOrientations
|
||||
{
|
||||
if ((self.orientationDelegate != nil) && [self.orientationDelegate respondsToSelector:@selector(supportedInterfaceOrientations)]) {
|
||||
return [self.orientationDelegate supportedInterfaceOrientations];
|
||||
}
|
||||
|
||||
return 1 << UIInterfaceOrientationPortrait;
|
||||
}
|
||||
|
||||
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
|
||||
{
|
||||
if ((self.orientationDelegate != nil) && [self.orientationDelegate respondsToSelector:@selector(shouldAutorotateToInterfaceOrientation:)]) {
|
||||
return [self.orientationDelegate shouldAutorotateToInterfaceOrientation:interfaceOrientation];
|
||||
}
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
||||
@end
|
||||
53
src/ios/CDVInAppBrowserOptions.h
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
|
||||
|
||||
@interface CDVInAppBrowserOptions : NSObject {}
|
||||
|
||||
@property (nonatomic, assign) BOOL usewkwebview;
|
||||
@property (nonatomic, assign) BOOL location;
|
||||
@property (nonatomic, assign) BOOL toolbar;
|
||||
@property (nonatomic, copy) NSString* closebuttoncaption;
|
||||
@property (nonatomic, copy) NSString* closebuttoncolor;
|
||||
@property (nonatomic, assign) BOOL lefttoright;
|
||||
@property (nonatomic, copy) NSString* toolbarposition;
|
||||
@property (nonatomic, copy) NSString* toolbarcolor;
|
||||
@property (nonatomic, assign) BOOL toolbartranslucent;
|
||||
@property (nonatomic, assign) BOOL hidenavigationbuttons;
|
||||
@property (nonatomic, copy) NSString* navigationbuttoncolor;
|
||||
@property (nonatomic, assign) BOOL cleardata;
|
||||
@property (nonatomic, assign) BOOL clearcache;
|
||||
@property (nonatomic, assign) BOOL clearsessioncache;
|
||||
@property (nonatomic, assign) BOOL hidespinner;
|
||||
|
||||
@property (nonatomic, copy) NSString* presentationstyle;
|
||||
@property (nonatomic, copy) NSString* transitionstyle;
|
||||
|
||||
@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;
|
||||
|
||||
+ (CDVInAppBrowserOptions*)parseOptions:(NSString*)options;
|
||||
|
||||
@end
|
||||
93
src/ios/CDVInAppBrowserOptions.m
Normal file
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
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 "CDVInAppBrowserOptions.h"
|
||||
|
||||
@implementation CDVInAppBrowserOptions
|
||||
|
||||
- (id)init
|
||||
{
|
||||
if (self = [super init]) {
|
||||
// default values
|
||||
self.usewkwebview = NO;
|
||||
self.location = YES;
|
||||
self.toolbar = YES;
|
||||
self.closebuttoncaption = nil;
|
||||
self.toolbarposition = @"bottom";
|
||||
self.cleardata = NO;
|
||||
self.clearcache = NO;
|
||||
self.clearsessioncache = NO;
|
||||
self.hidespinner = NO;
|
||||
|
||||
self.enableviewportscale = NO;
|
||||
self.mediaplaybackrequiresuseraction = NO;
|
||||
self.allowinlinemediaplayback = NO;
|
||||
self.keyboarddisplayrequiresuseraction = YES;
|
||||
self.suppressesincrementalrendering = NO;
|
||||
self.hidden = NO;
|
||||
self.disallowoverscroll = NO;
|
||||
self.hidenavigationbuttons = NO;
|
||||
self.closebuttoncolor = nil;
|
||||
self.lefttoright = false;
|
||||
self.toolbarcolor = nil;
|
||||
self.toolbartranslucent = YES;
|
||||
self.beforeload = @"";
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
+ (CDVInAppBrowserOptions*)parseOptions:(NSString*)options
|
||||
{
|
||||
CDVInAppBrowserOptions* obj = [[CDVInAppBrowserOptions alloc] init];
|
||||
|
||||
// NOTE: this parsing does not handle quotes within values
|
||||
NSArray* pairs = [options componentsSeparatedByString:@","];
|
||||
|
||||
// parse keys and values, set the properties
|
||||
for (NSString* pair in pairs) {
|
||||
NSArray* keyvalue = [pair componentsSeparatedByString:@"="];
|
||||
|
||||
if ([keyvalue count] == 2) {
|
||||
NSString* key = [[keyvalue objectAtIndex:0] lowercaseString];
|
||||
NSString* value = [keyvalue objectAtIndex:1];
|
||||
NSString* value_lc = [value lowercaseString];
|
||||
|
||||
BOOL isBoolean = [value_lc isEqualToString:@"yes"] || [value_lc isEqualToString:@"no"];
|
||||
NSNumberFormatter* numberFormatter = [[NSNumberFormatter alloc] init];
|
||||
[numberFormatter setAllowsFloats:YES];
|
||||
BOOL isNumber = [numberFormatter numberFromString:value_lc] != nil;
|
||||
|
||||
// set the property according to the key name
|
||||
if ([obj respondsToSelector:NSSelectorFromString(key)]) {
|
||||
if (isNumber) {
|
||||
[obj setValue:[numberFormatter numberFromString:value_lc] forKey:key];
|
||||
} else if (isBoolean) {
|
||||
[obj setValue:[NSNumber numberWithBool:[value_lc isEqualToString:@"yes"]] forKey:key];
|
||||
} else {
|
||||
[obj setValue:value forKey:key];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
@end
|
||||
91
src/ios/CDVUIInAppBrowser.h
Normal file
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
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
|
||||
1129
src/ios/CDVUIInAppBrowser.m
Normal file
80
src/ios/CDVWKInAppBrowser.h
Normal file
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
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 "CDVWKInAppBrowserUIDelegate.h"
|
||||
#import "CDVInAppBrowserOptions.h"
|
||||
#import "CDVInAppBrowserNavigationController.h"
|
||||
|
||||
@class CDVWKInAppBrowserViewController;
|
||||
|
||||
@interface CDVWKInAppBrowser : CDVPlugin {
|
||||
@private
|
||||
NSString* _beforeload;
|
||||
BOOL _waitForBeforeload;
|
||||
}
|
||||
|
||||
@property (nonatomic, retain) CDVWKInAppBrowser* instance;
|
||||
@property (nonatomic, retain) CDVWKInAppBrowserViewController* 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 CDVWKInAppBrowserViewController : UIViewController <CDVScreenOrientationDelegate,WKNavigationDelegate,WKUIDelegate,WKScriptMessageHandler>{
|
||||
@private
|
||||
NSString* _userAgent;
|
||||
NSString* _prevUserAgent;
|
||||
NSInteger _userAgentLockToken;
|
||||
CDVInAppBrowserOptions *_browserOptions;
|
||||
}
|
||||
|
||||
@property (nonatomic, strong) IBOutlet WKWebView* webView;
|
||||
@property (nonatomic, strong) IBOutlet WKWebViewConfiguration* configuration;
|
||||
@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, strong) IBOutlet CDVWKInAppBrowserUIDelegate* webViewUIDelegate;
|
||||
|
||||
@property (nonatomic, weak) id <CDVScreenOrientationDelegate> orientationDelegate;
|
||||
@property (nonatomic, weak) CDVWKInAppBrowser* 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
|
||||
1275
src/ios/CDVWKInAppBrowser.m
Normal file
32
src/ios/CDVWKInAppBrowserUIDelegate.h
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
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 <WebKit/WebKit.h>
|
||||
|
||||
@interface CDVWKInAppBrowserUIDelegate : NSObject <WKUIDelegate>{
|
||||
@private
|
||||
UIViewController* _viewController;
|
||||
}
|
||||
|
||||
@property (nonatomic, copy) NSString* title;
|
||||
|
||||
- (instancetype)initWithTitle:(NSString*)title;
|
||||
-(void) setViewController:(UIViewController*) viewController;
|
||||
|
||||
@end
|
||||
127
src/ios/CDVWKInAppBrowserUIDelegate.m
Normal file
@@ -0,0 +1,127 @@
|
||||
/*
|
||||
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 "CDVWKInAppBrowserUIDelegate.h"
|
||||
|
||||
@implementation CDVWKInAppBrowserUIDelegate
|
||||
|
||||
- (instancetype)initWithTitle:(NSString*)title
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
self.title = title;
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) webView:(WKWebView*)webView runJavaScriptAlertPanelWithMessage:(NSString*)message
|
||||
initiatedByFrame:(WKFrameInfo*)frame completionHandler:(void (^)(void))completionHandler
|
||||
{
|
||||
UIAlertController* alert = [UIAlertController alertControllerWithTitle:self.title
|
||||
message:message
|
||||
preferredStyle:UIAlertControllerStyleAlert];
|
||||
|
||||
UIAlertAction* ok = [UIAlertAction actionWithTitle:NSLocalizedString(@"OK", @"OK")
|
||||
style:UIAlertActionStyleDefault
|
||||
handler:^(UIAlertAction* action)
|
||||
{
|
||||
completionHandler();
|
||||
[alert dismissViewControllerAnimated:YES completion:nil];
|
||||
}];
|
||||
|
||||
[alert addAction:ok];
|
||||
|
||||
[[self getViewController] presentViewController:alert animated:YES completion:nil];
|
||||
}
|
||||
|
||||
- (void) webView:(WKWebView*)webView runJavaScriptConfirmPanelWithMessage:(NSString*)message
|
||||
initiatedByFrame:(WKFrameInfo*)frame completionHandler:(void (^)(BOOL result))completionHandler
|
||||
{
|
||||
UIAlertController* alert = [UIAlertController alertControllerWithTitle:self.title
|
||||
message:message
|
||||
preferredStyle:UIAlertControllerStyleAlert];
|
||||
|
||||
UIAlertAction* ok = [UIAlertAction actionWithTitle:NSLocalizedString(@"OK", @"OK")
|
||||
style:UIAlertActionStyleDefault
|
||||
handler:^(UIAlertAction* action)
|
||||
{
|
||||
completionHandler(YES);
|
||||
[alert dismissViewControllerAnimated:YES completion:nil];
|
||||
}];
|
||||
|
||||
[alert addAction:ok];
|
||||
|
||||
UIAlertAction* cancel = [UIAlertAction actionWithTitle:NSLocalizedString(@"Cancel", @"Cancel")
|
||||
style:UIAlertActionStyleDefault
|
||||
handler:^(UIAlertAction* action)
|
||||
{
|
||||
completionHandler(NO);
|
||||
[alert dismissViewControllerAnimated:YES completion:nil];
|
||||
}];
|
||||
[alert addAction:cancel];
|
||||
|
||||
[[self getViewController] presentViewController:alert animated:YES completion:nil];
|
||||
}
|
||||
|
||||
- (void) webView:(WKWebView*)webView runJavaScriptTextInputPanelWithPrompt:(NSString*)prompt
|
||||
defaultText:(NSString*)defaultText initiatedByFrame:(WKFrameInfo*)frame
|
||||
completionHandler:(void (^)(NSString* result))completionHandler
|
||||
{
|
||||
UIAlertController* alert = [UIAlertController alertControllerWithTitle:self.title
|
||||
message:prompt
|
||||
preferredStyle:UIAlertControllerStyleAlert];
|
||||
|
||||
UIAlertAction* ok = [UIAlertAction actionWithTitle:NSLocalizedString(@"OK", @"OK")
|
||||
style:UIAlertActionStyleDefault
|
||||
handler:^(UIAlertAction* action)
|
||||
{
|
||||
completionHandler(((UITextField*)alert.textFields[0]).text);
|
||||
[alert dismissViewControllerAnimated:YES completion:nil];
|
||||
}];
|
||||
|
||||
[alert addAction:ok];
|
||||
|
||||
UIAlertAction* cancel = [UIAlertAction actionWithTitle:NSLocalizedString(@"Cancel", @"Cancel")
|
||||
style:UIAlertActionStyleDefault
|
||||
handler:^(UIAlertAction* action)
|
||||
{
|
||||
completionHandler(nil);
|
||||
[alert dismissViewControllerAnimated:YES completion:nil];
|
||||
}];
|
||||
[alert addAction:cancel];
|
||||
|
||||
[alert addTextFieldWithConfigurationHandler:^(UITextField* textField) {
|
||||
textField.text = defaultText;
|
||||
}];
|
||||
|
||||
[[self getViewController] presentViewController:alert animated:YES completion:nil];
|
||||
}
|
||||
|
||||
-(UIViewController*) getViewController
|
||||
{
|
||||
return _viewController;
|
||||
}
|
||||
|
||||
-(void) setViewController:(UIViewController*) viewController
|
||||
{
|
||||
_viewController = viewController;
|
||||
}
|
||||
|
||||
@end
|
||||
30
src/osx/CDVInAppBrowser.h
Normal file
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
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
|
||||
|
||||
89
src/osx/CDVInAppBrowser.m
Normal file
@@ -0,0 +1,89 @@
|
||||
/*
|
||||
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
|
||||
|
||||
@@ -1,69 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* Copyright 2013 Canonical Ltd.
|
||||
*
|
||||
* 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 QtQuick 2.0
|
||||
import QtWebKit 3.0
|
||||
import Ubuntu.Components.Popups 0.1
|
||||
import Ubuntu.Components 0.1
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
id: inappbrowser
|
||||
property string url1
|
||||
Rectangle {
|
||||
border.color: "black"
|
||||
width: parent.width
|
||||
height: urlEntry.height
|
||||
color: "gray"
|
||||
TextInput {
|
||||
id: urlEntry
|
||||
width: parent.width - closeButton.width
|
||||
text: url1
|
||||
activeFocusOnPress: false
|
||||
}
|
||||
Image {
|
||||
id: closeButton
|
||||
width: height
|
||||
x: parent.width - width
|
||||
height: parent.height
|
||||
source: "close.png"
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: {
|
||||
root.exec("InAppBrowser", "close", [0, 0])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
WebView {
|
||||
width: parent.width
|
||||
y: urlEntry.height
|
||||
height: parent.height - y
|
||||
url: url1
|
||||
onLoadingChanged: {
|
||||
if (loadRequest.status) {
|
||||
root.exec("InAppBrowser", "loadFinished", [loadRequest.status])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 461 B |
@@ -1,106 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* Copyright 2013 Canonical Ltd.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <QQuickView>
|
||||
#include <QQuickItem>
|
||||
|
||||
#include "inappbrowser.h"
|
||||
#include <cordova.h>
|
||||
|
||||
Inappbrowser::Inappbrowser(Cordova *cordova): CPlugin(cordova), _eventCb(0) {
|
||||
}
|
||||
|
||||
const char code[] = "\
|
||||
var component, object; \
|
||||
function createObject() { \
|
||||
component = Qt.createComponent(%1); \
|
||||
if (component.status == Component.Ready) \
|
||||
finishCreation(); \
|
||||
else \
|
||||
component.statusChanged.connect(finishCreation); \
|
||||
} \
|
||||
function finishCreation() { \
|
||||
CordovaWrapper.object = component.createObject(root, \
|
||||
{root: root, cordova: cordova, url1: %2}); \
|
||||
} \
|
||||
createObject()";
|
||||
|
||||
const char EXIT_EVENT[] = "'exit'";
|
||||
const char LOADSTART_EVENT[] = "'loadstart'";
|
||||
const char LOADSTOP_EVENT[] = "'loadstop'";
|
||||
const char LOADERROR_EVENT[] = "'loaderror'";
|
||||
|
||||
void Inappbrowser::open(int cb, int, const QString &url, const QString &windowName, const QString &windowFeatures) {
|
||||
assert(_eventCb == 0);
|
||||
|
||||
_eventCb = cb;
|
||||
|
||||
QString path = m_cordova->get_app_dir() + "/../qml/InAppBrowser.qml";
|
||||
|
||||
// TODO: relative url
|
||||
QString qml = QString(code)
|
||||
.arg(CordovaInternal::format(path)).arg(CordovaInternal::format(url));
|
||||
m_cordova->execQML(qml);
|
||||
}
|
||||
|
||||
void Inappbrowser::show(int, int) {
|
||||
m_cordova->execQML("CordovaWrapper.object.visible = true");
|
||||
}
|
||||
|
||||
void Inappbrowser::close(int, int) {
|
||||
m_cordova->execQML("CordovaWrapper.object.destroy()");
|
||||
this->callbackWithoutRemove(_eventCb, EXIT_EVENT);
|
||||
_eventCb = 0;
|
||||
}
|
||||
|
||||
void Inappbrowser::injectStyleFile(int cb, int, const QString&, bool) {
|
||||
// TODO:
|
||||
qCritical() << "unimplemented " << __PRETTY_FUNCTION__;
|
||||
}
|
||||
|
||||
void Inappbrowser::injectStyleCode(int cb, int, const QString&, bool) {
|
||||
// TODO:
|
||||
qCritical() << "unimplemented " << __PRETTY_FUNCTION__;
|
||||
}
|
||||
|
||||
void Inappbrowser::injectScriptFile(int cb, int, const QString&, bool) {
|
||||
// TODO:
|
||||
qCritical() << "unimplemented " << __PRETTY_FUNCTION__;
|
||||
}
|
||||
|
||||
void Inappbrowser::injectScriptCode(int cb, int, const QString&, bool) {
|
||||
// TODO:
|
||||
qCritical() << "unimplemented " << __PRETTY_FUNCTION__;
|
||||
}
|
||||
|
||||
void Inappbrowser::loadFinished(int status) {
|
||||
if (status == 2) {
|
||||
this->callbackWithoutRemove(_eventCb, LOADERROR_EVENT);
|
||||
}
|
||||
if (status == 0) {
|
||||
this->callbackWithoutRemove(_eventCb, LOADSTART_EVENT);
|
||||
}
|
||||
if (status == 3) {
|
||||
this->callbackWithoutRemove(_eventCb, LOADSTOP_EVENT);
|
||||
}
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* Copyright 2013 Canonical Ltd.
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
#ifndef INAPPBROWSER_H
|
||||
#define INAPPBROWSER_H
|
||||
|
||||
#include <QtCore>
|
||||
#include <cplugin.h>
|
||||
|
||||
class Inappbrowser: public CPlugin {
|
||||
Q_OBJECT
|
||||
public:
|
||||
Inappbrowser(Cordova *cordova);
|
||||
|
||||
virtual const QString fullName() override {
|
||||
return Inappbrowser::fullID();
|
||||
}
|
||||
|
||||
virtual const QString shortName() override {
|
||||
return "InAppBrowser";
|
||||
}
|
||||
|
||||
static const QString fullID() {
|
||||
return "InAppBrowser";
|
||||
}
|
||||
|
||||
public slots:
|
||||
void open(int cb, int, const QString &url, const QString &windowName, const QString &windowFeatures);
|
||||
void show(int, int);
|
||||
void close(int, int);
|
||||
void injectStyleFile(int cb, int, const QString&, bool);
|
||||
void injectStyleCode(int cb, int, const QString&, bool);
|
||||
void injectScriptFile(int cb, int, const QString&, bool);
|
||||
void injectScriptCode(int cb, int, const QString&, bool);
|
||||
|
||||
void loadFinished(int status);
|
||||
|
||||
private:
|
||||
int _eventCb;
|
||||
};
|
||||
|
||||
#endif
|
||||
385
src/windows/InAppBrowserProxy.js
Normal file
@@ -0,0 +1,385 @@
|
||||
/*
|
||||
*
|
||||
* 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);
|
||||
@@ -1,408 +0,0 @@
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Ink;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Animation;
|
||||
using System.Windows.Shapes;
|
||||
using Microsoft.Phone.Controls;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.Serialization;
|
||||
using WPCordovaClassLib.Cordova;
|
||||
using WPCordovaClassLib.Cordova.Commands;
|
||||
using WPCordovaClassLib.Cordova.JSON;
|
||||
using Microsoft.Phone.Shell;
|
||||
using Microsoft.Phone.Tasks;
|
||||
|
||||
namespace WPCordovaClassLib.Cordova.Commands
|
||||
{
|
||||
[DataContract]
|
||||
public class BrowserOptions
|
||||
{
|
||||
[DataMember]
|
||||
public string url;
|
||||
|
||||
[DataMember]
|
||||
public bool isGeolocationEnabled;
|
||||
}
|
||||
|
||||
public class InAppBrowser : BaseCommand
|
||||
{
|
||||
|
||||
private static WebBrowser browser;
|
||||
private static ApplicationBarIconButton backButton;
|
||||
private static ApplicationBarIconButton fwdButton;
|
||||
|
||||
protected ApplicationBar AppBar;
|
||||
|
||||
protected bool ShowLocation {get;set;}
|
||||
protected bool StartHidden {get;set;}
|
||||
|
||||
public void open(string options)
|
||||
{
|
||||
// reset defaults on ShowLocation + StartHidden features
|
||||
ShowLocation = true;
|
||||
StartHidden = false;
|
||||
|
||||
string[] args = JSON.JsonHelper.Deserialize<string[]>(options);
|
||||
//BrowserOptions opts = JSON.JsonHelper.Deserialize<BrowserOptions>(options);
|
||||
string urlLoc = args[0];
|
||||
string target = args[1];
|
||||
string featString = args[2];
|
||||
|
||||
string[] features = featString.Split(',');
|
||||
foreach (string str in features)
|
||||
{
|
||||
try
|
||||
{
|
||||
string[] split = str.Split('=');
|
||||
switch (split[0])
|
||||
{
|
||||
case "location":
|
||||
ShowLocation = split[1].ToLower().StartsWith("yes");
|
||||
break;
|
||||
case "hidden":
|
||||
StartHidden = split[1].ToLower().StartsWith("yes");
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch(Exception)
|
||||
{
|
||||
// some sort of invalid param was passed, moving on ...
|
||||
}
|
||||
|
||||
}
|
||||
/*
|
||||
_self - opens in the Cordova WebView if url is in the white-list, else it opens in the InAppBrowser
|
||||
_blank - always open in the InAppBrowser
|
||||
_system - always open in the system web browser
|
||||
*/
|
||||
switch (target)
|
||||
{
|
||||
case "_blank":
|
||||
ShowInAppBrowser(urlLoc);
|
||||
break;
|
||||
case "_self":
|
||||
ShowCordovaBrowser(urlLoc);
|
||||
break;
|
||||
case "_system":
|
||||
ShowSystemBrowser(urlLoc);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void show(string options)
|
||||
{
|
||||
string[] args = JSON.JsonHelper.Deserialize<string[]>(options);
|
||||
|
||||
|
||||
if (browser != null)
|
||||
{
|
||||
Deployment.Current.Dispatcher.BeginInvoke(() =>
|
||||
{
|
||||
browser.Visibility = Visibility.Visible;
|
||||
AppBar.IsVisible = true;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void injectScriptCode(string options)
|
||||
{
|
||||
string[] args = JSON.JsonHelper.Deserialize<string[]>(options);
|
||||
|
||||
bool bCallback = false;
|
||||
if (bool.TryParse(args[1], out bCallback)) { };
|
||||
|
||||
string callbackId = args[2];
|
||||
|
||||
if (browser != null)
|
||||
{
|
||||
Deployment.Current.Dispatcher.BeginInvoke(() =>
|
||||
{
|
||||
var res = browser.InvokeScript("eval", new string[] { args[0] });
|
||||
|
||||
if (bCallback)
|
||||
{
|
||||
PluginResult result = new PluginResult(PluginResult.Status.OK, res.ToString());
|
||||
result.KeepCallback = false;
|
||||
this.DispatchCommandResult(result);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void injectScriptFile(string options)
|
||||
{
|
||||
Debug.WriteLine("Error : Windows Phone org.apache.cordova.inappbrowser does not currently support executeScript");
|
||||
string[] args = JSON.JsonHelper.Deserialize<string[]>(options);
|
||||
// throw new NotImplementedException("Windows Phone does not currently support 'executeScript'");
|
||||
}
|
||||
|
||||
public void injectStyleCode(string options)
|
||||
{
|
||||
Debug.WriteLine("Error : Windows Phone org.apache.cordova.inappbrowser does not currently support insertCSS");
|
||||
return;
|
||||
|
||||
//string[] args = JSON.JsonHelper.Deserialize<string[]>(options);
|
||||
//bool bCallback = false;
|
||||
//if (bool.TryParse(args[1], out bCallback)) { };
|
||||
|
||||
//string callbackId = args[2];
|
||||
|
||||
//if (browser != null)
|
||||
//{
|
||||
//Deployment.Current.Dispatcher.BeginInvoke(() =>
|
||||
//{
|
||||
// if (bCallback)
|
||||
// {
|
||||
// string cssInsertString = "try{(function(doc){var c = '<style>body{background-color:#ffff00;}</style>'; doc.head.innerHTML += c;})(document);}catch(ex){alert('oops : ' + ex.message);}";
|
||||
// //cssInsertString = cssInsertString.Replace("_VALUE_", args[0]);
|
||||
// Debug.WriteLine("cssInsertString = " + cssInsertString);
|
||||
// var res = browser.InvokeScript("eval", new string[] { cssInsertString });
|
||||
// if (bCallback)
|
||||
// {
|
||||
// PluginResult result = new PluginResult(PluginResult.Status.OK, res.ToString());
|
||||
// result.KeepCallback = false;
|
||||
// this.DispatchCommandResult(result);
|
||||
// }
|
||||
// }
|
||||
|
||||
//});
|
||||
//}
|
||||
}
|
||||
|
||||
public void injectStyleFile(string options)
|
||||
{
|
||||
Debug.WriteLine("Error : Windows Phone org.apache.cordova.inappbrowser does not currently support insertCSS");
|
||||
return;
|
||||
|
||||
//string[] args = JSON.JsonHelper.Deserialize<string[]>(options);
|
||||
//throw new NotImplementedException("Windows Phone does not currently support 'insertCSS'");
|
||||
}
|
||||
|
||||
|
||||
private void ShowCordovaBrowser(string url)
|
||||
{
|
||||
Uri loc = new Uri(url, UriKind.RelativeOrAbsolute);
|
||||
Deployment.Current.Dispatcher.BeginInvoke(() =>
|
||||
{
|
||||
PhoneApplicationFrame frame = Application.Current.RootVisual as PhoneApplicationFrame;
|
||||
if (frame != null)
|
||||
{
|
||||
PhoneApplicationPage page = frame.Content as PhoneApplicationPage;
|
||||
if (page != null)
|
||||
{
|
||||
CordovaView cView = page.FindName("CordovaView") as CordovaView;
|
||||
if (cView != null)
|
||||
{
|
||||
WebBrowser br = cView.Browser;
|
||||
br.Navigate(loc);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void ShowSystemBrowser(string url)
|
||||
{
|
||||
WebBrowserTask webBrowserTask = new WebBrowserTask();
|
||||
webBrowserTask.Uri = new Uri(url, UriKind.Absolute);
|
||||
webBrowserTask.Show();
|
||||
}
|
||||
|
||||
|
||||
private void ShowInAppBrowser(string url)
|
||||
{
|
||||
Uri loc = new Uri(url, UriKind.RelativeOrAbsolute);
|
||||
|
||||
Deployment.Current.Dispatcher.BeginInvoke(() =>
|
||||
{
|
||||
if (browser != null)
|
||||
{
|
||||
//browser.IsGeolocationEnabled = opts.isGeolocationEnabled;
|
||||
browser.Navigate(loc);
|
||||
}
|
||||
else
|
||||
{
|
||||
PhoneApplicationFrame frame = Application.Current.RootVisual as PhoneApplicationFrame;
|
||||
if (frame != null)
|
||||
{
|
||||
PhoneApplicationPage page = frame.Content as PhoneApplicationPage;
|
||||
|
||||
string baseImageUrl = "Images/";
|
||||
|
||||
if (page != null)
|
||||
{
|
||||
Grid grid = page.FindName("LayoutRoot") as Grid;
|
||||
if (grid != null)
|
||||
{
|
||||
browser = new WebBrowser();
|
||||
browser.IsScriptEnabled = true;
|
||||
browser.LoadCompleted += new System.Windows.Navigation.LoadCompletedEventHandler(browser_LoadCompleted);
|
||||
|
||||
browser.Navigating += new EventHandler<NavigatingEventArgs>(browser_Navigating);
|
||||
browser.NavigationFailed += new System.Windows.Navigation.NavigationFailedEventHandler(browser_NavigationFailed);
|
||||
browser.Navigated += new EventHandler<System.Windows.Navigation.NavigationEventArgs>(browser_Navigated);
|
||||
browser.Navigate(loc);
|
||||
|
||||
if (StartHidden)
|
||||
{
|
||||
browser.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
|
||||
//browser.IsGeolocationEnabled = opts.isGeolocationEnabled;
|
||||
grid.Children.Add(browser);
|
||||
}
|
||||
|
||||
ApplicationBar bar = new ApplicationBar();
|
||||
bar.BackgroundColor = Colors.Gray;
|
||||
bar.IsMenuEnabled = false;
|
||||
|
||||
backButton = new ApplicationBarIconButton();
|
||||
backButton.Text = "Back";
|
||||
|
||||
backButton.IconUri = new Uri(baseImageUrl + "appbar.back.rest.png", UriKind.Relative);
|
||||
backButton.Click += new EventHandler(backButton_Click);
|
||||
bar.Buttons.Add(backButton);
|
||||
|
||||
|
||||
fwdButton = new ApplicationBarIconButton();
|
||||
fwdButton.Text = "Forward";
|
||||
fwdButton.IconUri = new Uri(baseImageUrl + "appbar.next.rest.png", UriKind.Relative);
|
||||
fwdButton.Click += new EventHandler(fwdButton_Click);
|
||||
bar.Buttons.Add(fwdButton);
|
||||
|
||||
ApplicationBarIconButton closeBtn = new ApplicationBarIconButton();
|
||||
closeBtn.Text = "Close";
|
||||
closeBtn.IconUri = new Uri(baseImageUrl + "appbar.close.rest.png", UriKind.Relative);
|
||||
closeBtn.Click += new EventHandler(closeBtn_Click);
|
||||
bar.Buttons.Add(closeBtn);
|
||||
|
||||
page.ApplicationBar = bar;
|
||||
bar.IsVisible = !StartHidden;
|
||||
AppBar = bar;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void browser_LoadCompleted(object sender, System.Windows.Navigation.NavigationEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void fwdButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (browser != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
#if WP8
|
||||
browser.GoForward();
|
||||
#else
|
||||
browser.InvokeScript("execScript", "history.forward();");
|
||||
#endif
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void backButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (browser != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
#if WP8
|
||||
browser.GoBack();
|
||||
#else
|
||||
browser.InvokeScript("execScript", "history.back();");
|
||||
#endif
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void closeBtn_Click(object sender, EventArgs e)
|
||||
{
|
||||
this.close();
|
||||
}
|
||||
|
||||
|
||||
public void close(string options = "")
|
||||
{
|
||||
if (browser != null)
|
||||
{
|
||||
Deployment.Current.Dispatcher.BeginInvoke(() =>
|
||||
{
|
||||
PhoneApplicationFrame frame = Application.Current.RootVisual as PhoneApplicationFrame;
|
||||
if (frame != null)
|
||||
{
|
||||
PhoneApplicationPage page = frame.Content as PhoneApplicationPage;
|
||||
if (page != null)
|
||||
{
|
||||
Grid grid = page.FindName("LayoutRoot") as Grid;
|
||||
if (grid != null)
|
||||
{
|
||||
grid.Children.Remove(browser);
|
||||
}
|
||||
page.ApplicationBar = null;
|
||||
}
|
||||
}
|
||||
browser = null;
|
||||
string message = "{\"type\":\"exit\"}";
|
||||
PluginResult result = new PluginResult(PluginResult.Status.OK, message);
|
||||
result.KeepCallback = false;
|
||||
this.DispatchCommandResult(result);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void browser_Navigated(object sender, System.Windows.Navigation.NavigationEventArgs e)
|
||||
{
|
||||
#if WP8
|
||||
if (browser != null)
|
||||
{
|
||||
backButton.IsEnabled = browser.CanGoBack;
|
||||
fwdButton.IsEnabled = browser.CanGoForward;
|
||||
|
||||
}
|
||||
#endif
|
||||
string message = "{\"type\":\"loadstop\", \"url\":\"" + e.Uri.OriginalString + "\"}";
|
||||
PluginResult result = new PluginResult(PluginResult.Status.OK, message);
|
||||
result.KeepCallback = true;
|
||||
this.DispatchCommandResult(result);
|
||||
}
|
||||
|
||||
void browser_NavigationFailed(object sender, System.Windows.Navigation.NavigationFailedEventArgs e)
|
||||
{
|
||||
string message = "{\"type\":\"error\",\"url\":\"" + e.Uri.OriginalString + "\"}";
|
||||
PluginResult result = new PluginResult(PluginResult.Status.ERROR, message);
|
||||
result.KeepCallback = true;
|
||||
this.DispatchCommandResult(result);
|
||||
}
|
||||
|
||||
void browser_Navigating(object sender, NavigatingEventArgs e)
|
||||
{
|
||||
string message = "{\"type\":\"loadstart\",\"url\":\"" + e.Uri.OriginalString + "\"}";
|
||||
PluginResult result = new PluginResult(PluginResult.Status.OK, message);
|
||||
result.KeepCallback = true;
|
||||
this.DispatchCommandResult(result);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
BIN
test/.DS_Store
vendored
72
test/cordova-incl.js
vendored
@@ -1,72 +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.
|
||||
*
|
||||
*/
|
||||
|
||||
var PLAT;
|
||||
if (/cordova-amazon-fireos/.exec(navigator.userAgent)) {
|
||||
PLAT = 'amazon-fireos';
|
||||
}else if (/Android/.exec(navigator.userAgent)) {
|
||||
PLAT = 'android';
|
||||
} else if (/(iPad)|(iPhone)|(iPod)/.exec(navigator.userAgent)) {
|
||||
PLAT = 'ios';
|
||||
} else if (/(BB10)|(PlayBook)|(BlackBerry)/.exec(navigator.userAgent)) {
|
||||
PLAT = 'blackberry';
|
||||
}
|
||||
|
||||
var scripts = document.getElementsByTagName('script');
|
||||
var currentPath = scripts[scripts.length - 1].src;
|
||||
var platformCordovaPath = currentPath.replace("cordova-incl.js", "cordova." + PLAT + ".js");
|
||||
var normalCordovaPath = currentPath.replace("cordova-incl.js", "cordova.js");
|
||||
var cordovaPath = normalCordovaPath;
|
||||
|
||||
if (PLAT) {
|
||||
// XHR to local file is an error on some platforms, windowsphone for one
|
||||
try {
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("GET", platformCordovaPath, false);
|
||||
xhr.onreadystatechange = function() {
|
||||
|
||||
if (this.readyState == this.DONE && this.responseText.length > 0) {
|
||||
if(parseInt(this.status) >= 400){
|
||||
cordovaPath = normalCordovaPath;
|
||||
}else{
|
||||
cordovaPath = platformCordovaPath;
|
||||
}
|
||||
}
|
||||
};
|
||||
xhr.send(null);
|
||||
}
|
||||
catch(e){
|
||||
cordovaPath = normalCordovaPath;
|
||||
} // access denied!
|
||||
}
|
||||
|
||||
if (!window._doNotWriteCordovaScript) {
|
||||
document.write('<script type="text/javascript" charset="utf-8" src="' + cordovaPath + '"></script>');
|
||||
}
|
||||
|
||||
function backHome() {
|
||||
if (window.device && device.platform && (device.platform.toLowerCase() == 'android' || device.platform.toLowerCase() == 'amazon-fireos')) {
|
||||
navigator.app.backHistory();
|
||||
}
|
||||
else {
|
||||
window.history.go(-1);
|
||||
}
|
||||
}
|
||||
@@ -1,258 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<!--
|
||||
|
||||
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.
|
||||
|
||||
-->
|
||||
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width,height=device-height,user-scalable=no,maximum-scale=1.0,initial-scale=1.0" />
|
||||
<meta http-equiv="Content-type" content="text/html; charset=utf-8"> <!-- ISO-8859-1 -->
|
||||
<title>Cordova Mobile Spec</title>
|
||||
<link rel="stylesheet" href="../master.css" type="text/css" media="screen" title="no title" charset="utf-8">
|
||||
<script type="text/javascript" charset="utf-8" src="../cordova-incl.js"></script>
|
||||
|
||||
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
|
||||
var deviceReady = false;
|
||||
|
||||
/**
|
||||
* Function called when page has finished loading.
|
||||
*/
|
||||
function init() {
|
||||
document.addEventListener("deviceready", function() {
|
||||
deviceReady = true;
|
||||
console.log("Device="+device.platform+" "+device.version);
|
||||
}, false);
|
||||
function updateUserAgent() {
|
||||
document.getElementById("user-agent").textContent = navigator.userAgent;
|
||||
}
|
||||
updateUserAgent();
|
||||
window.setInterval(updateUserAgent, 1500);
|
||||
window.setTimeout(function() {
|
||||
if (!deviceReady) {
|
||||
alert("Error: Apache Cordova did not initialize. Demo will not run correctly.");
|
||||
}
|
||||
},1000);
|
||||
}
|
||||
|
||||
function doOpen(url, target, params, numExpectedRedirects) {
|
||||
numExpectedRedirects = numExpectedRedirects || 0;
|
||||
var iab = window.open(url, target, params);
|
||||
if (!iab) {
|
||||
alert('window.open returned ' + iab);
|
||||
return;
|
||||
}
|
||||
var counts;
|
||||
var lastLoadStartURL;
|
||||
var wasReset = false;
|
||||
function reset() {
|
||||
counts = {
|
||||
'loaderror': 0,
|
||||
'loadstart': 0,
|
||||
'loadstop': 0,
|
||||
'exit': 0
|
||||
};
|
||||
lastLoadStartURL = '';
|
||||
}
|
||||
reset();
|
||||
|
||||
function logEvent(e) {
|
||||
console.log('IAB event=' + JSON.stringify(e));
|
||||
counts[e.type]++;
|
||||
// Verify that event.url gets updated on redirects.
|
||||
if (e.type == 'loadstart') {
|
||||
if (e.url == lastLoadStartURL) {
|
||||
alert('Unexpected: loadstart fired multiple times for the same URL.');
|
||||
}
|
||||
lastLoadStartURL = e.url;
|
||||
}
|
||||
// Verify the right number of loadstart events were fired.
|
||||
if (e.type == 'loadstop' || e.type == 'loaderror') {
|
||||
if (e.url != lastLoadStartURL) {
|
||||
alert('Unexpected: ' + e.type + ' event.url != loadstart\'s event.url');
|
||||
}
|
||||
if (numExpectedRedirects === 0 && counts['loadstart'] !== 1) {
|
||||
// Do allow a loaderror without a loadstart (e.g. in the case of an invalid URL).
|
||||
if (!(e.type == 'loaderror' && counts['loadstart'] === 0)) {
|
||||
alert('Unexpected: got multiple loadstart events. (' + counts['loadstart'] + ')');
|
||||
}
|
||||
} else if (numExpectedRedirects > 0 && counts['loadstart'] < (numExpectedRedirects+1)) {
|
||||
alert('Unexpected: should have got at least ' + (numExpectedRedirects+1) + ' loadstart events, but got ' + counts['loadstart']);
|
||||
}
|
||||
wasReset = true;
|
||||
numExpectedRedirects = 0;
|
||||
reset();
|
||||
}
|
||||
// Verify that loadend / loaderror was called.
|
||||
if (e.type == 'exit') {
|
||||
var numStopEvents = counts['loadstop'] + counts['loaderror'];
|
||||
if (numStopEvents === 0 && !wasReset) {
|
||||
alert('Unexpected: browser closed without a loadstop or loaderror.')
|
||||
} else if (numStopEvents > 1) {
|
||||
alert('Unexpected: got multiple loadstop/loaderror events.');
|
||||
}
|
||||
}
|
||||
}
|
||||
iab.addEventListener('loaderror', logEvent, false);
|
||||
iab.addEventListener('loadstart', logEvent, false);
|
||||
iab.addEventListener('loadstop', logEvent, false);
|
||||
iab.addEventListener('exit', logEvent, false);
|
||||
|
||||
return iab;
|
||||
}
|
||||
|
||||
function openWithStyle(url, cssUrl, useCallback) {
|
||||
var iab = doOpen(url, '_blank', 'location=yes');
|
||||
var callback = function(results) {
|
||||
if (results && results.length === 0) {
|
||||
alert('Results verified');
|
||||
} else {
|
||||
console.log(results);
|
||||
alert('Got: ' + typeof(results) + '\n' + JSON.stringify(results));
|
||||
}
|
||||
};
|
||||
if (cssUrl) {
|
||||
iab.addEventListener('loadstop', function(event) {
|
||||
iab.insertCSS({file: cssUrl}, useCallback && callback);
|
||||
});
|
||||
} else {
|
||||
iab.addEventListener('loadstop', function(event) {
|
||||
iab.insertCSS({code:'#style-update-literal { \ndisplay: block !important; \n}'},
|
||||
useCallback && callback);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function openWithScript(url, jsUrl, useCallback) {
|
||||
var iab = doOpen(url, '_blank', 'location=yes');
|
||||
if (jsUrl) {
|
||||
iab.addEventListener('loadstop', function(event) {
|
||||
iab.executeScript({file: jsUrl}, useCallback && function(results) {
|
||||
if (results && results.length === 0) {
|
||||
alert('Results verified');
|
||||
} else {
|
||||
console.log(results);
|
||||
alert('Got: ' + typeof(results) + '\n' + JSON.stringify(results));
|
||||
}
|
||||
});
|
||||
});
|
||||
} else {
|
||||
iab.addEventListener('loadstop', function(event) {
|
||||
var code = '(function(){\n' +
|
||||
' var header = document.getElementById("header");\n' +
|
||||
' header.innerHTML = "Script literal successfully injected";\n' +
|
||||
' return "abc";\n' +
|
||||
'})()';
|
||||
iab.executeScript({code:code}, useCallback && function(results) {
|
||||
if (results && results.length === 1 && results[0] === 'abc') {
|
||||
alert('Results verified');
|
||||
} else {
|
||||
console.log(results);
|
||||
alert('Got: ' + typeof(results) + '\n' + JSON.stringify(results));
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
var hiddenwnd=null;
|
||||
var loadlistener = function(event) { alert('background window loaded ' ); };
|
||||
function openHidden(url, startHidden) {
|
||||
var shopt =(startHidden) ? 'hidden=yes' : '';
|
||||
hiddenwnd = window.open(url,'random_string',shopt);
|
||||
if (!hiddenwnd) {
|
||||
alert('window.open returned ' + hiddenwnd);
|
||||
return;
|
||||
}
|
||||
if(startHidden) hiddenwnd.addEventListener('loadstop', loadlistener);
|
||||
}
|
||||
function showHidden() {
|
||||
if(!!hiddenwnd ) {
|
||||
hiddenwnd.show();
|
||||
}
|
||||
}
|
||||
function closeHidden() {
|
||||
if(!!hiddenwnd ) {
|
||||
hiddenwnd.removeEventListener('loadstop',loadlistener);
|
||||
hiddenwnd.close();
|
||||
hiddenwnd=null;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body onload="init();" id="stage" class="theme">
|
||||
|
||||
<h1>InAppBrowser</h1>
|
||||
<div id="info">
|
||||
Make sure http://www.google.com is white listed. </br>
|
||||
Make sure http://www.apple.com is not in the white list.</br> In iOS, starred <span style="vertical-align:super">*</span> tests will leave the app with no way to return. </br>
|
||||
<h4>User-Agent: <span id="user-agent"> </span></h4>
|
||||
</div>
|
||||
<div onclick="backHome();">Back</div>
|
||||
<h1>Local URL</h1>
|
||||
<div class="btn large" onclick="doOpen('local.html');">Default: CordovaWebView</div>
|
||||
<div class="btn large" onclick="doOpen('local.html', '_self');">Target=Self: CordovaWebView</div>
|
||||
<div class="btn large" onclick="doOpen('local.html', '_system');">Target=System: Error</div>
|
||||
<div class="btn large" onclick="doOpen('local.html', '_blank');">Target=Blank: InAppBrowser</div>
|
||||
<div class="btn large" onclick="doOpen('local.html', 'random_string');">Target=Random: InAppBrowser</div>
|
||||
<div class="btn large" onclick="doOpen('local.html', 'random_string', 'location=no');">Target=Random, no location bar: InAppBrowser</div>
|
||||
<h1>White Listed URL</h1>
|
||||
<div class="btn large" onclick="doOpen('http://www.google.com');">Default: CordovaWebView<span style="vertical-align:super">*</span></div>
|
||||
<div class="btn large" onclick="doOpen('http://www.google.com', '_self');">Target=Self: CordovaWebView<span style="vertical-align:super">*</span></div>
|
||||
<div class="btn large" onclick="doOpen('http://www.google.com', '_system');">Target=System: System Browser</div>
|
||||
<div class="btn large" onclick="doOpen('http://www.google.com', '_blank');">Target=Blank: InAppBrowser</div>
|
||||
<div class="btn large" onclick="doOpen('http://www.google.com', 'random_string');">Target=Random: InAppBrowser</div>
|
||||
<div class="btn large" onclick="doOpen('http://www.google.com', 'random_string', 'location=no');">Target=Random, no location bar: InAppBrowser</div>
|
||||
<h1>Non White Listed URL</h1>
|
||||
<div class="btn large" onclick="doOpen('http://www.apple.com');">Default: InAppBrowser</div>
|
||||
<div class="btn large" onclick="doOpen('http://www.apple.com', '_self');">Target=Self: InAppBrowser</div>
|
||||
<div class="btn large" onclick="doOpen('http://www.apple.com', '_system');">Target=System: System</div>
|
||||
<div class="btn large" onclick="doOpen('http://www.apple.com', '_blank');">Target=Blank: InAppBrowser</div>
|
||||
<div class="btn large" onclick="doOpen('http://www.apple.com', 'random_string');">Target=Random: InAppBrowser</div>
|
||||
<div class="btn large" onclick="doOpen('http://www.apple.com', 'random_string', 'location=no');">Target=Random, no location bar: InAppBrowser</div>
|
||||
<h1>Page with redirect</h1>
|
||||
<div class="btn large" onclick="doOpen('http://google.com', 'random_string', '', 1);">http://google.com (should 301)</div>
|
||||
<div class="btn large" onclick="doOpen('http://goo.gl/pUFqg', 'random_string', '', 2);">http://www.zhihu.com/answer/16714076 (should 302)</div>
|
||||
<h1>PDF URL</h1>
|
||||
<div class="btn large" onclick="doOpen('http://www.stluciadance.com/prospectus_file/sample.pdf');">Remote URL</div>
|
||||
<div class="btn large" onclick="doOpen('local.pdf', '_blank');">Local URL</div>
|
||||
<h1>INVALID URL</h1>
|
||||
<div class="btn large" onclick="doOpen('x-ttp://www.invalid.com/', '_blank');">Invalid Scheme</div>
|
||||
<div class="btn large" onclick="doOpen('http://www.inv;alid.com/', '_blank');">Invalid Host</div>
|
||||
<div class="btn large" onclick="doOpen('nonexistent.html', '_blank');">Missing File</div>
|
||||
<h1>CSS / JS Injection</h1>
|
||||
<div class="btn large" onclick="doOpen('inject.html', '_blank');">Original Document</div>
|
||||
<div class="btn large" onclick="openWithStyle('inject.html','inject.css');">CSS File Injection</div>
|
||||
<div class="btn large" onclick="openWithStyle('inject.html','inject.css', true);">CSS File Injection (CB)</div>
|
||||
<div class="btn large" onclick="openWithStyle('inject.html');">CSS Literal Injection</div>
|
||||
<div class="btn large" onclick="openWithStyle('inject.html', null, true);">CSS Literal Injection (CB)</div>
|
||||
<div class="btn large" onclick="openWithScript('inject.html', 'inject.js');">Script File Injection</div>
|
||||
<div class="btn large" onclick="openWithScript('inject.html', 'inject.js', true);">Script File Injection (CB)</div>
|
||||
<div class="btn large" onclick="openWithScript('inject.html');">Script Literal Injection</div>
|
||||
<div class="btn large" onclick="openWithScript('inject.html', null, true);">Script Literal Injection (CB)</div>
|
||||
<h1>Open Hidden </h1>
|
||||
<div class="btn large" onclick="openHidden('http://google.com',true);">google.com hidden</div>
|
||||
<div class="btn large" onclick="showHidden();">show hidden</div>
|
||||
<div class="btn large" onclick="closeHidden();">close hidden</div>
|
||||
<div class="btn large" onclick="openHidden('http://google.com',false);">google.com not hidden</div>
|
||||
<h2> </h2><div class="backBtn" onclick="backHome();">Back</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,65 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<!--
|
||||
|
||||
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.
|
||||
|
||||
-->
|
||||
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width,height=device-height,user-scalable=no,initial-scale=1.0" />
|
||||
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
||||
<title>Cordova Mobile Spec</title>
|
||||
<link rel="stylesheet" href="master.css" type="text/css" media="screen" title="no title" charset="utf-8">
|
||||
<script type="text/javascript" charset="utf-8" src="cordova-incl.js"></script>
|
||||
<script type="text/javascript" charset="utf-8" src="main.js"></script>
|
||||
|
||||
</head>
|
||||
<body onload="init();" id="stage" class="theme">
|
||||
<h1>Apache Cordova Tests</h1>
|
||||
<div id="info">
|
||||
<h4>Platform: <span id="platform"> </span></h4>
|
||||
<h4>Version: <span id="version"> </span></h4>
|
||||
<h4>UUID: <span id="uuid"> </span></h4>
|
||||
<h4>Name: <span id="name"> </span></h4>
|
||||
<h4>Model: <span id="model"> </span></h4>
|
||||
<h4>Width: <span id="width"> </span>, Height: <span id="height">
|
||||
</span>, Color Depth: <span id="colorDepth"></span></h4>
|
||||
<h4>User-Agent: <span id="user-agent"> </span></h4>
|
||||
</div>
|
||||
<a href="autotest/index.html" class="btn large">Automatic Test</a>
|
||||
<a href="accelerometer/index.html" class="btn large">Accelerometer</a>
|
||||
<a href="audio/index.html" class="btn large">Audio Play/Record</a>
|
||||
<a href="battery/index.html" class="btn large">Battery</a>
|
||||
<a href="camera/index.html" class="btn large">Camera</a>
|
||||
<a href="compass/index.html" class="btn large">Compass</a>
|
||||
<a href="contacts/index.html" class="btn large">Contacts</a>
|
||||
<a href="events/index.html" class="btn large">Events</a>
|
||||
<a href="location/index.html" class="btn large">Location</a>
|
||||
<a href="lazyloadjs/index.html" class="btn large">Lazy Loading of cordova-incl.js</a>
|
||||
<a href="misc/index.html" class="btn large">Misc Content</a>
|
||||
<a href="network/index.html" class="btn large">Network</a>
|
||||
<a href="notification/index.html" class="btn large">Notification</a>
|
||||
<a href="splashscreen/index.html" class="btn large">Splashscreen</a>
|
||||
<a href="sql/index.html" class="btn large">Web SQL</a>
|
||||
<a href="storage/index.html" class="btn large">Local Storage</a>
|
||||
<a href="benchmarks/index.html" class="btn large">Benchmarks</a>
|
||||
<a href="inappbrowser/index.html" class="btn large">In App Browser</a>
|
||||
</body>
|
||||
</html>
|
||||
163
test/main.js
@@ -1,163 +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.
|
||||
*
|
||||
*/
|
||||
|
||||
var deviceInfo = function() {
|
||||
document.getElementById("platform").innerHTML = device.platform;
|
||||
document.getElementById("version").innerHTML = device.version;
|
||||
document.getElementById("uuid").innerHTML = device.uuid;
|
||||
document.getElementById("name").innerHTML = device.name;
|
||||
document.getElementById("model").innerHTML = device.model;
|
||||
document.getElementById("width").innerHTML = screen.width;
|
||||
document.getElementById("height").innerHTML = screen.height;
|
||||
document.getElementById("colorDepth").innerHTML = screen.colorDepth;
|
||||
};
|
||||
|
||||
var getLocation = function() {
|
||||
var suc = function(p) {
|
||||
alert(p.coords.latitude + " " + p.coords.longitude);
|
||||
};
|
||||
var locFail = function() {
|
||||
};
|
||||
navigator.geolocation.getCurrentPosition(suc, locFail);
|
||||
};
|
||||
|
||||
var beep = function() {
|
||||
navigator.notification.beep(2);
|
||||
};
|
||||
|
||||
var vibrate = function() {
|
||||
navigator.notification.vibrate(0);
|
||||
};
|
||||
|
||||
function roundNumber(num) {
|
||||
var dec = 3;
|
||||
var result = Math.round(num * Math.pow(10, dec)) / Math.pow(10, dec);
|
||||
return result;
|
||||
}
|
||||
|
||||
var accelerationWatch = null;
|
||||
|
||||
function updateAcceleration(a) {
|
||||
document.getElementById('x').innerHTML = roundNumber(a.x);
|
||||
document.getElementById('y').innerHTML = roundNumber(a.y);
|
||||
document.getElementById('z').innerHTML = roundNumber(a.z);
|
||||
}
|
||||
|
||||
var toggleAccel = function() {
|
||||
if (accelerationWatch !== null) {
|
||||
navigator.accelerometer.clearWatch(accelerationWatch);
|
||||
updateAcceleration({
|
||||
x : "",
|
||||
y : "",
|
||||
z : ""
|
||||
});
|
||||
accelerationWatch = null;
|
||||
} else {
|
||||
var options = {};
|
||||
options.frequency = 1000;
|
||||
accelerationWatch = navigator.accelerometer.watchAcceleration(
|
||||
updateAcceleration, function(ex) {
|
||||
alert("accel fail (" + ex.name + ": " + ex.message + ")");
|
||||
}, options);
|
||||
}
|
||||
};
|
||||
|
||||
var preventBehavior = function(e) {
|
||||
e.preventDefault();
|
||||
};
|
||||
|
||||
function dump_pic(data) {
|
||||
var viewport = document.getElementById('viewport');
|
||||
console.log(data);
|
||||
viewport.style.display = "";
|
||||
viewport.style.position = "absolute";
|
||||
viewport.style.top = "10px";
|
||||
viewport.style.left = "10px";
|
||||
document.getElementById("test_img").src = "data:image/jpeg;base64," + data;
|
||||
}
|
||||
|
||||
function fail(msg) {
|
||||
alert(msg);
|
||||
}
|
||||
|
||||
function show_pic() {
|
||||
navigator.camera.getPicture(dump_pic, fail, {
|
||||
quality : 50
|
||||
});
|
||||
}
|
||||
|
||||
function close() {
|
||||
var viewport = document.getElementById('viewport');
|
||||
viewport.style.position = "relative";
|
||||
viewport.style.display = "none";
|
||||
}
|
||||
|
||||
// This is just to do this.
|
||||
function readFile() {
|
||||
navigator.file.read('/sdcard/cordova.txt', fail, fail);
|
||||
}
|
||||
|
||||
function writeFile() {
|
||||
navigator.file.write('foo.txt', "This is a test of writing to a file",
|
||||
fail, fail);
|
||||
}
|
||||
|
||||
function contacts_success(contacts) {
|
||||
alert(contacts.length
|
||||
+ ' contacts returned.'
|
||||
+ (contacts[2] && contacts[2].name ? (' Third contact is ' + contacts[2].name.formatted)
|
||||
: ''));
|
||||
}
|
||||
|
||||
function get_contacts() {
|
||||
var obj = new ContactFindOptions();
|
||||
obj.filter = "";
|
||||
obj.multiple = true;
|
||||
obj.limit = 5;
|
||||
navigator.service.contacts.find(
|
||||
[ "displayName", "name" ], contacts_success,
|
||||
fail, obj);
|
||||
}
|
||||
|
||||
var networkReachableCallback = function(reachability) {
|
||||
// There is no consistency on the format of reachability
|
||||
var networkState = reachability.code || reachability;
|
||||
|
||||
var currentState = {};
|
||||
currentState[NetworkStatus.NOT_REACHABLE] = 'No network connection';
|
||||
currentState[NetworkStatus.REACHABLE_VIA_CARRIER_DATA_NETWORK] = 'Carrier data connection';
|
||||
currentState[NetworkStatus.REACHABLE_VIA_WIFI_NETWORK] = 'WiFi connection';
|
||||
|
||||
confirm("Connection type:\n" + currentState[networkState]);
|
||||
};
|
||||
|
||||
function check_network() {
|
||||
navigator.network.isReachable("www.mobiledevelopersolutions.com",
|
||||
networkReachableCallback, {});
|
||||
}
|
||||
|
||||
function init() {
|
||||
// the next line makes it impossible to see Contacts on the HTC Evo since it
|
||||
// doesn't have a scroll button
|
||||
// document.addEventListener("touchmove", preventBehavior, false);
|
||||
document.addEventListener("deviceready", deviceInfo, true);
|
||||
document.getElementById("user-agent").textContent = navigator.userAgent;
|
||||
}
|
||||
164
test/master.css
@@ -1,164 +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.
|
||||
*
|
||||
*/
|
||||
|
||||
body {
|
||||
background:#222 none repeat scroll 0 0;
|
||||
color:#666;
|
||||
font-family:Helvetica;
|
||||
font-size:72%;
|
||||
line-height:1.5em;
|
||||
margin:0;
|
||||
border-top:1px solid #393939;
|
||||
}
|
||||
|
||||
#info{
|
||||
background:#ffa;
|
||||
border: 1px solid #ffd324;
|
||||
-webkit-border-radius: 5px;
|
||||
border-radius: 5px;
|
||||
clear:both;
|
||||
margin:15px 6px 0;
|
||||
min-width:295px;
|
||||
max-width:97%;
|
||||
padding:4px 0px 2px 10px;
|
||||
word-wrap:break-word;
|
||||
margin-bottom:10px;
|
||||
display:inline-block;
|
||||
min-height: 160px;
|
||||
max-height: 300px;
|
||||
overflow: auto;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
}
|
||||
|
||||
#info > h4{
|
||||
font-size:.95em;
|
||||
margin:5px 0;
|
||||
}
|
||||
|
||||
#stage.theme{
|
||||
padding-top:3px;
|
||||
}
|
||||
|
||||
/* Definition List */
|
||||
#stage.theme > dl{
|
||||
padding-top:10px;
|
||||
clear:both;
|
||||
margin:0;
|
||||
list-style-type:none;
|
||||
padding-left:10px;
|
||||
overflow:auto;
|
||||
}
|
||||
|
||||
#stage.theme > dl > dt{
|
||||
font-weight:bold;
|
||||
float:left;
|
||||
margin-left:5px;
|
||||
}
|
||||
|
||||
#stage.theme > dl > dd{
|
||||
width:45px;
|
||||
float:left;
|
||||
color:#a87;
|
||||
font-weight:bold;
|
||||
}
|
||||
|
||||
/* Content Styling */
|
||||
#stage.theme > h1, #stage.theme > h2, #stage.theme > p{
|
||||
margin:1em 0 .5em 13px;
|
||||
}
|
||||
|
||||
#stage.theme > h1{
|
||||
color:#eee;
|
||||
font-size:1.6em;
|
||||
text-align:center;
|
||||
margin:0;
|
||||
margin-top:15px;
|
||||
padding:0;
|
||||
}
|
||||
|
||||
#stage.theme > h2{
|
||||
clear:both;
|
||||
margin:0;
|
||||
padding:3px;
|
||||
font-size:1em;
|
||||
text-align:center;
|
||||
}
|
||||
|
||||
/* Stage Buttons */
|
||||
#stage.theme .btn{
|
||||
border: 1px solid #555;
|
||||
-webkit-border-radius: 5px;
|
||||
border-radius: 5px;
|
||||
text-align:center;
|
||||
display:inline-block;
|
||||
background:#444;
|
||||
width:150px;
|
||||
color:#9ab;
|
||||
font-size:1.1em;
|
||||
text-decoration:none;
|
||||
padding:1.2em 0;
|
||||
margin:3px 0px 3px 5px;
|
||||
}
|
||||
|
||||
#stage.theme .large{
|
||||
width:308px;
|
||||
padding:1.2em 0;
|
||||
}
|
||||
|
||||
#stage.theme .wide{
|
||||
width:100%;
|
||||
padding:1.2em 0;
|
||||
}
|
||||
|
||||
#stage.theme .backBtn{
|
||||
border: 1px solid #555;
|
||||
-webkit-border-radius: 5px;
|
||||
border-radius: 5px;
|
||||
text-align:center;
|
||||
display:block;
|
||||
float:right;
|
||||
background:#666;
|
||||
width:75px;
|
||||
color:#9ab;
|
||||
font-size:1.1em;
|
||||
text-decoration:none;
|
||||
padding:1.2em 0;
|
||||
margin:3px 5px 3px 5px;
|
||||
}
|
||||
|
||||
#stage.theme .input{
|
||||
border: 1px solid #555;
|
||||
-webkit-border-radius: 5px;
|
||||
border-radius: 5px;
|
||||
text-align:center;
|
||||
display:block;
|
||||
float:light;
|
||||
background:#888;
|
||||
color:#9cd;
|
||||
font-size:1.1em;
|
||||
text-decoration:none;
|
||||
padding:1.2em 0;
|
||||
margin:3px 0px 3px 5px;
|
||||
}
|
||||
|
||||
#stage.theme .numeric{
|
||||
width:100%;
|
||||
}
|
||||
2
tests/.eslintrc.yml
Normal file
@@ -0,0 +1,2 @@
|
||||
env:
|
||||
jasmine: true
|
||||
14
tests/package.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"name": "cordova-plugin-inappbrowser-tests",
|
||||
"version": "3.1.0",
|
||||
"description": "",
|
||||
"cordova": {
|
||||
"id": "cordova-plugin-inappbrowser-tests",
|
||||
"platforms": []
|
||||
},
|
||||
"keywords": [
|
||||
"ecosystem:cordova"
|
||||
],
|
||||
"author": "",
|
||||
"license": "Apache-2.0"
|
||||
}
|
||||
40
tests/plugin.xml
Normal file
@@ -0,0 +1,40 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
-->
|
||||
|
||||
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
||||
id="cordova-plugin-inappbrowser-tests"
|
||||
version="3.1.0">
|
||||
<name>Cordova InAppBrowser Plugin Tests</name>
|
||||
<license>Apache 2.0</license>
|
||||
|
||||
<dependency id="cordova-plugin-dialogs" />
|
||||
|
||||
<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>
|
||||
@@ -26,12 +26,13 @@
|
||||
<meta name="viewport" content="width=device-width,height=device-height,user-scalable=no,maximum-scale=1.0,initial-scale=1.0" />
|
||||
<meta http-equiv="Content-type" content="text/html; charset=utf-8"> <!-- ISO-8859-1 -->
|
||||
<title>Cordova Mobile Spec</title>
|
||||
<link rel="stylesheet" href="../master.css" type="text/css" media="screen" title="no title" charset="utf-8">
|
||||
<link rel="stylesheet" href="../../master.css" type="text/css" media="screen" title="no title" charset="utf-8">
|
||||
</head>
|
||||
<body id="stage" class="theme">
|
||||
<h1 id="header">InAppBrowser - Script / Style Injection Test</h1>
|
||||
<h2 id="style-update-file" style="display:none">Style updated from file</h2>
|
||||
<h2 id="style-update-literal" style="display:none">Style updated from literal</h2>
|
||||
<div>User-Agent: <cite id="u-a"></cite></div>
|
||||
</body>
|
||||
<script>
|
||||
function updateUserAgent() {
|
||||
@@ -16,5 +16,5 @@
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
var d = document.getElementById("header")
|
||||
d.innerHTML = "Script file successfully injected";
|
||||
var d = document.getElementById('header');
|
||||
d.innerHTML = 'Script file successfully injected';
|
||||
67
tests/resources/local.html
Normal file
@@ -0,0 +1,67 @@
|
||||
<!DOCTYPE html>
|
||||
<!--
|
||||
|
||||
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.
|
||||
|
||||
-->
|
||||
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width,height=device-height,user-scalable=no,maximum-scale=1.0,initial-scale=1.0" />
|
||||
<meta http-equiv="Content-type" content="text/html; charset=utf-8"> <!-- ISO-8859-1 -->
|
||||
<title>IAB test page</title>
|
||||
<script type="text/javascript" charset="utf-8" src="../../cordova-incl.js"></script>
|
||||
<script type="text/javascript" charset="utf-8">
|
||||
function onDeviceReady() {
|
||||
document.getElementById("hint").textContent = "Running CordovaWebView, deviceVersion=" + device.version + ", no toolbar should be present, Back link should work, logcat should NOT have failed 'gap:' calls.";
|
||||
}
|
||||
document.addEventListener("deviceready", onDeviceReady, false);
|
||||
</script>
|
||||
<style>
|
||||
body {background-color: #ffffff;}
|
||||
</style>
|
||||
</head>
|
||||
<body id="stage" class="theme">
|
||||
<h1>Local URL</h1>
|
||||
<div id="info">
|
||||
You have successfully loaded a local URL:
|
||||
<script>document.write(location.href)</script>
|
||||
</div>
|
||||
<hr />
|
||||
<div>User-Agent = <span id="u-a"></span></div>
|
||||
<hr />
|
||||
<div id="hint">Likely running inAppBrowser: Device version from Cordova=not found, Back link should not work, toolbar may be present, logcat should show failed 'gap:' calls.</div>
|
||||
<hr />
|
||||
<div><a href="http://www.google.com">Visit Google</a> (whitelisted)</div>
|
||||
<div><a href="http://www.yahoo.com">Visit Yahoo</a> (not whitelisted)</div>
|
||||
<div><a href="http://www.stluciadance.com/prospectus_file/sample.pdf">Check out my remote PDF</a></div>
|
||||
<div><a href="local.pdf">Check out my local PDF</a></div>
|
||||
<p /><a href="javascript:;" onclick="history.back();">Back</a>
|
||||
<p />
|
||||
<a name="anchor2"></a>
|
||||
<div style="height: 1000px;border:1px solid red;">tall div with border</div>
|
||||
</body>
|
||||
<script>
|
||||
function updateUserAgent() {
|
||||
document.getElementById("u-a").textContent = navigator.userAgent;
|
||||
}
|
||||
updateUserAgent();
|
||||
window.setInterval(updateUserAgent, 1500);
|
||||
</script>
|
||||
</html>
|
||||
@@ -26,26 +26,20 @@
|
||||
<meta name="viewport" content="width=device-width,height=device-height,user-scalable=no,maximum-scale=1.0,initial-scale=1.0" />
|
||||
<meta http-equiv="Content-type" content="text/html; charset=utf-8"> <!-- ISO-8859-1 -->
|
||||
<title>Cordova Mobile Spec</title>
|
||||
<link rel="stylesheet" href="../master.css" type="text/css" media="screen" title="no title" charset="utf-8">
|
||||
<script type="text/javascript" charset="utf-8" src="../cordova-incl.js"></script>
|
||||
|
||||
</head>
|
||||
<body id="stage" class="theme">
|
||||
<h1>InAppBrowser - Local URL</h1>
|
||||
<div id="info">
|
||||
You have successfully loaded a local URL
|
||||
</div>
|
||||
<div>User-Agent = <span id="u-a"></span></div>
|
||||
<div><a href="http://www.google.com">Visit Google</a></div>
|
||||
<div><a href="http://www.yahoo.com">Visit Yahoo</a></div>
|
||||
<div><a href="http://www.stluciadance.com/prospectus_file/sample.pdf">Check out my remote PDF</a></div>
|
||||
<div><a href="local.pdf">Check out my local PDF</a></div>
|
||||
<h2> </h2><div class="backBtn" onclick="backHome();">Back</div>
|
||||
<body>
|
||||
<video width=100% height=100% id="player">
|
||||
<source src="http://m.comptoir-info.com/app/beta/sample.mp4">
|
||||
<meta property="og:video:secure_url" content="http://m.comptoir-info.com/app/beta/sample.mp4">
|
||||
<meta property="og:video:type" content="video/mp4">
|
||||
</video>
|
||||
<div>
|
||||
<button onclick="document.getElementById('player').play()"> play </button>
|
||||
<button onclick="document.getElementById('player').pause()"> pause </button>
|
||||
</div>
|
||||
<script>
|
||||
document.getElementById('player').play();
|
||||
</script>
|
||||
</body>
|
||||
<script>
|
||||
function updateUserAgent() {
|
||||
document.getElementById("u-a").textContent = navigator.userAgent;
|
||||
}
|
||||
updateUserAgent();
|
||||
window.setInterval(updateUserAgent, 1500);
|
||||
</script>
|
||||
</html>
|
||||
764
tests/tests.js
Normal file
@@ -0,0 +1,764 @@
|
||||
/*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
/* global MSApp */
|
||||
|
||||
var cordova = require('cordova');
|
||||
var isWindows = cordova.platformId === 'windows';
|
||||
var isIos = cordova.platformId === 'ios';
|
||||
var isAndroid = cordova.platformId === 'android';
|
||||
var isBrowser = cordova.platformId === 'browser';
|
||||
|
||||
window.alert = window.alert || navigator.notification.alert;
|
||||
if (isWindows && navigator && navigator.notification && navigator.notification.alert) {
|
||||
// window.alert is defined but not functional on UWP
|
||||
window.alert = navigator.notification.alert;
|
||||
}
|
||||
|
||||
exports.defineAutoTests = function () {
|
||||
var createTests = function (platformOpts) {
|
||||
platformOpts = platformOpts || '';
|
||||
|
||||
describe('cordova.InAppBrowser', function () {
|
||||
|
||||
it('inappbrowser.spec.1 should exist', function () {
|
||||
expect(cordova.InAppBrowser).toBeDefined();
|
||||
});
|
||||
|
||||
it('inappbrowser.spec.2 should contain open function', function () {
|
||||
expect(cordova.InAppBrowser.open).toBeDefined();
|
||||
expect(cordova.InAppBrowser.open).toEqual(jasmine.any(Function));
|
||||
});
|
||||
});
|
||||
|
||||
describe('open method', function () {
|
||||
|
||||
if (cordova.platformId === 'osx') {
|
||||
pending('Open method not fully supported on OSX.');
|
||||
return;
|
||||
}
|
||||
|
||||
var iabInstance;
|
||||
var originalTimeout;
|
||||
var url = 'https://dist.apache.org/repos/dist/dev/cordova/';
|
||||
var badUrl = 'http://bad-uri/';
|
||||
|
||||
beforeEach(function () {
|
||||
// increase timeout to ensure test url could be loaded within test time
|
||||
originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 30000;
|
||||
|
||||
iabInstance = null;
|
||||
});
|
||||
|
||||
afterEach(function (done) {
|
||||
// restore original timeout
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout;
|
||||
|
||||
if (iabInstance !== null && iabInstance.close) {
|
||||
iabInstance.close();
|
||||
}
|
||||
iabInstance = null;
|
||||
// add some extra time so that iab dialog is closed
|
||||
setTimeout(done, 2000);
|
||||
});
|
||||
|
||||
function verifyEvent (evt, type) {
|
||||
expect(evt).toBeDefined();
|
||||
expect(evt.type).toEqual(type);
|
||||
// `exit` event does not have url field, browser returns null url for CORS requests
|
||||
if (type !== 'exit' && !isBrowser) {
|
||||
expect(evt.url).toEqual(url);
|
||||
}
|
||||
}
|
||||
|
||||
function verifyLoadErrorEvent (evt) {
|
||||
expect(evt).toBeDefined();
|
||||
expect(evt.type).toEqual('loaderror');
|
||||
expect(evt.url).toEqual(badUrl);
|
||||
expect(evt.code).toEqual(jasmine.any(Number));
|
||||
expect(evt.message).toEqual(jasmine.any(String));
|
||||
}
|
||||
|
||||
it('inappbrowser.spec.3 should return InAppBrowser instance with required methods', function () {
|
||||
iabInstance = cordova.InAppBrowser.open(url, '_blank', platformOpts);
|
||||
|
||||
expect(iabInstance).toBeDefined();
|
||||
|
||||
expect(iabInstance.addEventListener).toEqual(jasmine.any(Function));
|
||||
expect(iabInstance.removeEventListener).toEqual(jasmine.any(Function));
|
||||
expect(iabInstance.close).toEqual(jasmine.any(Function));
|
||||
expect(iabInstance.show).toEqual(jasmine.any(Function));
|
||||
expect(iabInstance.hide).toEqual(jasmine.any(Function));
|
||||
expect(iabInstance.executeScript).toEqual(jasmine.any(Function));
|
||||
expect(iabInstance.insertCSS).toEqual(jasmine.any(Function));
|
||||
});
|
||||
|
||||
it('inappbrowser.spec.4 should support loadstart and loadstop events', function (done) {
|
||||
var onLoadStart = jasmine.createSpy('loadstart event callback').and.callFake(function (evt) {
|
||||
verifyEvent(evt, 'loadstart');
|
||||
});
|
||||
|
||||
iabInstance = cordova.InAppBrowser.open(url, '_blank', platformOpts);
|
||||
iabInstance.addEventListener('loadstart', onLoadStart);
|
||||
iabInstance.addEventListener('loadstop', function (evt) {
|
||||
verifyEvent(evt, 'loadstop');
|
||||
if (!isBrowser) {
|
||||
// according to documentation, "loadstart" event is not supported on browser
|
||||
// https://github.com/apache/cordova-plugin-inappbrowser#browser-quirks-1
|
||||
expect(onLoadStart).toHaveBeenCalled();
|
||||
}
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('inappbrowser.spec.5 should support exit event', function (done) {
|
||||
iabInstance = cordova.InAppBrowser.open(url, '_blank', platformOpts);
|
||||
iabInstance.addEventListener('exit', function (evt) {
|
||||
verifyEvent(evt, 'exit');
|
||||
done();
|
||||
});
|
||||
iabInstance.addEventListener('loadstop', function (evt) {
|
||||
iabInstance.close();
|
||||
iabInstance = null;
|
||||
});
|
||||
});
|
||||
|
||||
it('inappbrowser.spec.6 should support loaderror event', function (done) {
|
||||
if (isBrowser) {
|
||||
// according to documentation, "loaderror" event is not supported on browser
|
||||
// https://github.com/apache/cordova-plugin-inappbrowser#browser-quirks-1
|
||||
pending('Browser platform doesn\'t support loaderror event');
|
||||
}
|
||||
iabInstance = cordova.InAppBrowser.open(badUrl, '_blank', platformOpts);
|
||||
iabInstance.addEventListener('loaderror', function (evt) {
|
||||
verifyLoadErrorEvent(evt);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('inappbrowser.spec.7 should support message event', function (done) {
|
||||
if (!isAndroid && !isIos) {
|
||||
return pending(cordova.platformId + ' platform doesn\'t support message event');
|
||||
}
|
||||
var messageKey = 'my_message';
|
||||
var messageValue = 'is_this';
|
||||
iabInstance = cordova.InAppBrowser.open(url, '_blank', platformOpts);
|
||||
iabInstance.addEventListener('message', function (evt) {
|
||||
// Verify message event
|
||||
expect(evt).toBeDefined();
|
||||
expect(evt.type).toEqual('message');
|
||||
expect(evt.data).toBeDefined();
|
||||
expect(evt.data[messageKey]).toBeDefined();
|
||||
expect(evt.data[messageKey]).toEqual(messageValue);
|
||||
done();
|
||||
});
|
||||
iabInstance.addEventListener('loadstop', function (evt) {
|
||||
var code = '(function(){\n' +
|
||||
' var message = {' + messageKey + ': "' + messageValue + '"};\n' +
|
||||
' webkit.messageHandlers.cordova_iab.postMessage(JSON.stringify(message));\n' +
|
||||
'})()';
|
||||
iabInstance.executeScript({ code: code });
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
};
|
||||
if (isIos) {
|
||||
createTests('usewkwebview=no');
|
||||
createTests('usewkwebview=yes');
|
||||
} else {
|
||||
createTests();
|
||||
}
|
||||
};
|
||||
|
||||
exports.defineManualTests = function (contentEl, createActionButton) {
|
||||
|
||||
var platformOpts = '';
|
||||
var platform_info = '';
|
||||
if (isIos) {
|
||||
platformOpts = 'usewkwebview=no';
|
||||
platform_info = '<h1>Webview</h1>' +
|
||||
'<p>Use this button to toggle the Webview implementation.</p>' +
|
||||
'<div id="webviewToggle"></div>';
|
||||
}
|
||||
|
||||
function doOpen (url, target, params, numExpectedRedirects, useWindowOpen) {
|
||||
numExpectedRedirects = numExpectedRedirects || 0;
|
||||
useWindowOpen = useWindowOpen || false;
|
||||
console.log('Opening ' + url);
|
||||
|
||||
var counts;
|
||||
var lastLoadStartURL;
|
||||
var wasReset = false;
|
||||
function reset () {
|
||||
counts = {
|
||||
'loaderror': 0,
|
||||
'loadstart': 0,
|
||||
'loadstop': 0,
|
||||
'exit': 0
|
||||
};
|
||||
lastLoadStartURL = '';
|
||||
}
|
||||
reset();
|
||||
|
||||
var iab;
|
||||
var callbacks = {
|
||||
loaderror: logEvent,
|
||||
loadstart: logEvent,
|
||||
loadstop: logEvent,
|
||||
exit: logEvent
|
||||
};
|
||||
if (useWindowOpen) {
|
||||
console.log('Use window.open() for url');
|
||||
iab = window.open(url, target, params, callbacks);
|
||||
} else {
|
||||
if (platformOpts) {
|
||||
params += (params ? ',' : '') + platformOpts;
|
||||
}
|
||||
iab = cordova.InAppBrowser.open(url, target, params, callbacks);
|
||||
}
|
||||
if (!iab) {
|
||||
alert('open returned ' + iab); // eslint-disable-line no-undef
|
||||
return;
|
||||
}
|
||||
|
||||
function logEvent (e) {
|
||||
console.log('IAB event=' + JSON.stringify(e));
|
||||
counts[e.type]++;
|
||||
// Verify that event.url gets updated on redirects.
|
||||
if (e.type === 'loadstart') {
|
||||
if (e.url === lastLoadStartURL) {
|
||||
alert('Unexpected: loadstart fired multiple times for the same URL.'); // eslint-disable-line no-undef
|
||||
}
|
||||
lastLoadStartURL = e.url;
|
||||
}
|
||||
// Verify the right number of loadstart events were fired.
|
||||
if (e.type === 'loadstop' || e.type === 'loaderror') {
|
||||
if (e.url !== lastLoadStartURL) {
|
||||
alert('Unexpected: ' + e.type + ' event.url != loadstart\'s event.url'); // eslint-disable-line no-undef
|
||||
}
|
||||
if (numExpectedRedirects === 0 && counts.loadstart !== 1) {
|
||||
// Do allow a loaderror without a loadstart (e.g. in the case of an invalid URL).
|
||||
if (!(e.type === 'loaderror' && counts.loadstart === 0)) {
|
||||
alert('Unexpected: got multiple loadstart events. (' + counts.loadstart + ')'); // eslint-disable-line no-undef
|
||||
}
|
||||
} else if (numExpectedRedirects > 0 && counts.loadstart < (numExpectedRedirects + 1)) {
|
||||
alert('Unexpected: should have got at least ' + (numExpectedRedirects + 1) + ' loadstart events, but got ' + counts.loadstart); // eslint-disable-line no-undef
|
||||
}
|
||||
wasReset = true;
|
||||
numExpectedRedirects = 0;
|
||||
reset();
|
||||
}
|
||||
// Verify that loadend / loaderror was called.
|
||||
if (e.type === 'exit') {
|
||||
var numStopEvents = counts.loadstop + counts.loaderror;
|
||||
if (numStopEvents === 0 && !wasReset) {
|
||||
alert('Unexpected: browser closed without a loadstop or loaderror.'); // eslint-disable-line no-undef
|
||||
} else if (numStopEvents > 1) {
|
||||
alert('Unexpected: got multiple loadstop/loaderror events.'); // eslint-disable-line no-undef
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return iab;
|
||||
}
|
||||
|
||||
function doHookOpen (url, target, params, numExpectedRedirects) {
|
||||
var originalFunc = window.open;
|
||||
var wasClobbered = window.hasOwnProperty('open');
|
||||
window.open = cordova.InAppBrowser.open;
|
||||
|
||||
try {
|
||||
doOpen(url, target, params, numExpectedRedirects, true);
|
||||
} finally {
|
||||
if (wasClobbered) {
|
||||
window.open = originalFunc;
|
||||
} else {
|
||||
console.log('just delete, to restore open from prototype');
|
||||
delete window.open;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function openWithStyle (url, cssUrl, useCallback) {
|
||||
var iab = doOpen(url, '_blank', 'location=yes');
|
||||
var callback = function (results) {
|
||||
if (results && results.length === 0) {
|
||||
alert('Results verified'); // eslint-disable-line no-undef
|
||||
} else {
|
||||
console.log(results);
|
||||
alert('Got: ' + typeof (results) + '\n' + JSON.stringify(results)); // eslint-disable-line no-undef
|
||||
}
|
||||
};
|
||||
if (cssUrl) {
|
||||
iab.addEventListener('loadstop', function (event) {
|
||||
iab.insertCSS({ file: cssUrl }, useCallback && callback);
|
||||
});
|
||||
} else {
|
||||
iab.addEventListener('loadstop', function (event) {
|
||||
iab.insertCSS({ code: '#style-update-literal { \ndisplay: block !important; \n}' },
|
||||
useCallback && callback);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function openWithScript (url, jsUrl, useCallback) {
|
||||
var iab = doOpen(url, '_blank', 'location=yes');
|
||||
if (jsUrl) {
|
||||
iab.addEventListener('loadstop', function (event) {
|
||||
iab.executeScript({ file: jsUrl }, useCallback && function (results) {
|
||||
if (results && results.length === 0) {
|
||||
alert('Results verified'); // eslint-disable-line no-undef
|
||||
} else {
|
||||
console.log(results);
|
||||
alert('Got: ' + typeof (results) + '\n' + JSON.stringify(results)); // eslint-disable-line no-undef
|
||||
}
|
||||
});
|
||||
});
|
||||
} else {
|
||||
iab.addEventListener('loadstop', function (event) {
|
||||
var code = '(function(){\n' +
|
||||
' var header = document.getElementById("header");\n' +
|
||||
' header.innerHTML = "Script literal successfully injected";\n' +
|
||||
' return "abc";\n' +
|
||||
'})()';
|
||||
iab.executeScript({ code: code }, useCallback && function (results) {
|
||||
if (results && results.length === 1 && results[0] === 'abc') {
|
||||
alert('Results verified'); // eslint-disable-line no-undef
|
||||
} else {
|
||||
console.log(results);
|
||||
alert('Got: ' + typeof (results) + '\n' + JSON.stringify(results)); // eslint-disable-line no-undef
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
var hiddenwnd = null;
|
||||
var loadlistener = function (event) { alert('background window loaded '); }; // eslint-disable-line no-undef
|
||||
function openHidden (url, startHidden) {
|
||||
var shopt = (startHidden) ? 'hidden=yes' : '';
|
||||
if (platformOpts) {
|
||||
shopt += (shopt ? ',' : '') + platformOpts;
|
||||
}
|
||||
hiddenwnd = cordova.InAppBrowser.open(url, 'random_string', shopt);
|
||||
if (!hiddenwnd) {
|
||||
alert('cordova.InAppBrowser.open returned ' + hiddenwnd); // eslint-disable-line no-undef
|
||||
return;
|
||||
}
|
||||
if (startHidden) hiddenwnd.addEventListener('loadstop', loadlistener);
|
||||
}
|
||||
function showHidden () {
|
||||
if (hiddenwnd) {
|
||||
hiddenwnd.show();
|
||||
}
|
||||
}
|
||||
function closeHidden () {
|
||||
if (hiddenwnd) {
|
||||
hiddenwnd.removeEventListener('loadstop', loadlistener);
|
||||
hiddenwnd.close();
|
||||
hiddenwnd = null;
|
||||
}
|
||||
}
|
||||
|
||||
var info_div = '<h1>InAppBrowser</h1>' +
|
||||
'<div id="info">' +
|
||||
'Make sure http://cordova.apache.org and http://google.co.uk and https://www.google.co.uk are white listed. </br>' +
|
||||
'Make sure http://www.apple.com is not in the white list.</br>' +
|
||||
'In iOS, starred <span style="vertical-align:super">*</span> tests will put the app in a state with no way to return. </br>' +
|
||||
'<h4>User-Agent: <span id="user-agent"> </span></hr>' +
|
||||
'</div>';
|
||||
|
||||
var local_tests = '<h1>Local URL</h1>' +
|
||||
'<div id="openLocal"></div>' +
|
||||
'Expected result: opens successfully in CordovaWebView.' +
|
||||
'<p/> <div id="openLocalHook"></div>' +
|
||||
'Expected result: opens successfully in CordovaWebView (using hook of window.open()).' +
|
||||
'<p/> <div id="openLocalSelf"></div>' +
|
||||
'Expected result: opens successfully in CordovaWebView.' +
|
||||
'<p/> <div id="openLocalSystem"></div>' +
|
||||
'Expected result: fails to open' +
|
||||
'<p/> <div id="openLocalBlank"></div>' +
|
||||
'Expected result: opens successfully in InAppBrowser with locationBar at top.' +
|
||||
'<p/> <div id="openLocalRandomNoLocation"></div>' +
|
||||
'Expected result: opens successfully in InAppBrowser without locationBar.' +
|
||||
'<p/> <div id="openLocalRandomToolBarBottom"></div>' +
|
||||
'Expected result: opens successfully in InAppBrowser with locationBar. On iOS the toolbar is at the bottom.' +
|
||||
'<p/> <div id="openLocalRandomToolBarTop"></div>' +
|
||||
'Expected result: opens successfully in InAppBrowser with locationBar. On iOS the toolbar is at the top.' +
|
||||
'<p/><div id="openLocalRandomToolBarTopNoLocation"></div>' +
|
||||
'Expected result: open successfully in InAppBrowser with no locationBar. On iOS the toolbar is at the top.';
|
||||
|
||||
var white_listed_tests = '<h1>White Listed URL</h1>' +
|
||||
'<div id="openWhiteListed"></div>' +
|
||||
'Expected result: open successfully in CordovaWebView to cordova.apache.org' +
|
||||
'<p/> <div id="openWhiteListedHook"></div>' +
|
||||
'Expected result: open successfully in CordovaWebView to cordova.apache.org (using hook of window.open())' +
|
||||
'<p/> <div id="openWhiteListedSelf"></div>' +
|
||||
'Expected result: open successfully in CordovaWebView to cordova.apache.org' +
|
||||
'<p/> <div id="openWhiteListedSystem"></div>' +
|
||||
'Expected result: open successfully in system browser to cordova.apache.org' +
|
||||
'<p/> <div id="openWhiteListedBlank"></div>' +
|
||||
'Expected result: open successfully in InAppBrowser to cordova.apache.org' +
|
||||
'<p/> <div id="openWhiteListedRandom"></div>' +
|
||||
'Expected result: open successfully in InAppBrowser to cordova.apache.org' +
|
||||
'<p/> <div id="openWhiteListedRandomNoLocation"></div>' +
|
||||
'Expected result: open successfully in InAppBrowser to cordova.apache.org with no location bar.';
|
||||
|
||||
var non_white_listed_tests = '<h1>Non White Listed URL</h1>' +
|
||||
'<div id="openNonWhiteListed"></div>' +
|
||||
'Expected result: open successfully in InAppBrowser to apple.com.' +
|
||||
'<p/> <div id="openNonWhiteListedHook"></div>' +
|
||||
'Expected result: open successfully in InAppBrowser to apple.com (using hook of window.open()).' +
|
||||
'<p/> <div id="openNonWhiteListedSelf"></div>' +
|
||||
'Expected result: open successfully in InAppBrowser to apple.com (_self enforces whitelist).' +
|
||||
'<p/> <div id="openNonWhiteListedSystem"></div>' +
|
||||
'Expected result: open successfully in system browser to apple.com.' +
|
||||
'<p/> <div id="openNonWhiteListedBlank"></div>' +
|
||||
'Expected result: open successfully in InAppBrowser to apple.com.' +
|
||||
'<p/> <div id="openNonWhiteListedRandom"></div>' +
|
||||
'Expected result: open successfully in InAppBrowser to apple.com.' +
|
||||
'<p/> <div id="openNonWhiteListedRandomNoLocation"></div>' +
|
||||
'Expected result: open successfully in InAppBrowser to apple.com without locationBar.';
|
||||
|
||||
var page_with_redirects_tests = '<h1>Page with redirect</h1>' +
|
||||
'<div id="openRedirect301"></div>' +
|
||||
'Expected result: should 301 and open successfully in InAppBrowser to https://www.google.co.uk.' +
|
||||
'<p/> <div id="openRedirect302"></div>' +
|
||||
'Expected result: should 302 and open successfully in InAppBrowser to www.zhihu.com/answer/16714076.';
|
||||
|
||||
var pdf_url_tests = '<h1>PDF URL</h1>' +
|
||||
'<div id="openPDF"></div>' +
|
||||
'Expected result: InAppBrowser opens. PDF should render on iOS.' +
|
||||
'<p/> <div id="openPDFBlank"></div>' +
|
||||
'Expected result: InAppBrowser opens. PDF should render on iOS.';
|
||||
|
||||
var invalid_url_tests = '<h1>Invalid URL</h1>' +
|
||||
'<div id="openInvalidScheme"></div>' +
|
||||
'Expected result: fail to load in InAppBrowser.' +
|
||||
'<p/> <div id="openInvalidHost"></div>' +
|
||||
'Expected result: fail to load in InAppBrowser.' +
|
||||
'<p/> <div id="openInvalidMissing"></div>' +
|
||||
'Expected result: fail to load in InAppBrowser (404).';
|
||||
|
||||
var css_js_injection_tests = '<h1>CSS / JS Injection</h1>' +
|
||||
'<div id="openOriginalDocument"></div>' +
|
||||
'Expected result: open successfully in InAppBrowser without text "Style updated from..."' +
|
||||
'<p/> <div id="openCSSInjection"></div>' +
|
||||
'Expected result: open successfully in InAppBrowser with "Style updated from file".' +
|
||||
'<p/> <div id="openCSSInjectionCallback"></div>' +
|
||||
'Expected result: open successfully in InAppBrowser with "Style updated from file", and alert dialog with text "Results verified".' +
|
||||
'<p/> <div id="openCSSLiteralInjection"></div>' +
|
||||
'Expected result: open successfully in InAppBrowser with "Style updated from literal".' +
|
||||
'<p/> <div id="openCSSLiteralInjectionCallback"></div>' +
|
||||
'Expected result: open successfully in InAppBrowser with "Style updated from literal", and alert dialog with text "Results verified".' +
|
||||
'<p/> <div id="openScriptInjection"></div>' +
|
||||
'Expected result: open successfully in InAppBrowser with text "Script file successfully injected".' +
|
||||
'<p/> <div id="openScriptInjectionCallback"></div>' +
|
||||
'Expected result: open successfully in InAppBrowser with text "Script file successfully injected" and alert dialog with the text "Results verified".' +
|
||||
'<p/> <div id="openScriptLiteralInjection"></div>' +
|
||||
'Expected result: open successfully in InAppBrowser with the text "Script literal successfully injected" .' +
|
||||
'<p/> <div id="openScriptLiteralInjectionCallback"></div>' +
|
||||
'Expected result: open successfully in InAppBrowser with the text "Script literal successfully injected" and alert dialog with the text "Results verified".';
|
||||
|
||||
var open_hidden_tests = '<h1>Open Hidden </h1>' +
|
||||
'<div id="openHidden"></div>' +
|
||||
'Expected result: no additional browser window. Alert appears with the text "background window loaded".' +
|
||||
'<p/> <div id="showHidden"></div>' +
|
||||
'Expected result: after first clicking on previous test "create hidden", open successfully in InAppBrowser to https://www.google.co.uk.' +
|
||||
'<p/> <div id="closeHidden"></div>' +
|
||||
'Expected result: no output. But click on "show hidden" again and nothing should be shown.' +
|
||||
'<p/> <div id="openHiddenShow"></div>' +
|
||||
'Expected result: open successfully in InAppBrowser to https://www.google.co.uk' +
|
||||
'<p/> <div id="openVisibleAndHide"></div>' +
|
||||
'Expected result: open successfully in InAppBrowser to https://www.google.co.uk. Hide after 2 seconds';
|
||||
|
||||
var clearing_cache_tests = '<h1>Clearing Cache</h1>' +
|
||||
'<div id="openClearCache"></div>' +
|
||||
'Expected result: ?' +
|
||||
'<p/> <div id="openClearSessionCache"></div>' +
|
||||
'Expected result: ?';
|
||||
|
||||
var video_tag_tests = '<h1>Video tag</h1>' +
|
||||
'<div id="openRemoteVideo"></div>' +
|
||||
'Expected result: open successfully in InAppBrowser with an embedded video plays automatically on iOS and Android.' +
|
||||
'<div id="openRemoteNeedUserNoVideo"></div>' +
|
||||
'Expected result: open successfully in InAppBrowser with an embedded video plays automatically on iOS and Android.' +
|
||||
'<div id="openRemoteNeedUserYesVideo"></div>' +
|
||||
'Expected result: open successfully in InAppBrowser with an embedded video does not play automatically on iOS and Android but rather works after clicking the "play" button.';
|
||||
|
||||
var local_with_anchor_tag_tests = '<h1>Local with anchor tag</h1>' +
|
||||
'<div id="openAnchor1"></div>' +
|
||||
'Expected result: open successfully in InAppBrowser to the local page, scrolled to the top as normal.' +
|
||||
'<p/> <div id="openAnchor2"></div>' +
|
||||
'Expected result: open successfully in InAppBrowser to the local page, scrolled to the beginning of the tall div with border.';
|
||||
|
||||
var hardwareback_tests = '<h1>HardwareBack</h1>' +
|
||||
'<p/> <div id="openHardwareBackDefault"></div>' +
|
||||
'Expected result: By default hardwareback is yes so pressing back button should navigate backwards in history then close InAppBrowser' +
|
||||
'<p/> <div id="openHardwareBackYes"></div>' +
|
||||
'Expected result: hardwareback=yes pressing back button should navigate backwards in history then close InAppBrowser' +
|
||||
'<p/> <div id="openHardwareBackNo"></div>' +
|
||||
'Expected result: hardwareback=no pressing back button should close InAppBrowser regardless history' +
|
||||
'<p/> <div id="openHardwareBackDefaultAfterNo"></div>' +
|
||||
'Expected result: consistently open browsers with with the appropriate option: hardwareback=defaults to yes then hardwareback=no then hardwareback=defaults to yes. By default hardwareback is yes so pressing back button should navigate backwards in history then close InAppBrowser';
|
||||
|
||||
// CB-7490 We need to wrap this code due to Windows security restrictions
|
||||
// see http://msdn.microsoft.com/en-us/library/windows/apps/hh465380.aspx#differences for details
|
||||
if (window.MSApp && window.MSApp.execUnsafeLocalFunction) {
|
||||
MSApp.execUnsafeLocalFunction(function () {
|
||||
contentEl.innerHTML = info_div + platform_info + local_tests + white_listed_tests + non_white_listed_tests + page_with_redirects_tests + pdf_url_tests + invalid_url_tests +
|
||||
css_js_injection_tests + open_hidden_tests + clearing_cache_tests + video_tag_tests + local_with_anchor_tag_tests + hardwareback_tests;
|
||||
});
|
||||
} else {
|
||||
contentEl.innerHTML = info_div + platform_info + local_tests + white_listed_tests + non_white_listed_tests + page_with_redirects_tests + pdf_url_tests + invalid_url_tests +
|
||||
css_js_injection_tests + open_hidden_tests + clearing_cache_tests + video_tag_tests + local_with_anchor_tag_tests + hardwareback_tests;
|
||||
}
|
||||
|
||||
document.getElementById('user-agent').textContent = navigator.userAgent;
|
||||
|
||||
// we are already in cdvtests directory
|
||||
var basePath = 'iab-resources/';
|
||||
var localhtml = basePath + 'local.html';
|
||||
var localpdf = basePath + 'local.pdf';
|
||||
var injecthtml = basePath + 'inject.html';
|
||||
var injectjs = isWindows ? basePath + 'inject.js' : 'inject.js';
|
||||
var injectcss = isWindows ? basePath + 'inject.css' : 'inject.css';
|
||||
var videohtml = basePath + 'video.html';
|
||||
if (isIos) {
|
||||
createActionButton('Webview=UIWebView', function () {
|
||||
var webviewOption = 'usewkwebview=';
|
||||
var webviewToggle = document.getElementById('webviewToggle');
|
||||
var button = webviewToggle.getElementsByClassName('topcoat-button')[0];
|
||||
if (platformOpts === webviewOption + 'yes') {
|
||||
platformOpts = webviewOption + 'no';
|
||||
button.textContent = 'Webview=UIWebView';
|
||||
} else {
|
||||
platformOpts = webviewOption + 'yes';
|
||||
button.textContent = 'Webview=WKWebView';
|
||||
}
|
||||
}, 'webviewToggle');
|
||||
}
|
||||
|
||||
// Local
|
||||
createActionButton('target=Default', function () {
|
||||
doOpen(localhtml);
|
||||
}, 'openLocal');
|
||||
createActionButton('target=Default (window.open)', function () {
|
||||
doHookOpen(localhtml);
|
||||
}, 'openLocalHook');
|
||||
createActionButton('target=_self', function () {
|
||||
doOpen(localhtml, '_self');
|
||||
}, 'openLocalSelf');
|
||||
createActionButton('target=_system', function () {
|
||||
doOpen(localhtml, '_system');
|
||||
}, 'openLocalSystem');
|
||||
createActionButton('target=_blank', function () {
|
||||
doOpen(localhtml, '_blank');
|
||||
}, 'openLocalBlank');
|
||||
createActionButton('target=Random, location=no, disallowoverscroll=yes', function () {
|
||||
doOpen(localhtml, 'random_string', 'location=no, disallowoverscroll=yes');
|
||||
}, 'openLocalRandomNoLocation');
|
||||
createActionButton('target=Random, toolbarposition=bottom', function () {
|
||||
doOpen(localhtml, 'random_string', 'toolbarposition=bottom');
|
||||
}, 'openLocalRandomToolBarBottom');
|
||||
createActionButton('target=Random, toolbarposition=top', function () {
|
||||
doOpen(localhtml, 'random_string', 'toolbarposition=top');
|
||||
}, 'openLocalRandomToolBarTop');
|
||||
createActionButton('target=Random, toolbarposition=top, location=no', function () {
|
||||
doOpen(localhtml, 'random_string', 'toolbarposition=top,location=no');
|
||||
}, 'openLocalRandomToolBarTopNoLocation');
|
||||
|
||||
// White Listed
|
||||
createActionButton('* target=Default', function () {
|
||||
doOpen('http://cordova.apache.org');
|
||||
}, 'openWhiteListed');
|
||||
createActionButton('* target=Default (window.open)', function () {
|
||||
doHookOpen('http://cordova.apache.org');
|
||||
}, 'openWhiteListedHook');
|
||||
createActionButton('* target=_self', function () {
|
||||
doOpen('http://cordova.apache.org', '_self');
|
||||
}, 'openWhiteListedSelf');
|
||||
createActionButton('target=_system', function () {
|
||||
doOpen('http://cordova.apache.org', '_system');
|
||||
}, 'openWhiteListedSystem');
|
||||
createActionButton('target=_blank', function () {
|
||||
doOpen('http://cordova.apache.org', '_blank');
|
||||
}, 'openWhiteListedBlank');
|
||||
createActionButton('target=Random', function () {
|
||||
doOpen('http://cordova.apache.org', 'random_string');
|
||||
}, 'openWhiteListedRandom');
|
||||
createActionButton('* target=Random, no location bar', function () {
|
||||
doOpen('http://cordova.apache.org', 'random_string', 'location=no');
|
||||
}, 'openWhiteListedRandomNoLocation');
|
||||
|
||||
// Non White Listed
|
||||
createActionButton('target=Default', function () {
|
||||
doOpen('http://www.apple.com');
|
||||
}, 'openNonWhiteListed');
|
||||
createActionButton('target=Default (window.open)', function () {
|
||||
doHookOpen('http://www.apple.com');
|
||||
}, 'openNonWhiteListedHook');
|
||||
createActionButton('target=_self', function () {
|
||||
doOpen('http://www.apple.com', '_self');
|
||||
}, 'openNonWhiteListedSelf');
|
||||
createActionButton('target=_system', function () {
|
||||
doOpen('http://www.apple.com', '_system');
|
||||
}, 'openNonWhiteListedSystem');
|
||||
createActionButton('target=_blank', function () {
|
||||
doOpen('http://www.apple.com', '_blank');
|
||||
}, 'openNonWhiteListedBlank');
|
||||
createActionButton('target=Random', function () {
|
||||
doOpen('http://www.apple.com', 'random_string');
|
||||
}, 'openNonWhiteListedRandom');
|
||||
createActionButton('* target=Random, no location bar', function () {
|
||||
doOpen('http://www.apple.com', 'random_string', 'location=no');
|
||||
}, 'openNonWhiteListedRandomNoLocation');
|
||||
|
||||
// Page with redirect
|
||||
createActionButton('http://google.co.uk', function () {
|
||||
doOpen('http://google.co.uk', 'random_string', '', 1);
|
||||
}, 'openRedirect301');
|
||||
createActionButton('http://goo.gl/pUFqg', function () {
|
||||
doOpen('http://goo.gl/pUFqg', 'random_string', '', 2);
|
||||
}, 'openRedirect302');
|
||||
|
||||
// PDF URL
|
||||
createActionButton('Remote URL', function () {
|
||||
doOpen('http://www.stluciadance.com/prospectus_file/sample.pdf');
|
||||
}, 'openPDF');
|
||||
createActionButton('Local URL', function () {
|
||||
doOpen(localpdf, '_blank');
|
||||
}, 'openPDFBlank');
|
||||
|
||||
// Invalid URL
|
||||
createActionButton('Invalid Scheme', function () {
|
||||
doOpen('x-ttp://www.invalid.com/', '_blank');
|
||||
}, 'openInvalidScheme');
|
||||
createActionButton('Invalid Host', function () {
|
||||
doOpen('http://www.inv;alid.com/', '_blank');
|
||||
}, 'openInvalidHost');
|
||||
createActionButton('Missing Local File', function () {
|
||||
doOpen('nonexistent.html', '_blank');
|
||||
}, 'openInvalidMissing');
|
||||
|
||||
// CSS / JS injection
|
||||
createActionButton('Original Document', function () {
|
||||
doOpen(injecthtml, '_blank');
|
||||
}, 'openOriginalDocument');
|
||||
createActionButton('CSS File Injection', function () {
|
||||
openWithStyle(injecthtml, injectcss);
|
||||
}, 'openCSSInjection');
|
||||
createActionButton('CSS File Injection (callback)', function () {
|
||||
openWithStyle(injecthtml, injectcss, true);
|
||||
}, 'openCSSInjectionCallback');
|
||||
createActionButton('CSS Literal Injection', function () {
|
||||
openWithStyle(injecthtml);
|
||||
}, 'openCSSLiteralInjection');
|
||||
createActionButton('CSS Literal Injection (callback)', function () {
|
||||
openWithStyle(injecthtml, null, true);
|
||||
}, 'openCSSLiteralInjectionCallback');
|
||||
createActionButton('Script File Injection', function () {
|
||||
openWithScript(injecthtml, injectjs);
|
||||
}, 'openScriptInjection');
|
||||
createActionButton('Script File Injection (callback)', function () {
|
||||
openWithScript(injecthtml, injectjs, true);
|
||||
}, 'openScriptInjectionCallback');
|
||||
createActionButton('Script Literal Injection', function () {
|
||||
openWithScript(injecthtml);
|
||||
}, 'openScriptLiteralInjection');
|
||||
createActionButton('Script Literal Injection (callback)', function () {
|
||||
openWithScript(injecthtml, null, true);
|
||||
}, 'openScriptLiteralInjectionCallback');
|
||||
|
||||
// Open hidden
|
||||
createActionButton('Create Hidden', function () {
|
||||
openHidden('https://www.google.co.uk', true);
|
||||
}, 'openHidden');
|
||||
createActionButton('Show Hidden', function () {
|
||||
showHidden();
|
||||
}, 'showHidden');
|
||||
createActionButton('Close Hidden', function () {
|
||||
closeHidden();
|
||||
}, 'closeHidden');
|
||||
createActionButton('google.co.uk Not Hidden', function () {
|
||||
openHidden('https://www.google.co.uk', false);
|
||||
}, 'openHiddenShow');
|
||||
createActionButton('google.co.uk shown for 2 seconds than hidden', function () {
|
||||
var iab = doOpen('https://www.google.co.uk/', 'random_sting');
|
||||
setTimeout(function () {
|
||||
iab.hide();
|
||||
}, 2000);
|
||||
}, 'openVisibleAndHide');
|
||||
|
||||
// Clearing cache
|
||||
createActionButton('Clear Browser Cache', function () {
|
||||
doOpen('https://www.google.co.uk', '_blank', 'clearcache=yes');
|
||||
}, 'openClearCache');
|
||||
createActionButton('Clear Session Cache', function () {
|
||||
doOpen('https://www.google.co.uk', '_blank', 'clearsessioncache=yes');
|
||||
}, 'openClearSessionCache');
|
||||
|
||||
// Video tag
|
||||
createActionButton('Remote Video', function () {
|
||||
doOpen(videohtml, '_blank');
|
||||
}, 'openRemoteVideo');
|
||||
createActionButton('Remote Need User No Video', function () {
|
||||
doOpen(videohtml, '_blank', 'mediaPlaybackRequiresUserAction=no');
|
||||
}, 'openRemoteNeedUserNoVideo');
|
||||
createActionButton('Remote Need User Yes Video', function () {
|
||||
doOpen(videohtml, '_blank', 'mediaPlaybackRequiresUserAction=yes');
|
||||
}, 'openRemoteNeedUserYesVideo');
|
||||
|
||||
// Local With Anchor Tag
|
||||
createActionButton('Anchor1', function () {
|
||||
doOpen(localhtml + '#bogusanchor', '_blank');
|
||||
}, 'openAnchor1');
|
||||
createActionButton('Anchor2', function () {
|
||||
doOpen(localhtml + '#anchor2', '_blank');
|
||||
}, 'openAnchor2');
|
||||
|
||||
// Hardwareback
|
||||
createActionButton('no hardwareback (defaults to yes)', function () {
|
||||
doOpen('http://cordova.apache.org', '_blank');
|
||||
}, 'openHardwareBackDefault');
|
||||
createActionButton('hardwareback=yes', function () {
|
||||
doOpen('http://cordova.apache.org', '_blank', 'hardwareback=yes');
|
||||
}, 'openHardwareBackYes');
|
||||
createActionButton('hardwareback=no', function () {
|
||||
doOpen('http://cordova.apache.org', '_blank', 'hardwareback=no');
|
||||
}, 'openHardwareBackNo');
|
||||
createActionButton('no hardwareback -> hardwareback=no -> no hardwareback', function () {
|
||||
var ref = cordova.InAppBrowser.open('https://google.com', '_blank', 'location=yes' + (platformOpts ? ',' + platformOpts : ''));
|
||||
ref.addEventListener('loadstop', function () {
|
||||
ref.close();
|
||||
});
|
||||
ref.addEventListener('exit', function () {
|
||||
var ref2 = cordova.InAppBrowser.open('https://google.com', '_blank', 'location=yes,hardwareback=no' + (platformOpts ? ',' + platformOpts : ''));
|
||||
ref2.addEventListener('loadstop', function () {
|
||||
ref2.close();
|
||||
});
|
||||
ref2.addEventListener('exit', function () {
|
||||
cordova.InAppBrowser.open('https://google.com', '_blank', 'location=yes' + (platformOpts ? ',' + platformOpts : ''));
|
||||
});
|
||||
});
|
||||
}, 'openHardwareBackDefaultAfterNo');
|
||||
};
|
||||
103
types/index.d.ts
vendored
Normal file
@@ -0,0 +1,103 @@
|
||||
// Type definitions for Apache Cordova InAppBrowser plugin
|
||||
// Project: https://github.com/apache/cordova-plugin-inappbrowser
|
||||
// Definitions by: Microsoft Open Technologies Inc <http://msopentech.com>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
//
|
||||
// Copyright (c) Microsoft Open Technologies Inc
|
||||
// Licensed under the MIT license.
|
||||
// TypeScript Version: 2.3
|
||||
type channel = "loadstart" | "loadstop" | "loaderror" | "exit" | "message";
|
||||
|
||||
interface Window {
|
||||
/**
|
||||
* Opens a URL in a new InAppBrowser instance, the current browser instance, or the system browser.
|
||||
* @param url The URL to load.
|
||||
* @param target The target in which to load the URL, an optional parameter that defaults to _self.
|
||||
* @param options Options for the InAppBrowser. Optional, defaulting to: location=yes.
|
||||
* The options string must not contain any blank space, and each feature's
|
||||
* 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;
|
||||
onexit(type: InAppBrowserEvent): void;
|
||||
// addEventListener overloads
|
||||
/**
|
||||
* Adds a listener for an event from the InAppBrowser.
|
||||
* @param type loadstart: event fires when the InAppBrowser starts to load a URL.
|
||||
* loadstop: event fires when the InAppBrowser finishes loading a URL.
|
||||
* loaderror: event fires when the InAppBrowser encounters an error when loading a URL.
|
||||
* exit: event fires when the InAppBrowser window is closed.
|
||||
* @param callback the function that executes when the event fires. The function is
|
||||
* passed an InAppBrowserEvent object as a parameter.
|
||||
*/
|
||||
addEventListener(type: channel, callback: InAppBrowserEventListenerOrEventListenerObject): void;
|
||||
// removeEventListener overloads
|
||||
/**
|
||||
* Removes a listener for an event from the InAppBrowser.
|
||||
* @param type The event to stop listening for.
|
||||
* loadstart: event fires when the InAppBrowser starts to load a URL.
|
||||
* loadstop: event fires when the InAppBrowser finishes loading a URL.
|
||||
* loaderror: event fires when the InAppBrowser encounters an error when loading a URL.
|
||||
* exit: event fires when the InAppBrowser window is closed.
|
||||
* @param callback the function that executes when the event fires. The function is
|
||||
* passed an InAppBrowserEvent object as a parameter.
|
||||
*/
|
||||
removeEventListener(type: channel, callback: InAppBrowserEventListenerOrEventListenerObject): void;
|
||||
/** Closes the InAppBrowser window. */
|
||||
close(): void;
|
||||
/** Hides the InAppBrowser window. Calling this has no effect if the InAppBrowser was already hidden. */
|
||||
hide(): void;
|
||||
/**
|
||||
* Displays an InAppBrowser window that was opened hidden. Calling this has no effect
|
||||
* if the InAppBrowser was already visible.
|
||||
*/
|
||||
show(): void;
|
||||
/**
|
||||
* Injects JavaScript code into the InAppBrowser window.
|
||||
* @param script Details of the script to run, specifying either a file or code key.
|
||||
* @param callback The function that executes after the JavaScript code is injected.
|
||||
* If the injected script is of type code, the callback executes with
|
||||
* a single parameter, which is the return value of the script, wrapped in an Array.
|
||||
* For multi-line scripts, this is the return value of the last statement,
|
||||
* or the last expression evaluated.
|
||||
*/
|
||||
executeScript(script: { code: string } | { file: string }, callback: (result: any) => void): void;
|
||||
/**
|
||||
* Injects CSS into the InAppBrowser window.
|
||||
* @param css Details of the script to run, specifying either a file or code key.
|
||||
* @param callback The function that executes after the CSS is injected.
|
||||
*/
|
||||
insertCSS(css: { code: string } | { file: string }, callback: () => void): void;
|
||||
}
|
||||
|
||||
type InAppBrowserEventListenerOrEventListenerObject = InAppBrowserEventListener | InAppBrowserEventListenerObject;
|
||||
|
||||
type InAppBrowserEventListener = (evt: InAppBrowserEvent) => void;
|
||||
|
||||
interface InAppBrowserEventListenerObject {
|
||||
handleEvent(evt: InAppBrowserEvent): void;
|
||||
}
|
||||
|
||||
interface InAppBrowserEvent extends Event {
|
||||
/** the eventname, either loadstart, loadstop, loaderror, or exit. */
|
||||
type: string;
|
||||
/** the URL that was loaded. */
|
||||
url: string;
|
||||
/** the error code, only in the case of loaderror. */
|
||||
code: number;
|
||||
/** the error message, only in the case of loaderror. */
|
||||
message: string;
|
||||
}
|
||||
|
||||
interface Cordova {
|
||||
InAppBrowser: InAppBrowser;
|
||||
}
|
||||
@@ -1,100 +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.
|
||||
*
|
||||
*/
|
||||
|
||||
var exec = require('cordova/exec');
|
||||
var channel = require('cordova/channel');
|
||||
var modulemapper = require('cordova/modulemapper');
|
||||
var urlutil = require('cordova/urlutil');
|
||||
|
||||
function InAppBrowser() {
|
||||
this.channels = {
|
||||
'loadstart': channel.create('loadstart'),
|
||||
'loadstop' : channel.create('loadstop'),
|
||||
'loaderror' : channel.create('loaderror'),
|
||||
'exit' : channel.create('exit')
|
||||
};
|
||||
this._alive = true;
|
||||
}
|
||||
|
||||
InAppBrowser.prototype = {
|
||||
_eventHandler: function (event) {
|
||||
if (event.type in this.channels) {
|
||||
this.channels[event.type].fire(event);
|
||||
}
|
||||
},
|
||||
close: function (eventname) {
|
||||
if (this._alive) {
|
||||
this._alive = false;
|
||||
exec(null, null, "InAppBrowser", "close", []);
|
||||
}
|
||||
},
|
||||
show: function (eventname) {
|
||||
exec(null, null, "InAppBrowser", "show", []);
|
||||
},
|
||||
addEventListener: function (eventname,f) {
|
||||
if (eventname in this.channels) {
|
||||
this.channels[eventname].subscribe(f);
|
||||
}
|
||||
},
|
||||
removeEventListener: function(eventname, f) {
|
||||
if (eventname in this.channels) {
|
||||
this.channels[eventname].unsubscribe(f);
|
||||
}
|
||||
},
|
||||
|
||||
executeScript: function(injectDetails, cb) {
|
||||
if (injectDetails.code) {
|
||||
exec(cb, null, "InAppBrowser", "injectScriptCode", [injectDetails.code, !!cb]);
|
||||
} else if (injectDetails.file) {
|
||||
exec(cb, null, "InAppBrowser", "injectScriptFile", [injectDetails.file, !!cb]);
|
||||
} else {
|
||||
throw new Error('executeScript requires exactly one of code or file to be specified');
|
||||
}
|
||||
},
|
||||
|
||||
insertCSS: function(injectDetails, cb) {
|
||||
if (injectDetails.code) {
|
||||
exec(cb, null, "InAppBrowser", "injectStyleCode", [injectDetails.code, !!cb]);
|
||||
} else if (injectDetails.file) {
|
||||
exec(cb, null, "InAppBrowser", "injectStyleFile", [injectDetails.file, !!cb]);
|
||||
} else {
|
||||
throw new Error('insertCSS requires exactly one of code or file to be specified');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = function(strUrl, strWindowName, strWindowFeatures) {
|
||||
// Don't catch calls that write to existing frames (e.g. named iframes).
|
||||
if (window.frames && window.frames[strWindowName]) {
|
||||
var origOpenFunc = modulemapper.getOriginalSymbol(window, 'open');
|
||||
return origOpenFunc.apply(window, arguments);
|
||||
}
|
||||
|
||||
strUrl = urlutil.makeAbsolute(strUrl);
|
||||
var iab = new InAppBrowser();
|
||||
var cb = function(eventname) {
|
||||
iab._eventHandler(eventname);
|
||||
};
|
||||
|
||||
exec(cb, cb, "InAppBrowser", "open", [strUrl, strWindowName, strWindowFeatures]);
|
||||
return iab;
|
||||
};
|
||||
|
||||
114
www/inappbrowser.css
Normal file
@@ -0,0 +1,114 @@
|
||||
/*
|
||||
* 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";
|
||||
}
|
||||
125
www/inappbrowser.js
Normal file
@@ -0,0 +1,125 @@
|
||||
/*
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
*/
|
||||
|
||||
(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');
|
||||
|
||||
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')
|
||||
};
|
||||
}
|
||||
|
||||
InAppBrowser.prototype = {
|
||||
_eventHandler: function (event) {
|
||||
if (event && (event.type in this.channels)) {
|
||||
if (event.type === 'beforeload') {
|
||||
this.channels[event.type].fire(event, this._loadAfterBeforeload);
|
||||
} else {
|
||||
this.channels[event.type].fire(event);
|
||||
}
|
||||
}
|
||||
},
|
||||
_loadAfterBeforeload: function (strUrl) {
|
||||
strUrl = urlutil.makeAbsolute(strUrl);
|
||||
exec(null, null, 'InAppBrowser', 'loadAfterBeforeload', [strUrl]);
|
||||
},
|
||||
close: function (eventname) {
|
||||
exec(null, null, 'InAppBrowser', 'close', []);
|
||||
},
|
||||
show: function (eventname) {
|
||||
exec(null, null, 'InAppBrowser', 'show', []);
|
||||
},
|
||||
hide: function (eventname) {
|
||||
exec(null, null, 'InAppBrowser', 'hide', []);
|
||||
},
|
||||
addEventListener: function (eventname, f) {
|
||||
if (eventname in this.channels) {
|
||||
this.channels[eventname].subscribe(f);
|
||||
}
|
||||
},
|
||||
removeEventListener: function (eventname, f) {
|
||||
if (eventname in this.channels) {
|
||||
this.channels[eventname].unsubscribe(f);
|
||||
}
|
||||
},
|
||||
|
||||
executeScript: function (injectDetails, cb) {
|
||||
if (injectDetails.code) {
|
||||
exec(cb, null, 'InAppBrowser', 'injectScriptCode', [injectDetails.code, !!cb]);
|
||||
} else if (injectDetails.file) {
|
||||
exec(cb, null, 'InAppBrowser', 'injectScriptFile', [injectDetails.file, !!cb]);
|
||||
} else {
|
||||
throw new Error('executeScript requires exactly one of code or file to be specified');
|
||||
}
|
||||
},
|
||||
|
||||
insertCSS: function (injectDetails, cb) {
|
||||
if (injectDetails.code) {
|
||||
exec(cb, null, 'InAppBrowser', 'injectStyleCode', [injectDetails.code, !!cb]);
|
||||
} else if (injectDetails.file) {
|
||||
exec(cb, null, 'InAppBrowser', 'injectStyleFile', [injectDetails.file, !!cb]);
|
||||
} else {
|
||||
throw new Error('insertCSS requires exactly one of code or file to be specified');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = function (strUrl, strWindowName, strWindowFeatures, callbacks) {
|
||||
// Don't catch calls that write to existing frames (e.g. named iframes).
|
||||
if (window.frames && window.frames[strWindowName]) {
|
||||
var origOpenFunc = modulemapper.getOriginalSymbol(window, 'open');
|
||||
return origOpenFunc.apply(window, arguments);
|
||||
}
|
||||
|
||||
strUrl = urlutil.makeAbsolute(strUrl);
|
||||
var iab = new InAppBrowser();
|
||||
|
||||
callbacks = callbacks || {};
|
||||
for (var callbackName in callbacks) {
|
||||
iab.addEventListener(callbackName, callbacks[callbackName]);
|
||||
}
|
||||
|
||||
var cb = function (eventname) {
|
||||
iab._eventHandler(eventname);
|
||||
};
|
||||
|
||||
strWindowFeatures = strWindowFeatures || '';
|
||||
|
||||
exec(cb, cb, 'InAppBrowser', 'open', [strUrl, strWindowName, strWindowFeatures]);
|
||||
return iab;
|
||||
};
|
||||
})();
|
||||
@@ -1,111 +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, require, document, setTimeout, window, module */
|
||||
|
||||
|
||||
|
||||
var cordova = require('cordova'),
|
||||
channel = require('cordova/channel');
|
||||
|
||||
var browserWrap;
|
||||
|
||||
var IAB = {
|
||||
|
||||
close: function (win, lose) {
|
||||
if (browserWrap) {
|
||||
browserWrap.parentNode.removeChild(browserWrap);
|
||||
browserWrap = null;
|
||||
}
|
||||
},
|
||||
show: function (win, lose) {
|
||||
/* empty block, ran out of bacon?
|
||||
if (browserWrap) {
|
||||
|
||||
}*/
|
||||
},
|
||||
open: function (win, lose, args) {
|
||||
var strUrl = args[0],
|
||||
target = args[1],
|
||||
features = args[2],
|
||||
url,
|
||||
elem;
|
||||
|
||||
if (target === "_system") {
|
||||
url = new Windows.Foundation.Uri(strUrl);
|
||||
Windows.System.Launcher.launchUriAsync(url);
|
||||
} else if (target === "_blank") {
|
||||
if (!browserWrap) {
|
||||
browserWrap = document.createElement("div");
|
||||
browserWrap.style.position = "absolute";
|
||||
browserWrap.style.width = (window.innerWidth - 80) + "px";
|
||||
browserWrap.style.height = (window.innerHeight - 80) + "px";
|
||||
browserWrap.style.borderWidth = "40px";
|
||||
browserWrap.style.borderStyle = "solid";
|
||||
browserWrap.style.borderColor = "rgba(0,0,0,0.25)";
|
||||
|
||||
browserWrap.onclick = function () {
|
||||
setTimeout(function () {
|
||||
IAB.close();
|
||||
}, 0);
|
||||
};
|
||||
|
||||
document.body.appendChild(browserWrap);
|
||||
}
|
||||
|
||||
elem = document.createElement("iframe");
|
||||
elem.style.width = (window.innerWidth - 80) + "px";
|
||||
elem.style.height = (window.innerHeight - 80) + "px";
|
||||
elem.style.borderWidth = "0px";
|
||||
elem.name = "targetFrame";
|
||||
elem.src = strUrl;
|
||||
|
||||
window.addEventListener("resize", function () {
|
||||
if (browserWrap && elem) {
|
||||
elem.style.width = (window.innerWidth - 80) + "px";
|
||||
elem.style.height = (window.innerHeight - 80) + "px";
|
||||
}
|
||||
});
|
||||
|
||||
browserWrap.appendChild(elem);
|
||||
} else {
|
||||
window.location = strUrl;
|
||||
}
|
||||
|
||||
//var object = new WinJS.UI.HtmlControl(elem, { uri: strUrl });
|
||||
|
||||
},
|
||||
|
||||
injectScriptCode: function (code, bCB) {
|
||||
|
||||
// "(function(d) { var c = d.createElement('script'); c.src = %@; d.body.appendChild(c); })(document)"
|
||||
},
|
||||
|
||||
injectScriptFile: function (file, bCB) {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = IAB;
|
||||
|
||||
|
||||
require("cordova/windows8/commandProxy").add("InAppBrowser", module.exports);
|
||||