123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- From: csagan5 <32685696+csagan5@users.noreply.github.com>
- Date: Sat, 28 Dec 2019 10:23:04 +0100
- Subject: Show site settings for cookies, javascript and ads
- Avoid displaying info about intrusive ads
- ---
- .../site_settings/SingleWebsiteSettings.java | 52 +++++++++----------
- .../browser_ui/site_settings/Website.java | 14 +++--
- 2 files changed, 35 insertions(+), 31 deletions(-)
- diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SingleWebsiteSettings.java b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SingleWebsiteSettings.java
- --- a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SingleWebsiteSettings.java
- +++ b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/SingleWebsiteSettings.java
- @@ -492,6 +492,8 @@ public class SingleWebsiteSettings extends SiteSettingsPreferenceFragment
- setUpSoundPreference(preference);
- } else if (type == ContentSettingsType.JAVASCRIPT) {
- setUpJavascriptPreference(preference);
- + } else if (type == ContentSettingsType.COOKIES) {
- + setUpCookiesPreference(preference);
- } else if (type == ContentSettingsType.GEOLOCATION) {
- setUpLocationPreference(preference);
- } else if (type == ContentSettingsType.NOTIFICATIONS) {
- @@ -818,16 +820,8 @@ public class SingleWebsiteSettings extends SiteSettingsPreferenceFragment
- private void setUpAdsInformationalBanner() {
- // Add the informational banner which shows at the top of the UI if ad blocking is
- // activated on this site.
- - boolean adBlockingActivated = SiteSettingsCategory.adsCategoryEnabled()
- - && WebsitePreferenceBridge.getAdBlockingActivated(
- - getSiteSettingsDelegate().getBrowserContextHandle(),
- - mSite.getAddress().getOrigin())
- - && findPreference(getPreferenceKey(ContentSettingsType.ADS)) != null;
- -
- - if (!adBlockingActivated) {
- removePreferenceSafely(PREF_INTRUSIVE_ADS_INFO);
- removePreferenceSafely(PREF_INTRUSIVE_ADS_INFO_DIVIDER);
- - }
- }
-
- private SiteSettingsCategory getWarningCategory() {
- @@ -989,17 +983,35 @@ public class SingleWebsiteSettings extends SiteSettingsPreferenceFragment
- @Nullable
- Integer currentValue =
- mSite.getContentSetting(browserContextHandle, ContentSettingsType.JAVASCRIPT);
- - // If Javascript is blocked by default, then always show a Javascript permission.
- - // To do this, set it to the default value (blocked).
- - if ((currentValue == null)
- - && !WebsitePreferenceBridge.isCategoryEnabled(
- - browserContextHandle, ContentSettingsType.JAVASCRIPT)) {
- - currentValue = ContentSettingValues.BLOCK;
- + // Always show the Javascript permission
- + if (currentValue == null) {
- + currentValue = WebsitePreferenceBridge.isCategoryEnabled(
- + browserContextHandle, ContentSettingsType.JAVASCRIPT)
- + ? ContentSettingValues.ALLOW
- + : ContentSettingValues.BLOCK;
- }
- // Not possible to embargo JAVASCRIPT.
- setupContentSettingsPreference(preference, currentValue, false /* isEmbargoed */);
- }
-
- + private void setUpCookiesPreference(Preference preference) {
- + BrowserContextHandle browserContextHandle =
- + getSiteSettingsDelegate().getBrowserContextHandle();
- + @ContentSettingValues
- + @Nullable
- + Integer currentValue =
- + mSite.getContentSetting(browserContextHandle, ContentSettingsType.COOKIES);
- + // Always show the cookies permission
- + if (currentValue == null || currentValue == ContentSettingValues.DEFAULT) {
- + currentValue = WebsitePreferenceBridge.isCategoryEnabled(
- + browserContextHandle, ContentSettingsType.COOKIES)
- + ? ContentSettingValues.ALLOW
- + : ContentSettingValues.BLOCK;
- + }
- + // Not possible to embargo COOKIES.
- + setupContentSettingsPreference(preference, currentValue, false /* isEmbargoed */);
- + }
- +
- /**
- * Updates the ads list preference based on whether the site is a candidate for blocking. This
- * has some custom behavior.
- @@ -1015,22 +1027,10 @@ public class SingleWebsiteSettings extends SiteSettingsPreferenceFragment
- setupContentSettingsPreference(preference, null, false);
- return;
- }
- - // If the ad blocker is activated, then this site will have ads blocked unless there is an
- - // explicit permission disallowing the blocking.
- - boolean activated = WebsitePreferenceBridge.getAdBlockingActivated(
- - browserContextHandle, mSite.getAddress().getOrigin());
- @ContentSettingValues
- @Nullable
- Integer permission = mSite.getContentSetting(browserContextHandle, ContentSettingsType.ADS);
-
- - // If |permission| is null, there is no explicit (non-default) permission set for this site.
- - // If the site is not considered a candidate for blocking, do the standard thing and remove
- - // the preference.
- - if (permission == null && !activated) {
- - setupContentSettingsPreference(preference, null, false);
- - return;
- - }
- -
- // However, if the blocking is activated, we still want to show the permission, even if it
- // is in the default state.
- if (permission == null) {
- diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/Website.java b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/Website.java
- --- a/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/Website.java
- +++ b/components/browser_ui/site_settings/android/java/src/org/chromium/components/browser_ui/site_settings/Website.java
- @@ -187,13 +187,17 @@ public final class Website implements Serializable {
-
- ContentSettingException exception = getContentSettingException(type);
- if (type == ContentSettingsType.ADS) {
- - // It is possible to set the permission without having an existing exception,
- - // because we can show the BLOCK state even when this permission is set to the
- - // default. In that case, just set an exception now to BLOCK to enable changing the
- - // permission.
- + // It is possible to set the permission without having an existing exception
- if (exception == null) {
- exception = new ContentSettingException(ContentSettingsType.ADS,
- - getAddress().getOrigin(), ContentSettingValues.BLOCK, "");
- + getAddress().getOrigin(), value, "");
- + setContentSettingException(type, exception);
- + }
- + } else if (type == ContentSettingsType.COOKIES) {
- + // It is possible to set the permission without having an existing exception
- + if (exception == null) {
- + exception = new ContentSettingException(ContentSettingsType.COOKIES,
- + getAddress().getOrigin(), value, "");
- setContentSettingException(type, exception);
- }
- } else if (type == ContentSettingsType.JAVASCRIPT) {
- --
- 2.25.1
|