Bug 1329152 - turn on CustomTabs via SwitchBoard r=nechen,sebastian
authorJulian_Chu <walkingice0204@gmail.com>
Fri, 21 Apr 2017 15:05:19 +0800
changeset 431676 7033e71f79294542fe45a40f591e45b06f236431
parent 431675 e692d1d1be1e51ac1b0dbd527b236bc2eef63d75
child 431677 b37909c3b506a2196d9e7c41c8f72e23b15eb3c9
push id7785
push userryanvm@gmail.com
push dateThu, 21 Sep 2017 13:39:55 +0000
treeherdermozilla-beta@06d4034a8a03 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnechen, sebastian
bugs1329152
milestone57.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 1329152 - turn on CustomTabs via SwitchBoard r=nechen,sebastian We are going to enable Custom Tabs by default. Now it is still controlled by SwitchBoard in case of any accident. MozReview-Commit-ID: JREAhkYzVSu
mobile/android/base/java/org/mozilla/gecko/Experiments.java
mobile/android/base/java/org/mozilla/gecko/LauncherActivity.java
--- a/mobile/android/base/java/org/mozilla/gecko/Experiments.java
+++ b/mobile/android/base/java/org/mozilla/gecko/Experiments.java
@@ -49,16 +49,19 @@ public class Experiments {
     public static final String URLBAR_SHOW_EV_CERT_OWNER = "urlbar-show-ev-cert-owner";
 
     // Play HLS videos in a VideoView (Bug 1313391)
     public static final String HLS_VIDEO_PLAYBACK = "hls-video-playback";
 
     // Show AddOns menu-item in top level menu
     public static final String TOP_ADDONS_MENU = "top-addons-menu";
 
+    // User in this group will enable Custom Tabs
+    public static final String CUSTOM_TABS = "custom-tabs";
+
     // Enable full bookmark management(full-page dialog, bookmark/folder modification, etc.)
     public static final String FULL_BOOKMARK_MANAGEMENT = "full-bookmark-management";
 
     // Enable Leanplum SDK
     public static final String LEANPLUM = "leanplum-start";
 
     // Enable to use testing user id for Leanplum
     public static final String LEANPLUM_DEBUG = "leanplum-debug";
--- a/mobile/android/base/java/org/mozilla/gecko/LauncherActivity.java
+++ b/mobile/android/base/java/org/mozilla/gecko/LauncherActivity.java
@@ -1,24 +1,26 @@
 /* -*- Mode: Java; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: nil; -*-
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 package org.mozilla.gecko;
 
 import android.app.Activity;
+import android.content.Context;
 import android.content.Intent;
 import android.net.Uri;
 import android.os.Bundle;
 import android.support.annotation.NonNull;
 import android.support.customtabs.CustomTabsIntent;
 import android.util.Log;
 
 import org.mozilla.gecko.home.HomeConfig;
+import org.mozilla.gecko.switchboard.SwitchBoard;
 import org.mozilla.gecko.webapps.WebAppActivity;
 import org.mozilla.gecko.webapps.WebAppIndexer;
 import org.mozilla.gecko.customtabs.CustomTabsActivity;
 import org.mozilla.gecko.db.BrowserContract;
 import org.mozilla.gecko.mozglue.SafeIntent;
 import org.mozilla.gecko.preferences.GeckoPreferences;
 import org.mozilla.gecko.tabqueue.TabQueueHelper;
 import org.mozilla.gecko.tabqueue.TabQueueService;
@@ -65,17 +67,17 @@ public class LauncherActivity extends Ac
         // Is this web app?
         } else if (isWebAppIntent(safeIntent)) {
             dispatchWebAppIntent();
 
         // If it's not a view intent, it won't be a custom tabs intent either. Just launch!
         } else if (!isViewIntentWithURL(safeIntent)) {
             dispatchNormalIntent();
 
-        } else if (isCustomTabsIntent(safeIntent)) {
+        } else if (isCustomTabsIntent(safeIntent) && isCustomTabsEnabled(this) ) {
             dispatchCustomTabsIntent();
 
         // Can we dispatch this VIEW action intent to the tab queue service?
         } else if (!safeIntent.getBooleanExtra(BrowserContract.SKIP_TAB_QUEUE_FLAG, false)
                 && TabQueueHelper.TAB_QUEUE_ENABLED
                 && TabQueueHelper.isTabQueueEnabled(this)) {
             dispatchTabQueueIntent();
 
@@ -154,16 +156,20 @@ public class LauncherActivity extends Ac
         intent.setFlags(intent.getFlags() & ~Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
     }
 
     private static boolean isViewIntentWithURL(@NonNull final SafeIntent safeIntent) {
         return Intent.ACTION_VIEW.equals(safeIntent.getAction())
                 && safeIntent.getDataString() != null;
     }
 
+    private static boolean isCustomTabsEnabled(@NonNull final Context context) {
+        return SwitchBoard.isInExperiment(context, Experiments.CUSTOM_TABS);
+    }
+
     private static boolean isCustomTabsIntent(@NonNull final SafeIntent safeIntent) {
         return isViewIntentWithURL(safeIntent)
                 && safeIntent.hasExtra(CustomTabsIntent.EXTRA_SESSION);
     }
 
     private static boolean isWebAppIntent(@NonNull final SafeIntent safeIntent) {
         return GeckoApp.ACTION_WEBAPP.equals(safeIntent.getAction());
     }