Chromium Code Reviews| 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..362456742c674dbfd7de7a484d6f29eb75368bcb 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,26 @@ void HostContentSettingsMap::SetWebsiteSettingCustomScope( |
| std::unique_ptr<base::Value> value) { |
| DCHECK(SupportsResourceIdentifier(content_type) || |
| resource_identifier.empty()); |
| +#if defined(OS_ANDROID) && DCHECK_IS_ON() |
| + // The notification permission on Android only allows valid origins with a |
| + // restricted set of settings, or the global wildcard origin. |
| + if (content_type == CONTENT_SETTINGS_TYPE_NOTIFICATIONS && |
| + !primary_pattern.MatchesAllHosts()) { |
| + // The |primary_pattern| must be a valid GURL as it may be presented to the |
| + // user: Android Notification Channels may be used on Android O onward. |
| + DCHECK(GURL(primary_pattern.ToString()).is_valid()); |
| + |
| + ContentSetting setting = |
| + content_settings::ValueToContentSetting(value.get()); |
| + |
| + // Disallow notification content setting updates for specific origins that |
| + // are not ALLOW/BLOCK/DEFAULT on Android. |
| + DCHECK(setting == CONTENT_SETTING_ALLOW || |
| + setting == CONTENT_SETTING_BLOCK || |
| + setting == CONTENT_SETTING_DEFAULT); |
| + } |
| +#endif |
|
raymes
2017/06/06 01:08:14
This is getting complicated and I'm not quite happ
awdf
2017/06/08 14:46:11
I agree there's got to be a nicer way to ensure ou
|
| + |
| UsedContentSettingsProviders(); |
| for (const auto& provider_pair : content_settings_providers_) { |
| @@ -910,4 +931,4 @@ HostContentSettingsMap::GetContentSettingValueAndPatterns( |
| void HostContentSettingsMap::SetClockForTesting( |
| std::unique_ptr<base::Clock> clock) { |
| pref_provider_->SetClockForTesting(std::move(clock)); |
| -} |
| +} |