cordova-plugin-inappbrowser-patch 6.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/CONTRIBUTING.md +37 -0
  2. package/LICENSE +202 -0
  3. package/NOTICE +5 -0
  4. package/README.md +722 -0
  5. package/RELEASENOTES.md +801 -0
  6. package/package.json +60 -0
  7. package/plugin.xml +103 -0
  8. package/src/android/InAppBrowser.java +1503 -0
  9. package/src/android/InAppBrowserDialog.java +57 -0
  10. package/src/android/InAppChromeClient.java +190 -0
  11. package/src/android/res/drawable-hdpi/ic_action_next_item.png +0 -0
  12. package/src/android/res/drawable-hdpi/ic_action_previous_item.png +0 -0
  13. package/src/android/res/drawable-hdpi/ic_action_remove.png +0 -0
  14. package/src/android/res/drawable-mdpi/ic_action_next_item.png +0 -0
  15. package/src/android/res/drawable-mdpi/ic_action_previous_item.png +0 -0
  16. package/src/android/res/drawable-mdpi/ic_action_remove.png +0 -0
  17. package/src/android/res/drawable-xhdpi/ic_action_next_item.png +0 -0
  18. package/src/android/res/drawable-xhdpi/ic_action_previous_item.png +0 -0
  19. package/src/android/res/drawable-xhdpi/ic_action_remove.png +0 -0
  20. package/src/android/res/drawable-xxhdpi/ic_action_next_item.png +0 -0
  21. package/src/android/res/drawable-xxhdpi/ic_action_previous_item.png +0 -0
  22. package/src/android/res/drawable-xxhdpi/ic_action_remove.png +0 -0
  23. package/src/browser/InAppBrowserProxy.js +245 -0
  24. package/src/ios/CDVInAppBrowserNavigationController.h +28 -0
  25. package/src/ios/CDVInAppBrowserNavigationController.m +63 -0
  26. package/src/ios/CDVInAppBrowserOptions.h +51 -0
  27. package/src/ios/CDVInAppBrowserOptions.m +90 -0
  28. package/src/ios/CDVWKInAppBrowser.h +80 -0
  29. package/src/ios/CDVWKInAppBrowser.m +1223 -0
  30. package/src/ios/CDVWKInAppBrowserUIDelegate.h +32 -0
  31. package/src/ios/CDVWKInAppBrowserUIDelegate.m +127 -0
  32. package/types/index.d.ts +109 -0
  33. package/www/inappbrowser.js +124 -0
@@ -0,0 +1,57 @@
1
+ /*
2
+ Licensed to the Apache Software Foundation (ASF) under one
3
+ or more contributor license agreements. See the NOTICE file
4
+ distributed with this work for additional information
5
+ regarding copyright ownership. The ASF licenses this file
6
+ to you under the Apache License, Version 2.0 (the
7
+ "License"); you may not use this file except in compliance
8
+ with the License. You may obtain a copy of the License at
9
+
10
+ http://www.apache.org/licenses/LICENSE-2.0
11
+
12
+ Unless required by applicable law or agreed to in writing,
13
+ software distributed under the License is distributed on an
14
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ KIND, either express or implied. See the License for the
16
+ specific language governing permissions and limitations
17
+ under the License.
18
+ */
19
+ package org.apache.cordova.inappbrowser;
20
+
21
+ import android.app.AlertDialog;
22
+ import android.app.Dialog;
23
+ import android.content.Context;
24
+
25
+ import org.json.JSONException;
26
+ import org.json.JSONObject;
27
+
28
+ /**
29
+ * Created by Oliver on 22/11/2013.
30
+ */
31
+ public class InAppBrowserDialog extends Dialog {
32
+ Context context;
33
+ InAppBrowser inAppBrowser = null;
34
+
35
+ public InAppBrowserDialog(Context context, int theme) {
36
+ super(context, theme);
37
+ this.context = context;
38
+ }
39
+
40
+ public void setInAppBroswer(InAppBrowser browser) {
41
+ this.inAppBrowser = browser;
42
+ }
43
+
44
+ public void onBackPressed () {
45
+ if (this.inAppBrowser == null) {
46
+ this.dismiss();
47
+ } else {
48
+ // better to go through the in inAppBrowser
49
+ // because it does a clean up
50
+ if (this.inAppBrowser.hardwareBack() && this.inAppBrowser.canGoBack()) {
51
+ this.inAppBrowser.goBack();
52
+ } else {
53
+ this.inAppBrowser.closeDialog();
54
+ }
55
+ }
56
+ }
57
+ }
@@ -0,0 +1,190 @@
1
+ /*
2
+ Licensed to the Apache Software Foundation (ASF) under one
3
+ or more contributor license agreements. See the NOTICE file
4
+ distributed with this work for additional information
5
+ regarding copyright ownership. The ASF licenses this file
6
+ to you under the Apache License, Version 2.0 (the
7
+ "License"); you may not use this file except in compliance
8
+ with the License. You may obtain a copy of the License at
9
+
10
+ http://www.apache.org/licenses/LICENSE-2.0
11
+
12
+ Unless required by applicable law or agreed to in writing,
13
+ software distributed under the License is distributed on an
14
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ KIND, either express or implied. See the License for the
16
+ specific language governing permissions and limitations
17
+ under the License.
18
+ */
19
+ package org.apache.cordova.inappbrowser;
20
+
21
+ import org.apache.cordova.CordovaWebView;
22
+ import org.apache.cordova.LOG;
23
+ import org.apache.cordova.PluginResult;
24
+ import org.json.JSONArray;
25
+ import org.json.JSONException;
26
+
27
+ import android.annotation.TargetApi;
28
+ import android.os.Build;
29
+ import android.os.Message;
30
+ import android.webkit.JsPromptResult;
31
+ import android.webkit.WebChromeClient;
32
+ import android.webkit.WebResourceRequest;
33
+ import android.webkit.WebStorage;
34
+ import android.webkit.WebView;
35
+ import android.webkit.WebViewClient;
36
+ import android.webkit.GeolocationPermissions.Callback;
37
+ import android.webkit.PermissionRequest;
38
+
39
+ public class InAppChromeClient extends WebChromeClient {
40
+
41
+ private CordovaWebView webView;
42
+ private String LOG_TAG = "InAppChromeClient";
43
+ private long MAX_QUOTA = 100 * 1024 * 1024;
44
+
45
+ public InAppChromeClient(CordovaWebView webView) {
46
+ super();
47
+ this.webView = webView;
48
+ }
49
+
50
+ public void onPermissionRequest(final PermissionRequest request) {
51
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
52
+ request.grant(request.getResources());
53
+ }
54
+ }
55
+
56
+ /**
57
+ * Handle database quota exceeded notification.
58
+ *
59
+ * @param url
60
+ * @param databaseIdentifier
61
+ * @param currentQuota
62
+ * @param estimatedSize
63
+ * @param totalUsedQuota
64
+ * @param quotaUpdater
65
+ */
66
+ @Override
67
+ public void onExceededDatabaseQuota(String url, String databaseIdentifier, long currentQuota, long estimatedSize,
68
+ long totalUsedQuota, WebStorage.QuotaUpdater quotaUpdater)
69
+ {
70
+ LOG.d(LOG_TAG, "onExceededDatabaseQuota estimatedSize: %d currentQuota: %d totalUsedQuota: %d", estimatedSize, currentQuota, totalUsedQuota);
71
+ quotaUpdater.updateQuota(MAX_QUOTA);
72
+ }
73
+
74
+ /**
75
+ * Instructs the client to show a prompt to ask the user to set the Geolocation permission state for the specified origin.
76
+ *
77
+ * @param origin
78
+ * @param callback
79
+ */
80
+ @Override
81
+ public void onGeolocationPermissionsShowPrompt(String origin, Callback callback) {
82
+ super.onGeolocationPermissionsShowPrompt(origin, callback);
83
+ callback.invoke(origin, true, false);
84
+ }
85
+
86
+ /**
87
+ * Tell the client to display a prompt dialog to the user.
88
+ * If the client returns true, WebView will assume that the client will
89
+ * handle the prompt dialog and call the appropriate JsPromptResult method.
90
+ *
91
+ * The prompt bridge provided for the InAppBrowser is capable of executing any
92
+ * oustanding callback belonging to the InAppBrowser plugin. Care has been
93
+ * taken that other callbacks cannot be triggered, and that no other code
94
+ * execution is possible.
95
+ *
96
+ * To trigger the bridge, the prompt default value should be of the form:
97
+ *
98
+ * gap-iab://<callbackId>
99
+ *
100
+ * where <callbackId> is the string id of the callback to trigger (something
101
+ * like "InAppBrowser0123456789")
102
+ *
103
+ * If present, the prompt message is expected to be a JSON-encoded value to
104
+ * pass to the callback. A JSON_EXCEPTION is returned if the JSON is invalid.
105
+ *
106
+ * @param view
107
+ * @param url
108
+ * @param message
109
+ * @param defaultValue
110
+ * @param result
111
+ */
112
+ @Override
113
+ public boolean onJsPrompt(WebView view, String url, String message, String defaultValue, JsPromptResult result) {
114
+ // See if the prompt string uses the 'gap-iab' protocol. If so, the remainder should be the id of a callback to execute.
115
+ if (defaultValue != null && defaultValue.startsWith("gap")) {
116
+ if(defaultValue.startsWith("gap-iab://")) {
117
+ PluginResult scriptResult;
118
+ String scriptCallbackId = defaultValue.substring(10);
119
+ if (scriptCallbackId.matches("^InAppBrowser[0-9]{1,10}$")) {
120
+ if(message == null || message.length() == 0) {
121
+ scriptResult = new PluginResult(PluginResult.Status.OK, new JSONArray());
122
+ } else {
123
+ try {
124
+ scriptResult = new PluginResult(PluginResult.Status.OK, new JSONArray(message));
125
+ } catch(JSONException e) {
126
+ scriptResult = new PluginResult(PluginResult.Status.JSON_EXCEPTION, e.getMessage());
127
+ }
128
+ }
129
+ this.webView.sendPluginResult(scriptResult, scriptCallbackId);
130
+ result.confirm("");
131
+ return true;
132
+ }
133
+ else {
134
+ // Anything else that doesn't look like InAppBrowser0123456789 should end up here
135
+ LOG.w(LOG_TAG, "InAppBrowser callback called with invalid callbackId : "+ scriptCallbackId);
136
+ result.cancel();
137
+ return true;
138
+ }
139
+ }
140
+ else {
141
+ // Anything else with a gap: prefix should get this message
142
+ LOG.w(LOG_TAG, "InAppBrowser does not support Cordova API calls: " + url + " " + defaultValue);
143
+ result.cancel();
144
+ return true;
145
+ }
146
+ }
147
+ return false;
148
+ }
149
+
150
+ /**
151
+ * The InAppWebBrowser WebView is configured to MultipleWindow mode to mitigate a security
152
+ * bug found in Chromium prior to version 83.0.4103.106.
153
+ * See https://bugs.chromium.org/p/chromium/issues/detail?id=1083819
154
+ *
155
+ * Valid Urls set to open in new window will be routed back to load in the original WebView.
156
+ *
157
+ * @param view
158
+ * @param isDialog
159
+ * @param isUserGesture
160
+ * @param resultMsg
161
+ * @return
162
+ */
163
+ @Override
164
+ public boolean onCreateWindow(WebView view, boolean isDialog, boolean isUserGesture, Message resultMsg) {
165
+ WebView inAppWebView = view;
166
+ final WebViewClient webViewClient =
167
+ new WebViewClient() {
168
+ @Override
169
+ public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
170
+ inAppWebView.loadUrl(request.getUrl().toString());
171
+ return true;
172
+ }
173
+
174
+ @Override
175
+ public boolean shouldOverrideUrlLoading(WebView view, String url) {
176
+ inAppWebView.loadUrl(url);
177
+ return true;
178
+ }
179
+ };
180
+
181
+ final WebView newWebView = new WebView(view.getContext());
182
+ newWebView.setWebViewClient(webViewClient);
183
+
184
+ final WebView.WebViewTransport transport = (WebView.WebViewTransport) resultMsg.obj;
185
+ transport.setWebView(newWebView);
186
+ resultMsg.sendToTarget();
187
+
188
+ return true;
189
+ }
190
+ }
@@ -0,0 +1,245 @@
1
+ /*
2
+ *
3
+ * Licensed to the Apache Software Foundation (ASF) under one
4
+ * or more contributor license agreements. See the NOTICE file
5
+ * distributed with this work for additional information
6
+ * regarding copyright ownership. The ASF licenses this file
7
+ * to you under the Apache License, Version 2.0 (the
8
+ * "License"); you may not use this file except in compliance
9
+ * with the License. You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing,
14
+ * software distributed under the License is distributed on an
15
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ * KIND, either express or implied. See the License for the
17
+ * specific language governing permissions and limitations
18
+ * under the License.
19
+ *
20
+ */
21
+
22
+ const modulemapper = require('cordova/modulemapper');
23
+
24
+ let browserWrap, popup, navigationButtonsDiv, navigationButtonsDivInner, backButton, forwardButton, closeButton;
25
+
26
+ function attachNavigationEvents (element, callback) {
27
+ const onError = function () {
28
+ try {
29
+ callback({ type: 'loaderror', url: this.contentWindow.location.href }, { keepCallback: true }); // eslint-disable-line n/no-callback-literal
30
+ } catch (err) {
31
+ // blocked by CORS :\
32
+ callback({ type: 'loaderror', url: null }, { keepCallback: true }); // eslint-disable-line n/no-callback-literal
33
+ }
34
+ };
35
+
36
+ element.addEventListener('pageshow', function () {
37
+ try {
38
+ callback({ type: 'loadstart', url: this.contentWindow.location.href }, { keepCallback: true }); // eslint-disable-line n/no-callback-literal
39
+ } catch (err) {
40
+ // blocked by CORS :\
41
+ callback({ type: 'loadstart', url: null }, { keepCallback: true }); // eslint-disable-line n/no-callback-literal
42
+ }
43
+ });
44
+
45
+ element.addEventListener('load', function () {
46
+ try {
47
+ callback({ type: 'loadstop', url: this.contentWindow.location.href }, { keepCallback: true }); // eslint-disable-line n/no-callback-literal
48
+ } catch (err) {
49
+ // blocked by CORS :\
50
+ callback({ type: 'loadstop', url: null }, { keepCallback: true }); // eslint-disable-line n/no-callback-literal
51
+ }
52
+ });
53
+
54
+ element.addEventListener('error', onError);
55
+ element.addEventListener('abort', onError);
56
+ }
57
+
58
+ const IAB = {
59
+ close: function (win, lose) {
60
+ if (browserWrap) {
61
+ // use the "open" function callback so that the exit event is fired properly
62
+ if (IAB._win) IAB._win({ type: 'exit' });
63
+
64
+ browserWrap.parentNode.removeChild(browserWrap);
65
+ browserWrap = null;
66
+ popup = null;
67
+ }
68
+ },
69
+
70
+ show: function (win, lose) {
71
+ if (browserWrap) {
72
+ browserWrap.style.display = 'block';
73
+ }
74
+ },
75
+
76
+ open: function (win, lose, args) {
77
+ const strUrl = args[0];
78
+ const target = args[1];
79
+ const features = args[2];
80
+
81
+ IAB._win = win;
82
+
83
+ if (target === '_self' || !target) {
84
+ window.location = strUrl;
85
+ } else if (target === '_system') {
86
+ modulemapper.getOriginalSymbol(window, 'window.open').call(window, strUrl, '_blank');
87
+ } else {
88
+ // "_blank" or anything else
89
+ if (!browserWrap) {
90
+ browserWrap = document.createElement('div');
91
+ browserWrap.style.position = 'absolute';
92
+ browserWrap.style.top = '0';
93
+ browserWrap.style.left = '0';
94
+ browserWrap.style.boxSizing = 'border-box';
95
+ browserWrap.style.borderWidth = '40px';
96
+ browserWrap.style.width = '100vw';
97
+ browserWrap.style.height = '100vh';
98
+ browserWrap.style.borderStyle = 'solid';
99
+ browserWrap.style.borderColor = 'rgba(0,0,0,0.25)';
100
+
101
+ browserWrap.onclick = function () {
102
+ setTimeout(function () {
103
+ IAB.close();
104
+ }, 0);
105
+ };
106
+
107
+ document.body.appendChild(browserWrap);
108
+ }
109
+
110
+ if (features.indexOf('hidden=yes') !== -1) {
111
+ browserWrap.style.display = 'none';
112
+ }
113
+
114
+ popup = document.createElement('iframe');
115
+ popup.style.borderWidth = '0px';
116
+ popup.style.width = '100%';
117
+
118
+ browserWrap.appendChild(popup);
119
+
120
+ if (features.indexOf('location=yes') !== -1 || features.indexOf('location') === -1) {
121
+ popup.style.height = 'calc(100% - 60px)';
122
+ popup.style.marginBottom = '-4px';
123
+
124
+ navigationButtonsDiv = document.createElement('div');
125
+ navigationButtonsDiv.style.height = '60px';
126
+ navigationButtonsDiv.style.backgroundColor = '#404040';
127
+ navigationButtonsDiv.style.zIndex = '999';
128
+ navigationButtonsDiv.onclick = function (e) {
129
+ e.cancelBubble = true;
130
+ };
131
+
132
+ navigationButtonsDivInner = document.createElement('div');
133
+ navigationButtonsDivInner.style.paddingTop = '10px';
134
+ navigationButtonsDivInner.style.height = '50px';
135
+ navigationButtonsDivInner.style.width = '160px';
136
+ navigationButtonsDivInner.style.margin = '0 auto';
137
+ navigationButtonsDivInner.style.backgroundColor = '#404040';
138
+ navigationButtonsDivInner.style.zIndex = '999';
139
+ navigationButtonsDivInner.onclick = function (e) {
140
+ e.cancelBubble = true;
141
+ };
142
+
143
+ backButton = document.createElement('button');
144
+ backButton.style.width = '40px';
145
+ backButton.style.height = '40px';
146
+ backButton.style.borderRadius = '40px';
147
+
148
+ backButton.innerHTML = '←';
149
+ backButton.addEventListener('click', function (e) {
150
+ if (popup.canGoBack) {
151
+ popup.goBack();
152
+ }
153
+ });
154
+
155
+ forwardButton = document.createElement('button');
156
+ forwardButton.style.marginLeft = '20px';
157
+ forwardButton.style.width = '40px';
158
+ forwardButton.style.height = '40px';
159
+ forwardButton.style.borderRadius = '40px';
160
+
161
+ forwardButton.innerHTML = '→';
162
+ forwardButton.addEventListener('click', function (e) {
163
+ if (popup.canGoForward) {
164
+ popup.goForward();
165
+ }
166
+ });
167
+
168
+ closeButton = document.createElement('button');
169
+ closeButton.style.marginLeft = '20px';
170
+ closeButton.style.width = '40px';
171
+ closeButton.style.height = '40px';
172
+ closeButton.style.borderRadius = '40px';
173
+
174
+ closeButton.innerHTML = '✖';
175
+ closeButton.addEventListener('click', function (e) {
176
+ setTimeout(function () {
177
+ IAB.close();
178
+ }, 0);
179
+ });
180
+
181
+ // iframe navigation is not yet supported
182
+ backButton.disabled = true;
183
+ forwardButton.disabled = true;
184
+
185
+ navigationButtonsDivInner.appendChild(backButton);
186
+ navigationButtonsDivInner.appendChild(forwardButton);
187
+ navigationButtonsDivInner.appendChild(closeButton);
188
+ navigationButtonsDiv.appendChild(navigationButtonsDivInner);
189
+
190
+ browserWrap.appendChild(navigationButtonsDiv);
191
+ } else {
192
+ popup.style.height = '100%';
193
+ }
194
+
195
+ // start listening for navigation events
196
+ attachNavigationEvents(popup, win);
197
+
198
+ popup.src = strUrl;
199
+ }
200
+ },
201
+
202
+ injectScriptCode: function (win, fail, args) {
203
+ const code = args[0];
204
+ const hasCallback = args[1];
205
+
206
+ if (browserWrap && popup) {
207
+ try {
208
+ popup.contentWindow.eval(code);
209
+ if (hasCallback) {
210
+ win([]);
211
+ }
212
+ } catch (e) {
213
+ console.error('Error occured while trying to injectScriptCode: ' + JSON.stringify(e));
214
+ }
215
+ }
216
+ },
217
+
218
+ injectScriptFile: function (win, fail, args) {
219
+ const msg = 'Browser cordova-plugin-inappbrowser injectScriptFile is not yet implemented';
220
+ console.warn(msg);
221
+ if (fail) {
222
+ fail(msg);
223
+ }
224
+ },
225
+
226
+ injectStyleCode: function (win, fail, args) {
227
+ const msg = 'Browser cordova-plugin-inappbrowser injectStyleCode is not yet implemented';
228
+ console.warn(msg);
229
+ if (fail) {
230
+ fail(msg);
231
+ }
232
+ },
233
+
234
+ injectStyleFile: function (win, fail, args) {
235
+ const msg = 'Browser cordova-plugin-inappbrowser injectStyleFile is not yet implemented';
236
+ console.warn(msg);
237
+ if (fail) {
238
+ fail(msg);
239
+ }
240
+ }
241
+ };
242
+
243
+ module.exports = IAB;
244
+
245
+ require('cordova/exec/proxy').add('InAppBrowser', module.exports);
@@ -0,0 +1,28 @@
1
+ /*
2
+ Licensed to the Apache Software Foundation (ASF) under one
3
+ or more contributor license agreements. See the NOTICE file
4
+ distributed with this work for additional information
5
+ regarding copyright ownership. The ASF licenses this file
6
+ to you under the Apache License, Version 2.0 (the
7
+ "License"); you may not use this file except in compliance
8
+ with the License. You may obtain a copy of the License at
9
+
10
+ http://www.apache.org/licenses/LICENSE-2.0
11
+
12
+ Unless required by applicable law or agreed to in writing,
13
+ software distributed under the License is distributed on an
14
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ KIND, either express or implied. See the License for the
16
+ specific language governing permissions and limitations
17
+ under the License.
18
+ */
19
+
20
+ #import <UIKit/UINavigationController.h>
21
+ #import <Cordova/CDVScreenOrientationDelegate.h>
22
+
23
+
24
+ @interface CDVInAppBrowserNavigationController : UINavigationController
25
+
26
+ @property (nonatomic, weak) id <CDVScreenOrientationDelegate> orientationDelegate;
27
+
28
+ @end
@@ -0,0 +1,63 @@
1
+ /*
2
+ Licensed to the Apache Software Foundation (ASF) under one
3
+ or more contributor license agreements. See the NOTICE file
4
+ distributed with this work for additional information
5
+ regarding copyright ownership. The ASF licenses this file
6
+ to you under the Apache License, Version 2.0 (the
7
+ "License"); you may not use this file except in compliance
8
+ with the License. You may obtain a copy of the License at
9
+
10
+ http://www.apache.org/licenses/LICENSE-2.0
11
+
12
+ Unless required by applicable law or agreed to in writing,
13
+ software distributed under the License is distributed on an
14
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ KIND, either express or implied. See the License for the
16
+ specific language governing permissions and limitations
17
+ under the License.
18
+ */
19
+
20
+ #import "CDVInAppBrowserNavigationController.h"
21
+
22
+ @implementation CDVInAppBrowserNavigationController : UINavigationController
23
+
24
+ - (void) dismissViewControllerAnimated:(BOOL)flag completion:(void (^)(void))completion {
25
+ if ( self.presentedViewController) {
26
+ [super dismissViewControllerAnimated:flag completion:completion];
27
+ }
28
+ }
29
+
30
+ - (void) viewDidLoad {
31
+ [super viewDidLoad];
32
+ }
33
+
34
+ - (CGRect) invertFrameIfNeeded:(CGRect)rect {
35
+ if (UIInterfaceOrientationIsLandscape([[UIApplication sharedApplication] statusBarOrientation])) {
36
+ CGFloat temp = rect.size.width;
37
+ rect.size.width = rect.size.height;
38
+ rect.size.height = temp;
39
+ }
40
+ rect.origin = CGPointZero;
41
+ return rect;
42
+ }
43
+
44
+ #pragma mark CDVScreenOrientationDelegate
45
+
46
+ - (BOOL)shouldAutorotate
47
+ {
48
+ if ((self.orientationDelegate != nil) && [self.orientationDelegate respondsToSelector:@selector(shouldAutorotate)]) {
49
+ return [self.orientationDelegate shouldAutorotate];
50
+ }
51
+ return YES;
52
+ }
53
+
54
+ - (UIInterfaceOrientationMask)supportedInterfaceOrientations
55
+ {
56
+ if ((self.orientationDelegate != nil) && [self.orientationDelegate respondsToSelector:@selector(supportedInterfaceOrientations)]) {
57
+ return [self.orientationDelegate supportedInterfaceOrientations];
58
+ }
59
+
60
+ return 1 << UIInterfaceOrientationPortrait;
61
+ }
62
+
63
+ @end
@@ -0,0 +1,51 @@
1
+ /*
2
+ Licensed to the Apache Software Foundation (ASF) under one
3
+ or more contributor license agreements. See the NOTICE file
4
+ distributed with this work for additional information
5
+ regarding copyright ownership. The ASF licenses this file
6
+ to you under the Apache License, Version 2.0 (the
7
+ "License"); you may not use this file except in compliance
8
+ with the License. You may obtain a copy of the License at
9
+
10
+ http://www.apache.org/licenses/LICENSE-2.0
11
+
12
+ Unless required by applicable law or agreed to in writing,
13
+ software distributed under the License is distributed on an
14
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ KIND, either express or implied. See the License for the
16
+ specific language governing permissions and limitations
17
+ under the License.
18
+ */
19
+
20
+ #import <Foundation/Foundation.h>
21
+
22
+ @interface CDVInAppBrowserOptions : NSObject {}
23
+
24
+ @property (nonatomic, assign) BOOL location;
25
+ @property (nonatomic, assign) BOOL toolbar;
26
+ @property (nonatomic, copy) NSString* closebuttoncaption;
27
+ @property (nonatomic, copy) NSString* closebuttoncolor;
28
+ @property (nonatomic, assign) BOOL lefttoright;
29
+ @property (nonatomic, copy) NSString* toolbarposition;
30
+ @property (nonatomic, copy) NSString* toolbarcolor;
31
+ @property (nonatomic, assign) BOOL toolbartranslucent;
32
+ @property (nonatomic, assign) BOOL hidenavigationbuttons;
33
+ @property (nonatomic, copy) NSString* navigationbuttoncolor;
34
+ @property (nonatomic, assign) BOOL cleardata;
35
+ @property (nonatomic, assign) BOOL clearcache;
36
+ @property (nonatomic, assign) BOOL clearsessioncache;
37
+ @property (nonatomic, assign) BOOL hidespinner;
38
+
39
+ @property (nonatomic, copy) NSString* presentationstyle;
40
+ @property (nonatomic, copy) NSString* transitionstyle;
41
+
42
+ @property (nonatomic, assign) BOOL enableviewportscale;
43
+ @property (nonatomic, assign) BOOL mediaplaybackrequiresuseraction;
44
+ @property (nonatomic, assign) BOOL allowinlinemediaplayback;
45
+ @property (nonatomic, assign) BOOL hidden;
46
+ @property (nonatomic, assign) BOOL disallowoverscroll;
47
+ @property (nonatomic, copy) NSString* beforeload;
48
+
49
+ + (CDVInAppBrowserOptions*)parseOptions:(NSString*)options;
50
+
51
+ @end