Bug 1173147 - Prompt user when opening market intent. r=sebastian
☠☠ backed out by 9d8432afaf64 ☠ ☠
authorMichael Comella <michael.l.comella@gmail.com>
Thu, 17 Sep 2015 18:42:07 -0700
changeset 266925 5a4df2457628c2fc41385dcca653e05eb8f5caa1
parent 266924 a43a907c02fe32724322bf907e4ff4136e364ea4
child 266926 afd881fc08a25c38a57343434ba58becb836ffa0
push id29503
push usercbook@mozilla.com
push dateFri, 09 Oct 2015 09:36:47 +0000
treeherdermozilla-central@462074ffada4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssebastian
bugs1173147
milestone44.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1173147 - Prompt user when opening market intent. r=sebastian
mobile/android/base/IntentHelper.java
--- a/mobile/android/base/IntentHelper.java
+++ b/mobile/android/base/IntentHelper.java
@@ -7,24 +7,25 @@ package org.mozilla.gecko;
 
 import org.mozilla.gecko.util.ActivityResultHandler;
 import org.mozilla.gecko.util.EventCallback;
 import org.mozilla.gecko.util.GeckoEventListener;
 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;
 
 import java.io.UnsupportedEncodingException;
 import java.net.URISyntaxException;
 import java.net.URLEncoder;
 import java.util.Arrays;
 import java.util.List;
@@ -48,25 +49,25 @@ public final class IntentHelper implemen
     private static String MARKET_INTENT_URI_PACKAGE_PREFIX = "market://details?id=";
     private static String EXTRA_BROWSER_FALLBACK_URL = "browser_fallback_url";
 
     /** A partial URI to an error page - the encoded error URI should be appended before loading. */
     private static String UNKNOWN_PROTOCOL_URI_PREFIX = "about:neterror?e=unknownProtocolFound&u=";
 
     private static IntentHelper instance;
 
-    private final Activity activity;
+    private final FragmentActivity activity;
 
-    private IntentHelper(Activity activity) {
+    private IntentHelper(final FragmentActivity activity) {
         this.activity = activity;
         EventDispatcher.getInstance().registerGeckoThreadListener((GeckoEventListener) this, EVENTS);
         EventDispatcher.getInstance().registerGeckoThreadListener((NativeEventListener) this, NATIVE_EVENTS);
     }
 
-    public static IntentHelper init(Activity activity) {
+    public static IntentHelper init(final FragmentActivity activity) {
         if (instance == null) {
             instance = new IntentHelper(activity);
         } else {
             Log.w(LOGTAG, "IntentHelper.init() called twice, ignoring.");
         }
 
         return instance;
     }
@@ -196,17 +197,18 @@ public final class IntentHelper implemen
             // malicious software). Better to leave that one alone.
             final String marketUri = MARKET_INTENT_URI_PACKAGE_PREFIX + intent.getPackage();
             final Intent marketIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(marketUri));
             marketIntent.addCategory(Intent.CATEGORY_BROWSABLE);
             marketIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
 
             // (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.
-            activity.startActivity(marketIntent);
+            ExternalIntentDuringPrivateBrowsingPromptFragment.showDialogOrAndroidChooser(
+                    activity, activity.getSupportFragmentManager(), marketIntent);
             callback.sendSuccess(null);
 
         }  else {
             // Don't log the URI to prevent leaking it.
             Log.w(LOGTAG, "Unable to open URI, default case - loading about:neterror");
             callback.sendError(getUnknownProtocolErrorPageUri(intent.getData().toString()));
         }
     }