| 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 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 setUpListPreference(preference, mSite.getMicrophonePermission())
; | 306 setUpListPreference(preference, mSite.getMicrophonePermission())
; |
| 307 } else if (PREF_MIDI_SYSEX_PERMISSION.equals(preference.getKey())) { | 307 } else if (PREF_MIDI_SYSEX_PERMISSION.equals(preference.getKey())) { |
| 308 setUpListPreference(preference, mSite.getMidiPermission()); | 308 setUpListPreference(preference, mSite.getMidiPermission()); |
| 309 } else if (PREF_NOTIFICATIONS_PERMISSION.equals(preference.getKey())
) { | 309 } else if (PREF_NOTIFICATIONS_PERMISSION.equals(preference.getKey())
) { |
| 310 setUpListPreference(preference, mSite.getNotificationPermission(
)); | 310 setUpListPreference(preference, mSite.getNotificationPermission(
)); |
| 311 } else if (PREF_POPUP_PERMISSION.equals(preference.getKey())) { | 311 } else if (PREF_POPUP_PERMISSION.equals(preference.getKey())) { |
| 312 setUpListPreference(preference, mSite.getPopupPermission()); | 312 setUpListPreference(preference, mSite.getPopupPermission()); |
| 313 } else if (PREF_PROTECTED_MEDIA_IDENTIFIER_PERMISSION.equals(prefere
nce.getKey())) { | 313 } else if (PREF_PROTECTED_MEDIA_IDENTIFIER_PERMISSION.equals(prefere
nce.getKey())) { |
| 314 setUpListPreference(preference, mSite.getProtectedMediaIdentifie
rPermission()); | 314 setUpListPreference(preference, mSite.getProtectedMediaIdentifie
rPermission()); |
| 315 } else if (PREF_SUBRESOURCE_FILTER_PERMISSION.equals(preference.getK
ey())) { | 315 } else if (PREF_SUBRESOURCE_FILTER_PERMISSION.equals(preference.getK
ey())) { |
| 316 setUpListPreference(preference, mSite.getSubresourceFilterPermis
sion()); | 316 setUpSubresourceFilterPreference(preference); |
| 317 } | 317 } |
| 318 | 318 |
| 319 if (permissionPreferenceKeys.contains(preference.getKey())) { | 319 if (permissionPreferenceKeys.contains(preference.getKey())) { |
| 320 maxPermissionOrder = Math.max(maxPermissionOrder, preference.get
Order()); | 320 maxPermissionOrder = Math.max(maxPermissionOrder, preference.get
Order()); |
| 321 } | 321 } |
| 322 } | 322 } |
| 323 | 323 |
| 324 for (UsbInfo info : mSite.getUsbInfo()) { | 324 for (UsbInfo info : mSite.getUsbInfo()) { |
| 325 Preference preference = new Preference(getActivity()); | 325 Preference preference = new Preference(getActivity()); |
| 326 preference.getExtras().putSerializable(EXTRA_USB_INFO, info); | 326 preference.getExtras().putSerializable(EXTRA_USB_INFO, info); |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 String origin = mSite.getAddress().getOrigin(); | 490 String origin = mSite.getAddress().getOrigin(); |
| 491 mSite.setGeolocationInfo(new GeolocationInfo(origin, origin, false))
; | 491 mSite.setGeolocationInfo(new GeolocationInfo(origin, origin, false))
; |
| 492 setUpListPreference(preference, (boolean) locationAllowed | 492 setUpListPreference(preference, (boolean) locationAllowed |
| 493 ? ContentSetting.ALLOW : ContentSetting.BLOCK); | 493 ? ContentSetting.ALLOW : ContentSetting.BLOCK); |
| 494 } else { | 494 } else { |
| 495 setUpListPreference(preference, permission); | 495 setUpListPreference(preference, permission); |
| 496 } | 496 } |
| 497 } | 497 } |
| 498 | 498 |
| 499 /** | 499 /** |
| 500 * Updates the subresource filter list preference based on subresource filte
r activation. This |
| 501 * has some custom behavior. |
| 502 * 1. If the site is filtering, the permission should show up even if it is
set as the default |
| 503 * (e.g. |preference| is null). |
| 504 * 2. The BLOCK string is custom. |
| 505 */ |
| 506 private void setUpSubresourceFilterPreference(Preference preference) { |
| 507 // If the subresource filter is activated, then this site will have reso
urces filtered |
| 508 // unless there is an explicit permission disallowing the filtering. |
| 509 boolean subresourceFilterActivated = WebsitePreferenceBridge.getSubresou
rceFilterActivated( |
| 510 mSite.getAddress().getOrigin()); |
| 511 ContentSetting permission = mSite.getSubresourceFilterPermission(); |
| 512 |
| 513 // If |permission| is null, there is no explicit (non-default) permissio
n set for this site. |
| 514 // However, if the filtering is activated, we still want to show the per
mission as BLOCK. |
| 515 if (permission == null && !subresourceFilterActivated) { |
| 516 setUpListPreference(preference, null); |
| 517 return; |
| 518 } |
| 519 setUpListPreference(preference, permission == null ? ContentSetting.BLOC
K : permission); |
| 520 |
| 521 // The subresource filter permission has a custom BLOCK string. |
| 522 ListPreference listPreference = (ListPreference) preference; |
| 523 Resources res = getResources(); |
| 524 listPreference.setEntries( |
| 525 new String[] {res.getString(R.string.website_settings_permission
s_allow), |
| 526 res.getString(R.string.subresource_filter_permission_blo
ck)}); |
| 527 listPreference.setValueIndex(permission == ContentSetting.ALLOW ? 0 : 1)
; |
| 528 } |
| 529 |
| 530 /** |
| 500 * Returns true if the current host matches the default search engine host a
nd location for the | 531 * Returns true if the current host matches the default search engine host a
nd location for the |
| 501 * default search engine is being granted via x-geo. | 532 * default search engine is being granted via x-geo. |
| 502 * @param context The current context. | 533 * @param context The current context. |
| 503 */ | 534 */ |
| 504 private boolean hasXGeoLocationPermission(Context context) { | 535 private boolean hasXGeoLocationPermission(Context context) { |
| 505 if (ChromeFeatureList.isEnabled(ChromeFeatureList.CONSISTENT_OMNIBOX_GEO
LOCATION)) { | 536 if (ChromeFeatureList.isEnabled(ChromeFeatureList.CONSISTENT_OMNIBOX_GEO
LOCATION)) { |
| 506 return false; | 537 return false; |
| 507 } | 538 } |
| 508 | 539 |
| 509 String searchUrl = TemplateUrlService.getInstance().getUrlForSearchQuery
("foo"); | 540 String searchUrl = TemplateUrlService.getInstance().getUrlForSearchQuery
("foo"); |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 723 if (mSite.getTotalUsage() > 0) { | 754 if (mSite.getTotalUsage() > 0) { |
| 724 clearStoredData(); | 755 clearStoredData(); |
| 725 } else { | 756 } else { |
| 726 // Clearing stored data implies popping back to parent menu if there | 757 // Clearing stored data implies popping back to parent menu if there |
| 727 // is nothing left to show. Therefore, we only need to explicitly | 758 // is nothing left to show. Therefore, we only need to explicitly |
| 728 // close the activity if there's no stored data to begin with. | 759 // close the activity if there's no stored data to begin with. |
| 729 getActivity().finish(); | 760 getActivity().finish(); |
| 730 } | 761 } |
| 731 } | 762 } |
| 732 } | 763 } |
| OLD | NEW |