Commit f3248b29 authored by Matthew Finkel's avatar Matthew Finkel Committed by Matthew Finkel
Browse files

Bug 26529 - Prompt before opening external app

parent 556518ae
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -175,6 +175,7 @@ import org.mozilla.gecko.util.WindowUtil;
import org.mozilla.gecko.widget.ActionModePresenter;
import org.mozilla.gecko.widget.AnchoredPopup;
import org.mozilla.gecko.widget.AnimatedProgressBar;
import org.mozilla.gecko.widget.ExternalIntentDuringPrivateBrowsingPromptFragment;
import org.mozilla.gecko.widget.GeckoActionProvider;
import org.mozilla.gecko.widget.SplashScreen;
import org.mozilla.geckoview.DynamicToolbarAnimator;
@@ -4165,7 +4166,8 @@ public class BrowserApp extends GeckoApp
        if (flags.contains(OnUrlOpenListener.Flags.OPEN_WITH_INTENT)) {
            Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setData(Uri.parse(url));
            startActivity(intent);
            ExternalIntentDuringPrivateBrowsingPromptFragment.showDialogOrAndroidChooser(
                this, getSupportFragmentManager(), intent);
        } else {
            // By default this listener is used for lists where the offline reader-view icon
            // is shown - hence we need to redirect to the reader-view page by default.
+5 −2
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@ import org.mozilla.gecko.util.ThreadUtils;
import org.mozilla.gecko.util.ViewUtil;
import org.mozilla.gecko.widget.ActionModePresenter;
import org.mozilla.gecko.widget.AnchoredPopup;
import org.mozilla.gecko.widget.ExternalIntentDuringPrivateBrowsingPromptFragment;
import org.mozilla.geckoview.GeckoSession;
import org.mozilla.geckoview.GeckoSessionSettings;
import org.mozilla.geckoview.GeckoView;
@@ -765,11 +766,13 @@ public abstract class GeckoApp extends GeckoActivity
            if (email != null) {
                Uri contactUri = Uri.parse(email);
                Intent i = new Intent(ContactsContract.Intents.SHOW_OR_CREATE_CONTACT, contactUri);
                startActivity(i);
                ExternalIntentDuringPrivateBrowsingPromptFragment.showDialogOrAndroidChooser(
                        this, getSupportFragmentManager(), i);
            } else if (phone != null) {
                Uri contactUri = Uri.parse(phone);
                Intent i = new Intent(ContactsContract.Intents.SHOW_OR_CREATE_CONTACT, contactUri);
                startActivity(i);
                ExternalIntentDuringPrivateBrowsingPromptFragment.showDialogOrAndroidChooser(
                        this, getSupportFragmentManager(), i);
            } else {
                // something went wrong.
                Log.e(LOGTAG, "Received Contact:Add message with no email nor phone number");
+5 −2
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.design.widget.Snackbar;
import android.support.multidex.MultiDex;
import android.support.v7.app.AppCompatActivity;
import android.text.TextUtils;
import android.util.Base64;
import android.util.Log;
@@ -64,6 +65,7 @@ import org.mozilla.gecko.util.PRNGFixes;
import org.mozilla.gecko.util.ProxySelector;
import org.mozilla.gecko.util.ShortcutUtils;
import org.mozilla.gecko.util.ThreadUtils;
import org.mozilla.gecko.widget.ExternalIntentDuringPrivateBrowsingPromptFragment;
import org.mozilla.geckoview.GeckoRuntime;
import org.mozilla.geckoview.GeckoRuntimeSettings;

@@ -813,8 +815,9 @@ public class GeckoApplication extends Application
                        context.getContentResolver().delete(intent.getData(), null, null);
                    }
                };
                ActivityHandlerHelper.startIntentForActivity(currentActivity, chooser,
                                                             handler);
                ActivityHandlerHelper.registerActivityHandler(handler);
                ExternalIntentDuringPrivateBrowsingPromptFragment.showDialogOrAndroidChooser(
                        currentActivity, ((AppCompatActivity)currentActivity).getSupportFragmentManager(), intent);
            }
        });
    }
+11 −4
Original line number Diff line number Diff line
@@ -123,7 +123,7 @@ public final class IntentHelper implements BundleEventListener {
                                          String className,
                                          String action,
                                          String title,
                                          final boolean showPromptInPrivateBrowsing) {
                                          boolean showPromptInPrivateBrowsing) {
        final Context context = getContext();
        final Intent intent = getOpenURIIntent(context, targetURI,
                                               mimeType, action, title);
@@ -141,10 +141,15 @@ public final class IntentHelper implements BundleEventListener {
            }
        }

        // Always prompt for Intents
        showPromptInPrivateBrowsing = true;

        final FragmentActivity activity = getActivity();
        if (!showPromptInPrivateBrowsing || activity == null) {
            if (activity == null) {
                intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                //intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                // We'll find out what this breaks.
                return false;
            }
            return ActivityHandlerHelper.startIntentAndCatch(LOGTAG, context, intent);
        } else {
@@ -152,7 +157,7 @@ public final class IntentHelper implements BundleEventListener {
            // statically, but since this method is called from Gecko and I'm
            // unfamiliar with that code, this is a simpler solution.
            return ExternalIntentDuringPrivateBrowsingPromptFragment.showDialogOrAndroidChooser(
                    context, activity.getSupportFragmentManager(), intent);
                    activity, activity.getSupportFragmentManager(), intent);
        }
    }

@@ -472,7 +477,9 @@ public final class IntentHelper implements BundleEventListener {
        // isn't owned exclusively by Firefox, so there's no real benefit to using content:// URIs
        // here.
        try (StrictModeContext unused = StrictModeContext.allowAllVmPolicies()) {
            ActivityHandlerHelper.startIntentForActivity(activity, intent, handler);
            // Always prompt.
            ExternalIntentDuringPrivateBrowsingPromptFragment.showDialogOrAndroidChooser(
                    activity, activity.getSupportFragmentManager(), intent);
        } catch (SecurityException e) {
            Log.w(LOGTAG, "Forbidden to launch activity.", e);
        }
+1 −0
Original line number Diff line number Diff line
@@ -222,6 +222,7 @@ public abstract class BrowserToolbar extends ThemedRelativeLayout
        prefs = new ToolbarPrefs();
        urlDisplayLayout.setToolbarPrefs(prefs);
        urlEditLayout.setToolbarPrefs(prefs);
        urlEditLayout.setActivity(activity);

        // ScrollViews are allowed to have only one child.
        final View scrollChild = urlDisplayScroll.getChildAt(0);
Loading