138 lines
7.9 KiB
Diff
138 lines
7.9 KiB
Diff
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 | 59 +++++++++----------
|
|
.../browser_ui/site_settings/Website.java | 20 +++++++
|
|
2 files changed, 47 insertions(+), 32 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
|
|
@@ -349,6 +349,8 @@ public class SingleWebsiteSettings extends SiteSettingsPreferenceFragment
|
|
setUpSoundPreference(preference);
|
|
} else if (i == ContentSettingException.Type.JAVASCRIPT) {
|
|
setUpJavascriptPreference(preference);
|
|
+ } else if (i == ContentSettingException.Type.COOKIE) {
|
|
+ setUpCookiePreference(preference);
|
|
} else {
|
|
// ContentSettingException can not be embargoed.
|
|
setUpListPreference(preference, mSite.getContentSettingPermission(i),
|
|
@@ -671,19 +673,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(
|
|
- getSiteSettingsClient().getBrowserContextHandle(),
|
|
- mSite.getAddress().getOrigin())
|
|
- && findPreference(PERMISSION_PREFERENCE_KEYS[ContentSettingException.Type.ADS])
|
|
- != null;
|
|
-
|
|
- if (!adBlockingActivated) {
|
|
- removePreferenceSafely(PREF_INTRUSIVE_ADS_INFO);
|
|
- removePreferenceSafely(PREF_INTRUSIVE_ADS_INFO_DIVIDER);
|
|
- }
|
|
+ removePreferenceSafely(PREF_INTRUSIVE_ADS_INFO);
|
|
+ removePreferenceSafely(PREF_INTRUSIVE_ADS_INFO_DIVIDER);
|
|
}
|
|
|
|
private SiteSettingsCategory getWarningCategory() {
|
|
@@ -838,13 +829,29 @@ public class SingleWebsiteSettings extends SiteSettingsPreferenceFragment
|
|
@Nullable
|
|
Integer currentValue =
|
|
mSite.getContentSettingPermission(ContentSettingException.Type.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(
|
|
- getSiteSettingsClient().getBrowserContextHandle(),
|
|
- ContentSettingsType.JAVASCRIPT)) {
|
|
- currentValue = ContentSettingValues.BLOCK;
|
|
+ // Always show the Javascript permission
|
|
+ if (currentValue == null) {
|
|
+ currentValue = WebsitePreferenceBridge.isCategoryEnabled(
|
|
+ getSiteSettingsClient().getBrowserContextHandle(),
|
|
+ ContentSettingsType.JAVASCRIPT)
|
|
+ ? ContentSettingValues.ALLOW
|
|
+ : ContentSettingValues.BLOCK;
|
|
+ }
|
|
+ setUpListPreference(preference, currentValue, false);
|
|
+ }
|
|
+
|
|
+ private void setUpCookiePreference(Preference preference) {
|
|
+ @ContentSettingValues
|
|
+ @Nullable
|
|
+ Integer currentValue =
|
|
+ mSite.getContentSettingPermission(ContentSettingException.Type.COOKIE);
|
|
+ // Always show the cookies permission
|
|
+ if (currentValue == null) {
|
|
+ currentValue = WebsitePreferenceBridge.isCategoryEnabled(
|
|
+ getSiteSettingsClient().getBrowserContextHandle(),
|
|
+ ContentSettingsType.COOKIES)
|
|
+ ? ContentSettingValues.ALLOW
|
|
+ : ContentSettingValues.BLOCK;
|
|
}
|
|
// Not possible to embargo JAVASCRIPT.
|
|
setUpListPreference(preference, currentValue, false /* isEmbargoed */);
|
|
@@ -863,22 +870,10 @@ public class SingleWebsiteSettings extends SiteSettingsPreferenceFragment
|
|
setUpListPreference(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(
|
|
- getSiteSettingsClient().getBrowserContextHandle(), mSite.getAddress().getOrigin());
|
|
@ContentSettingValues
|
|
@Nullable
|
|
Integer permission = mSite.getContentSettingPermission(ContentSettingException.Type.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) {
|
|
- setUpListPreference(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
|
|
@@ -220,6 +220,26 @@ public class Website implements Serializable {
|
|
} else {
|
|
RecordUserAction.record("JavascriptContentSetting.DisableBy.SiteSettings");
|
|
}
|
|
+ } else if (type == ContentSettingException.Type.COOKIE) {
|
|
+ // It is possible to set the permission without having an existing exception,
|
|
+ // because we can show the ALLOW state even when this permission is set to the
|
|
+ // default. In that case, just set an exception now to ALLOW to enable changing the
|
|
+ // permission.
|
|
+ if (mContentSettingException[type] == null) {
|
|
+ mContentSettingException[type] =
|
|
+ new ContentSettingException(ContentSettingsType.COOKIES,
|
|
+ getAddress().getOrigin(), ContentSettingValues.ALLOW, "");
|
|
+ }
|
|
+ } else if (type == ContentSettingException.Type.JAVASCRIPT) {
|
|
+ // It is possible to set the permission without having an existing exception,
|
|
+ // because we can show the ALLOW state even when this permission is set to the
|
|
+ // default. In that case, just set an exception now to ALLOW to enable changing the
|
|
+ // permission.
|
|
+ if (mContentSettingException[type] == null) {
|
|
+ mContentSettingException[type] =
|
|
+ new ContentSettingException(ContentSettingsType.JAVASCRIPT,
|
|
+ getAddress().getOrigin(), ContentSettingValues.ALLOW, "");
|
|
+ }
|
|
} else if (type == ContentSettingException.Type.SOUND) {
|
|
// It is possible to set the permission without having an existing exception,
|
|
// because we always show the sound permission in Site Settings.
|
|
--
|
|
2.17.1
|
|
|