| 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.content.Context; | 7 import android.content.Context; |
| 8 import android.content.DialogInterface; | 8 import android.content.DialogInterface; |
| 9 import android.content.Intent; | 9 import android.content.Intent; |
| 10 import android.os.StrictMode; | 10 import android.os.StrictMode; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 return ChromePreferenceManager.getInstance( | 62 return ChromePreferenceManager.getInstance( |
| 63 ContextUtils.getApplicationContext()).getCachedWebApkRuntime
Enabled(); | 63 ContextUtils.getApplicationContext()).getCachedWebApkRuntime
Enabled(); |
| 64 } finally { | 64 } finally { |
| 65 StrictMode.setThreadPolicy(oldPolicy); | 65 StrictMode.setThreadPolicy(oldPolicy); |
| 66 } | 66 } |
| 67 } | 67 } |
| 68 | 68 |
| 69 /** | 69 /** |
| 70 * Show dialog warning user that "installation from unknown sources" is requ
ired by the WebAPK | 70 * Show dialog warning user that "installation from unknown sources" is requ
ired by the WebAPK |
| 71 * experiment if: | 71 * experiment if: |
| 72 * - The user toggled the --enable-webapk command line flag via chrome://fla
gs | 72 * - The user toggled the --enable-improved-a2hs command line flag via chrom
e://flags |
| 73 * AND | 73 * AND |
| 74 * - WebAPKs are not disabled via variations kill switch. | 74 * - WebAPKs are not disabled via variations kill switch. |
| 75 * Must be run prior to {@link cacheEnabledStateForNextLaunch}. | 75 * Must be run prior to {@link cacheEnabledStateForNextLaunch}. |
| 76 */ | 76 */ |
| 77 public static void launchWebApkRequirementsDialogIfNeeded(Context context) { | 77 public static void launchWebApkRequirementsDialogIfNeeded(Context context) { |
| 78 // Show dialog on Canary & Dev. Installation via "unknown sources" is di
sabled via | 78 // Show dialog on Canary & Dev. Installation via "unknown sources" is di
sabled via |
| 79 // variations on other channels. | 79 // variations on other channels. |
| 80 if (!ChromeVersionInfo.isCanaryBuild() && !ChromeVersionInfo.isDevBuild(
)) return; | 80 if (!ChromeVersionInfo.isCanaryBuild() && !ChromeVersionInfo.isDevBuild(
)) return; |
| 81 | 81 |
| 82 Context applicationContext = ContextUtils.getApplicationContext(); | 82 Context applicationContext = ContextUtils.getApplicationContext(); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 105 } | 105 } |
| 106 | 106 |
| 107 boolean wasEnabled = isEnabledInPrefs(); | 107 boolean wasEnabled = isEnabledInPrefs(); |
| 108 boolean isEnabled = computeEnabled(); | 108 boolean isEnabled = computeEnabled(); |
| 109 if (isEnabled != wasEnabled) { | 109 if (isEnabled != wasEnabled) { |
| 110 Log.d(TAG, "WebApk setting changed (%s => %s)", wasEnabled, isEnable
d); | 110 Log.d(TAG, "WebApk setting changed (%s => %s)", wasEnabled, isEnable
d); |
| 111 preferenceManager.setCachedWebApkRuntimeEnabled(isEnabled); | 111 preferenceManager.setCachedWebApkRuntimeEnabled(isEnabled); |
| 112 } | 112 } |
| 113 } | 113 } |
| 114 | 114 |
| 115 /** Returns whether the --enable-webapk command line flag is set */ | 115 /** Returns whether the --enable-improved-a2hs command line flag is set */ |
| 116 private static boolean isCommandLineFlagSet() { | 116 private static boolean isCommandLineFlagSet() { |
| 117 return CommandLine.getInstance().hasSwitch(ChromeSwitches.ENABLE_WEBAPK)
; | 117 return CommandLine.getInstance().hasSwitch(ChromeSwitches.ENABLE_WEBAPK)
; |
| 118 } | 118 } |
| 119 | 119 |
| 120 /** Returns whether we should enable WebAPKs */ | 120 /** Returns whether we should enable WebAPKs */ |
| 121 private static boolean computeEnabled() { | 121 private static boolean computeEnabled() { |
| 122 return isCommandLineFlagSet() && ChromeFeatureList.isEnabled(ChromeFeatu
reList.WEBAPKS); | 122 return isCommandLineFlagSet() && ChromeFeatureList.isEnabled(ChromeFeatu
reList.WEBAPKS); |
| 123 } | 123 } |
| 124 | 124 |
| 125 /** | 125 /** |
| (...skipping 28 matching lines...) Expand all Loading... |
| 154 } | 154 } |
| 155 }); | 155 }); |
| 156 builder.setNegativeButton(android.R.string.cancel, new DialogInterface.O
nClickListener() { | 156 builder.setNegativeButton(android.R.string.cancel, new DialogInterface.O
nClickListener() { |
| 157 @Override | 157 @Override |
| 158 public void onClick(DialogInterface dialog, int id) {} | 158 public void onClick(DialogInterface dialog, int id) {} |
| 159 }); | 159 }); |
| 160 AlertDialog dialog = builder.create(); | 160 AlertDialog dialog = builder.create(); |
| 161 dialog.show(); | 161 dialog.show(); |
| 162 } | 162 } |
| 163 } | 163 } |
| OLD | NEW |