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

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/preferences/website/SiteSettingsCategory.java

Issue 2159533002: Add a section to Site Settings listing USB devices. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@android_usb_settings
Patch Set: Iterate ArrayLists by index. Created 4 years, 4 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 unified diff | Download patch
OLDNEW
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 27 matching lines...) Expand all
38 public static final String CATEGORY_CAMERA = "camera"; 38 public static final String CATEGORY_CAMERA = "camera";
39 public static final String CATEGORY_COOKIES = "cookies"; 39 public static final String CATEGORY_COOKIES = "cookies";
40 public static final String CATEGORY_DEVICE_LOCATION = "device_location"; 40 public static final String CATEGORY_DEVICE_LOCATION = "device_location";
41 public static final String CATEGORY_FULLSCREEN = "fullscreen"; 41 public static final String CATEGORY_FULLSCREEN = "fullscreen";
42 public static final String CATEGORY_JAVASCRIPT = "javascript"; 42 public static final String CATEGORY_JAVASCRIPT = "javascript";
43 public static final String CATEGORY_MICROPHONE = "microphone"; 43 public static final String CATEGORY_MICROPHONE = "microphone";
44 public static final String CATEGORY_NOTIFICATIONS = "notifications"; 44 public static final String CATEGORY_NOTIFICATIONS = "notifications";
45 public static final String CATEGORY_POPUPS = "popups"; 45 public static final String CATEGORY_POPUPS = "popups";
46 public static final String CATEGORY_PROTECTED_MEDIA = "protected_content"; 46 public static final String CATEGORY_PROTECTED_MEDIA = "protected_content";
47 public static final String CATEGORY_USE_STORAGE = "use_storage"; 47 public static final String CATEGORY_USE_STORAGE = "use_storage";
48 public static final String CATEGORY_USB = "usb";
48 49
49 // The id of this category. 50 // The id of this category.
50 private String mCategory; 51 private String mCategory;
51 52
52 // The id of a permission in Android M that governs this category. Can be bl ank if Android has 53 // The id of a permission in Android M that governs this category. Can be bl ank if Android has
53 // no equivalent permission for the category. 54 // no equivalent permission for the category.
54 private String mAndroidPermission; 55 private String mAndroidPermission;
55 56
56 // The content settings type that this category represents. Can be -1 if the category has no 57 // The content settings type that this category represents. Can be -1 if the category has no
57 // content settings type (such as All Sites). 58 // content settings type (such as All Sites).
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 return new SiteSettingsCategory(CATEGORY_POPUPS, "", 125 return new SiteSettingsCategory(CATEGORY_POPUPS, "",
125 ContentSettingsType.CONTENT_SETTINGS_TYPE_POPUPS); 126 ContentSettingsType.CONTENT_SETTINGS_TYPE_POPUPS);
126 } 127 }
127 if (CATEGORY_PROTECTED_MEDIA.equals(category)) { 128 if (CATEGORY_PROTECTED_MEDIA.equals(category)) {
128 return new SiteSettingsCategory(CATEGORY_PROTECTED_MEDIA, "", 129 return new SiteSettingsCategory(CATEGORY_PROTECTED_MEDIA, "",
129 ContentSettingsType.CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_ID ENTIFIER); 130 ContentSettingsType.CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_ID ENTIFIER);
130 } 131 }
131 if (CATEGORY_USE_STORAGE.equals(category)) { 132 if (CATEGORY_USE_STORAGE.equals(category)) {
132 return new SiteSettingsCategory(CATEGORY_USE_STORAGE, "", -1); 133 return new SiteSettingsCategory(CATEGORY_USE_STORAGE, "", -1);
133 } 134 }
135 if (CATEGORY_USB.equals(category)) {
136 return new SiteSettingsCategory(
137 CATEGORY_USB, "", ContentSettingsType.CONTENT_SETTINGS_TYPE_ USB_CHOOSER_DATA);
138 }
134 139
135 return null; 140 return null;
136 } 141 }
137 142
138 /** 143 /**
139 * Construct a SiteSettingsCategory from a content settings type. Note that not all categories 144 * Construct a SiteSettingsCategory from a content settings type. Note that not all categories
140 * are associated with a content settings type (e.g. All Sites). Such catego ries must be created 145 * are associated with a content settings type (e.g. All Sites). Such catego ries must be created
141 * fromString(). 146 * fromString().
142 */ 147 */
143 public static SiteSettingsCategory fromContentSettingsType(int contentSettin gsType) { 148 public static SiteSettingsCategory fromContentSettingsType(int contentSettin gsType) {
(...skipping 24 matching lines...) Expand all
168 if (contentSettingsType == ContentSettingsType.CONTENT_SETTINGS_TYPE_NOT IFICATIONS) { 173 if (contentSettingsType == ContentSettingsType.CONTENT_SETTINGS_TYPE_NOT IFICATIONS) {
169 return fromString(CATEGORY_NOTIFICATIONS); 174 return fromString(CATEGORY_NOTIFICATIONS);
170 } 175 }
171 if (contentSettingsType == ContentSettingsType.CONTENT_SETTINGS_TYPE_POP UPS) { 176 if (contentSettingsType == ContentSettingsType.CONTENT_SETTINGS_TYPE_POP UPS) {
172 return fromString(CATEGORY_POPUPS); 177 return fromString(CATEGORY_POPUPS);
173 } 178 }
174 if (contentSettingsType 179 if (contentSettingsType
175 == ContentSettingsType.CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDE NTIFIER) { 180 == ContentSettingsType.CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDE NTIFIER) {
176 return fromString(CATEGORY_PROTECTED_MEDIA); 181 return fromString(CATEGORY_PROTECTED_MEDIA);
177 } 182 }
183 if (contentSettingsType == ContentSettingsType.CONTENT_SETTINGS_TYPE_USB _CHOOSER_DATA) {
184 return fromString(CATEGORY_USB);
185 }
178 186
179 return null; 187 return null;
180 } 188 }
181 189
182 /** 190 /**
183 * Returns the content settings type for this category, or -1 if no such typ e exists. 191 * Returns the content settings type for this category, or -1 if no such typ e exists.
184 */ 192 */
185 public int toContentSettingsType() { 193 public int toContentSettingsType() {
186 return mContentSettingsType; 194 return mContentSettingsType;
187 } 195 }
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 } 282 }
275 283
276 /** 284 /**
277 * Returns whether this category is the Storage category. 285 * Returns whether this category is the Storage category.
278 */ 286 */
279 public boolean showStorageSites() { 287 public boolean showStorageSites() {
280 return CATEGORY_USE_STORAGE.equals(mCategory); 288 return CATEGORY_USE_STORAGE.equals(mCategory);
281 } 289 }
282 290
283 /** 291 /**
292 * Returns whether this category is the USB category.
293 */
294 public boolean showUsbDevices() {
295 return mContentSettingsType == ContentSettingsType.CONTENT_SETTINGS_TYPE _USB_CHOOSER_DATA;
296 }
297
298 /**
284 * Returns whether the current category is managed either by enterprise poli cy or by the 299 * Returns whether the current category is managed either by enterprise poli cy or by the
285 * custodian of a supervised account. 300 * custodian of a supervised account.
286 */ 301 */
287 public boolean isManaged() { 302 public boolean isManaged() {
288 PrefServiceBridge prefs = PrefServiceBridge.getInstance(); 303 PrefServiceBridge prefs = PrefServiceBridge.getInstance();
289 if (showBackgroundSyncSites()) return prefs.isBackgroundSyncManaged(); 304 if (showBackgroundSyncSites()) return prefs.isBackgroundSyncManaged();
290 if (showCameraSites()) return !prefs.isCameraUserModifiable(); 305 if (showCameraSites()) return !prefs.isCameraUserModifiable();
291 if (showCookiesSites()) return prefs.isAcceptCookiesManaged(); 306 if (showCookiesSites()) return prefs.isAcceptCookiesManaged();
292 if (showFullscreenSites()) return prefs.isFullscreenManaged(); 307 if (showFullscreenSites()) return prefs.isFullscreenManaged();
293 if (showGeolocationSites()) { 308 if (showGeolocationSites()) {
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
467 * Returns whether a per-app permission is enabled. 482 * Returns whether a per-app permission is enabled.
468 * @param permission The string of the permission to check. 483 * @param permission The string of the permission to check.
469 */ 484 */
470 private boolean permissionOnInAndroid(String permission, Context context) { 485 private boolean permissionOnInAndroid(String permission, Context context) {
471 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) return true; 486 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) return true;
472 487
473 return PackageManager.PERMISSION_GRANTED == context.getPackageManager(). checkPermission( 488 return PackageManager.PERMISSION_GRANTED == context.getPackageManager(). checkPermission(
474 permission, context.getPackageName()); 489 permission, context.getPackageName());
475 } 490 }
476 } 491 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698