Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(71)

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/webapps/ChromeWebApkHost.java

Issue 2259093003: Move native "enable-webapk" check to ChromeWebApkHost. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix compile error. Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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; 11 import org.chromium.base.FieldTrialList;
12 import org.chromium.base.Log; 12 import org.chromium.base.Log;
13 import org.chromium.base.annotations.CalledByNative;
13 import org.chromium.chrome.browser.ChromeSwitches; 14 import org.chromium.chrome.browser.ChromeSwitches;
14 import org.chromium.chrome.browser.preferences.ChromePreferenceManager; 15 import org.chromium.chrome.browser.preferences.ChromePreferenceManager;
15 import org.chromium.webapk.lib.client.WebApkValidator; 16 import org.chromium.webapk.lib.client.WebApkValidator;
16 17
17 /** 18 /**
18 * Contains functionality needed for Chrome to host WebAPKs. 19 * Contains functionality needed for Chrome to host WebAPKs.
19 */ 20 */
20 public class ChromeWebApkHost { 21 public class ChromeWebApkHost {
21 // The public key to verify whether a WebAPK is signed by WebAPK Minting 22 // The public key to verify whether a WebAPK is signed by WebAPK Minting
22 // Server. 23 // Server.
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 public static void initForTesting(boolean enabled) { 90 public static void initForTesting(boolean enabled) {
90 sEnabledForTesting = enabled; 91 sEnabledForTesting = enabled;
91 } 92 }
92 93
93 public static boolean isEnabled() { 94 public static boolean isEnabled() {
94 if (sEnabledForTesting != null) return sEnabledForTesting; 95 if (sEnabledForTesting != null) return sEnabledForTesting;
95 96
96 return isEnabledInPrefs(); 97 return isEnabledInPrefs();
97 } 98 }
98 99
100 @CalledByNative
101 private static boolean areWebApkEnabled() {
102 return ChromeWebApkHost.isEnabled();
103 }
104
99 /** 105 /**
100 * Check the cached value to figure out if the feature is enabled. We have 106 * Check the cached value to figure out if the feature is enabled. We have
101 * to use the cached value because native library may not yet been loaded. 107 * to use the cached value because native library may not yet been loaded.
102 * 108 *
103 * @return Whether the feature is enabled. 109 * @return Whether the feature is enabled.
104 */ 110 */
105 private static boolean isEnabledInPrefs() { 111 private static boolean isEnabledInPrefs() {
106 // Will go away once the feature is enabled for everyone by default. 112 // Will go away once the feature is enabled for everyone by default.
107 StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads(); 113 StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskReads();
108 try { 114 try {
(...skipping 15 matching lines...) Expand all
124 boolean isEnabled = (!WEBAPK_RUNTIME_DISABLED.equals(experiment) 130 boolean isEnabled = (!WEBAPK_RUNTIME_DISABLED.equals(experiment)
125 && instance.hasSwitch(ChromeSwitches.ENABLE_WEBAPK)); 131 && instance.hasSwitch(ChromeSwitches.ENABLE_WEBAPK));
126 132
127 if (isEnabled != wasEnabled) { 133 if (isEnabled != wasEnabled) {
128 Log.d(TAG, "WebApk setting changed (%s => %s)", wasEnabled, isEnable d); 134 Log.d(TAG, "WebApk setting changed (%s => %s)", wasEnabled, isEnable d);
129 ChromePreferenceManager.getInstance(ContextUtils.getApplicationConte xt()) 135 ChromePreferenceManager.getInstance(ContextUtils.getApplicationConte xt())
130 .setCachedWebApkRuntimeEnabled(isEnabled); 136 .setCachedWebApkRuntimeEnabled(isEnabled);
131 } 137 }
132 } 138 }
133 } 139 }
OLDNEW
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/ShortcutHelper.java ('k') | chrome/browser/android/shortcut_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698