Show-site-settings-for-cookies.patch
This commit is contained in:
parent
935696718c
commit
017658ac80
1 changed files with 59 additions and 58 deletions
|
@ -4,23 +4,23 @@ Subject: Show site settings for cookies
|
|||
|
||||
Avoid displaying info about intrusive ads
|
||||
---
|
||||
.../site_settings/SingleWebsiteSettings.java | 59 +++++++++----------
|
||||
.../browser_ui/site_settings/Website.java | 14 +++--
|
||||
2 files changed, 37 insertions(+), 36 deletions(-)
|
||||
.../site_settings/SingleWebsiteSettings.java | 57 +++++++++----------
|
||||
.../browser_ui/site_settings/Website.java | 9 ++-
|
||||
2 files changed, 36 insertions(+), 30 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
|
||||
@@ -433,6 +433,8 @@ public class SingleWebsiteSettings extends SiteSettingsPreferenceFragment
|
||||
setUpSoundPreference(preference);
|
||||
} else if (type == ContentSettingsType.JAVASCRIPT) {
|
||||
setUpJavascriptPreference(preference);
|
||||
+ } else if (type == ContentSettingsType.COOKIES) {
|
||||
+ setUpCookiePreference(preference);
|
||||
} else if (type == ContentSettingsType.GEOLOCATION) {
|
||||
setUpLocationPreference(preference);
|
||||
} else if (type == ContentSettingsType.NOTIFICATIONS) {
|
||||
@@ -754,18 +756,8 @@ public class SingleWebsiteSettings extends SiteSettingsPreferenceFragment
|
||||
@@ -476,6 +476,8 @@ public class SingleWebsiteSettings extends SiteSettingsPreferenceFragment
|
||||
setUpLocationPreference(preference);
|
||||
} else if (type == ContentSettingsType.NOTIFICATIONS) {
|
||||
setUpNotificationsPreference(preference, isPermissionEmbargoed(type));
|
||||
+ } else if (type == ContentSettingsType.COOKIES) {
|
||||
+ setUpCookiePreference(preference);
|
||||
} else {
|
||||
setupContentSettingsPreference(preference,
|
||||
mSite.getContentSetting(
|
||||
@@ -785,18 +787,7 @@ public class SingleWebsiteSettings extends SiteSettingsPreferenceFragment
|
||||
}
|
||||
|
||||
private void setUpAdsInformationalBanner() {
|
||||
|
@ -28,7 +28,7 @@ diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/c
|
|||
- // activated on this site.
|
||||
- boolean adBlockingActivated = SiteSettingsCategory.adsCategoryEnabled()
|
||||
- && WebsitePreferenceBridge.getAdBlockingActivated(
|
||||
- getSiteSettingsClient().getBrowserContextHandle(),
|
||||
- getSiteSettingsDelegate().getBrowserContextHandle(),
|
||||
- mSite.getAddress().getOrigin())
|
||||
- && findPreference(getPreferenceKey(ContentSettingsType.ADS)) != null;
|
||||
-
|
||||
|
@ -36,12 +36,11 @@ diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/c
|
|||
- 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() {
|
||||
@@ -935,14 +927,31 @@ public class SingleWebsiteSettings extends SiteSettingsPreferenceFragment
|
||||
@@ -987,15 +978,15 @@ public class SingleWebsiteSettings extends SiteSettingsPreferenceFragment
|
||||
@Nullable
|
||||
Integer currentValue =
|
||||
mSite.getContentSetting(browserContextHandle, ContentSettingsType.JAVASCRIPT);
|
||||
|
@ -54,81 +53,83 @@ diff --git a/components/browser_ui/site_settings/android/java/src/org/chromium/c
|
|||
+ // Always show the Javascript permission
|
||||
+ if (currentValue == null) {
|
||||
+ currentValue = WebsitePreferenceBridge.isCategoryEnabled(
|
||||
+ getSiteSettingsClient().getBrowserContextHandle(),
|
||||
+ getSiteSettingsDelegate().getBrowserContextHandle(),
|
||||
+ ContentSettingsType.JAVASCRIPT)
|
||||
+ ? ContentSettingValues.ALLOW
|
||||
+ : ContentSettingValues.BLOCK;
|
||||
}
|
||||
- // Not possible to embargo JAVASCRIPT.
|
||||
- setupContentSettingsPreference(preference, currentValue, false /* isEmbargoed */);
|
||||
+ setUpListPreference(preference, currentValue, false);
|
||||
+ }
|
||||
+
|
||||
+ private void setUpCookiePreference(Preference preference) {
|
||||
+ @ContentSettingValues
|
||||
+ @Nullable
|
||||
+ Integer currentValue =
|
||||
+ mSite.getContentSetting(getSiteSettingsClient().getBrowserContextHandle(), ContentSettingsType.COOKIES);
|
||||
+ // Always show the cookies permission
|
||||
+ if (currentValue == null) {
|
||||
+ currentValue = WebsitePreferenceBridge.isCategoryEnabled(
|
||||
+ getSiteSettingsClient().getBrowserContextHandle(),
|
||||
+ ContentSettingsType.COOKIES)
|
||||
+ ? ContentSettingValues.ALLOW
|
||||
+ : ContentSettingValues.BLOCK;
|
||||
+ }
|
||||
+ // Not possible to embargo COOKIES.
|
||||
setUpListPreference(preference, currentValue, false /* isEmbargoed */);
|
||||
}
|
||||
|
||||
@@ -961,22 +970,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(
|
||||
- browserContextHandle, mSite.getAddress().getOrigin());
|
||||
/**
|
||||
@@ -1020,15 +1011,6 @@ public class SingleWebsiteSettings extends SiteSettingsPreferenceFragment
|
||||
@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) {
|
||||
- setUpListPreference(preference, null, false);
|
||||
- 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) {
|
||||
@@ -1050,6 +1032,23 @@ public class SingleWebsiteSettings extends SiteSettingsPreferenceFragment
|
||||
}
|
||||
}
|
||||
|
||||
+ private void setUpCookiePreference(Preference preference) {
|
||||
+ @ContentSettingValues
|
||||
+ @Nullable
|
||||
+ Integer currentValue =
|
||||
+ mSite.getContentSetting(getSiteSettingsDelegate().getBrowserContextHandle(), ContentSettingsType.COOKIES);
|
||||
+ // Always show the cookies permission
|
||||
+ if (currentValue == null) {
|
||||
+ currentValue = WebsitePreferenceBridge.isCategoryEnabled(
|
||||
+ getSiteSettingsDelegate().getBrowserContextHandle(),
|
||||
+ ContentSettingsType.COOKIES)
|
||||
+ ? ContentSettingValues.ALLOW
|
||||
+ : ContentSettingValues.BLOCK;
|
||||
+ }
|
||||
+ // Not possible to embargo COOKIES.
|
||||
+ setupContentSettingsPreference(preference, currentValue, false /* isEmbargoed */);
|
||||
+ }
|
||||
+
|
||||
private String getDSECategorySummary(@ContentSettingValues int value) {
|
||||
return value == ContentSettingValues.ALLOW
|
||||
? getString(R.string.website_settings_permissions_allowed_dse)
|
||||
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
|
||||
@@ -193,7 +193,7 @@ public final class Website implements Serializable {
|
||||
// permission.
|
||||
if (exception == null) {
|
||||
exception = new ContentSettingException(ContentSettingsType.ADS,
|
||||
- getAddress().getOrigin(), ContentSettingValues.BLOCK, "");
|
||||
+ getAddress().getOrigin(), value, "");
|
||||
+ setContentSettingException(type, exception);
|
||||
+ }
|
||||
setContentSettingException(type, exception);
|
||||
}
|
||||
} else if (type == ContentSettingsType.JAVASCRIPT) {
|
||||
@@ -212,6 +212,13 @@ public final class Website implements Serializable {
|
||||
} else {
|
||||
RecordUserAction.record("JavascriptContentSetting.DisableBy.SiteSettings");
|
||||
}
|
||||
+ } 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) {
|
||||
+ setContentSettingException(type, exception);
|
||||
+ }
|
||||
} else if (type == ContentSettingsType.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
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue