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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/preferences/PrefServiceBridge.java

Issue 2682863002: [Android] Explicitly request all needed runtime permissions. (Closed)
Patch Set: Address mlamouri@ comments Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: chrome/android/java/src/org/chromium/chrome/browser/preferences/PrefServiceBridge.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/preferences/PrefServiceBridge.java b/chrome/android/java/src/org/chromium/chrome/browser/preferences/PrefServiceBridge.java
index 1722110318785d5b1e5f1449c53de6ebeb81ac50..550bd341ed2bae1a48f5807cc2373e6b1818be80 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/preferences/PrefServiceBridge.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/preferences/PrefServiceBridge.java
@@ -37,6 +37,19 @@ public final class PrefServiceBridge {
private static final String MIGRATION_PREF_KEY = "PrefMigrationVersion";
private static final int MIGRATION_CURRENT_VERSION = 4;
+ /** The android permissions associated with requesting location. */
+ public static final String[] LOCATION_PERMISSIONS = {
+ android.Manifest.permission.ACCESS_FINE_LOCATION,
+ android.Manifest.permission.ACCESS_COARSE_LOCATION
+ };
+ /** The android permissions associated with requesting access to the camera. */
+ public static final String[] CAMERA_PERMISSIONS = {android.Manifest.permission.CAMERA};
+ /** The android permissions associated with requesting access to the microphone. */
+ public static final String[] MICROPHONE_PERMISSIONS =
+ {android.Manifest.permission.RECORD_AUDIO};
+ /** Signifies there are no permissions associated. */
+ public static final String[] EMPTY_PERMISSIONS = {};
+
private static final String HTTPS_SCHEME = "https";
// Object to notify when "clear browsing data" completes.
@@ -236,24 +249,24 @@ public final class PrefServiceBridge {
}
/**
- * Return the android permission string for a given {@link ContentSettingsType}. If there
- * is no corresponding permission, then null will be returned.
+ * Return the list of android permission strings for a given {@link ContentSettingsType}. If
+ * there is no permissions associated with the content setting, then an empty array is returned.
*
* @param contentSettingType The content setting to get the android permission for.
- * @return The android permission for the given content setting.
+ * @return The android permissions for the given content setting.
*/
@CalledByNative
- public static String getAndroidPermissionForContentSetting(int contentSettingType) {
+ public static String[] getAndroidPermissionsForContentSetting(int contentSettingType) {
if (contentSettingType == ContentSettingsType.CONTENT_SETTINGS_TYPE_GEOLOCATION) {
- return android.Manifest.permission.ACCESS_FINE_LOCATION;
+ return LOCATION_PERMISSIONS;
}
if (contentSettingType == ContentSettingsType.CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC) {
- return android.Manifest.permission.RECORD_AUDIO;
+ return MICROPHONE_PERMISSIONS;
}
if (contentSettingType == ContentSettingsType.CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA) {
- return android.Manifest.permission.CAMERA;
+ return CAMERA_PERMISSIONS;
}
- return null;
+ return EMPTY_PERMISSIONS;
}
/**

Powered by Google App Engine
This is Rietveld 408576698