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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkUpdateManager.java

Issue 2496443002: Disable WebAPK updates when "installation from unknown sources" is disabled (Closed)
Patch Set: Merge branch 'master' into disable_update_unsigned_sources Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/android/junit/src/org/chromium/chrome/browser/webapps/WebApkUpdateManagerTest.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkUpdateManager.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkUpdateManager.java b/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkUpdateManager.java
index 0bc8a7673f500be9a8882cbfc7c1161a52bbe2ba..e1f967c538f5aad50bb636073ed8e02e6f384e44 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkUpdateManager.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/webapps/WebApkUpdateManager.java
@@ -4,9 +4,11 @@
package org.chromium.chrome.browser.webapps;
+import android.content.ContentResolver;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
+import android.provider.Settings;
import org.chromium.base.CommandLine;
import org.chromium.base.ContextUtils;
@@ -224,6 +226,14 @@ public class WebApkUpdateManager implements ManifestUpgradeDetector.Callback {
*/
private boolean shouldCheckIfWebManifestUpdated(
WebappDataStorage storage, WebApkMetaData metaData, boolean previousUpdateSucceeded) {
+ // Updating WebAPKs 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).
+ if (!installingFromUnknownSourcesAllowed()) {
+ return false;
+ }
+
if (CommandLine.getInstance().hasSwitch(
ChromeSwitches.CHECK_FOR_WEB_MANIFEST_UPDATE_ON_STARTUP)) {
return true;
@@ -253,6 +263,21 @@ public class WebApkUpdateManager implements ManifestUpgradeDetector.Callback {
}
/**
+ * Returns whether the user has enabled installing apps from sources other than the Google
+ * Play Store.
+ */
+ private static boolean installingFromUnknownSourcesAllowed() {
+ ContentResolver contentResolver = ContextUtils.getApplicationContext().getContentResolver();
+ try {
+ int setting = Settings.Secure.getInt(
+ contentResolver, Settings.Secure.INSTALL_NON_MARKET_APPS);
+ return setting == 1;
+ } catch (Settings.SettingNotFoundException e) {
+ return false;
+ }
+ }
+
+ /**
* Called after either a request to update the WebAPK has been sent or the update process
* fails.
*/
« no previous file with comments | « no previous file | chrome/android/junit/src/org/chromium/chrome/browser/webapps/WebApkUpdateManagerTest.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698