Bug 1515651 - Open LP URLs specifically in Fennec. r=sdaswani
authorVlad Baicu <vlad.baicu@softvision.ro>
Fri, 18 Jan 2019 18:08:39 +0000
changeset 514483 8d878be3b4bf0851b5c945ee3871b8aa0ab334b5
parent 514482 c31d2c5695b185f5dab74513f911388ddcb23a46
child 514484 7b123a6c5f5a6b680da3a9c387a0508f1819baf7
push id1953
push userffxbld-merge
push dateMon, 11 Mar 2019 12:10:20 +0000
treeherdermozilla-release@9c35dcbaa899 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssdaswani
bugs1515651
milestone66.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 1515651 - Open LP URLs specifically in Fennec. r=sdaswani Created a new "open" deeplink to open pages directly in Fennec. Differential Revision: https://phabricator.services.mozilla.com/D15127
mobile/android/base/java/org/mozilla/gecko/LauncherActivity.java
mobile/android/base/java/org/mozilla/gecko/deeplink/DeepLinkContract.java
mobile/android/docs/mma.rst
--- a/mobile/android/base/java/org/mozilla/gecko/LauncherActivity.java
+++ b/mobile/android/base/java/org/mozilla/gecko/LauncherActivity.java
@@ -27,27 +27,29 @@ import org.mozilla.gecko.preferences.Gec
 import org.mozilla.gecko.tabqueue.TabQueueHelper;
 import org.mozilla.gecko.tabqueue.TabQueueService;
 
 import static org.mozilla.gecko.BrowserApp.ACTIVITY_REQUEST_PREFERENCES;
 import static org.mozilla.gecko.deeplink.DeepLinkContract.DEEP_LINK_SCHEME;
 import static org.mozilla.gecko.deeplink.DeepLinkContract.LINK_BOOKMARK_LIST;
 import static org.mozilla.gecko.deeplink.DeepLinkContract.LINK_DEFAULT_BROWSER;
 import static org.mozilla.gecko.deeplink.DeepLinkContract.LINK_HISTORY_LIST;
+import static org.mozilla.gecko.deeplink.DeepLinkContract.LINK_OPEN;
 import static org.mozilla.gecko.deeplink.DeepLinkContract.LINK_PREFERENCES_HOME;
 import static org.mozilla.gecko.deeplink.DeepLinkContract.LINK_PREFERENCES;
 import static org.mozilla.gecko.deeplink.DeepLinkContract.LINK_PREFERENCES_ACCESSIBILITY;
 import static org.mozilla.gecko.deeplink.DeepLinkContract.LINK_PREFERENCES_GENERAL;
 import static org.mozilla.gecko.deeplink.DeepLinkContract.LINK_PREFERENCES_NOTIFICATIONS;
 import static org.mozilla.gecko.deeplink.DeepLinkContract.LINK_PREFERENCES_PRIAVACY;
 import static org.mozilla.gecko.deeplink.DeepLinkContract.LINK_PREFERENCES_SEARCH;
 import static org.mozilla.gecko.deeplink.DeepLinkContract.LINK_SAVE_AS_PDF;
 import static org.mozilla.gecko.deeplink.DeepLinkContract.LINK_SIGN_UP;
 import static org.mozilla.gecko.deeplink.DeepLinkContract.SUMO_DEFAULT_BROWSER;
 import static org.mozilla.gecko.deeplink.DeepLinkContract.LINK_FXA_SIGNIN;
+import static org.mozilla.gecko.deeplink.DeepLinkContract.URL_PARAM;
 import static org.mozilla.gecko.util.FileUtils.isContentUri;
 
 import org.mozilla.gecko.deeplink.DeepLinkContract;
 
 /**
  * Activity that receives incoming Intents and dispatches them to the appropriate activities (e.g. browser, custom tabs, web app).
  */
 public class LauncherActivity extends Activity {
@@ -199,16 +201,19 @@ public class LauncherActivity extends Ac
         final String localUid = getSharedPreferences(BrowserApp.class.getName(), MODE_PRIVATE).getString(MmaDelegate.KEY_ANDROID_PREF_STRING_LEANPLUM_DEVICE_ID, null);
         final boolean isMmaDeepLink = uid != null && localUid != null && uid.equals(localUid);
 
         if (!validateMmaDeepLink(deepLink, isMmaDeepLink)) {
             return;
         }
 
         switch (deepLink) {
+            case LINK_OPEN:
+                dispatchUrlDeepLink(intent);
+                break;
             case LINK_DEFAULT_BROWSER:
                 GeckoSharedPrefs.forApp(this).edit().putBoolean(GeckoPreferences.PREFS_DEFAULT_BROWSER, true).apply();
 
                 if (AppConstants.Versions.feature24Plus) {
                     // We are special casing the link to set the default browser here: On old Android versions we
                     // link to a SUMO page but on new Android versions we can link to the default app settings where
                     // the user can actually set a default browser (Bug 1312686).
                     final Intent changeDefaultApps = new Intent("android.settings.MANAGE_DEFAULT_APPS_SETTINGS");
@@ -299,9 +304,15 @@ public class LauncherActivity extends Ac
         }
 
         intent.setClassName(getApplicationContext(), AppConstants.MOZ_ANDROID_BROWSER_INTENT_CLASS);
 
         filterFlags(intent);
         startActivity(intent);
     }
 
+    private void dispatchUrlDeepLink(final SafeIntent intent) {
+        String url = intent.getData().getQueryParameter(URL_PARAM);
+        if (url != null) {
+            dispatchUrlIntent(url);
+        }
+    }
 }
--- a/mobile/android/base/java/org/mozilla/gecko/deeplink/DeepLinkContract.java
+++ b/mobile/android/base/java/org/mozilla/gecko/deeplink/DeepLinkContract.java
@@ -9,25 +9,28 @@ package org.mozilla.gecko.deeplink;
 public class DeepLinkContract {
 
     // Sumo page for setting Fennec as default browser
     public static final String SUMO_DEFAULT_BROWSER = "https://support.mozilla.org/kb/make-firefox-default-browser-android?utm_source=inproduct&amp;utm_medium=settings&amp;utm_campaign=mobileandroid";
     public static final String DEEP_LINK_SCHEME = "firefox";
 
     public static final String LINK_FXA_SIGNIN = "fxa-signin";
 
+    public static final String LINK_OPEN = "open";
     public static final String LINK_DEFAULT_BROWSER = "default_browser";
     public static final String LINK_SAVE_AS_PDF = "save_as_pdf";
     public static final String LINK_BOOKMARK_LIST = "bookmark_list";
     public static final String LINK_HISTORY_LIST = "history_list";
     public static final String LINK_SIGN_UP = "sign_up";
     public static final String LINK_PREFERENCES_GENERAL = "preferences_general";
     public static final String LINK_PREFERENCES = "preferences";
     public static final String LINK_PREFERENCES_PRIAVACY = "preferences_privacy";
     public static final String LINK_PREFERENCES_SEARCH = "preferences_search";
     public static final String LINK_PREFERENCES_NOTIFICATIONS = "preferences_notifications";
     public static final String LINK_PREFERENCES_ACCESSIBILITY = "preferences_accessibility";
     public static final String LINK_PREFERENCES_HOME = "preferences_home";
 
+    public static final String URL_PARAM = "url";
+
     public static final String ACCOUNTS_TOKEN_PARAM = "signin";
     public static final String ACCOUNTS_ENTRYPOINT_PARAM = "entrypoint";
     public static final String ACCOUNTS_UTM_PREFIX = "utm_";
 }
--- a/mobile/android/docs/mma.rst
+++ b/mobile/android/docs/mma.rst
@@ -172,16 +172,17 @@ List of current Events related data that
 {
   "event" : "E_Just_Installed_Klar"
 }
 
 Deep Links:
 Deep links are actions that can point Fennec to open certain pages or load features such as `show bookmark list` or
 `open a SUMO page`. When users see a prompt Leanplum message, they can click the button(s) on it. These buttons can
 trigger the following deep links
+* Link to open pages specifically in Fennec (firefox://open?url=)
 * Link to Set Default Browser settings (firefox://default_browser)
 * Link to specific Add-on page (http://link_to_the_add_on_page)
 * Link to sync signup/sign in (firefox://sign_up)
 * Link to default search engine settings (firefox://preferences_search)
 * Link to “Save as PDF” feature (firefox://save_as_pdf)
 * Take user directly to a Sign up for a newsletter (http://link_to_newsletter_page)
 * Link to bookmark list (firefox://bookmark_list)
 * Link to history list (firefox://history_list)