Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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.preferences.website; | 5 package org.chromium.chrome.browser.preferences.website; |
| 6 | 6 |
| 7 import android.app.Activity; | 7 import android.app.Activity; |
| 8 import android.content.Context; | 8 import android.content.Context; |
| 9 import android.content.Intent; | 9 import android.content.Intent; |
| 10 import android.content.pm.PackageManager; | 10 import android.content.pm.PackageManager; |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 31 * A base class for dealing with website settings categories. | 31 * A base class for dealing with website settings categories. |
| 32 */ | 32 */ |
| 33 public class SiteSettingsCategory { | 33 public class SiteSettingsCategory { |
| 34 // Valid values for passing to fromString() in this class. | 34 // Valid values for passing to fromString() in this class. |
| 35 public static final String CATEGORY_ALL_SITES = "all_sites"; | 35 public static final String CATEGORY_ALL_SITES = "all_sites"; |
| 36 public static final String CATEGORY_CAMERA = "camera"; | 36 public static final String CATEGORY_CAMERA = "camera"; |
| 37 public static final String CATEGORY_COOKIES = "cookies"; | 37 public static final String CATEGORY_COOKIES = "cookies"; |
| 38 public static final String CATEGORY_DEVICE_LOCATION = "device_location"; | 38 public static final String CATEGORY_DEVICE_LOCATION = "device_location"; |
| 39 public static final String CATEGORY_FULLSCREEN = "fullscreen"; | 39 public static final String CATEGORY_FULLSCREEN = "fullscreen"; |
| 40 public static final String CATEGORY_JAVASCRIPT = "javascript"; | 40 public static final String CATEGORY_JAVASCRIPT = "javascript"; |
| 41 public static final String CATEGORY_KEYGEN = "keygen"; | |
| 41 public static final String CATEGORY_MICROPHONE = "microphone"; | 42 public static final String CATEGORY_MICROPHONE = "microphone"; |
| 42 public static final String CATEGORY_POPUPS = "popups"; | 43 public static final String CATEGORY_POPUPS = "popups"; |
| 43 public static final String CATEGORY_PROTECTED_MEDIA = "protected_content"; | 44 public static final String CATEGORY_PROTECTED_MEDIA = "protected_content"; |
| 44 public static final String CATEGORY_NOTIFICATIONS = "notifications"; | 45 public static final String CATEGORY_NOTIFICATIONS = "notifications"; |
| 45 public static final String CATEGORY_USE_STORAGE = "use_storage"; | 46 public static final String CATEGORY_USE_STORAGE = "use_storage"; |
| 46 | 47 |
| 47 // The id of this category. | 48 // The id of this category. |
| 48 private String mCategory; | 49 private String mCategory; |
| 49 | 50 |
| 50 // The id of a permission in Android M that governs this category. Can be bl ank if Android has | 51 // The id of a permission in Android M that governs this category. Can be bl ank if Android has |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 86 ContentSettingsType.CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA ); | 87 ContentSettingsType.CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA ); |
| 87 } | 88 } |
| 88 if (CATEGORY_COOKIES.equals(category)) { | 89 if (CATEGORY_COOKIES.equals(category)) { |
| 89 return new SiteSettingsCategory(CATEGORY_COOKIES, "", | 90 return new SiteSettingsCategory(CATEGORY_COOKIES, "", |
| 90 ContentSettingsType.CONTENT_SETTINGS_TYPE_COOKIES); | 91 ContentSettingsType.CONTENT_SETTINGS_TYPE_COOKIES); |
| 91 } | 92 } |
| 92 if (CATEGORY_JAVASCRIPT.equals(category)) { | 93 if (CATEGORY_JAVASCRIPT.equals(category)) { |
| 93 return new SiteSettingsCategory(CATEGORY_JAVASCRIPT, "", | 94 return new SiteSettingsCategory(CATEGORY_JAVASCRIPT, "", |
| 94 ContentSettingsType.CONTENT_SETTINGS_TYPE_JAVASCRIPT); | 95 ContentSettingsType.CONTENT_SETTINGS_TYPE_JAVASCRIPT); |
| 95 } | 96 } |
| 97 if (CATEGORY_KEYGEN.equals(category)) { | |
| 98 return new SiteSettingsCategory(CATEGORY_KEYGEN, "", | |
| 99 ContentSettingsType.CONTENT_SETTINGS_TYPE_KEYGEN); | |
| 100 } | |
| 96 if (CATEGORY_DEVICE_LOCATION.equals(category)) { | 101 if (CATEGORY_DEVICE_LOCATION.equals(category)) { |
| 97 return new LocationCategory(); | 102 return new LocationCategory(); |
| 98 } | 103 } |
| 99 if (CATEGORY_FULLSCREEN.equals(category)) { | 104 if (CATEGORY_FULLSCREEN.equals(category)) { |
| 100 return new SiteSettingsCategory(CATEGORY_FULLSCREEN, "", | 105 return new SiteSettingsCategory(CATEGORY_FULLSCREEN, "", |
| 101 ContentSettingsType.CONTENT_SETTINGS_TYPE_FULLSCREEN); | 106 ContentSettingsType.CONTENT_SETTINGS_TYPE_FULLSCREEN); |
| 102 } | 107 } |
| 103 if (CATEGORY_MICROPHONE.equals(category)) { | 108 if (CATEGORY_MICROPHONE.equals(category)) { |
| 104 return new SiteSettingsCategory( | 109 return new SiteSettingsCategory( |
| 105 SiteSettingsCategory.CATEGORY_MICROPHONE, | 110 SiteSettingsCategory.CATEGORY_MICROPHONE, |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 133 public static SiteSettingsCategory fromContentSettingsType(int contentSettin gsType) { | 138 public static SiteSettingsCategory fromContentSettingsType(int contentSettin gsType) { |
| 134 if (contentSettingsType == ContentSettingsType.CONTENT_SETTINGS_TYPE_MED IASTREAM_CAMERA) { | 139 if (contentSettingsType == ContentSettingsType.CONTENT_SETTINGS_TYPE_MED IASTREAM_CAMERA) { |
| 135 return fromString(CATEGORY_CAMERA); | 140 return fromString(CATEGORY_CAMERA); |
| 136 } | 141 } |
| 137 if (contentSettingsType == ContentSettingsType.CONTENT_SETTINGS_TYPE_COO KIES) { | 142 if (contentSettingsType == ContentSettingsType.CONTENT_SETTINGS_TYPE_COO KIES) { |
| 138 return fromString(CATEGORY_COOKIES); | 143 return fromString(CATEGORY_COOKIES); |
| 139 } | 144 } |
| 140 if (contentSettingsType == ContentSettingsType.CONTENT_SETTINGS_TYPE_JAV ASCRIPT) { | 145 if (contentSettingsType == ContentSettingsType.CONTENT_SETTINGS_TYPE_JAV ASCRIPT) { |
| 141 return fromString(CATEGORY_JAVASCRIPT); | 146 return fromString(CATEGORY_JAVASCRIPT); |
| 142 } | 147 } |
| 148 if (contentSettingsType == ContentSettingsType.CONTENT_SETTINGS_TYPE_KEY GEN) { | |
| 149 return fromString(CATEGORY_KEYGEN); | |
| 150 } | |
| 143 if (contentSettingsType == ContentSettingsType.CONTENT_SETTINGS_TYPE_GEO LOCATION) { | 151 if (contentSettingsType == ContentSettingsType.CONTENT_SETTINGS_TYPE_GEO LOCATION) { |
| 144 return fromString(CATEGORY_DEVICE_LOCATION); | 152 return fromString(CATEGORY_DEVICE_LOCATION); |
| 145 } | 153 } |
| 146 if (contentSettingsType == ContentSettingsType.CONTENT_SETTINGS_TYPE_FUL LSCREEN) { | 154 if (contentSettingsType == ContentSettingsType.CONTENT_SETTINGS_TYPE_FUL LSCREEN) { |
| 147 return fromString(CATEGORY_FULLSCREEN); | 155 return fromString(CATEGORY_FULLSCREEN); |
| 148 } | 156 } |
| 149 if (contentSettingsType == ContentSettingsType.CONTENT_SETTINGS_TYPE_MED IASTREAM_MIC) { | 157 if (contentSettingsType == ContentSettingsType.CONTENT_SETTINGS_TYPE_MED IASTREAM_MIC) { |
| 150 return fromString(CATEGORY_MICROPHONE); | 158 return fromString(CATEGORY_MICROPHONE); |
| 151 } | 159 } |
| 152 if (contentSettingsType == ContentSettingsType.CONTENT_SETTINGS_TYPE_POP UPS) { | 160 if (contentSettingsType == ContentSettingsType.CONTENT_SETTINGS_TYPE_POP UPS) { |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 207 } | 215 } |
| 208 | 216 |
| 209 /** | 217 /** |
| 210 * Returns whether this category is the JavaScript category. | 218 * Returns whether this category is the JavaScript category. |
| 211 */ | 219 */ |
| 212 public boolean showJavaScriptSites() { | 220 public boolean showJavaScriptSites() { |
| 213 return mContentSettingsType == ContentSettingsType.CONTENT_SETTINGS_TYPE _JAVASCRIPT; | 221 return mContentSettingsType == ContentSettingsType.CONTENT_SETTINGS_TYPE _JAVASCRIPT; |
| 214 } | 222 } |
| 215 | 223 |
| 216 /** | 224 /** |
| 225 * Returns whether this category is the Keygen category. | |
| 226 */ | |
| 227 public boolean showKeygenSites() { | |
| 228 return mContentSettingsType == ContentSettingsType.CONTENT_SETTINGS_TYPE _KEYGEN; | |
| 229 } | |
| 230 | |
| 231 /** | |
| 217 * Returns whether this category is the Microphone category. | 232 * Returns whether this category is the Microphone category. |
| 218 */ | 233 */ |
| 219 public boolean showMicrophoneSites() { | 234 public boolean showMicrophoneSites() { |
| 220 return mContentSettingsType == ContentSettingsType.CONTENT_SETTINGS_TYPE _MEDIASTREAM_MIC; | 235 return mContentSettingsType == ContentSettingsType.CONTENT_SETTINGS_TYPE _MEDIASTREAM_MIC; |
| 221 } | 236 } |
| 222 | 237 |
| 223 /** | 238 /** |
| 224 * Returns whether this category is the Popup category. | 239 * Returns whether this category is the Popup category. |
| 225 */ | 240 */ |
| 226 public boolean showPopupSites() { | 241 public boolean showPopupSites() { |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 256 */ | 271 */ |
| 257 public boolean isManaged() { | 272 public boolean isManaged() { |
| 258 PrefServiceBridge prefs = PrefServiceBridge.getInstance(); | 273 PrefServiceBridge prefs = PrefServiceBridge.getInstance(); |
| 259 if (showCameraSites()) return !prefs.isCameraUserModifiable(); | 274 if (showCameraSites()) return !prefs.isCameraUserModifiable(); |
| 260 if (showCookiesSites()) return prefs.isAcceptCookiesManaged(); | 275 if (showCookiesSites()) return prefs.isAcceptCookiesManaged(); |
| 261 if (showFullscreenSites()) return prefs.isFullscreenManaged(); | 276 if (showFullscreenSites()) return prefs.isFullscreenManaged(); |
| 262 if (showGeolocationSites()) { | 277 if (showGeolocationSites()) { |
| 263 return !prefs.isAllowLocationUserModifiable(); | 278 return !prefs.isAllowLocationUserModifiable(); |
| 264 } | 279 } |
| 265 if (showJavaScriptSites()) return prefs.javaScriptManaged(); | 280 if (showJavaScriptSites()) return prefs.javaScriptManaged(); |
| 281 if (showKeygenSites()) return prefs.keygenManaged(); | |
|
Finnur
2015/11/05 20:44:41
I don't think you need any of these changes if you
svaldez
2015/11/10 15:25:02
Done.
| |
| 266 if (showMicrophoneSites()) return !prefs.isMicUserModifiable(); | 282 if (showMicrophoneSites()) return !prefs.isMicUserModifiable(); |
| 267 if (showPopupSites()) return prefs.isPopupsManaged(); | 283 if (showPopupSites()) return prefs.isPopupsManaged(); |
| 268 return false; | 284 return false; |
| 269 } | 285 } |
| 270 | 286 |
| 271 /** | 287 /** |
| 272 * Returns whether the current category is managed by the custodian (e.g. pa rent, not an | 288 * Returns whether the current category is managed by the custodian (e.g. pa rent, not an |
| 273 * enterprise admin) of the account if the account is supervised. | 289 * enterprise admin) of the account if the account is supervised. |
| 274 */ | 290 */ |
| 275 public boolean isManagedByCustodian() { | 291 public boolean isManagedByCustodian() { |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 436 * Returns whether a per-app permission is enabled. | 452 * Returns whether a per-app permission is enabled. |
| 437 * @param permission The string of the permission to check. | 453 * @param permission The string of the permission to check. |
| 438 */ | 454 */ |
| 439 private boolean permissionOnInAndroid(String permission, Context context) { | 455 private boolean permissionOnInAndroid(String permission, Context context) { |
| 440 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) return true; | 456 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) return true; |
| 441 | 457 |
| 442 return PackageManager.PERMISSION_GRANTED == context.getPackageManager(). checkPermission( | 458 return PackageManager.PERMISSION_GRANTED == context.getPackageManager(). checkPermission( |
| 443 permission, context.getPackageName()); | 459 permission, context.getPackageName()); |
| 444 } | 460 } |
| 445 } | 461 } |
| OLD | NEW |