| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.chrome.browser.webapps; | 5 package org.chromium.chrome.browser.webapps; |
| 6 | 6 |
| 7 import android.os.StrictMode; | 7 import android.os.StrictMode; |
| 8 | 8 |
| 9 import org.chromium.base.CommandLine; | 9 import org.chromium.base.CommandLine; |
| 10 import org.chromium.base.ContextUtils; | 10 import org.chromium.base.ContextUtils; |
| 11 import org.chromium.base.FieldTrialList; | |
| 12 import org.chromium.base.Log; | 11 import org.chromium.base.Log; |
| 13 import org.chromium.base.annotations.CalledByNative; | 12 import org.chromium.base.annotations.CalledByNative; |
| 13 import org.chromium.chrome.browser.ChromeFeatureList; |
| 14 import org.chromium.chrome.browser.ChromeSwitches; | 14 import org.chromium.chrome.browser.ChromeSwitches; |
| 15 import org.chromium.chrome.browser.preferences.ChromePreferenceManager; | 15 import org.chromium.chrome.browser.preferences.ChromePreferenceManager; |
| 16 import org.chromium.webapk.lib.client.WebApkValidator; | 16 import org.chromium.webapk.lib.client.WebApkValidator; |
| 17 | 17 |
| 18 /** | 18 /** |
| 19 * Contains functionality needed for Chrome to host WebAPKs. | 19 * Contains functionality needed for Chrome to host WebAPKs. |
| 20 */ | 20 */ |
| 21 public class ChromeWebApkHost { | 21 public class ChromeWebApkHost { |
| 22 private static final String TAG = "ChromeWebApkHost"; | 22 private static final String TAG = "ChromeWebApkHost"; |
| 23 | 23 |
| 24 /** Finch experiment name. */ | |
| 25 private static final String WEBAPK_DISABLE_EXPERIMENT_NAME = "WebApkKillSwit
ch"; | |
| 26 | |
| 27 /** Finch experiment group which forces WebAPKs off. */ | |
| 28 private static final String WEBAPK_RUNTIME_DISABLED = "Disabled"; | |
| 29 | |
| 30 private static Boolean sEnabledForTesting; | 24 private static Boolean sEnabledForTesting; |
| 31 | 25 |
| 32 public static void init() { | 26 public static void init() { |
| 33 WebApkValidator.initWithBrowserHostSignature(ChromeWebApkHostSignature.E
XPECTED_SIGNATURE); | 27 WebApkValidator.initWithBrowserHostSignature(ChromeWebApkHostSignature.E
XPECTED_SIGNATURE); |
| 34 } | 28 } |
| 35 | 29 |
| 36 public static void initForTesting(boolean enabled) { | 30 public static void initForTesting(boolean enabled) { |
| 37 sEnabledForTesting = enabled; | 31 sEnabledForTesting = enabled; |
| 38 } | 32 } |
| 39 | 33 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 65 } | 59 } |
| 66 } | 60 } |
| 67 | 61 |
| 68 /** | 62 /** |
| 69 * Once native is loaded we can consult the command-line (set via about:flag
s) and also finch | 63 * Once native is loaded we can consult the command-line (set via about:flag
s) and also finch |
| 70 * state to see if we should enable WebAPKs. | 64 * state to see if we should enable WebAPKs. |
| 71 */ | 65 */ |
| 72 public static void cacheEnabledStateForNextLaunch() { | 66 public static void cacheEnabledStateForNextLaunch() { |
| 73 boolean wasEnabled = isEnabledInPrefs(); | 67 boolean wasEnabled = isEnabledInPrefs(); |
| 74 CommandLine instance = CommandLine.getInstance(); | 68 CommandLine instance = CommandLine.getInstance(); |
| 75 String experiment = FieldTrialList.findFullName(WEBAPK_DISABLE_EXPERIMEN
T_NAME); | 69 boolean isEnabled = ChromeFeatureList.isEnabled(ChromeFeatureList.WEBAPK
) |
| 76 boolean isEnabled = (!WEBAPK_RUNTIME_DISABLED.equals(experiment) | 70 && instance.hasSwitch(ChromeSwitches.ENABLE_WEBAPK); |
| 77 && instance.hasSwitch(ChromeSwitches.ENABLE_WEBAPK)); | |
| 78 | 71 |
| 79 if (isEnabled != wasEnabled) { | 72 if (isEnabled != wasEnabled) { |
| 80 Log.d(TAG, "WebApk setting changed (%s => %s)", wasEnabled, isEnable
d); | 73 Log.d(TAG, "WebApk setting changed (%s => %s)", wasEnabled, isEnable
d); |
| 81 ChromePreferenceManager.getInstance(ContextUtils.getApplicationConte
xt()) | 74 ChromePreferenceManager.getInstance(ContextUtils.getApplicationConte
xt()) |
| 82 .setCachedWebApkRuntimeEnabled(isEnabled); | 75 .setCachedWebApkRuntimeEnabled(isEnabled); |
| 83 } | 76 } |
| 84 } | 77 } |
| 85 } | 78 } |
| OLD | NEW |