summaryrefslogtreecommitdiff
path: root/StoneIsland/plugins/cordova-plugin-inappbrowser/src
diff options
context:
space:
mode:
Diffstat (limited to 'StoneIsland/plugins/cordova-plugin-inappbrowser/src')
-rw-r--r--[-rwxr-xr-x]StoneIsland/plugins/cordova-plugin-inappbrowser/src/amazon/InAppBrowser.java0
-rw-r--r--[-rwxr-xr-x]StoneIsland/plugins/cordova-plugin-inappbrowser/src/amazon/InAppChromeClient.java0
-rw-r--r--[-rwxr-xr-x]StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/InAppBrowser.java294
-rw-r--r--[-rwxr-xr-x]StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/InAppBrowserDialog.java1
-rw-r--r--[-rwxr-xr-x]StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/InAppChromeClient.java0
-rw-r--r--[-rwxr-xr-x]StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-hdpi/ic_action_next_item.pngbin593 -> 593 bytes
-rw-r--r--[-rwxr-xr-x]StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-hdpi/ic_action_previous_item.pngbin599 -> 599 bytes
-rw-r--r--[-rwxr-xr-x]StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-hdpi/ic_action_remove.pngbin438 -> 438 bytes
-rw-r--r--[-rwxr-xr-x]StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-mdpi/ic_action_next_item.pngbin427 -> 427 bytes
-rw-r--r--[-rwxr-xr-x]StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-mdpi/ic_action_previous_item.pngbin438 -> 438 bytes
-rw-r--r--[-rwxr-xr-x]StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-mdpi/ic_action_remove.pngbin328 -> 328 bytes
-rw-r--r--[-rwxr-xr-x]StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-xhdpi/ic_action_next_item.pngbin727 -> 727 bytes
-rw-r--r--[-rwxr-xr-x]StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-xhdpi/ic_action_previous_item.pngbin744 -> 744 bytes
-rw-r--r--[-rwxr-xr-x]StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-xhdpi/ic_action_remove.pngbin536 -> 536 bytes
-rw-r--r--[-rwxr-xr-x]StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-xxhdpi/ic_action_next_item.pngbin1021 -> 1021 bytes
-rw-r--r--[-rwxr-xr-x]StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-xxhdpi/ic_action_previous_item.pngbin1038 -> 1038 bytes
-rw-r--r--[-rwxr-xr-x]StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-xxhdpi/ic_action_remove.pngbin681 -> 681 bytes
-rw-r--r--[-rwxr-xr-x]StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/README.md0
-rw-r--r--[-rwxr-xr-x]StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/de/README.md0
-rw-r--r--[-rwxr-xr-x]StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/es/README.md0
-rw-r--r--[-rwxr-xr-x]StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/fr/README.md0
-rw-r--r--[-rwxr-xr-x]StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/it/README.md0
-rw-r--r--[-rwxr-xr-x]StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/ja/README.md0
-rw-r--r--[-rwxr-xr-x]StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/ko/README.md0
-rw-r--r--[-rwxr-xr-x]StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/pl/README.md0
-rw-r--r--[-rwxr-xr-x]StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/zh/README.md0
-rw-r--r--[-rwxr-xr-x]StoneIsland/plugins/cordova-plugin-inappbrowser/src/browser/InAppBrowserProxy.js35
-rw-r--r--[-rwxr-xr-x]StoneIsland/plugins/cordova-plugin-inappbrowser/src/firefoxos/InAppBrowserProxy.js24
-rw-r--r--[-rwxr-xr-x]StoneIsland/plugins/cordova-plugin-inappbrowser/src/ios/CDVInAppBrowser.h1
-rw-r--r--[-rwxr-xr-x]StoneIsland/plugins/cordova-plugin-inappbrowser/src/ios/CDVInAppBrowser.m86
-rw-r--r--[-rwxr-xr-x]StoneIsland/plugins/cordova-plugin-inappbrowser/src/ubuntu/InAppBrowser.qml0
-rw-r--r--[-rwxr-xr-x]StoneIsland/plugins/cordova-plugin-inappbrowser/src/ubuntu/InAppBrowser_escapeScript.js3
-rw-r--r--[-rwxr-xr-x]StoneIsland/plugins/cordova-plugin-inappbrowser/src/ubuntu/close.pngbin461 -> 461 bytes
-rw-r--r--[-rwxr-xr-x]StoneIsland/plugins/cordova-plugin-inappbrowser/src/ubuntu/inappbrowser.cpp0
-rw-r--r--[-rwxr-xr-x]StoneIsland/plugins/cordova-plugin-inappbrowser/src/ubuntu/inappbrowser.h0
-rw-r--r--[-rwxr-xr-x]StoneIsland/plugins/cordova-plugin-inappbrowser/src/windows/InAppBrowserProxy.js420
-rw-r--r--[-rwxr-xr-x]StoneIsland/plugins/cordova-plugin-inappbrowser/src/wp/InAppBrowser.cs0
37 files changed, 550 insertions, 314 deletions
diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/amazon/InAppBrowser.java b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/amazon/InAppBrowser.java
index 0263ea2c..0263ea2c 100755..100644
--- a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/amazon/InAppBrowser.java
+++ b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/amazon/InAppBrowser.java
diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/amazon/InAppChromeClient.java b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/amazon/InAppChromeClient.java
index 37cf101f..37cf101f 100755..100644
--- a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/amazon/InAppChromeClient.java
+++ b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/amazon/InAppChromeClient.java
diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/InAppBrowser.java b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/InAppBrowser.java
index 60437451..8f4f3d97 100755..100644
--- a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/InAppBrowser.java
+++ b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/InAppBrowser.java
@@ -19,7 +19,6 @@
package org.apache.cordova.inappbrowser;
import android.annotation.SuppressLint;
-import org.apache.cordova.inappbrowser.InAppBrowserDialog;
import android.content.Context;
import android.content.Intent;
import android.provider.Browser;
@@ -30,7 +29,6 @@ import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.text.InputType;
-import android.util.Log;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.KeyEvent;
@@ -41,17 +39,21 @@ import android.view.WindowManager.LayoutParams;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodManager;
import android.webkit.CookieManager;
+import android.webkit.CookieSyncManager;
+import android.webkit.HttpAuthHandler;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
-import android.widget.Button;
import android.widget.EditText;
+import android.widget.ImageButton;
+import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import org.apache.cordova.CallbackContext;
import org.apache.cordova.Config;
import org.apache.cordova.CordovaArgs;
+import org.apache.cordova.CordovaHttpAuthHandler;
import org.apache.cordova.CordovaPlugin;
import org.apache.cordova.CordovaWebView;
import org.apache.cordova.LOG;
@@ -61,6 +63,7 @@ import org.json.JSONException;
import org.json.JSONObject;
import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.StringTokenizer;
@@ -82,6 +85,8 @@ public class InAppBrowser extends CordovaPlugin {
private static final String CLEAR_ALL_CACHE = "clearcache";
private static final String CLEAR_SESSION_CACHE = "clearsessioncache";
private static final String HARDWARE_BACK_BUTTON = "hardwareback";
+ private static final String MEDIA_PLAYBACK_REQUIRES_USER_ACTION = "mediaPlaybackRequiresUserAction";
+ private static final String SHOULD_PAUSE = "shouldPauseOnSuspend";
private InAppBrowserDialog dialog;
private WebView inAppWebView;
@@ -93,6 +98,8 @@ public class InAppBrowser extends CordovaPlugin {
private boolean clearAllCache = false;
private boolean clearSessionCache = false;
private boolean hadwareBackButton = true;
+ private boolean mediaPlaybackRequiresUserGesture = false;
+ private boolean shouldPauseInAppBrowser = false;
/**
* Executes the request and returns PluginResult.
@@ -113,7 +120,7 @@ public class InAppBrowser extends CordovaPlugin {
final String target = t;
final HashMap<String, Boolean> features = parseFeature(args.optString(2));
- Log.d(LOG_TAG, "target = " + target);
+ LOG.d(LOG_TAG, "target = " + target);
this.cordova.getActivity().runOnUiThread(new Runnable() {
@Override
@@ -121,7 +128,7 @@ public class InAppBrowser extends CordovaPlugin {
String result = "";
// SELF
if (SELF.equals(target)) {
- Log.d(LOG_TAG, "in self");
+ LOG.d(LOG_TAG, "in self");
/* This code exists for compatibility between 3.x and 4.x versions of Cordova.
* Previously the Config class had a static method, isUrlWhitelisted(). That
* responsibility has been moved to the plugins, with an aggregating method in
@@ -136,8 +143,11 @@ public class InAppBrowser extends CordovaPlugin {
Method iuw = Config.class.getMethod("isUrlWhiteListed", String.class);
shouldAllowNavigation = (Boolean)iuw.invoke(null, url);
} catch (NoSuchMethodException e) {
+ LOG.d(LOG_TAG, e.getLocalizedMessage());
} catch (IllegalAccessException e) {
+ LOG.d(LOG_TAG, e.getLocalizedMessage());
} catch (InvocationTargetException e) {
+ LOG.d(LOG_TAG, e.getLocalizedMessage());
}
}
if (shouldAllowNavigation == null) {
@@ -147,20 +157,23 @@ public class InAppBrowser extends CordovaPlugin {
Method san = pm.getClass().getMethod("shouldAllowNavigation", String.class);
shouldAllowNavigation = (Boolean)san.invoke(pm, url);
} catch (NoSuchMethodException e) {
+ LOG.d(LOG_TAG, e.getLocalizedMessage());
} catch (IllegalAccessException e) {
+ LOG.d(LOG_TAG, e.getLocalizedMessage());
} catch (InvocationTargetException e) {
+ LOG.d(LOG_TAG, e.getLocalizedMessage());
}
}
// load in webview
if (Boolean.TRUE.equals(shouldAllowNavigation)) {
- Log.d(LOG_TAG, "loading in webview");
+ LOG.d(LOG_TAG, "loading in webview");
webView.loadUrl(url);
}
//Load the dialer
else if (url.startsWith(WebView.SCHEME_TEL))
{
try {
- Log.d(LOG_TAG, "loading in dialer");
+ LOG.d(LOG_TAG, "loading in dialer");
Intent intent = new Intent(Intent.ACTION_DIAL);
intent.setData(Uri.parse(url));
cordova.getActivity().startActivity(intent);
@@ -170,18 +183,18 @@ public class InAppBrowser extends CordovaPlugin {
}
// load in InAppBrowser
else {
- Log.d(LOG_TAG, "loading in InAppBrowser");
+ LOG.d(LOG_TAG, "loading in InAppBrowser");
result = showWebPage(url, features);
}
}
// SYSTEM
else if (SYSTEM.equals(target)) {
- Log.d(LOG_TAG, "in system");
+ LOG.d(LOG_TAG, "in system");
result = openExternal(url);
}
// BLANK - or anything else
else {
- Log.d(LOG_TAG, "in blank");
+ LOG.d(LOG_TAG, "in blank");
result = showWebPage(url, features);
}
@@ -197,7 +210,7 @@ public class InAppBrowser extends CordovaPlugin {
else if (action.equals("injectScriptCode")) {
String jsWrapper = null;
if (args.getBoolean(1)) {
- jsWrapper = String.format("prompt(JSON.stringify([eval(%%s)]), 'gap-iab://%s')", callbackContext.getCallbackId());
+ jsWrapper = String.format("(function(){prompt(JSON.stringify([eval(%%s)]), 'gap-iab://%s')})()", callbackContext.getCallbackId());
}
injectDeferredObject(args.getString(0), jsWrapper);
}
@@ -254,6 +267,26 @@ public class InAppBrowser extends CordovaPlugin {
}
/**
+ * Called when the system is about to start resuming a previous activity.
+ */
+ @Override
+ public void onPause(boolean multitasking) {
+ if (shouldPauseInAppBrowser) {
+ inAppWebView.onPause();
+ }
+ }
+
+ /**
+ * Called when the activity will start interacting with the user.
+ */
+ @Override
+ public void onResume(boolean multitasking) {
+ if (shouldPauseInAppBrowser) {
+ inAppWebView.onResume();
+ }
+ }
+
+ /**
* Called by AccelBroker when listener is to be shut down.
* Stop listener.
*/
@@ -350,7 +383,7 @@ public class InAppBrowser extends CordovaPlugin {
this.cordova.getActivity().startActivity(intent);
return "";
} catch (android.content.ActivityNotFoundException e) {
- Log.d(LOG_TAG, "InAppBrowser: Error loading url "+url+":"+ e.toString());
+ LOG.d(LOG_TAG, "InAppBrowser: Error loading url "+url+":"+ e.toString());
return e.toString();
}
}
@@ -359,20 +392,22 @@ public class InAppBrowser extends CordovaPlugin {
* Closes the dialog
*/
public void closeDialog() {
- final WebView childView = this.inAppWebView;
- // The JS protects against multiple calls, so this should happen only when
- // closeDialog() is called by other native code.
- if (childView == null) {
- return;
- }
this.cordova.getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
+ final WebView childView = inAppWebView;
+ // The JS protects against multiple calls, so this should happen only when
+ // closeDialog() is called by other native code.
+ if (childView == null) {
+ return;
+ }
+
childView.setWebViewClient(new WebViewClient() {
// NB: wait for about:blank before dismissing
public void onPageFinished(WebView view, String url) {
if (dialog != null) {
dialog.dismiss();
+ dialog = null;
}
}
});
@@ -380,16 +415,16 @@ public class InAppBrowser extends CordovaPlugin {
// other than your app's UI thread, it can cause unexpected results."
// http://developer.android.com/guide/webapps/migrating.html#Threads
childView.loadUrl("about:blank");
+
+ try {
+ JSONObject obj = new JSONObject();
+ obj.put("type", EXIT_EVENT);
+ sendUpdate(obj, false);
+ } catch (JSONException ex) {
+ LOG.d(LOG_TAG, "Should never happen");
+ }
}
});
-
- try {
- JSONObject obj = new JSONObject();
- obj.put("type", EXIT_EVENT);
- sendUpdate(obj, false);
- } catch (JSONException ex) {
- Log.d(LOG_TAG, "Should never happen");
- }
}
/**
@@ -468,6 +503,8 @@ public class InAppBrowser extends CordovaPlugin {
showLocationBar = true;
showZoomControls = true;
openWindowHidden = false;
+ mediaPlaybackRequiresUserGesture = false;
+
if (features != null) {
Boolean show = features.get(LOCATION);
if (show != null) {
@@ -485,6 +522,10 @@ public class InAppBrowser extends CordovaPlugin {
if (hardwareBack != null) {
hadwareBackButton = hardwareBack.booleanValue();
}
+ Boolean mediaPlayback = features.get(MEDIA_PLAYBACK_REQUIRES_USER_ACTION);
+ if (mediaPlayback != null) {
+ mediaPlaybackRequiresUserGesture = mediaPlayback.booleanValue();
+ }
Boolean cache = features.get(CLEAR_ALL_CACHE);
if (cache != null) {
clearAllCache = cache.booleanValue();
@@ -494,6 +535,10 @@ public class InAppBrowser extends CordovaPlugin {
clearSessionCache = cache.booleanValue();
}
}
+ Boolean shouldPause = features.get(SHOULD_PAUSE);
+ if (shouldPause != null) {
+ shouldPauseInAppBrowser = shouldPause.booleanValue();
+ }
}
final CordovaWebView thatWebView = this.webView;
@@ -516,6 +561,12 @@ public class InAppBrowser extends CordovaPlugin {
@SuppressLint("NewApi")
public void run() {
+
+ // CB-6702 InAppBrowser hangs when opening more than one instance
+ if (dialog != null) {
+ dialog.dismiss();
+ };
+
// Let's create the main dialog
dialog = new InAppBrowserDialog(cordova.getActivity(), android.R.style.Theme_NoTitleBar);
dialog.getWindow().getAttributes().windowAnimations = android.R.style.Animation_Dialog;
@@ -541,26 +592,28 @@ public class InAppBrowser extends CordovaPlugin {
actionButtonContainer.setLayoutParams(new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
actionButtonContainer.setHorizontalGravity(Gravity.LEFT);
actionButtonContainer.setVerticalGravity(Gravity.CENTER_VERTICAL);
- actionButtonContainer.setId(1);
+ actionButtonContainer.setId(Integer.valueOf(1));
// Back button
- Button back = new Button(cordova.getActivity());
+ ImageButton back = new ImageButton(cordova.getActivity());
RelativeLayout.LayoutParams backLayoutParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
backLayoutParams.addRule(RelativeLayout.ALIGN_LEFT);
back.setLayoutParams(backLayoutParams);
back.setContentDescription("Back Button");
- back.setId(2);
+ back.setId(Integer.valueOf(2));
Resources activityRes = cordova.getActivity().getResources();
int backResId = activityRes.getIdentifier("ic_action_previous_item", "drawable", cordova.getActivity().getPackageName());
Drawable backIcon = activityRes.getDrawable(backResId);
- if(android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN)
- {
- back.setBackgroundDrawable(backIcon);
- }
+ if (Build.VERSION.SDK_INT >= 16)
+ back.setBackground(null);
else
- {
- back.setBackground(backIcon);
- }
+ back.setBackgroundDrawable(null);
+ back.setImageDrawable(backIcon);
+ back.setScaleType(ImageView.ScaleType.FIT_CENTER);
+ back.setPadding(0, this.dpToPixels(10), 0, this.dpToPixels(10));
+ if (Build.VERSION.SDK_INT >= 16)
+ back.getAdjustViewBounds();
+
back.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
goBack();
@@ -568,22 +621,24 @@ public class InAppBrowser extends CordovaPlugin {
});
// Forward button
- Button forward = new Button(cordova.getActivity());
+ ImageButton forward = new ImageButton(cordova.getActivity());
RelativeLayout.LayoutParams forwardLayoutParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
forwardLayoutParams.addRule(RelativeLayout.RIGHT_OF, 2);
forward.setLayoutParams(forwardLayoutParams);
forward.setContentDescription("Forward Button");
- forward.setId(3);
+ forward.setId(Integer.valueOf(3));
int fwdResId = activityRes.getIdentifier("ic_action_next_item", "drawable", cordova.getActivity().getPackageName());
Drawable fwdIcon = activityRes.getDrawable(fwdResId);
- if(android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN)
- {
- forward.setBackgroundDrawable(fwdIcon);
- }
+ if (Build.VERSION.SDK_INT >= 16)
+ forward.setBackground(null);
else
- {
- forward.setBackground(fwdIcon);
- }
+ forward.setBackgroundDrawable(null);
+ forward.setImageDrawable(fwdIcon);
+ forward.setScaleType(ImageView.ScaleType.FIT_CENTER);
+ forward.setPadding(0, this.dpToPixels(10), 0, this.dpToPixels(10));
+ if (Build.VERSION.SDK_INT >= 16)
+ forward.getAdjustViewBounds();
+
forward.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
goForward();
@@ -596,7 +651,7 @@ public class InAppBrowser extends CordovaPlugin {
textLayoutParams.addRule(RelativeLayout.RIGHT_OF, 1);
textLayoutParams.addRule(RelativeLayout.LEFT_OF, 5);
edittext.setLayoutParams(textLayoutParams);
- edittext.setId(4);
+ edittext.setId(Integer.valueOf(4));
edittext.setSingleLine(true);
edittext.setText(url);
edittext.setInputType(InputType.TYPE_TEXT_VARIATION_URI);
@@ -614,22 +669,24 @@ public class InAppBrowser extends CordovaPlugin {
});
// Close/Done button
- Button close = new Button(cordova.getActivity());
+ ImageButton close = new ImageButton(cordova.getActivity());
RelativeLayout.LayoutParams closeLayoutParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
closeLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
close.setLayoutParams(closeLayoutParams);
forward.setContentDescription("Close Button");
- close.setId(5);
+ close.setId(Integer.valueOf(5));
int closeResId = activityRes.getIdentifier("ic_action_remove", "drawable", cordova.getActivity().getPackageName());
Drawable closeIcon = activityRes.getDrawable(closeResId);
- if(android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.JELLY_BEAN)
- {
- close.setBackgroundDrawable(closeIcon);
- }
+ if (Build.VERSION.SDK_INT >= 16)
+ close.setBackground(null);
else
- {
- close.setBackground(closeIcon);
- }
+ close.setBackgroundDrawable(null);
+ close.setImageDrawable(closeIcon);
+ close.setScaleType(ImageView.ScaleType.FIT_CENTER);
+ back.setPadding(0, this.dpToPixels(10), 0, this.dpToPixels(10));
+ if (Build.VERSION.SDK_INT >= 16)
+ close.getAdjustViewBounds();
+
close.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
closeDialog();
@@ -639,6 +696,7 @@ public class InAppBrowser extends CordovaPlugin {
// WebView
inAppWebView = new WebView(cordova.getActivity());
inAppWebView.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
+ inAppWebView.setId(Integer.valueOf(6));
inAppWebView.setWebChromeClient(new InAppChromeClient(thatWebView));
WebViewClient client = new InAppBrowserClient(thatWebView, edittext);
inAppWebView.setWebViewClient(client);
@@ -648,6 +706,20 @@ public class InAppBrowser extends CordovaPlugin {
settings.setBuiltInZoomControls(showZoomControls);
settings.setPluginState(android.webkit.WebSettings.PluginState.ON);
+ if(android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN_MR1) {
+ settings.setMediaPlaybackRequiresUserGesture(mediaPlaybackRequiresUserGesture);
+ }
+
+ String overrideUserAgent = preferences.getString("OverrideUserAgent", null);
+ String appendUserAgent = preferences.getString("AppendUserAgent", null);
+
+ if (overrideUserAgent != null) {
+ settings.setUserAgentString(overrideUserAgent);
+ }
+ if (appendUserAgent != null) {
+ settings.setUserAgentString(settings.getUserAgentString() + appendUserAgent);
+ }
+
//Toggle whether this is enabled or not!
Bundle appSettings = cordova.getActivity().getIntent().getExtras();
boolean enableDatabase = appSettings == null ? true : appSettings.getBoolean("InAppBrowserStorageEnabled", true);
@@ -665,7 +737,7 @@ public class InAppBrowser extends CordovaPlugin {
}
inAppWebView.loadUrl(url);
- inAppWebView.setId(6);
+ inAppWebView.setId(Integer.valueOf(6));
inAppWebView.getSettings().setLoadWithOverviewMode(true);
inAppWebView.getSettings().setUseWideViewPort(true);
inAppWebView.requestFocus();
@@ -753,34 +825,30 @@ public class InAppBrowser extends CordovaPlugin {
}
/**
- * Notify the host application that a page has started loading.
+ * Override the URL that should be loaded
+ *
+ * This handles a small subset of all the URIs that would be encountered.
*
- * @param view The webview initiating the callback.
- * @param url The url of the page.
+ * @param webView
+ * @param url
*/
@Override
- public void onPageStarted(WebView view, String url, Bitmap favicon) {
- super.onPageStarted(view, url, favicon);
- String newloc = "";
- if (url.startsWith("http:") || url.startsWith("https:") || url.startsWith("file:")) {
- newloc = url;
- }
- // If dialing phone (tel:5551212)
- else if (url.startsWith(WebView.SCHEME_TEL)) {
+ public boolean shouldOverrideUrlLoading(WebView webView, String url) {
+ if (url.startsWith(WebView.SCHEME_TEL)) {
try {
Intent intent = new Intent(Intent.ACTION_DIAL);
intent.setData(Uri.parse(url));
cordova.getActivity().startActivity(intent);
+ return true;
} catch (android.content.ActivityNotFoundException e) {
LOG.e(LOG_TAG, "Error dialing " + url + ": " + e.toString());
}
- }
-
- else if (url.startsWith("geo:") || url.startsWith(WebView.SCHEME_MAILTO) || url.startsWith("market:")) {
+ } else if (url.startsWith("geo:") || url.startsWith(WebView.SCHEME_MAILTO) || url.startsWith("market:") || url.startsWith("intent:")) {
try {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(url));
cordova.getActivity().startActivity(intent);
+ return true;
} catch (android.content.ActivityNotFoundException e) {
LOG.e(LOG_TAG, "Error with " + url + ": " + e.toString());
}
@@ -795,8 +863,7 @@ public class InAppBrowser extends CordovaPlugin {
int parmIndex = url.indexOf('?');
if (parmIndex == -1) {
address = url.substring(4);
- }
- else {
+ } else {
address = url.substring(4, parmIndex);
// If body, then set sms body
@@ -812,32 +879,64 @@ public class InAppBrowser extends CordovaPlugin {
intent.putExtra("address", address);
intent.setType("vnd.android-dir/mms-sms");
cordova.getActivity().startActivity(intent);
+ return true;
} catch (android.content.ActivityNotFoundException e) {
LOG.e(LOG_TAG, "Error sending sms " + url + ":" + e.toString());
}
}
- else {
+ return false;
+ }
+
+
+ /*
+ * onPageStarted fires the LOAD_START_EVENT
+ *
+ * @param view
+ * @param url
+ * @param favicon
+ */
+ @Override
+ public void onPageStarted(WebView view, String url, Bitmap favicon) {
+ super.onPageStarted(view, url, favicon);
+ String newloc = "";
+ if (url.startsWith("http:") || url.startsWith("https:") || url.startsWith("file:")) {
+ newloc = url;
+ }
+ else
+ {
+ // Assume that everything is HTTP at this point, because if we don't specify,
+ // it really should be. Complain loudly about this!!!
+ LOG.e(LOG_TAG, "Possible Uncaught/Unknown URI");
newloc = "http://" + url;
}
+ // Update the UI if we haven't already
if (!newloc.equals(edittext.getText().toString())) {
edittext.setText(newloc);
- }
+ }
try {
JSONObject obj = new JSONObject();
obj.put("type", LOAD_START_EVENT);
obj.put("url", newloc);
-
sendUpdate(obj, true);
} catch (JSONException ex) {
- Log.d(LOG_TAG, "Should never happen");
+ LOG.e(LOG_TAG, "URI passed in has caused a JSON error.");
}
}
+
+
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
+ // CB-10395 InAppBrowser's WebView not storing cookies reliable to local device storage
+ if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
+ CookieManager.getInstance().flush();
+ } else {
+ CookieSyncManager.getInstance().sync();
+ }
+
try {
JSONObject obj = new JSONObject();
obj.put("type", LOAD_STOP_EVENT);
@@ -845,7 +944,7 @@ public class InAppBrowser extends CordovaPlugin {
sendUpdate(obj, true);
} catch (JSONException ex) {
- Log.d(LOG_TAG, "Should never happen");
+ LOG.d(LOG_TAG, "Should never happen");
}
}
@@ -861,9 +960,46 @@ public class InAppBrowser extends CordovaPlugin {
sendUpdate(obj, true, PluginResult.Status.ERROR);
} catch (JSONException ex) {
- Log.d(LOG_TAG, "Should never happen");
+ LOG.d(LOG_TAG, "Should never happen");
}
}
+
+ /**
+ * On received http auth request.
+ */
+ @Override
+ public void onReceivedHttpAuthRequest(WebView view, HttpAuthHandler handler, String host, String realm) {
+
+ // Check if there is some plugin which can resolve this auth challenge
+ PluginManager pluginManager = null;
+ try {
+ Method gpm = webView.getClass().getMethod("getPluginManager");
+ pluginManager = (PluginManager)gpm.invoke(webView);
+ } catch (NoSuchMethodException e) {
+ LOG.d(LOG_TAG, e.getLocalizedMessage());
+ } catch (IllegalAccessException e) {
+ LOG.d(LOG_TAG, e.getLocalizedMessage());
+ } catch (InvocationTargetException e) {
+ LOG.d(LOG_TAG, e.getLocalizedMessage());
+ }
+
+ if (pluginManager == null) {
+ try {
+ Field pmf = webView.getClass().getField("pluginManager");
+ pluginManager = (PluginManager)pmf.get(webView);
+ } catch (NoSuchFieldException e) {
+ LOG.d(LOG_TAG, e.getLocalizedMessage());
+ } catch (IllegalAccessException e) {
+ LOG.d(LOG_TAG, e.getLocalizedMessage());
+ }
+ }
+
+ if (pluginManager != null && pluginManager.onReceivedHttpAuthRequest(webView, new CordovaHttpAuthHandler(handler), host, realm)) {
+ return;
+ }
+
+ // By default handle 401 like we'd normally do!
+ super.onReceivedHttpAuthRequest(view, handler, host, realm);
+ }
}
}
-
diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/InAppBrowserDialog.java b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/InAppBrowserDialog.java
index d7017202..e7b212f2 100755..100644
--- a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/InAppBrowserDialog.java
+++ b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/InAppBrowserDialog.java
@@ -21,7 +21,6 @@ package org.apache.cordova.inappbrowser;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
-import android.util.Log;
import org.json.JSONException;
import org.json.JSONObject;
diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/InAppChromeClient.java b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/InAppChromeClient.java
index a2145e6a..a2145e6a 100755..100644
--- a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/InAppChromeClient.java
+++ b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/InAppChromeClient.java
diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-hdpi/ic_action_next_item.png b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-hdpi/ic_action_next_item.png
index fa469d88..fa469d88 100755..100644
--- a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-hdpi/ic_action_next_item.png
+++ b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-hdpi/ic_action_next_item.png
Binary files differ
diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-hdpi/ic_action_previous_item.png b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-hdpi/ic_action_previous_item.png
index e861ecce..e861ecce 100755..100644
--- a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-hdpi/ic_action_previous_item.png
+++ b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-hdpi/ic_action_previous_item.png
Binary files differ
diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-hdpi/ic_action_remove.png b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-hdpi/ic_action_remove.png
index f889617e..f889617e 100755..100644
--- a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-hdpi/ic_action_remove.png
+++ b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-hdpi/ic_action_remove.png
Binary files differ
diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-mdpi/ic_action_next_item.png b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-mdpi/ic_action_next_item.png
index 47365a30..47365a30 100755..100644
--- a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-mdpi/ic_action_next_item.png
+++ b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-mdpi/ic_action_next_item.png
Binary files differ
diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-mdpi/ic_action_previous_item.png b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-mdpi/ic_action_previous_item.png
index 4ad2df42..4ad2df42 100755..100644
--- a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-mdpi/ic_action_previous_item.png
+++ b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-mdpi/ic_action_previous_item.png
Binary files differ
diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-mdpi/ic_action_remove.png b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-mdpi/ic_action_remove.png
index e84853e4..e84853e4 100755..100644
--- a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-mdpi/ic_action_remove.png
+++ b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-mdpi/ic_action_remove.png
Binary files differ
diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-xhdpi/ic_action_next_item.png b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-xhdpi/ic_action_next_item.png
index 5f304742..5f304742 100755..100644
--- a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-xhdpi/ic_action_next_item.png
+++ b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-xhdpi/ic_action_next_item.png
Binary files differ
diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-xhdpi/ic_action_previous_item.png b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-xhdpi/ic_action_previous_item.png
index ed8ac91d..ed8ac91d 100755..100644
--- a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-xhdpi/ic_action_previous_item.png
+++ b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-xhdpi/ic_action_previous_item.png
Binary files differ
diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-xhdpi/ic_action_remove.png b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-xhdpi/ic_action_remove.png
index 4cd0458b..4cd0458b 100755..100644
--- a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-xhdpi/ic_action_remove.png
+++ b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-xhdpi/ic_action_remove.png
Binary files differ
diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-xxhdpi/ic_action_next_item.png b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-xxhdpi/ic_action_next_item.png
index 51479d8d..51479d8d 100755..100644
--- a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-xxhdpi/ic_action_next_item.png
+++ b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-xxhdpi/ic_action_next_item.png
Binary files differ
diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-xxhdpi/ic_action_previous_item.png b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-xxhdpi/ic_action_previous_item.png
index bc8ff124..bc8ff124 100755..100644
--- a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-xxhdpi/ic_action_previous_item.png
+++ b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-xxhdpi/ic_action_previous_item.png
Binary files differ
diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-xxhdpi/ic_action_remove.png b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-xxhdpi/ic_action_remove.png
index 331c545b..331c545b 100755..100644
--- a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-xxhdpi/ic_action_remove.png
+++ b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/android/res/drawable-xxhdpi/ic_action_remove.png
Binary files differ
diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/README.md b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/README.md
index f0fa8607..f0fa8607 100755..100644
--- a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/README.md
+++ b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/README.md
diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/de/README.md b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/de/README.md
index e3944876..e3944876 100755..100644
--- a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/de/README.md
+++ b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/de/README.md
diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/es/README.md b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/es/README.md
index 75303369..75303369 100755..100644
--- a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/es/README.md
+++ b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/es/README.md
diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/fr/README.md b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/fr/README.md
index 179bd483..179bd483 100755..100644
--- a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/fr/README.md
+++ b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/fr/README.md
diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/it/README.md b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/it/README.md
index 8f0623df..8f0623df 100755..100644
--- a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/it/README.md
+++ b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/it/README.md
diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/ja/README.md b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/ja/README.md
index b9e4b7b7..b9e4b7b7 100755..100644
--- a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/ja/README.md
+++ b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/ja/README.md
diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/ko/README.md b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/ko/README.md
index 67fb8de3..67fb8de3 100755..100644
--- a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/ko/README.md
+++ b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/ko/README.md
diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/pl/README.md b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/pl/README.md
index ef199ee9..ef199ee9 100755..100644
--- a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/pl/README.md
+++ b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/pl/README.md
diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/zh/README.md b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/zh/README.md
index 241fb550..241fb550 100755..100644
--- a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/zh/README.md
+++ b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/blackberry10/doc/zh/README.md
diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/browser/InAppBrowserProxy.js b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/browser/InAppBrowserProxy.js
index 33fbe476..da7dacd3 100755..100644
--- a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/browser/InAppBrowserProxy.js
+++ b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/browser/InAppBrowserProxy.js
@@ -19,9 +19,7 @@
*
*/
-var cordova = require('cordova'),
- channel = require('cordova/channel'),
- urlutil = require('cordova/urlutil');
+var modulemapper = require('cordova/modulemapper');
var browserWrap,
popup,
@@ -68,19 +66,23 @@ var IAB = {
open: function (win, lose, args) {
var strUrl = args[0],
target = args[1],
- features = args[2],
- url;
+ features = args[2];
- if (target === "_system" || target === "_self" || !target) {
+ if (target === "_self" || !target) {
window.location = strUrl;
+ } else if (target === "_system") {
+ modulemapper.getOriginalSymbol(window, 'window.open').call(window, strUrl, "_blank");
} else {
// "_blank" or anything else
if (!browserWrap) {
browserWrap = document.createElement("div");
browserWrap.style.position = "absolute";
+ browserWrap.style.top = "0";
+ browserWrap.style.left = "0";
+ browserWrap.style.boxSizing = "border-box";
browserWrap.style.borderWidth = "40px";
- browserWrap.style.width = "calc(100% - 80px)";
- browserWrap.style.height = "calc(100% - 80px)";
+ browserWrap.style.width = "100vw";
+ browserWrap.style.height = "100vh";
browserWrap.style.borderStyle = "solid";
browserWrap.style.borderColor = "rgba(0,0,0,0.25)";
@@ -105,6 +107,7 @@ var IAB = {
if (features.indexOf("location=yes") !== -1 || features.indexOf("location") === -1) {
popup.style.height = "calc(100% - 60px)";
+ popup.style.marginBottom = "-4px";
navigationButtonsDiv = document.createElement("div");
navigationButtonsDiv.style.height = "60px";
@@ -190,7 +193,9 @@ var IAB = {
if (browserWrap && popup) {
try {
popup.contentWindow.eval(code);
- hasCallback && win([]);
+ if (hasCallback) {
+ win([]);
+ }
} catch(e) {
console.error('Error occured while trying to injectScriptCode: ' + JSON.stringify(e));
}
@@ -200,19 +205,25 @@ var IAB = {
injectScriptFile: function (win, fail, args) {
var msg = 'Browser cordova-plugin-inappbrowser injectScriptFile is not yet implemented';
console.warn(msg);
- fail && fail(msg);
+ if (fail) {
+ fail(msg);
+ }
},
injectStyleCode: function (win, fail, args) {
var msg = 'Browser cordova-plugin-inappbrowser injectStyleCode is not yet implemented';
console.warn(msg);
- fail && fail(msg);
+ if (fail) {
+ fail(msg);
+ }
},
injectStyleFile: function (win, fail, args) {
var msg = 'Browser cordova-plugin-inappbrowser injectStyleFile is not yet implemented';
console.warn(msg);
- fail && fail(msg);
+ if (fail) {
+ fail(msg);
+ }
}
};
diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/firefoxos/InAppBrowserProxy.js b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/firefoxos/InAppBrowserProxy.js
index f0d44c12..c09e3583 100755..100644
--- a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/firefoxos/InAppBrowserProxy.js
+++ b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/firefoxos/InAppBrowserProxy.js
@@ -21,9 +21,7 @@
// https://developer.mozilla.org/en-US/docs/WebAPI/Browser
-var cordova = require('cordova'),
- channel = require('cordova/channel'),
- modulemapper = require('cordova/modulemapper');
+var modulemapper = require('cordova/modulemapper');
var origOpenFunc = modulemapper.getOriginalSymbol(window, 'window.open');
var browserWrap;
@@ -49,9 +47,7 @@ var IABExecs = {
var strUrl = args[0],
target = args[1],
features_string = args[2] || "location=yes", //location=yes is default
- features = {},
- url,
- elem;
+ features = {};
var features_list = features_string.split(',');
features_list.forEach(function(feature) {
@@ -61,7 +57,7 @@ var IABExecs = {
} else if (tup[1] == 'no') {
tup[1] = false;
} else {
- var number = parseInt(tup[1]);
+ var number = parseInt(tup[1]);
if (!isNaN(number)) {
tup[1] = number;
}
@@ -115,7 +111,7 @@ var IABExecs = {
back.classList.add('inAppBrowserBack');
forward.classList.add('inAppBrowserForward');
- function checkForwardBackward() {
+ var checkForwardBackward = function () {
var backReq = browserElem.getCanGoBack();
backReq.onsuccess = function() {
if (this.result) {
@@ -123,7 +119,7 @@ var IABExecs = {
} else {
back.classList.add('disabled');
}
- }
+ };
var forwardReq = browserElem.getCanGoForward();
forwardReq.onsuccess = function() {
if (this.result) {
@@ -131,7 +127,7 @@ var IABExecs = {
} else {
forward.classList.add('disabled');
}
- }
+ };
};
browserElem.addEventListener('mozbrowserloadend', checkForwardBackward);
@@ -163,16 +159,16 @@ var IABExecs = {
win({
type:'loadstart',
url : e.detail
- })
+ });
}, false);
browserElem.addEventListener('mozbrowserloadend', function(e){
- win({type:'loadstop'})
+ win({type:'loadstop'});
}, false);
browserElem.addEventListener('mozbrowsererror', function(e){
- win({type:'loaderror'})
+ win({type:'loaderror'});
}, false);
browserElem.addEventListener('mozbrowserclose', function(e){
- win({type:'exit'})
+ win({type:'exit'});
}, false);
} else {
window.location = strUrl;
diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/ios/CDVInAppBrowser.h b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/ios/CDVInAppBrowser.h
index 1ccc7b14..6bb0ec16 100755..100644
--- a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/ios/CDVInAppBrowser.h
+++ b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/ios/CDVInAppBrowser.h
@@ -30,7 +30,6 @@
@class CDVInAppBrowserViewController;
@interface CDVInAppBrowser : CDVPlugin {
- BOOL _injectedIframeBridge;
}
@property (nonatomic, retain) CDVInAppBrowserViewController* inAppBrowserViewController;
diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/ios/CDVInAppBrowser.m b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/ios/CDVInAppBrowser.m
index 47a8ab3a..b342ca73 100755..100644
--- a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/ios/CDVInAppBrowser.m
+++ b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/ios/CDVInAppBrowser.m
@@ -47,6 +47,11 @@
_callbackIdPattern = nil;
}
+- (id)settingForKey:(NSString*)key
+{
+ return [self.commandDelegate.settings objectForKey:[key lowercaseString]];
+}
+
- (void)onReset
{
[self close:nil];
@@ -137,8 +142,16 @@
}
if (self.inAppBrowserViewController == nil) {
- NSString* originalUA = [CDVUserAgentUtil originalUserAgent];
- self.inAppBrowserViewController = [[CDVInAppBrowserViewController alloc] initWithUserAgent:originalUA prevUserAgent:[self.commandDelegate userAgent] browserOptions: browserOptions];
+ NSString* userAgent = [CDVUserAgentUtil originalUserAgent];
+ NSString* overrideUserAgent = [self settingForKey:@"OverrideUserAgent"];
+ NSString* appendUserAgent = [self settingForKey:@"AppendUserAgent"];
+ if(overrideUserAgent){
+ userAgent = overrideUserAgent;
+ }
+ if(appendUserAgent){
+ userAgent = [userAgent stringByAppendingString: appendUserAgent];
+ }
+ self.inAppBrowserViewController = [[CDVInAppBrowserViewController alloc] initWithUserAgent:userAgent prevUserAgent:[self.commandDelegate userAgent] browserOptions: browserOptions];
self.inAppBrowserViewController.navigationDelegate = self;
if ([self.viewController conformsToProtocol:@protocol(CDVScreenOrientationDelegate)]) {
@@ -218,6 +231,7 @@
initWithRootViewController:self.inAppBrowserViewController];
nav.orientationDelegate = self.inAppBrowserViewController;
nav.navigationBarHidden = YES;
+ nav.modalPresentationStyle = self.inAppBrowserViewController.modalPresentationStyle;
__weak CDVInAppBrowser* weakSelf = self;
@@ -231,25 +245,25 @@
- (void)openInCordovaWebView:(NSURL*)url withOptions:(NSString*)options
{
- if ([self.commandDelegate URLIsWhitelisted:url]) {
- NSURLRequest* request = [NSURLRequest requestWithURL:url];
+ NSURLRequest* request = [NSURLRequest requestWithURL:url];
+
#ifdef __CORDOVA_4_0_0
- [self.webViewEngine loadRequest:request];
+ // the webview engine itself will filter for this according to <allow-navigation> policy
+ // in config.xml for cordova-ios-4.0
+ [self.webViewEngine loadRequest:request];
#else
+ if ([self.commandDelegate URLIsWhitelisted:url]) {
[self.webView loadRequest:request];
-#endif
} else { // this assumes the InAppBrowser can be excepted from the white-list
[self openInInAppBrowser:url withOptions:options];
}
+#endif
}
- (void)openInSystem:(NSURL*)url
{
- if ([[UIApplication sharedApplication] canOpenURL:url]) {
- [[UIApplication sharedApplication] openURL:url];
- } else { // handle any custom schemes to plugins
- [[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:CDVPluginHandleOpenURLNotification object:url]];
- }
+ [[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:CDVPluginHandleOpenURLNotification object:url]];
+ [[UIApplication sharedApplication] openURL:url];
}
// This is a helper method for the inject{Script|Style}{Code|File} API calls, which
@@ -263,11 +277,8 @@
- (void)injectDeferredObject:(NSString*)source withWrapper:(NSString*)jsWrapper
{
- if (!_injectedIframeBridge) {
- _injectedIframeBridge = YES;
- // Create an iframe bridge in the new document to communicate with the CDVInAppBrowserViewController
- [self.inAppBrowserViewController.webView stringByEvaluatingJavaScriptFromString:@"(function(d){var e = _cdvIframeBridge = d.createElement('iframe');e.style.display='none';d.body.appendChild(e);})(document)"];
- }
+ // Ensure an iframe bridge is created to communicate with the CDVInAppBrowserViewController
+ [self.inAppBrowserViewController.webView stringByEvaluatingJavaScriptFromString:@"(function(d){_cdvIframeBridge=d.getElementById('_cdvIframeBridge');if(!_cdvIframeBridge) {var e = _cdvIframeBridge = d.createElement('iframe');e.id='_cdvIframeBridge'; e.style.display='none';d.body.appendChild(e);}})(document)"];
if (jsWrapper != nil) {
NSData* jsonData = [NSJSONSerialization dataWithJSONObject:@[source] options:0 error:nil];
@@ -390,7 +401,14 @@
[self.commandDelegate sendPluginResult:pluginResult callbackId:scriptCallbackId];
return NO;
}
- } else if ((self.callbackId != nil) && isTopLevelNavigation) {
+ }
+ //if is an app store link, let the system handle it, otherwise it fails to load it
+ else if ([[ url scheme] isEqualToString:@"itms-appss"] || [[ url scheme] isEqualToString:@"itms-apps"]) {
+ [theWebView stopLoading];
+ [self openInSystem:url];
+ return NO;
+ }
+ else if ((self.callbackId != nil) && isTopLevelNavigation) {
// Send a loadstart event for each top-level navigation (includes redirects).
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK
messageAsDictionary:@{@"type":@"loadstart", @"url":[url absoluteString]}];
@@ -404,7 +422,6 @@
- (void)webViewDidStartLoad:(UIWebView*)theWebView
{
- _injectedIframeBridge = NO;
}
- (void)webViewDidFinishLoad:(UIWebView*)theWebView
@@ -512,15 +529,15 @@
self.webView.scalesPageToFit = NO;
self.webView.userInteractionEnabled = YES;
- self.spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
+ self.spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
self.spinner.alpha = 1.000;
self.spinner.autoresizesSubviews = YES;
- self.spinner.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleTopMargin;
+ self.spinner.autoresizingMask = (UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleRightMargin);
self.spinner.clearsContextBeforeDrawing = NO;
self.spinner.clipsToBounds = NO;
self.spinner.contentMode = UIViewContentModeScaleToFill;
- self.spinner.frame = CGRectMake(454.0, 231.0, 20.0, 20.0);
- self.spinner.hidden = YES;
+ self.spinner.frame = CGRectMake(CGRectGetMidX(self.webView.frame), CGRectGetMidY(self.webView.frame), 20.0, 20.0);
+ self.spinner.hidden = NO;
self.spinner.hidesWhenStopped = YES;
self.spinner.multipleTouchEnabled = NO;
self.spinner.opaque = NO;
@@ -749,6 +766,10 @@
return UIStatusBarStyleDefault;
}
+- (BOOL)prefersStatusBarHidden {
+ return NO;
+}
+
- (void)close
{
[CDVUserAgentUtil releaseLock:&_userAgentLockToken];
@@ -988,19 +1009,38 @@
@implementation CDVInAppBrowserNavigationController : UINavigationController
+- (void) dismissViewControllerAnimated:(BOOL)flag completion:(void (^)(void))completion {
+ if ( self.presentedViewController) {
+ [super dismissViewControllerAnimated:flag completion:completion];
+ }
+}
+
- (void) viewDidLoad {
CGRect frame = [UIApplication sharedApplication].statusBarFrame;
// simplified from: http://stackoverflow.com/a/25669695/219684
- UIToolbar* bgToolbar = [[UIToolbar alloc] initWithFrame:frame];
+ UIToolbar* bgToolbar = [[UIToolbar alloc] initWithFrame:[self invertFrameIfNeeded:frame]];
bgToolbar.barStyle = UIBarStyleDefault;
+ [bgToolbar setAutoresizingMask:UIViewAutoresizingFlexibleWidth];
[self.view addSubview:bgToolbar];
[super viewDidLoad];
}
+- (CGRect) invertFrameIfNeeded:(CGRect)rect {
+ // We need to invert since on iOS 7 frames are always in Portrait context
+ if (!IsAtLeastiOSVersion(@"8.0")) {
+ if (UIInterfaceOrientationIsLandscape([[UIApplication sharedApplication] statusBarOrientation])) {
+ CGFloat temp = rect.size.width;
+ rect.size.width = rect.size.height;
+ rect.size.height = temp;
+ }
+ rect.origin = CGPointZero;
+ }
+ return rect;
+}
#pragma mark CDVScreenOrientationDelegate
diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/ubuntu/InAppBrowser.qml b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/ubuntu/InAppBrowser.qml
index 781e8a6e..781e8a6e 100755..100644
--- a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/ubuntu/InAppBrowser.qml
+++ b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/ubuntu/InAppBrowser.qml
diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/ubuntu/InAppBrowser_escapeScript.js b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/ubuntu/InAppBrowser_escapeScript.js
index 07661bb6..b01daeb5 100755..100644
--- a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/ubuntu/InAppBrowser_escapeScript.js
+++ b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/ubuntu/InAppBrowser_escapeScript.js
@@ -19,6 +19,9 @@
*
*/
+/* jshint -W061 */
+/* global oxide */
+
oxide.addMessageHandler("EXECUTE", function(msg) {
var code = msg.args.code;
try {
diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/ubuntu/close.png b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/ubuntu/close.png
index 56373d1f..56373d1f 100755..100644
--- a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/ubuntu/close.png
+++ b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/ubuntu/close.png
Binary files differ
diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/ubuntu/inappbrowser.cpp b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/ubuntu/inappbrowser.cpp
index c5a9e64a..c5a9e64a 100755..100644
--- a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/ubuntu/inappbrowser.cpp
+++ b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/ubuntu/inappbrowser.cpp
diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/ubuntu/inappbrowser.h b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/ubuntu/inappbrowser.h
index 1da4e033..1da4e033 100755..100644
--- a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/ubuntu/inappbrowser.h
+++ b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/ubuntu/inappbrowser.h
diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/windows/InAppBrowserProxy.js b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/windows/InAppBrowserProxy.js
index fc037bdb..23f6e547 100755..100644
--- a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/windows/InAppBrowserProxy.js
+++ b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/windows/InAppBrowserProxy.js
@@ -19,13 +19,10 @@
*
*/
-/*jslint sloppy:true */
-/*global Windows:true, require, document, setTimeout, window, module */
-
-
+/* jslint sloppy:true */
+/* global Windows:true, setImmediate */
var cordova = require('cordova'),
- channel = require('cordova/channel'),
urlutil = require('cordova/urlutil');
var browserWrap,
@@ -35,11 +32,13 @@ var browserWrap,
backButton,
forwardButton,
closeButton,
- bodyOverflowStyle;
+ bodyOverflowStyle,
+ navigationEventsCallback,
+ hardwareBackCallback;
// x-ms-webview is available starting from Windows 8.1 (platformId is 'windows')
// http://msdn.microsoft.com/en-us/library/windows/apps/dn301831.aspx
-var isWebViewAvailable = cordova.platformId == 'windows';
+var isWebViewAvailable = cordova.platformId === 'windows';
function attachNavigationEvents(element, callback) {
if (isWebViewAvailable) {
@@ -48,19 +47,32 @@ function attachNavigationEvents(element, callback) {
});
element.addEventListener("MSWebViewNavigationCompleted", function (e) {
- callback({ type: e.isSuccess ? "loadstop" : "loaderror", url: e.uri}, {keepCallback: true});
+ if (e.isSuccess) {
+ callback({ type: "loadstop", url: e.uri }, { keepCallback: true });
+ } else {
+ callback({ type: "loaderror", url: e.uri, code: e.webErrorStatus, message: "Navigation failed with error code " + e.webErrorStatus}, { keepCallback: true });
+ }
});
element.addEventListener("MSWebViewUnviewableContentIdentified", function (e) {
// WebView found the content to be not HTML.
// http://msdn.microsoft.com/en-us/library/windows/apps/dn609716.aspx
- callback({ type: "loaderror", url: e.uri}, {keepCallback: true});
+ callback({ type: "loaderror", url: e.uri, code: e.webErrorStatus, message: "Navigation failed with error code " + e.webErrorStatus}, { keepCallback: true });
});
element.addEventListener("MSWebViewContentLoading", function (e) {
- if (navigationButtonsDiv) {
- backButton.disabled = !popup.canGoBack;
- forwardButton.disabled = !popup.canGoForward;
+ if (navigationButtonsDiv && popup) {
+ if (popup.canGoBack) {
+ backButton.removeAttribute("disabled");
+ } else {
+ backButton.setAttribute("disabled", "true");
+ }
+
+ if (popup.canGoForward) {
+ forwardButton.removeAttribute("disabled");
+ } else {
+ forwardButton.setAttribute("disabled", "true");
+ }
}
});
} else {
@@ -83,228 +95,266 @@ function attachNavigationEvents(element, callback) {
var IAB = {
close: function (win, lose) {
- if (browserWrap) {
- if (win) win({ type: "exit" });
+ 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;
- }
+ 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) {
- if (browserWrap) {
- browserWrap.style.display = "block";
- }
+ setImmediate(function () {
+ if (browserWrap) {
+ browserWrap.style.display = "block";
+ }
+ });
},
open: function (win, lose, args) {
- var strUrl = args[0],
- target = args[1],
- features = args[2],
- url;
+ // make function async so that we can add navigation events handlers before view is loaded and navigation occured
+ setImmediate(function () {
+ var strUrl = args[0],
+ target = args[1],
+ features = args[2],
+ url;
- 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");
+ navigationEventsCallback = win;
- document.head.appendChild(browserWrapStyle);
+ 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");
- browserWrap = document.createElement("div");
- browserWrap.className = "inAppBrowserWrap";
+ document.head.appendChild(browserWrapStyle);
- if (features.indexOf("fullscreen=yes") > -1) {
- browserWrap.classList.add("inAppBrowserWrapFullscreen");
- }
+ browserWrap = document.createElement("div");
+ browserWrap.className = "inAppBrowserWrap";
- // Save body overflow style to be able to reset it back later
- bodyOverflowStyle = document.body.style.msOverflowStyle;
+ if (features.indexOf("fullscreen=yes") > -1) {
+ browserWrap.classList.add("inAppBrowserWrapFullscreen");
+ }
- browserWrap.onclick = function () {
- setTimeout(function () {
- IAB.close(win);
- }, 0);
- };
+ // Save body overflow style to be able to reset it back later
+ bodyOverflowStyle = document.body.style.msOverflowStyle;
- document.body.appendChild(browserWrap);
- // Hide scrollbars for the whole body while inappbrowser's window is open
- document.body.style.msOverflowStyle = "none";
- }
+ browserWrap.onclick = function () {
+ setTimeout(function () {
+ IAB.close(navigationEventsCallback);
+ }, 0);
+ };
- if (features.indexOf("hidden=yes") !== -1) {
- browserWrap.style.display = "none";
- }
+ document.body.appendChild(browserWrap);
+ // Hide scrollbars for the whole body while inappbrowser's window is open
+ document.body.style.msOverflowStyle = "none";
+ }
- popup = document.createElement(isWebViewAvailable ? "x-ms-webview" : "iframe");
- if (popup instanceof HTMLIFrameElement) {
- // For iframe we need to override bacground color of parent element here
- // otherwise pages without background color set will have transparent background
- popup.style.backgroundColor = "white";
- }
- popup.style.borderWidth = "0px";
- popup.style.width = "100%";
+ if (features.indexOf("hidden=yes") !== -1) {
+ browserWrap.style.display = "none";
+ }
- browserWrap.appendChild(popup);
+ popup = document.createElement(isWebViewAvailable ? "x-ms-webview" : "iframe");
+ if (popup instanceof HTMLIFrameElement) {
+ // For iframe we need to override bacground color of parent element here
+ // otherwise pages without background color set will have transparent background
+ popup.style.backgroundColor = "white";
+ }
+ popup.style.borderWidth = "0px";
+ popup.style.width = "100%";
+ popup.style.marginBottom = "-3px";
- if (features.indexOf("location=yes") !== -1 || features.indexOf("location") === -1) {
- popup.style.height = "calc(100% - 60px)";
+ browserWrap.appendChild(popup);
- navigationButtonsDiv = document.createElement("div");
- navigationButtonsDiv.style.height = "60px";
- navigationButtonsDiv.style.backgroundColor = "#404040";
- navigationButtonsDiv.style.zIndex = "999";
- navigationButtonsDiv.onclick = function (e) {
- e.cancelBubble = true;
+ var closeHandler = function (e) {
+ setTimeout(function () {
+ IAB.close(navigationEventsCallback);
+ }, 0);
};
- navigationButtonsDivInner = document.createElement("div");
- navigationButtonsDivInner.style.paddingTop = "10px";
- navigationButtonsDivInner.style.height = "50px";
- navigationButtonsDivInner.style.width = "160px";
- navigationButtonsDivInner.style.margin = "0 auto";
- navigationButtonsDivInner.style.backgroundColor = "#404040";
- navigationButtonsDivInner.style.zIndex = "999";
- navigationButtonsDivInner.onclick = function (e) {
- e.cancelBubble = true;
- };
+ if (features.indexOf("hardwareback=yes") > -1 || features.indexOf("hardwareback") === -1) {
+ hardwareBackCallback = function () {
+ if (browserWrap.style.display === 'none') {
+ // NOTE: backbutton handlers have to throw an exception in order to prevent
+ // returning 'true' inside cordova-js, which would mean that the event is handled by user.
+ // Throwing an exception means that the default/system navigation behavior will take place,
+ // which is to exit the app if the navigation stack is empty.
+ throw 'Exit the app';
+ }
+ if (popup.canGoBack) {
+ popup.goBack();
+ } else {
+ closeHandler();
+ }
+ };
+ } else if (features.indexOf("hardwareback=no") > -1) {
+ hardwareBackCallback = function () {
+ if (browserWrap.style.display === 'none') {
+ // See comment above
+ throw 'Exit the app';
+ }
- backButton = document.createElement("button");
- backButton.style.width = "40px";
- backButton.style.height = "40px";
- backButton.style.borderRadius = "40px";
+ closeHandler();
+ };
+ }
- backButton.innerText = "<-";
- backButton.addEventListener("click", function (e) {
- if (popup.canGoBack)
- popup.goBack();
- });
+ document.addEventListener("backbutton", hardwareBackCallback, false);
- forwardButton = document.createElement("button");
- forwardButton.style.marginLeft = "20px";
- forwardButton.style.width = "40px";
- forwardButton.style.height = "40px";
- forwardButton.style.borderRadius = "40px";
+ if (features.indexOf("location=yes") !== -1 || features.indexOf("location") === -1) {
+ popup.style.height = "calc(100% - 70px)";
- forwardButton.innerText = "->";
- forwardButton.addEventListener("click", function (e) {
- if (popup.canGoForward)
- popup.goForward();
- });
+ navigationButtonsDiv = document.createElement("div");
+ navigationButtonsDiv.className = "inappbrowser-app-bar";
+ navigationButtonsDiv.onclick = function (e) {
+ e.cancelBubble = true;
+ };
- closeButton = document.createElement("button");
- closeButton.style.marginLeft = "20px";
- closeButton.style.width = "40px";
- closeButton.style.height = "40px";
- closeButton.style.borderRadius = "40px";
+ navigationButtonsDivInner = document.createElement("div");
+ navigationButtonsDivInner.className = "inappbrowser-app-bar-inner";
+ navigationButtonsDivInner.onclick = function (e) {
+ e.cancelBubble = true;
+ };
- closeButton.innerText = "x";
- closeButton.addEventListener("click", function (e) {
- setTimeout(function () {
- IAB.close(win);
- }, 0);
- });
+ backButton = document.createElement("div");
+ backButton.innerText = "back";
+ backButton.className = "app-bar-action action-back";
+ backButton.addEventListener("click", function (e) {
+ if (popup.canGoBack)
+ popup.goBack();
+ });
- if (!isWebViewAvailable) {
- // iframe navigation is not yet supported
- backButton.disabled = true;
- forwardButton.disabled = true;
- }
+ forwardButton = document.createElement("div");
+ forwardButton.innerText = "forward";
+ forwardButton.className = "app-bar-action action-forward";
+ forwardButton.addEventListener("click", function (e) {
+ if (popup.canGoForward)
+ popup.goForward();
+ });
- navigationButtonsDivInner.appendChild(backButton);
- navigationButtonsDivInner.appendChild(forwardButton);
- navigationButtonsDivInner.appendChild(closeButton);
- navigationButtonsDiv.appendChild(navigationButtonsDivInner);
+ closeButton = document.createElement("div");
+ closeButton.innerText = "close";
+ closeButton.className = "app-bar-action action-close";
+ closeButton.addEventListener("click", closeHandler);
- browserWrap.appendChild(navigationButtonsDiv);
- } else {
- popup.style.height = "100%";
- }
+ if (!isWebViewAvailable) {
+ // iframe navigation is not yet supported
+ backButton.setAttribute("disabled", "true");
+ forwardButton.setAttribute("disabled", "true");
+ }
- // start listening for navigation events
- attachNavigationEvents(popup, win);
+ navigationButtonsDivInner.appendChild(backButton);
+ navigationButtonsDivInner.appendChild(forwardButton);
+ navigationButtonsDivInner.appendChild(closeButton);
+ navigationButtonsDiv.appendChild(navigationButtonsDivInner);
- if (isWebViewAvailable) {
- strUrl = strUrl.replace("ms-appx://", "ms-appx-web://");
+ 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;
}
- popup.src = strUrl;
- }
+ });
},
injectScriptCode: function (win, fail, args) {
- var code = args[0],
- hasCallback = args[1];
+ setImmediate(function () {
+ var code = args[0],
+ hasCallback = args[1];
- if (isWebViewAvailable && browserWrap && popup) {
- var op = popup.invokeScriptAsync("eval", code);
- op.oncomplete = function (e) {
- // return null if event target is unavailable by some reason
- var result = (e && e.target) ? [e.target.result] : [null];
- hasCallback && win(result);
- };
- op.onerror = function () { };
- op.start();
- }
+ if (isWebViewAvailable && browserWrap && popup) {
+ var op = popup.invokeScriptAsync("eval", code);
+ op.oncomplete = function (e) {
+ if (hasCallback) {
+ // return null if event target is unavailable by some reason
+ var result = (e && e.target) ? [e.target.result] : [null];
+ win(result);
+ }
+ };
+ op.onerror = function () { };
+ op.start();
+ }
+ });
},
injectScriptFile: function (win, fail, args) {
- var filePath = args[0],
- hasCallback = args[1];
+ setImmediate(function () {
+ var filePath = args[0],
+ hasCallback = args[1];
- if (!!filePath) {
- filePath = urlutil.makeAbsolute(filePath);
- }
+ if (!!filePath) {
+ filePath = urlutil.makeAbsolute(filePath);
+ }
- if (isWebViewAvailable && browserWrap && popup) {
- var uri = new Windows.Foundation.Uri(filePath);
- Windows.Storage.StorageFile.getFileFromApplicationUriAsync(uri).done(function (file) {
- Windows.Storage.FileIO.readTextAsync(file).done(function (code) {
- var op = popup.invokeScriptAsync("eval", code);
- op.oncomplete = function(e) {
- var result = [e.target.result];
- hasCallback && win(result);
- };
- op.onerror = function () { };
- op.start();
+ if (isWebViewAvailable && browserWrap && popup) {
+ var uri = new Windows.Foundation.Uri(filePath);
+ Windows.Storage.StorageFile.getFileFromApplicationUriAsync(uri).done(function (file) {
+ Windows.Storage.FileIO.readTextAsync(file).done(function (code) {
+ var op = popup.invokeScriptAsync("eval", code);
+ op.oncomplete = function(e) {
+ if (hasCallback) {
+ var result = [e.target.result];
+ win(result);
+ }
+ };
+ op.onerror = function () { };
+ op.start();
+ });
});
- });
- }
+ }
+ });
},
injectStyleCode: function (win, fail, args) {
- var code = args[0],
- hasCallback = args[1];
+ setImmediate(function () {
+ var code = args[0],
+ hasCallback = args[1];
- if (isWebViewAvailable && browserWrap && popup) {
- injectCSS(popup, code, hasCallback && win);
- }
+ if (isWebViewAvailable && browserWrap && popup) {
+ injectCSS(popup, code, hasCallback && win);
+ }
+ });
},
injectStyleFile: function (win, fail, args) {
- var filePath = args[0],
- hasCallback = args[1];
+ setImmediate(function () {
+ var filePath = args[0],
+ hasCallback = args[1];
- filePath = filePath && urlutil.makeAbsolute(filePath);
+ filePath = filePath && urlutil.makeAbsolute(filePath);
- if (isWebViewAvailable && browserWrap && popup) {
- var uri = new Windows.Foundation.Uri(filePath);
- Windows.Storage.StorageFile.getFileFromApplicationUriAsync(uri).then(function (file) {
- return Windows.Storage.FileIO.readTextAsync(file);
- }).done(function (code) {
- injectCSS(popup, code, hasCallback && win);
- }, function () {
- // no-op, just catch an error
- });
- }
+ if (isWebViewAvailable && browserWrap && popup) {
+ var uri = new Windows.Foundation.Uri(filePath);
+ Windows.Storage.StorageFile.getFileFromApplicationUriAsync(uri).then(function (file) {
+ return Windows.Storage.FileIO.readTextAsync(file);
+ }).done(function (code) {
+ injectCSS(popup, code, hasCallback && win);
+ }, function () {
+ // no-op, just catch an error
+ });
+ }
+ });
}
};
@@ -316,7 +366,9 @@ function injectCSS (webView, cssCode, callback) {
var op = webView.invokeScriptAsync("eval", evalWrapper);
op.oncomplete = function() {
- callback && callback([]);
+ if (callback) {
+ callback([]);
+ }
};
op.onerror = function () { };
op.start();
diff --git a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/wp/InAppBrowser.cs b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/wp/InAppBrowser.cs
index ddb51227..ddb51227 100755..100644
--- a/StoneIsland/plugins/cordova-plugin-inappbrowser/src/wp/InAppBrowser.cs
+++ b/StoneIsland/plugins/cordova-plugin-inappbrowser/src/wp/InAppBrowser.cs