| 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 org.chromium.base.Callback; | 7 import org.chromium.base.Callback; |
| 8 import org.chromium.base.annotations.CalledByNative; | 8 import org.chromium.base.annotations.CalledByNative; |
| 9 import org.chromium.chrome.browser.preferences.PrefServiceBridge; | 9 import org.chromium.chrome.browser.preferences.PrefServiceBridge; |
| 10 import org.chromium.content_public.browser.WebContents; | |
| 11 | 10 |
| 12 import java.util.ArrayList; | 11 import java.util.ArrayList; |
| 13 import java.util.HashMap; | 12 import java.util.HashMap; |
| 14 import java.util.List; | 13 import java.util.List; |
| 15 | 14 |
| 16 /** | 15 /** |
| 17 * Utility class that interacts with native to retrieve and set website settings
. | 16 * Utility class that interacts with native to retrieve and set website settings
. |
| 18 */ | 17 */ |
| 19 public abstract class WebsitePreferenceBridge { | 18 public abstract class WebsitePreferenceBridge { |
| 20 private static final String LOG_TAG = "WebsiteSettingsUtils"; | 19 private static final String LOG_TAG = "WebsiteSettingsUtils"; |
| 21 | 20 |
| 22 /** | 21 /** |
| 23 * Interface for an object that listens to storage info is cleared callback. | 22 * Interface for an object that listens to storage info is cleared callback. |
| 24 */ | 23 */ |
| 25 public interface StorageInfoClearedCallback { | 24 public interface StorageInfoClearedCallback { |
| 26 @CalledByNative("StorageInfoClearedCallback") | 25 @CalledByNative("StorageInfoClearedCallback") |
| 27 public void onStorageInfoCleared(); | 26 public void onStorageInfoCleared(); |
| 28 } | 27 } |
| 29 | 28 |
| 30 /** | 29 /** |
| 31 * @return the list of all origins that have keygen permissions in non-incog
nito mode. | |
| 32 */ | |
| 33 @SuppressWarnings("unchecked") | |
| 34 public static List<KeygenInfo> getKeygenInfo() { | |
| 35 ArrayList<KeygenInfo> list = new ArrayList<KeygenInfo>(); | |
| 36 nativeGetKeygenOrigins(list); | |
| 37 return list; | |
| 38 } | |
| 39 | |
| 40 @CalledByNative | |
| 41 private static void insertKeygenInfoIntoList( | |
| 42 ArrayList<KeygenInfo> list, String origin, String embedder) { | |
| 43 list.add(new KeygenInfo(origin, embedder, false)); | |
| 44 } | |
| 45 | |
| 46 /** | |
| 47 * @return whether we've blocked key generation in the current tab. | |
| 48 */ | |
| 49 @SuppressWarnings("unchecked") | |
| 50 public static boolean getKeygenBlocked(WebContents webContents) { | |
| 51 return nativeGetKeygenBlocked(webContents); | |
| 52 } | |
| 53 | |
| 54 /** | |
| 55 * @return the list of all origins that have geolocation permissions in non-
incognito mode. | 30 * @return the list of all origins that have geolocation permissions in non-
incognito mode. |
| 56 */ | 31 */ |
| 57 @SuppressWarnings("unchecked") | 32 @SuppressWarnings("unchecked") |
| 58 public static List<GeolocationInfo> getGeolocationInfo() { | 33 public static List<GeolocationInfo> getGeolocationInfo() { |
| 59 // Location can be managed by the custodian of a supervised account or b
y enterprise policy. | 34 // Location can be managed by the custodian of a supervised account or b
y enterprise policy. |
| 60 boolean managedOnly = !PrefServiceBridge.getInstance().isAllowLocationUs
erModifiable(); | 35 boolean managedOnly = !PrefServiceBridge.getInstance().isAllowLocationUs
erModifiable(); |
| 61 ArrayList<GeolocationInfo> list = new ArrayList<GeolocationInfo>(); | 36 ArrayList<GeolocationInfo> list = new ArrayList<GeolocationInfo>(); |
| 62 nativeGetGeolocationOrigins(list, managedOnly); | 37 nativeGetGeolocationOrigins(list, managedOnly); |
| 63 return list; | 38 return list; |
| 64 } | 39 } |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 private static void insertUsbInfoIntoList( | 215 private static void insertUsbInfoIntoList( |
| 241 ArrayList<UsbInfo> list, String origin, String embedder, String name
, String object) { | 216 ArrayList<UsbInfo> list, String origin, String embedder, String name
, String object) { |
| 242 list.add(new UsbInfo(origin, embedder, name, object)); | 217 list.add(new UsbInfo(origin, embedder, name, object)); |
| 243 } | 218 } |
| 244 | 219 |
| 245 private static native void nativeGetGeolocationOrigins(Object list, boolean
managedOnly); | 220 private static native void nativeGetGeolocationOrigins(Object list, boolean
managedOnly); |
| 246 static native int nativeGetGeolocationSettingForOrigin( | 221 static native int nativeGetGeolocationSettingForOrigin( |
| 247 String origin, String embedder, boolean isIncognito); | 222 String origin, String embedder, boolean isIncognito); |
| 248 public static native void nativeSetGeolocationSettingForOrigin( | 223 public static native void nativeSetGeolocationSettingForOrigin( |
| 249 String origin, String embedder, int value, boolean isIncognito); | 224 String origin, String embedder, int value, boolean isIncognito); |
| 250 private static native void nativeGetKeygenOrigins(Object list); | |
| 251 static native int nativeGetKeygenSettingForOrigin( | |
| 252 String origin, String embedder, boolean isIncognito); | |
| 253 static native void nativeSetKeygenSettingForOrigin( | |
| 254 String origin, int value, boolean isIncognito); | |
| 255 private static native boolean nativeGetKeygenBlocked(Object webContents); | |
| 256 private static native void nativeGetMidiOrigins(Object list); | 225 private static native void nativeGetMidiOrigins(Object list); |
| 257 static native int nativeGetMidiSettingForOrigin( | 226 static native int nativeGetMidiSettingForOrigin( |
| 258 String origin, String embedder, boolean isIncognito); | 227 String origin, String embedder, boolean isIncognito); |
| 259 static native void nativeSetMidiSettingForOrigin( | 228 static native void nativeSetMidiSettingForOrigin( |
| 260 String origin, String embedder, int value, boolean isIncognito); | 229 String origin, String embedder, int value, boolean isIncognito); |
| 261 private static native void nativeGetNotificationOrigins(Object list); | 230 private static native void nativeGetNotificationOrigins(Object list); |
| 262 static native int nativeGetNotificationSettingForOrigin( | 231 static native int nativeGetNotificationSettingForOrigin( |
| 263 String origin, boolean isIncognito); | 232 String origin, boolean isIncognito); |
| 264 static native void nativeSetNotificationSettingForOrigin( | 233 static native void nativeSetNotificationSettingForOrigin( |
| 265 String origin, int value, boolean isIncognito); | 234 String origin, int value, boolean isIncognito); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 282 static native void nativeClearLocalStorageData(String path); | 251 static native void nativeClearLocalStorageData(String path); |
| 283 static native void nativeClearStorageData(String origin, int type, Object ca
llback); | 252 static native void nativeClearStorageData(String origin, int type, Object ca
llback); |
| 284 private static native void nativeFetchLocalStorageInfo(Object callback); | 253 private static native void nativeFetchLocalStorageInfo(Object callback); |
| 285 private static native void nativeFetchStorageInfo(Object callback); | 254 private static native void nativeFetchStorageInfo(Object callback); |
| 286 static native boolean nativeIsContentSettingsPatternValid(String pattern); | 255 static native boolean nativeIsContentSettingsPatternValid(String pattern); |
| 287 static native boolean nativeUrlMatchesContentSettingsPattern(String url, Str
ing pattern); | 256 static native boolean nativeUrlMatchesContentSettingsPattern(String url, Str
ing pattern); |
| 288 static native void nativeGetUsbOrigins(Object list); | 257 static native void nativeGetUsbOrigins(Object list); |
| 289 static native void nativeRevokeUsbPermission(String origin, String embedder,
String object); | 258 static native void nativeRevokeUsbPermission(String origin, String embedder,
String object); |
| 290 static native void nativeClearBannerData(String origin); | 259 static native void nativeClearBannerData(String origin); |
| 291 } | 260 } |
| OLD | NEW |