OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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; | 5 package org.chromium.chrome.browser.preferences; |
6 | 6 |
7 import android.content.Context; | 7 import android.content.Context; |
8 import android.content.SharedPreferences; | 8 import android.content.SharedPreferences; |
9 import android.util.Log; | 9 import android.util.Log; |
10 | 10 |
11 import org.chromium.base.ContextUtils; | 11 import org.chromium.base.ContextUtils; |
12 import org.chromium.base.ThreadUtils; | 12 import org.chromium.base.ThreadUtils; |
13 import org.chromium.base.VisibleForTesting; | 13 import org.chromium.base.VisibleForTesting; |
14 import org.chromium.base.annotations.CalledByNative; | 14 import org.chromium.base.annotations.CalledByNative; |
15 import org.chromium.chrome.browser.ContentSettingsType; | 15 import org.chromium.chrome.browser.ContentSettingsType; |
16 import org.chromium.chrome.browser.preferences.website.ContentSetting; | 16 import org.chromium.chrome.browser.preferences.website.ContentSetting; |
17 import org.chromium.chrome.browser.preferences.website.ContentSettingException; | 17 import org.chromium.chrome.browser.preferences.website.ContentSettingException; |
18 import org.chromium.chrome.browser.preferences.website.GeolocationInfo; | 18 import org.chromium.chrome.browser.preferences.website.GeolocationInfo; |
19 import org.chromium.chrome.browser.preferences.website.WebsitePreferenceBridge; | 19 import org.chromium.chrome.browser.preferences.website.WebsitePreferenceBridge; |
20 import org.chromium.chrome.browser.search_engines.TemplateUrlService; | 20 import org.chromium.chrome.browser.search_engines.TemplateUrlService; |
21 | 21 |
22 import java.util.ArrayList; | 22 import java.util.ArrayList; |
| 23 import java.util.Arrays; |
23 import java.util.List; | 24 import java.util.List; |
24 | 25 |
25 /** | 26 /** |
26 * PrefServiceBridge is a singleton which provides access to some native prefere
nces. Ideally | 27 * PrefServiceBridge is a singleton which provides access to some native prefere
nces. Ideally |
27 * preferences should be grouped with their relevant functionality but this is a
grab-bag for other | 28 * preferences should be grouped with their relevant functionality but this is a
grab-bag for other |
28 * preferences. | 29 * preferences. |
29 */ | 30 */ |
30 public final class PrefServiceBridge { | 31 public final class PrefServiceBridge { |
31 // These values must match the native enum values in | 32 // These values must match the native enum values in |
32 // SupervisedUserURLFilter::FilteringBehavior | 33 // SupervisedUserURLFilter::FilteringBehavior |
33 public static final int SUPERVISED_USER_FILTERING_ALLOW = 0; | 34 public static final int SUPERVISED_USER_FILTERING_ALLOW = 0; |
34 public static final int SUPERVISED_USER_FILTERING_WARN = 1; | 35 public static final int SUPERVISED_USER_FILTERING_WARN = 1; |
35 public static final int SUPERVISED_USER_FILTERING_BLOCK = 2; | 36 public static final int SUPERVISED_USER_FILTERING_BLOCK = 2; |
36 | 37 |
37 private static final String MIGRATION_PREF_KEY = "PrefMigrationVersion"; | 38 private static final String MIGRATION_PREF_KEY = "PrefMigrationVersion"; |
38 private static final int MIGRATION_CURRENT_VERSION = 4; | 39 private static final int MIGRATION_CURRENT_VERSION = 4; |
39 | 40 |
40 private static final String HTTPS_SCHEME = "https"; | 41 /** The android permissions associated with requesting location. */ |
| 42 private static final String[] LOCATION_PERMISSIONS = { |
| 43 android.Manifest.permission.ACCESS_FINE_LOCATION, |
| 44 android.Manifest.permission.ACCESS_COARSE_LOCATION}; |
| 45 /** The android permissions associated with requesting access to the camera.
*/ |
| 46 private static final String[] CAMERA_PERMISSIONS = {android.Manifest.permiss
ion.CAMERA}; |
| 47 /** The android permissions associated with requesting access to the microph
one. */ |
| 48 private static final String[] MICROPHONE_PERMISSIONS = { |
| 49 android.Manifest.permission.RECORD_AUDIO}; |
| 50 /** Signifies there are no permissions associated. */ |
| 51 private static final String[] EMPTY_PERMISSIONS = {}; |
41 | 52 |
42 // Object to notify when "clear browsing data" completes. | 53 // Object to notify when "clear browsing data" completes. |
43 private OnClearBrowsingDataListener mClearBrowsingDataListener; | 54 private OnClearBrowsingDataListener mClearBrowsingDataListener; |
44 private static final String LOG_TAG = "PrefServiceBridge"; | 55 private static final String LOG_TAG = "PrefServiceBridge"; |
45 | 56 |
46 // Constants related to the Contextual Search preference. | 57 // Constants related to the Contextual Search preference. |
47 private static final String CONTEXTUAL_SEARCH_DISABLED = "false"; | 58 private static final String CONTEXTUAL_SEARCH_DISABLED = "false"; |
48 private static final String CONTEXTUAL_SEARCH_ENABLED = "true"; | 59 private static final String CONTEXTUAL_SEARCH_ENABLED = "true"; |
49 | 60 |
50 // The key to store whether the Location Permission was automatically added
for the search | 61 // The key to store whether the Location Permission was automatically added
for the search |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 int contentSettingsType, | 242 int contentSettingsType, |
232 String pattern, | 243 String pattern, |
233 int contentSetting, | 244 int contentSetting, |
234 String source) { | 245 String source) { |
235 ContentSettingException exception = new ContentSettingException( | 246 ContentSettingException exception = new ContentSettingException( |
236 contentSettingsType, pattern, ContentSetting.fromInt(contentSett
ing), source); | 247 contentSettingsType, pattern, ContentSetting.fromInt(contentSett
ing), source); |
237 list.add(exception); | 248 list.add(exception); |
238 } | 249 } |
239 | 250 |
240 /** | 251 /** |
241 * Return the android permission string for a given {@link ContentSettingsTy
pe}. If there | 252 * Return the list of android permission strings for a given {@link ContentS
ettingsType}. If |
242 * is no corresponding permission, then null will be returned. | 253 * there is no permissions associated with the content setting, then an empt
y array is returned. |
243 * | 254 * |
244 * @param contentSettingType The content setting to get the android permissi
on for. | 255 * @param contentSettingType The content setting to get the android permissi
on for. |
245 * @return The android permission for the given content setting. | 256 * @return The android permissions for the given content setting. |
246 */ | 257 */ |
247 @CalledByNative | 258 @CalledByNative |
248 public static String getAndroidPermissionForContentSetting(int contentSettin
gType) { | 259 public static String[] getAndroidPermissionsForContentSetting(int contentSet
tingType) { |
249 if (contentSettingType == ContentSettingsType.CONTENT_SETTINGS_TYPE_GEOL
OCATION) { | 260 if (contentSettingType == ContentSettingsType.CONTENT_SETTINGS_TYPE_GEOL
OCATION) { |
250 return android.Manifest.permission.ACCESS_FINE_LOCATION; | 261 return Arrays.copyOf(LOCATION_PERMISSIONS, LOCATION_PERMISSIONS.leng
th); |
251 } | 262 } |
252 if (contentSettingType == ContentSettingsType.CONTENT_SETTINGS_TYPE_MEDI
ASTREAM_MIC) { | 263 if (contentSettingType == ContentSettingsType.CONTENT_SETTINGS_TYPE_MEDI
ASTREAM_MIC) { |
253 return android.Manifest.permission.RECORD_AUDIO; | 264 return Arrays.copyOf(MICROPHONE_PERMISSIONS, MICROPHONE_PERMISSIONS.
length); |
254 } | 265 } |
255 if (contentSettingType == ContentSettingsType.CONTENT_SETTINGS_TYPE_MEDI
ASTREAM_CAMERA) { | 266 if (contentSettingType == ContentSettingsType.CONTENT_SETTINGS_TYPE_MEDI
ASTREAM_CAMERA) { |
256 return android.Manifest.permission.CAMERA; | 267 return Arrays.copyOf(CAMERA_PERMISSIONS, CAMERA_PERMISSIONS.length); |
257 } | 268 } |
258 return null; | 269 return EMPTY_PERMISSIONS; |
259 } | 270 } |
260 | 271 |
261 /** | 272 /** |
262 * @return Whether autoplay is enabled. | 273 * @return Whether autoplay is enabled. |
263 */ | 274 */ |
264 public boolean isAutoplayEnabled() { | 275 public boolean isAutoplayEnabled() { |
265 return nativeGetAutoplayEnabled(); | 276 return nativeGetAutoplayEnabled(); |
266 } | 277 } |
267 | 278 |
268 public boolean isAcceptCookiesEnabled() { | 279 public boolean isAcceptCookiesEnabled() { |
(...skipping 895 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1164 private native String nativeGetSupervisedUserSecondCustodianProfileImageURL(
); | 1175 private native String nativeGetSupervisedUserSecondCustodianProfileImageURL(
); |
1165 private native boolean nativeIsMetricsReportingEnabled(); | 1176 private native boolean nativeIsMetricsReportingEnabled(); |
1166 private native void nativeSetMetricsReportingEnabled(boolean enabled); | 1177 private native void nativeSetMetricsReportingEnabled(boolean enabled); |
1167 private native boolean nativeIsMetricsReportingManaged(); | 1178 private native boolean nativeIsMetricsReportingManaged(); |
1168 private native void nativeSetClickedUpdateMenuItem(boolean clicked); | 1179 private native void nativeSetClickedUpdateMenuItem(boolean clicked); |
1169 private native boolean nativeGetClickedUpdateMenuItem(); | 1180 private native boolean nativeGetClickedUpdateMenuItem(); |
1170 private native void nativeSetLatestVersionWhenClickedUpdateMenuItem(String v
ersion); | 1181 private native void nativeSetLatestVersionWhenClickedUpdateMenuItem(String v
ersion); |
1171 private native String nativeGetLatestVersionWhenClickedUpdateMenuItem(); | 1182 private native String nativeGetLatestVersionWhenClickedUpdateMenuItem(); |
1172 private native void nativeSetSupervisedUserId(String supervisedUserId); | 1183 private native void nativeSetSupervisedUserId(String supervisedUserId); |
1173 } | 1184 } |
OLD | NEW |