Bug 1329152 - turn on CustomTabs via SwitchBoard
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
--- 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());
}