Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/webapps/ChromeWebApkHost.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/webapps/ChromeWebApkHost.java b/chrome/android/java/src/org/chromium/chrome/browser/webapps/ChromeWebApkHost.java |
| index 3ca4a81dc52613c0a44094481c4d388412375046..8a431adab26bc00b12517eaa5ebe317f07697c89 100644 |
| --- a/chrome/android/java/src/org/chromium/chrome/browser/webapps/ChromeWebApkHost.java |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/webapps/ChromeWebApkHost.java |
| @@ -4,9 +4,7 @@ |
| package org.chromium.chrome.browser.webapps; |
| -import android.content.Context; |
| import android.os.StrictMode; |
| -import android.provider.Settings; |
| import org.chromium.base.ContextUtils; |
| import org.chromium.base.Log; |
| @@ -37,6 +35,8 @@ public class ChromeWebApkHost { |
| public static void initForTesting(boolean enabled) { |
| sEnabledForTesting = enabled; |
| + sGooglePlayInstallState = enabled ? GooglePlayInstallState.SUPPORTED |
| + : GooglePlayInstallState.NO_PLAY_SERVICES; |
| } |
| public static boolean isEnabled() { |
| @@ -47,13 +47,7 @@ public class ChromeWebApkHost { |
| // Returns whether updating the WebAPK is enabled. |
| public static boolean areUpdatesEnabled() { |
|
pkotwicz
2017/04/04 19:06:07
For a follow up CL: We can make this function alwa
Yaron
2017/04/04 19:49:07
Acknowledged.
|
| - if (!isEnabled()) return false; |
| - |
| - // Updating a WebAPK without going through Google Play requires "installation from unknown |
| - // sources" to be enabled. It is confusing for a user to see a dialog asking them to enable |
| - // "installation from unknown sources" when they are in the middle of using the WebAPK (as |
| - // opposed to after requesting to add a WebAPK to the homescreen). |
| - return installingFromUnknownSourcesAllowed() || canUseGooglePlayToInstallWebApk(); |
| + return canInstallWebApk(); |
| } |
| /** Computes the GooglePlayInstallState. */ |
| @@ -74,22 +68,11 @@ public class ChromeWebApkHost { |
| } |
| /** |
| - * Returns whether installing WebAPKs from Google Play is possible. |
| - * If {@link sCanUseGooglePlayInstall} hasn't been set yet, it returns false immediately and |
| - * calls the Google Play Install API to update {@link sCanUseGooglePlayInstall} asynchronously. |
| - */ |
| - private static boolean canUseGooglePlayToInstallWebApk() { |
| - return getGooglePlayInstallState() == GooglePlayInstallState.SUPPORTED; |
| - } |
| - |
| - /** |
| - * Returns whether installing WebAPKs is possible either from "unknown resources" or Google |
| - * Play. |
| + * Returns whether installing WebAPKs is possible. |
|
pkotwicz
2017/04/04 19:06:07
Nit: You can make this comment one line now :)
Yaron
2017/04/04 19:49:07
Done.
|
| */ |
| @CalledByNative |
| private static boolean canInstallWebApk() { |
| - return isEnabled() |
| - && (canUseGooglePlayToInstallWebApk() || nativeCanInstallFromUnknownSources()); |
| + return isEnabled() && getGooglePlayInstallState() == GooglePlayInstallState.SUPPORTED; |
| } |
| @CalledByNative |
| @@ -136,21 +119,5 @@ public class ChromeWebApkHost { |
| } |
| } |
| - /** |
| - * Returns whether the user has enabled installing apps from sources other than the Google Play |
| - * Store. |
| - */ |
| - private static boolean installingFromUnknownSourcesAllowed() { |
| - Context applicationContext = ContextUtils.getApplicationContext(); |
| - try { |
| - return Settings.Secure.getInt(applicationContext.getContentResolver(), |
| - Settings.Secure.INSTALL_NON_MARKET_APPS) |
| - == 1; |
| - } catch (Settings.SettingNotFoundException e) { |
| - return false; |
| - } |
| - } |
| - |
| private static native boolean nativeCanLaunchRendererInWebApkProcess(); |
| - private static native boolean nativeCanInstallFromUnknownSources(); |
| } |