Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(775)

Unified Diff: components/content_settings/core/browser/host_content_settings_map.cc

Issue 2886433002: [Android] Adding content settings provider for notification channels (Closed)
Patch Set: Use Origin.Serialize instead of GURL.spec() Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/content_settings/core/browser/host_content_settings_map.cc
diff --git a/components/content_settings/core/browser/host_content_settings_map.cc b/components/content_settings/core/browser/host_content_settings_map.cc
index 52a6708ea74cd789da27059c168cb63c4776712f..cc3516fcd315d5ea13a5bc384f2be62946f98e97 100644
--- a/components/content_settings/core/browser/host_content_settings_map.cc
+++ b/components/content_settings/core/browser/host_content_settings_map.cc
@@ -55,6 +55,7 @@ const ProviderNamesSourceMapEntry kProviderNamesSourceMap[] = {
{"policy", content_settings::SETTING_SOURCE_POLICY},
{"supervised_user", content_settings::SETTING_SOURCE_SUPERVISED},
{"extension", content_settings::SETTING_SOURCE_EXTENSION},
+ {"notification_android", content_settings::SETTING_SOURCE_USER},
{"preference", content_settings::SETTING_SOURCE_USER},
{"default", content_settings::SETTING_SOURCE_USER},
};
@@ -384,6 +385,25 @@ void HostContentSettingsMap::SetWebsiteSettingCustomScope(
std::unique_ptr<base::Value> value) {
DCHECK(SupportsResourceIdentifier(content_type) ||
resource_identifier.empty());
+#if defined(OS_ANDROID)
+ // Disallow arbitrary wildcard notification content setting updates on
+ // Android. The primary_pattern must either identify a specific origin
+ // or apply globally (for the default notifications toggle).
+ DCHECK(content_type != CONTENT_SETTINGS_TYPE_NOTIFICATIONS ||
+ GURL(primary_pattern.ToString()).is_valid() ||
+ primary_pattern.MatchesAllHosts());
+ // Disallow notification content setting updates for specific origins that are
+ // not ALLOW/BLOCK/DEFAULT on Android.
+ DCHECK(content_type != CONTENT_SETTINGS_TYPE_NOTIFICATIONS ||
+ primary_pattern.MatchesAllHosts() ||
+ content_settings::ValueToContentSetting(value.get()) ==
+ CONTENT_SETTING_ALLOW ||
+ content_settings::ValueToContentSetting(value.get()) ==
+ CONTENT_SETTING_BLOCK ||
+ content_settings::ValueToContentSetting(value.get()) ==
+ CONTENT_SETTING_DEFAULT);
+#endif
Peter Beverloo 2017/06/05 15:11:31 This is getting really complicated to read. What a
awdf 2017/06/05 17:06:56 Ooh, I didn't know about DCHECK_IS_ON. thanks! Do
+
UsedContentSettingsProviders();
for (const auto& provider_pair : content_settings_providers_) {
@@ -910,4 +930,4 @@ HostContentSettingsMap::GetContentSettingValueAndPatterns(
void HostContentSettingsMap::SetClockForTesting(
std::unique_ptr<base::Clock> clock) {
pref_provider_->SetClockForTesting(std::move(clock));
-}
+}

Powered by Google App Engine
This is Rietveld 408576698