diff --git a/mobile/android/base/ActivityHandlerHelper.java b/mobile/android/base/ActivityHandlerHelper.java index 7174c658077e..47755fde6fcb 100644 --- a/mobile/android/base/ActivityHandlerHelper.java +++ b/mobile/android/base/ActivityHandlerHelper.java @@ -8,10 +8,7 @@ import org.mozilla.gecko.util.ActivityResultHandler; import org.mozilla.gecko.util.ActivityResultHandlerMap; import android.app.Activity; -import android.content.ActivityNotFoundException; -import android.content.Context; import android.content.Intent; -import android.util.Log; public class ActivityHandlerHelper { private static final String LOGTAG = "GeckoActivityHandlerHelper"; @@ -25,26 +22,6 @@ public class ActivityHandlerHelper { startIntentForActivity(GeckoAppShell.getGeckoInterface().getActivity(), intent, activityResultHandler); } - /** - * Starts the Activity, catching & logging if the Activity fails to start. - * - * We catch to prevent callers from passing in invalid Intents and crashing the browser. - * - * @return true if the Activity is successfully started, false otherwise. - */ - public static boolean startIntentAndCatch(final String logtag, final Context context, final Intent intent) { - try { - context.startActivity(intent); - return true; - } catch (final ActivityNotFoundException e) { - Log.w(logtag, "Activity not found.", e); - return false; - } catch (final SecurityException e) { - Log.w(logtag, "Forbidden to launch activity.", e); - return false; - } - } - public static void startIntentForActivity(Activity activity, Intent intent, ActivityResultHandler activityResultHandler) { activity.startActivityForResult(intent, mActivityResultHandlerMap.put(activityResultHandler)); } diff --git a/mobile/android/base/BrowserApp.java b/mobile/android/base/BrowserApp.java index b4d50b9ce329..ed208df83fa9 100644 --- a/mobile/android/base/BrowserApp.java +++ b/mobile/android/base/BrowserApp.java @@ -1542,7 +1542,7 @@ public class BrowserApp extends GeckoApp } GeckoAppShell.openUriExternal(url, "text/plain", "", "", - Intent.ACTION_SEND, tab.getDisplayTitle(), false); + Intent.ACTION_SEND, tab.getDisplayTitle()); // Context: Sharing via chrome list (no explicit session is active) Telemetry.sendUIEvent(TelemetryContract.Event.SHARE, TelemetryContract.Method.LIST); @@ -1783,7 +1783,7 @@ public class BrowserApp extends GeckoApp } else if ("Reader:Share".equals(event)) { final String title = message.getString("title"); final String url = message.getString("url"); - GeckoAppShell.openUriExternal(url, "text/plain", "", "", Intent.ACTION_SEND, title, false); + GeckoAppShell.openUriExternal(url, "text/plain", "", "", Intent.ACTION_SEND, title); } else if ("Sanitize:ClearHistory".equals(event)) { handleClearHistory(message.optBoolean("clearSearchHistory", false)); callback.sendSuccess(true); diff --git a/mobile/android/base/GeckoApp.java b/mobile/android/base/GeckoApp.java index af6006ee436a..6a2361736681 100644 --- a/mobile/android/base/GeckoApp.java +++ b/mobile/android/base/GeckoApp.java @@ -639,7 +639,7 @@ public abstract class GeckoApp final String url = ReaderModeUtils.stripAboutReaderUrl(tab.getURL()); text += "\n\n" + url; } - GeckoAppShell.openUriExternal(text, "text/plain", "", "", Intent.ACTION_SEND, title, false); + GeckoAppShell.openUriExternal(text, "text/plain", "", "", Intent.ACTION_SEND, title); // Context: Sharing via chrome list (no explicit session is active) Telemetry.sendUIEvent(TelemetryContract.Event.SHARE, TelemetryContract.Method.LIST); diff --git a/mobile/android/base/GeckoAppShell.java b/mobile/android/base/GeckoAppShell.java index 75fc882cb561..331b0941b662 100644 --- a/mobile/android/base/GeckoAppShell.java +++ b/mobile/android/base/GeckoAppShell.java @@ -55,13 +55,13 @@ import org.mozilla.gecko.util.NativeJSContainer; import org.mozilla.gecko.util.NativeJSObject; import org.mozilla.gecko.util.ProxySelector; import org.mozilla.gecko.util.ThreadUtils; -import org.mozilla.gecko.widget.ExternalIntentDuringPrivateBrowsingPromptFragment; import android.annotation.TargetApi; import android.app.Activity; import android.app.ActivityManager; import android.app.AlarmManager; import android.app.PendingIntent; +import android.content.ActivityNotFoundException; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; @@ -106,7 +106,6 @@ import android.os.SystemClock; import android.os.Vibrator; import android.provider.Browser; import android.provider.Settings; -import android.support.v4.app.FragmentActivity; import android.telephony.TelephonyManager; import android.text.TextUtils; import android.util.Base64; @@ -1050,17 +1049,6 @@ public class GeckoAppShell return true; } - @WrapForJNI - public static boolean openUriExternal(String targetURI, - String mimeType, - String packageName, - String className, - String action, - String title) { - // Default to showing prompt in private browsing to be safe. - return openUriExternal(targetURI, mimeType, packageName, className, action, title, true); - } - /** * Given the inputs to getOpenURIIntent, plus an optional * package name and class name, create and fire an intent to open the @@ -1074,20 +1062,15 @@ public class GeckoAppShell * @param action an Android action specifier, such as * Intent.ACTION_SEND. * @param title the title to use in ACTION_SEND intents. - * @param showPromptInPrivateBrowsing whether or not the user should be prompted when opening - * this uri from private browsing. This should be true - * when the user doesn't explicitly choose to open an an - * external app (e.g. just clicked a link). - * @return true if the activity started successfully or the user was prompted to open the - * application; false otherwise. + * @return true if the activity started successfully; false otherwise. */ + @WrapForJNI public static boolean openUriExternal(String targetURI, String mimeType, String packageName, String className, String action, - String title, - final boolean showPromptInPrivateBrowsing) { + String title) { final Context context = getContext(); final Intent intent = getOpenURIIntent(context, targetURI, mimeType, action, title); @@ -1106,16 +1089,15 @@ public class GeckoAppShell } intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); - - if (!showPromptInPrivateBrowsing) { - return ActivityHandlerHelper.startIntentAndCatch(LOGTAG, context, intent); - } else { - // Ideally we retrieve the Activity from the calling args, rather than - // statically, but since this method is called from Gecko and I'm - // unfamiliar with that code, this is a simpler solution. - final FragmentActivity fragmentActivity = (FragmentActivity) getGeckoInterface().getActivity(); - return ExternalIntentDuringPrivateBrowsingPromptFragment.showDialogOrAndroidChooser( - context, fragmentActivity.getSupportFragmentManager(), intent); + try { + context.startActivity(intent); + return true; + } catch (ActivityNotFoundException e) { + Log.w(LOGTAG, "Activity not found.", e); + return false; + } catch (SecurityException e) { + Log.w(LOGTAG, "Forbidden to launch activity.", e); + return false; } } diff --git a/mobile/android/base/IntentHelper.java b/mobile/android/base/IntentHelper.java index 9c01e7b50671..0a04bcaea0aa 100644 --- a/mobile/android/base/IntentHelper.java +++ b/mobile/android/base/IntentHelper.java @@ -12,15 +12,14 @@ import org.mozilla.gecko.util.JSONUtils; import org.mozilla.gecko.util.NativeEventListener; import org.mozilla.gecko.util.NativeJSObject; import org.mozilla.gecko.util.WebActivityMapper; -import org.mozilla.gecko.widget.ExternalIntentDuringPrivateBrowsingPromptFragment; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; +import android.app.Activity; import android.content.Intent; import android.net.Uri; -import android.support.v4.app.FragmentActivity; import android.text.TextUtils; import android.util.Log; @@ -54,15 +53,15 @@ public final class IntentHelper implements GeckoEventListener, private static IntentHelper instance; - private final FragmentActivity activity; + private final Activity activity; - private IntentHelper(final FragmentActivity activity) { + private IntentHelper(Activity activity) { this.activity = activity; EventDispatcher.getInstance().registerGeckoThreadListener((GeckoEventListener) this, EVENTS); EventDispatcher.getInstance().registerGeckoThreadListener((NativeEventListener) this, NATIVE_EVENTS); } - public static IntentHelper init(final FragmentActivity activity) { + public static IntentHelper init(Activity activity) { if (instance == null) { instance = new IntentHelper(activity); } else { @@ -123,7 +122,7 @@ public final class IntentHelper implements GeckoEventListener, message.optString("packageName"), message.optString("className"), message.optString("action"), - message.optString("title"), false); + message.optString("title")); } private void openForResult(final JSONObject message) throws JSONException { @@ -202,8 +201,7 @@ public final class IntentHelper implements GeckoEventListener, // (Bug 1192436) We don't know if marketIntent matches any Activities (e.g. non-Play // Store devices). If it doesn't, clicking the link will cause no action to occur. - ExternalIntentDuringPrivateBrowsingPromptFragment.showDialogOrAndroidChooser( - activity, activity.getSupportFragmentManager(), marketIntent); + activity.startActivity(marketIntent); callback.sendSuccess(null); } else { diff --git a/mobile/android/base/home/HomeFragment.java b/mobile/android/base/home/HomeFragment.java index a19accc39f15..15775a87dd9f 100644 --- a/mobile/android/base/home/HomeFragment.java +++ b/mobile/android/base/home/HomeFragment.java @@ -197,7 +197,7 @@ public abstract class HomeFragment extends Fragment { return false; } else { GeckoAppShell.openUriExternal(info.url, SHARE_MIME_TYPE, "", "", - Intent.ACTION_SEND, info.getDisplayTitle(), false); + Intent.ACTION_SEND, info.getDisplayTitle()); // Context: Sharing via chrome homepage contextmenu list (home session should be active) Telemetry.sendUIEvent(TelemetryContract.Event.SHARE, TelemetryContract.Method.LIST); diff --git a/mobile/android/base/locales/en-US/android_strings.dtd b/mobile/android/base/locales/en-US/android_strings.dtd index 8058cae1ddf4..23ce3fa80573 100644 --- a/mobile/android/base/locales/en-US/android_strings.dtd +++ b/mobile/android/base/locales/en-US/android_strings.dtd @@ -705,19 +705,6 @@ just addresses the organization to follow, e.g. "This site is run by " --> - - - -