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.content.Context; | 7 import android.content.Context; |
8 import android.content.DialogInterface; | 8 import android.content.DialogInterface; |
9 import android.content.res.Resources; | 9 import android.content.res.Resources; |
10 import android.net.Uri; | 10 import android.net.Uri; |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 public static final String PREF_RESET_SITE = "reset_site_button"; | 70 public static final String PREF_RESET_SITE = "reset_site_button"; |
71 // Website permissions (if adding new, see hasPermissionsPreferences and res
etSite below): | 71 // Website permissions (if adding new, see hasPermissionsPreferences and res
etSite below): |
72 public static final String PREF_AUTOPLAY_PERMISSION = "autoplay_permission_l
ist"; | 72 public static final String PREF_AUTOPLAY_PERMISSION = "autoplay_permission_l
ist"; |
73 public static final String PREF_BACKGROUND_SYNC_PERMISSION = "background_syn
c_permission_list"; | 73 public static final String PREF_BACKGROUND_SYNC_PERMISSION = "background_syn
c_permission_list"; |
74 public static final String PREF_CAMERA_CAPTURE_PERMISSION = "camera_permissi
on_list"; | 74 public static final String PREF_CAMERA_CAPTURE_PERMISSION = "camera_permissi
on_list"; |
75 public static final String PREF_COOKIES_PERMISSION = "cookies_permission_lis
t"; | 75 public static final String PREF_COOKIES_PERMISSION = "cookies_permission_lis
t"; |
76 public static final String PREF_JAVASCRIPT_PERMISSION = "javascript_permissi
on_list"; | 76 public static final String PREF_JAVASCRIPT_PERMISSION = "javascript_permissi
on_list"; |
77 public static final String PREF_LOCATION_ACCESS = "location_access_list"; | 77 public static final String PREF_LOCATION_ACCESS = "location_access_list"; |
78 public static final String PREF_MIC_CAPTURE_PERMISSION = "microphone_permiss
ion_list"; | 78 public static final String PREF_MIC_CAPTURE_PERMISSION = "microphone_permiss
ion_list"; |
79 public static final String PREF_MIDI_SYSEX_PERMISSION = "midi_sysex_permissi
on_list"; | 79 public static final String PREF_MIDI_SYSEX_PERMISSION = "midi_sysex_permissi
on_list"; |
| 80 public static final String PREF_SENSORS_PERMISSION = "sensors_permission_lis
t"; |
80 public static final String PREF_NOTIFICATIONS_PERMISSION = "push_notificatio
ns_list"; | 81 public static final String PREF_NOTIFICATIONS_PERMISSION = "push_notificatio
ns_list"; |
81 public static final String PREF_POPUP_PERMISSION = "popup_permission_list"; | 82 public static final String PREF_POPUP_PERMISSION = "popup_permission_list"; |
82 public static final String PREF_PROTECTED_MEDIA_IDENTIFIER_PERMISSION = | 83 public static final String PREF_PROTECTED_MEDIA_IDENTIFIER_PERMISSION = |
83 "protected_media_identifier_permission_list"; | 84 "protected_media_identifier_permission_list"; |
84 public static final String PREF_SUBRESOURCE_FILTER_PERMISSION = | 85 public static final String PREF_SUBRESOURCE_FILTER_PERMISSION = |
85 "subresource_filter_permission_list"; | 86 "subresource_filter_permission_list"; |
86 | 87 |
87 // All permissions from the permissions preference category must be listed h
ere. | 88 // All permissions from the permissions preference category must be listed h
ere. |
88 // TODO(mvanouwerkerk): Use this array in more places to reduce verbosity. | 89 // TODO(mvanouwerkerk): Use this array in more places to reduce verbosity. |
89 private static final String[] PERMISSION_PREFERENCE_KEYS = { | 90 private static final String[] PERMISSION_PREFERENCE_KEYS = { |
90 PREF_AUTOPLAY_PERMISSION, | 91 PREF_AUTOPLAY_PERMISSION, PREF_BACKGROUND_SYNC_PERMISSION, |
91 PREF_BACKGROUND_SYNC_PERMISSION, | 92 PREF_CAMERA_CAPTURE_PERMISSION, PREF_COOKIES_PERMISSION, PREF_JAVASC
RIPT_PERMISSION, |
92 PREF_CAMERA_CAPTURE_PERMISSION, | 93 PREF_LOCATION_ACCESS, PREF_MIC_CAPTURE_PERMISSION, PREF_MIDI_SYSEX_P
ERMISSION, |
93 PREF_COOKIES_PERMISSION, | 94 PREF_NOTIFICATIONS_PERMISSION, PREF_POPUP_PERMISSION, |
94 PREF_JAVASCRIPT_PERMISSION, | 95 PREF_PROTECTED_MEDIA_IDENTIFIER_PERMISSION, PREF_SUBRESOURCE_FILTER_
PERMISSION, |
95 PREF_LOCATION_ACCESS, | 96 PREF_SENSORS_PERMISSION, |
96 PREF_MIC_CAPTURE_PERMISSION, | |
97 PREF_MIDI_SYSEX_PERMISSION, | |
98 PREF_NOTIFICATIONS_PERMISSION, | |
99 PREF_POPUP_PERMISSION, | |
100 PREF_PROTECTED_MEDIA_IDENTIFIER_PERMISSION, | |
101 PREF_SUBRESOURCE_FILTER_PERMISSION, | |
102 }; | 97 }; |
103 | 98 |
104 // The website this page is displaying details about. | 99 // The website this page is displaying details about. |
105 private Website mSite; | 100 private Website mSite; |
106 | 101 |
107 // The address of the site we want to display. Used only if EXTRA_ADDRESS is
provided. | 102 // The address of the site we want to display. Used only if EXTRA_ADDRESS is
provided. |
108 private WebsiteAddress mSiteAddress; | 103 private WebsiteAddress mSiteAddress; |
109 | 104 |
110 // The number of USB device permissions displayed. | 105 // The number of USB device permissions displayed. |
111 private int mUsbPermissionCount; | 106 private int mUsbPermissionCount; |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 merged.setSubresourceFilterException(other.getSubresourceFilterE
xception()); | 196 merged.setSubresourceFilterException(other.getSubresourceFilterE
xception()); |
202 } | 197 } |
203 if (merged.getGeolocationInfo() == null && other.getGeolocationInfo(
) != null | 198 if (merged.getGeolocationInfo() == null && other.getGeolocationInfo(
) != null |
204 && permissionInfoIsForTopLevelOrigin(other.getGeolocationInf
o(), origin)) { | 199 && permissionInfoIsForTopLevelOrigin(other.getGeolocationInf
o(), origin)) { |
205 merged.setGeolocationInfo(other.getGeolocationInfo()); | 200 merged.setGeolocationInfo(other.getGeolocationInfo()); |
206 } | 201 } |
207 if (merged.getMidiInfo() == null && other.getMidiInfo() != null | 202 if (merged.getMidiInfo() == null && other.getMidiInfo() != null |
208 && permissionInfoIsForTopLevelOrigin(other.getMidiInfo(), or
igin)) { | 203 && permissionInfoIsForTopLevelOrigin(other.getMidiInfo(), or
igin)) { |
209 merged.setMidiInfo(other.getMidiInfo()); | 204 merged.setMidiInfo(other.getMidiInfo()); |
210 } | 205 } |
| 206 if (merged.getSensorInfo() == null && other.getSensorInfo() != null |
| 207 && permissionInfoIsForTopLevelOrigin(other.getSensorInfo(),
origin)) { |
| 208 merged.setSensorInfo(other.getSensorInfo()); |
| 209 } |
211 if (merged.getProtectedMediaIdentifierInfo() == null | 210 if (merged.getProtectedMediaIdentifierInfo() == null |
212 && other.getProtectedMediaIdentifierInfo() != null | 211 && other.getProtectedMediaIdentifierInfo() != null |
213 && permissionInfoIsForTopLevelOrigin( | 212 && permissionInfoIsForTopLevelOrigin( |
214 other.getProtectedMediaIdentifierInfo(), origin))
{ | 213 other.getProtectedMediaIdentifierInfo(), origin))
{ |
215 merged.setProtectedMediaIdentifierInfo(other.getProtectedMediaId
entifierInfo()); | 214 merged.setProtectedMediaIdentifierInfo(other.getProtectedMediaId
entifierInfo()); |
216 } | 215 } |
217 if (merged.getNotificationInfo() == null | 216 if (merged.getNotificationInfo() == null |
218 && other.getNotificationInfo() != null | 217 && other.getNotificationInfo() != null |
219 && permissionInfoIsForTopLevelOrigin( | 218 && permissionInfoIsForTopLevelOrigin( |
220 other.getNotificationInfo(), origin)) { | 219 other.getNotificationInfo(), origin)) { |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 } else if (PREF_COOKIES_PERMISSION.equals(preference.getKey())) { | 298 } else if (PREF_COOKIES_PERMISSION.equals(preference.getKey())) { |
300 setUpListPreference(preference, mSite.getCookiePermission()); | 299 setUpListPreference(preference, mSite.getCookiePermission()); |
301 } else if (PREF_JAVASCRIPT_PERMISSION.equals(preference.getKey())) { | 300 } else if (PREF_JAVASCRIPT_PERMISSION.equals(preference.getKey())) { |
302 setUpListPreference(preference, mSite.getJavaScriptPermission())
; | 301 setUpListPreference(preference, mSite.getJavaScriptPermission())
; |
303 } else if (PREF_LOCATION_ACCESS.equals(preference.getKey())) { | 302 } else if (PREF_LOCATION_ACCESS.equals(preference.getKey())) { |
304 setUpLocationPreference(preference); | 303 setUpLocationPreference(preference); |
305 } else if (PREF_MIC_CAPTURE_PERMISSION.equals(preference.getKey()))
{ | 304 } else if (PREF_MIC_CAPTURE_PERMISSION.equals(preference.getKey()))
{ |
306 setUpListPreference(preference, mSite.getMicrophonePermission())
; | 305 setUpListPreference(preference, mSite.getMicrophonePermission())
; |
307 } else if (PREF_MIDI_SYSEX_PERMISSION.equals(preference.getKey())) { | 306 } else if (PREF_MIDI_SYSEX_PERMISSION.equals(preference.getKey())) { |
308 setUpListPreference(preference, mSite.getMidiPermission()); | 307 setUpListPreference(preference, mSite.getMidiPermission()); |
| 308 } else if (PREF_SENSORS_PERMISSION.equals(preference.getKey())) { |
| 309 setUpListPreference(preference, mSite.getSensorsPermission()); |
309 } else if (PREF_NOTIFICATIONS_PERMISSION.equals(preference.getKey())
) { | 310 } else if (PREF_NOTIFICATIONS_PERMISSION.equals(preference.getKey())
) { |
310 setUpListPreference(preference, mSite.getNotificationPermission(
)); | 311 setUpListPreference(preference, mSite.getNotificationPermission(
)); |
311 } else if (PREF_POPUP_PERMISSION.equals(preference.getKey())) { | 312 } else if (PREF_POPUP_PERMISSION.equals(preference.getKey())) { |
312 setUpListPreference(preference, mSite.getPopupPermission()); | 313 setUpListPreference(preference, mSite.getPopupPermission()); |
313 } else if (PREF_PROTECTED_MEDIA_IDENTIFIER_PERMISSION.equals(prefere
nce.getKey())) { | 314 } else if (PREF_PROTECTED_MEDIA_IDENTIFIER_PERMISSION.equals(prefere
nce.getKey())) { |
314 setUpListPreference(preference, mSite.getProtectedMediaIdentifie
rPermission()); | 315 setUpListPreference(preference, mSite.getProtectedMediaIdentifie
rPermission()); |
315 } else if (PREF_SUBRESOURCE_FILTER_PERMISSION.equals(preference.getK
ey())) { | 316 } else if (PREF_SUBRESOURCE_FILTER_PERMISSION.equals(preference.getK
ey())) { |
316 setUpListPreference(preference, mSite.getSubresourceFilterPermis
sion()); | 317 setUpListPreference(preference, mSite.getSubresourceFilterPermis
sion()); |
317 } | 318 } |
318 | 319 |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
567 case PREF_COOKIES_PERMISSION: | 568 case PREF_COOKIES_PERMISSION: |
568 return ContentSettingsType.CONTENT_SETTINGS_TYPE_COOKIES; | 569 return ContentSettingsType.CONTENT_SETTINGS_TYPE_COOKIES; |
569 case PREF_JAVASCRIPT_PERMISSION: | 570 case PREF_JAVASCRIPT_PERMISSION: |
570 return ContentSettingsType.CONTENT_SETTINGS_TYPE_JAVASCRIPT; | 571 return ContentSettingsType.CONTENT_SETTINGS_TYPE_JAVASCRIPT; |
571 case PREF_LOCATION_ACCESS: | 572 case PREF_LOCATION_ACCESS: |
572 return ContentSettingsType.CONTENT_SETTINGS_TYPE_GEOLOCATION; | 573 return ContentSettingsType.CONTENT_SETTINGS_TYPE_GEOLOCATION; |
573 case PREF_MIC_CAPTURE_PERMISSION: | 574 case PREF_MIC_CAPTURE_PERMISSION: |
574 return ContentSettingsType.CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC
; | 575 return ContentSettingsType.CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC
; |
575 case PREF_MIDI_SYSEX_PERMISSION: | 576 case PREF_MIDI_SYSEX_PERMISSION: |
576 return ContentSettingsType.CONTENT_SETTINGS_TYPE_MIDI_SYSEX; | 577 return ContentSettingsType.CONTENT_SETTINGS_TYPE_MIDI_SYSEX; |
| 578 case PREF_SENSORS_PERMISSION: |
| 579 return ContentSettingsType.CONTENT_SETTINGS_TYPE_SENSORS; |
577 case PREF_NOTIFICATIONS_PERMISSION: | 580 case PREF_NOTIFICATIONS_PERMISSION: |
578 return ContentSettingsType.CONTENT_SETTINGS_TYPE_NOTIFICATIONS; | 581 return ContentSettingsType.CONTENT_SETTINGS_TYPE_NOTIFICATIONS; |
579 case PREF_POPUP_PERMISSION: | 582 case PREF_POPUP_PERMISSION: |
580 return ContentSettingsType.CONTENT_SETTINGS_TYPE_POPUPS; | 583 return ContentSettingsType.CONTENT_SETTINGS_TYPE_POPUPS; |
581 case PREF_PROTECTED_MEDIA_IDENTIFIER_PERMISSION: | 584 case PREF_PROTECTED_MEDIA_IDENTIFIER_PERMISSION: |
582 return ContentSettingsType.CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA
_IDENTIFIER; | 585 return ContentSettingsType.CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA
_IDENTIFIER; |
583 case PREF_SUBRESOURCE_FILTER_PERMISSION: | 586 case PREF_SUBRESOURCE_FILTER_PERMISSION: |
584 return ContentSettingsType.CONTENT_SETTINGS_TYPE_SUBRESOURCE_FIL
TER; | 587 return ContentSettingsType.CONTENT_SETTINGS_TYPE_SUBRESOURCE_FIL
TER; |
585 default: | 588 default: |
586 return 0; | 589 return 0; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
629 } else if (PREF_COOKIES_PERMISSION.equals(preference.getKey())) { | 632 } else if (PREF_COOKIES_PERMISSION.equals(preference.getKey())) { |
630 mSite.setCookiePermission(permission); | 633 mSite.setCookiePermission(permission); |
631 } else if (PREF_JAVASCRIPT_PERMISSION.equals(preference.getKey())) { | 634 } else if (PREF_JAVASCRIPT_PERMISSION.equals(preference.getKey())) { |
632 mSite.setJavaScriptPermission(permission); | 635 mSite.setJavaScriptPermission(permission); |
633 } else if (PREF_LOCATION_ACCESS.equals(preference.getKey())) { | 636 } else if (PREF_LOCATION_ACCESS.equals(preference.getKey())) { |
634 mSite.setGeolocationPermission(permission); | 637 mSite.setGeolocationPermission(permission); |
635 } else if (PREF_MIC_CAPTURE_PERMISSION.equals(preference.getKey())) { | 638 } else if (PREF_MIC_CAPTURE_PERMISSION.equals(preference.getKey())) { |
636 mSite.setMicrophonePermission(permission); | 639 mSite.setMicrophonePermission(permission); |
637 } else if (PREF_MIDI_SYSEX_PERMISSION.equals(preference.getKey())) { | 640 } else if (PREF_MIDI_SYSEX_PERMISSION.equals(preference.getKey())) { |
638 mSite.setMidiPermission(permission); | 641 mSite.setMidiPermission(permission); |
| 642 } else if (PREF_SENSORS_PERMISSION.equals(preference.getKey())) { |
| 643 mSite.setSensorsPermission(permission); |
639 } else if (PREF_NOTIFICATIONS_PERMISSION.equals(preference.getKey())) { | 644 } else if (PREF_NOTIFICATIONS_PERMISSION.equals(preference.getKey())) { |
640 mSite.setNotificationPermission(permission); | 645 mSite.setNotificationPermission(permission); |
641 } else if (PREF_POPUP_PERMISSION.equals(preference.getKey())) { | 646 } else if (PREF_POPUP_PERMISSION.equals(preference.getKey())) { |
642 mSite.setPopupPermission(permission); | 647 mSite.setPopupPermission(permission); |
643 } else if (PREF_PROTECTED_MEDIA_IDENTIFIER_PERMISSION.equals(preference.
getKey())) { | 648 } else if (PREF_PROTECTED_MEDIA_IDENTIFIER_PERMISSION.equals(preference.
getKey())) { |
644 mSite.setProtectedMediaIdentifierPermission(permission); | 649 mSite.setProtectedMediaIdentifierPermission(permission); |
645 } else if (PREF_SUBRESOURCE_FILTER_PERMISSION.equals(preference.getKey()
)) { | 650 } else if (PREF_SUBRESOURCE_FILTER_PERMISSION.equals(preference.getKey()
)) { |
646 mSite.setSubresourceFilterPermission(permission); | 651 mSite.setSubresourceFilterPermission(permission); |
647 } | 652 } |
648 | 653 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
705 | 710 |
706 // Clear the permissions. | 711 // Clear the permissions. |
707 mSite.setAutoplayPermission(ContentSetting.DEFAULT); | 712 mSite.setAutoplayPermission(ContentSetting.DEFAULT); |
708 mSite.setBackgroundSyncPermission(ContentSetting.DEFAULT); | 713 mSite.setBackgroundSyncPermission(ContentSetting.DEFAULT); |
709 mSite.setCameraPermission(ContentSetting.DEFAULT); | 714 mSite.setCameraPermission(ContentSetting.DEFAULT); |
710 mSite.setCookiePermission(ContentSetting.DEFAULT); | 715 mSite.setCookiePermission(ContentSetting.DEFAULT); |
711 mSite.setGeolocationPermission(ContentSetting.DEFAULT); | 716 mSite.setGeolocationPermission(ContentSetting.DEFAULT); |
712 mSite.setJavaScriptPermission(ContentSetting.DEFAULT); | 717 mSite.setJavaScriptPermission(ContentSetting.DEFAULT); |
713 mSite.setMicrophonePermission(ContentSetting.DEFAULT); | 718 mSite.setMicrophonePermission(ContentSetting.DEFAULT); |
714 mSite.setMidiPermission(ContentSetting.DEFAULT); | 719 mSite.setMidiPermission(ContentSetting.DEFAULT); |
| 720 mSite.setSensorsPermission(ContentSetting.DEFAULT); |
715 mSite.setNotificationPermission(ContentSetting.DEFAULT); | 721 mSite.setNotificationPermission(ContentSetting.DEFAULT); |
716 mSite.setPopupPermission(ContentSetting.DEFAULT); | 722 mSite.setPopupPermission(ContentSetting.DEFAULT); |
717 mSite.setProtectedMediaIdentifierPermission(ContentSetting.DEFAULT); | 723 mSite.setProtectedMediaIdentifierPermission(ContentSetting.DEFAULT); |
718 mSite.setSubresourceFilterPermission(ContentSetting.DEFAULT); | 724 mSite.setSubresourceFilterPermission(ContentSetting.DEFAULT); |
719 | 725 |
720 for (UsbInfo info : mSite.getUsbInfo()) info.revoke(); | 726 for (UsbInfo info : mSite.getUsbInfo()) info.revoke(); |
721 | 727 |
722 // Clear the storage and finish the activity if necessary. | 728 // Clear the storage and finish the activity if necessary. |
723 if (mSite.getTotalUsage() > 0) { | 729 if (mSite.getTotalUsage() > 0) { |
724 clearStoredData(); | 730 clearStoredData(); |
725 } else { | 731 } else { |
726 // Clearing stored data implies popping back to parent menu if there | 732 // Clearing stored data implies popping back to parent menu if there |
727 // is nothing left to show. Therefore, we only need to explicitly | 733 // is nothing left to show. Therefore, we only need to explicitly |
728 // close the activity if there's no stored data to begin with. | 734 // close the activity if there's no stored data to begin with. |
729 getActivity().finish(); | 735 getActivity().finish(); |
730 } | 736 } |
731 } | 737 } |
732 } | 738 } |
OLD | NEW |