Chromium Code Reviews| Index: components/content_settings/core/browser/content_settings_registry.cc |
| diff --git a/components/content_settings/core/browser/content_settings_registry.cc b/components/content_settings/core/browser/content_settings_registry.cc |
| index acefb02f31da35ec104d587461ca060d8c79c629..1cfca224cf0365e10b36fc2c38ed686c8002635b 100644 |
| --- a/components/content_settings/core/browser/content_settings_registry.cc |
| +++ b/components/content_settings/core/browser/content_settings_registry.cc |
| @@ -124,6 +124,7 @@ void ContentSettingsRegistry::Init() { |
| ValidSettings(CONTENT_SETTING_ALLOW, CONTENT_SETTING_BLOCK, |
| CONTENT_SETTING_SESSION_ONLY), |
| WebsiteSettingsInfo::REQUESTING_DOMAIN_ONLY_SCOPE, |
| + WebsiteSettingsRegistry::ALL_PLATFORMS, |
| ContentSettingsInfo::INHERIT_IN_INCOGNITO); |
| Register(CONTENT_SETTINGS_TYPE_IMAGES, "images", CONTENT_SETTING_ALLOW, |
| @@ -132,6 +133,7 @@ void ContentSettingsRegistry::Init() { |
| kExtensionScheme), |
| ValidSettings(CONTENT_SETTING_ALLOW, CONTENT_SETTING_BLOCK), |
| WebsiteSettingsInfo::TOP_LEVEL_DOMAIN_ONLY_SCOPE, |
| + WebsiteSettingsRegistry::DESKTOP, |
| ContentSettingsInfo::INHERIT_IN_INCOGNITO); |
| Register(CONTENT_SETTINGS_TYPE_JAVASCRIPT, "javascript", |
| @@ -140,6 +142,8 @@ void ContentSettingsRegistry::Init() { |
| kExtensionScheme), |
| ValidSettings(CONTENT_SETTING_ALLOW, CONTENT_SETTING_BLOCK), |
| WebsiteSettingsInfo::TOP_LEVEL_DOMAIN_ONLY_SCOPE, |
| + WebsiteSettingsRegistry::DESKTOP | |
| + WebsiteSettingsRegistry::PLATFORM_ANDROID, |
| ContentSettingsInfo::INHERIT_IN_INCOGNITO); |
| Register(CONTENT_SETTINGS_TYPE_PLUGINS, "plugins", |
| @@ -150,6 +154,7 @@ void ContentSettingsRegistry::Init() { |
| CONTENT_SETTING_ASK, |
| CONTENT_SETTING_DETECT_IMPORTANT_CONTENT), |
| WebsiteSettingsInfo::TOP_LEVEL_DOMAIN_ONLY_SCOPE, |
| + WebsiteSettingsRegistry::DESKTOP, |
| ContentSettingsInfo::INHERIT_IN_INCOGNITO); |
| Register(CONTENT_SETTINGS_TYPE_POPUPS, "popups", CONTENT_SETTING_BLOCK, |
| @@ -158,6 +163,7 @@ void ContentSettingsRegistry::Init() { |
| kExtensionScheme), |
| ValidSettings(CONTENT_SETTING_ALLOW, CONTENT_SETTING_BLOCK), |
| WebsiteSettingsInfo::TOP_LEVEL_DOMAIN_ONLY_SCOPE, |
| + WebsiteSettingsRegistry::ALL_PLATFORMS, |
| ContentSettingsInfo::INHERIT_IN_INCOGNITO); |
| Register(CONTENT_SETTINGS_TYPE_GEOLOCATION, "geolocation", |
| @@ -166,6 +172,8 @@ void ContentSettingsRegistry::Init() { |
| ValidSettings(CONTENT_SETTING_ALLOW, CONTENT_SETTING_BLOCK, |
| CONTENT_SETTING_ASK), |
| WebsiteSettingsInfo::REQUESTING_ORIGIN_AND_TOP_LEVEL_ORIGIN_SCOPE, |
| + WebsiteSettingsRegistry::DESKTOP | |
| + WebsiteSettingsRegistry::PLATFORM_ANDROID, |
| ContentSettingsInfo::INHERIT_IN_INCOGNITO); |
| Register(CONTENT_SETTINGS_TYPE_NOTIFICATIONS, "notifications", |
| @@ -174,6 +182,8 @@ void ContentSettingsRegistry::Init() { |
| ValidSettings(CONTENT_SETTING_ALLOW, CONTENT_SETTING_BLOCK, |
| CONTENT_SETTING_ASK), |
| WebsiteSettingsInfo::REQUESTING_ORIGIN_ONLY_SCOPE, |
| + WebsiteSettingsRegistry::DESKTOP | |
| + WebsiteSettingsRegistry::PLATFORM_ANDROID, |
| // See also NotificationPermissionContext::DecidePermission which |
| // implements additional incognito exceptions. |
| ContentSettingsInfo::INHERIT_IN_INCOGNITO_EXCEPT_ALLOW); |
| @@ -183,6 +193,8 @@ void ContentSettingsRegistry::Init() { |
| WhitelistedSchemes(kChromeUIScheme, kChromeDevToolsScheme), |
| ValidSettings(CONTENT_SETTING_ALLOW, CONTENT_SETTING_ASK), |
| WebsiteSettingsInfo::REQUESTING_ORIGIN_AND_TOP_LEVEL_ORIGIN_SCOPE, |
| + WebsiteSettingsRegistry::DESKTOP | |
| + WebsiteSettingsRegistry::PLATFORM_ANDROID, |
| ContentSettingsInfo::INHERIT_IN_INCOGNITO); |
| Register(CONTENT_SETTINGS_TYPE_MOUSELOCK, "mouselock", CONTENT_SETTING_ASK, |
| @@ -191,6 +203,7 @@ void ContentSettingsRegistry::Init() { |
| ValidSettings(CONTENT_SETTING_ALLOW, CONTENT_SETTING_BLOCK, |
| CONTENT_SETTING_ASK), |
| WebsiteSettingsInfo::TOP_LEVEL_DOMAIN_ONLY_SCOPE, |
| + WebsiteSettingsRegistry::DESKTOP, |
| ContentSettingsInfo::INHERIT_IN_INCOGNITO); |
| Register(CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, "media-stream-mic", |
| @@ -199,6 +212,8 @@ void ContentSettingsRegistry::Init() { |
| ValidSettings(CONTENT_SETTING_ALLOW, CONTENT_SETTING_BLOCK, |
| CONTENT_SETTING_ASK), |
| WebsiteSettingsInfo::REQUESTING_ORIGIN_ONLY_SCOPE, |
| + WebsiteSettingsRegistry::DESKTOP | |
| + WebsiteSettingsRegistry::PLATFORM_ANDROID, |
| ContentSettingsInfo::INHERIT_IN_INCOGNITO); |
| Register(CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, "media-stream-camera", |
| @@ -207,6 +222,8 @@ void ContentSettingsRegistry::Init() { |
| ValidSettings(CONTENT_SETTING_ALLOW, CONTENT_SETTING_BLOCK, |
| CONTENT_SETTING_ASK), |
| WebsiteSettingsInfo::REQUESTING_ORIGIN_ONLY_SCOPE, |
| + WebsiteSettingsRegistry::DESKTOP | |
| + WebsiteSettingsRegistry::PLATFORM_ANDROID, |
| ContentSettingsInfo::INHERIT_IN_INCOGNITO); |
| Register(CONTENT_SETTINGS_TYPE_PPAPI_BROKER, "ppapi-broker", |
| @@ -215,6 +232,7 @@ void ContentSettingsRegistry::Init() { |
| ValidSettings(CONTENT_SETTING_ALLOW, CONTENT_SETTING_BLOCK, |
| CONTENT_SETTING_ASK), |
| WebsiteSettingsInfo::REQUESTING_ORIGIN_ONLY_SCOPE, |
| + WebsiteSettingsRegistry::DESKTOP, |
| ContentSettingsInfo::INHERIT_IN_INCOGNITO); |
| Register(CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, "automatic-downloads", |
| @@ -224,6 +242,8 @@ void ContentSettingsRegistry::Init() { |
| ValidSettings(CONTENT_SETTING_ALLOW, CONTENT_SETTING_BLOCK, |
| CONTENT_SETTING_ASK), |
| WebsiteSettingsInfo::TOP_LEVEL_DOMAIN_ONLY_SCOPE, |
| + WebsiteSettingsRegistry::DESKTOP | |
| + WebsiteSettingsRegistry::PLATFORM_ANDROID, |
| ContentSettingsInfo::INHERIT_IN_INCOGNITO); |
| Register(CONTENT_SETTINGS_TYPE_MIDI_SYSEX, "midi-sysex", CONTENT_SETTING_ASK, |
| @@ -231,6 +251,8 @@ void ContentSettingsRegistry::Init() { |
| ValidSettings(CONTENT_SETTING_ALLOW, CONTENT_SETTING_BLOCK, |
| CONTENT_SETTING_ASK), |
| WebsiteSettingsInfo::REQUESTING_ORIGIN_AND_TOP_LEVEL_ORIGIN_SCOPE, |
| + WebsiteSettingsRegistry::DESKTOP | |
| + WebsiteSettingsRegistry::PLATFORM_ANDROID, |
| ContentSettingsInfo::INHERIT_IN_INCOGNITO); |
| Register(CONTENT_SETTINGS_TYPE_PUSH_MESSAGING, "push-messaging", |
| @@ -239,30 +261,35 @@ void ContentSettingsRegistry::Init() { |
| ValidSettings(CONTENT_SETTING_ALLOW, CONTENT_SETTING_BLOCK, |
| CONTENT_SETTING_ASK), |
| WebsiteSettingsInfo::REQUESTING_ORIGIN_AND_TOP_LEVEL_ORIGIN_SCOPE, |
| + WebsiteSettingsRegistry::DESKTOP | |
| + WebsiteSettingsRegistry::PLATFORM_ANDROID, |
| ContentSettingsInfo::INHERIT_IN_INCOGNITO_EXCEPT_ALLOW); |
| -#if defined(OS_ANDROID) || defined(OS_CHROMEOS) |
| Register(CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER, |
| "protected-media-identifier", CONTENT_SETTING_ASK, |
| WebsiteSettingsInfo::UNSYNCABLE, WhitelistedSchemes(), |
| ValidSettings(CONTENT_SETTING_ALLOW, CONTENT_SETTING_BLOCK, |
| CONTENT_SETTING_ASK), |
| WebsiteSettingsInfo::REQUESTING_ORIGIN_AND_TOP_LEVEL_ORIGIN_SCOPE, |
| + WebsiteSettingsRegistry::PLATFORM_ANDROID | |
| + WebsiteSettingsRegistry::PLATFORM_CHROMEOS, |
| ContentSettingsInfo::INHERIT_IN_INCOGNITO); |
| -#endif |
| Register(CONTENT_SETTINGS_TYPE_DURABLE_STORAGE, "durable-storage", |
| CONTENT_SETTING_ASK, WebsiteSettingsInfo::UNSYNCABLE, |
| WhitelistedSchemes(), |
| ValidSettings(CONTENT_SETTING_ALLOW, CONTENT_SETTING_BLOCK), |
| WebsiteSettingsInfo::REQUESTING_ORIGIN_ONLY_SCOPE, |
| + WebsiteSettingsRegistry::DESKTOP | |
| + WebsiteSettingsRegistry::PLATFORM_ANDROID, |
| ContentSettingsInfo::INHERIT_IN_INCOGNITO); |
| - Register(CONTENT_SETTINGS_TYPE_KEYGEN, "keygen", |
| - CONTENT_SETTING_BLOCK, WebsiteSettingsInfo::SYNCABLE, |
| - WhitelistedSchemes(), |
| + Register(CONTENT_SETTINGS_TYPE_KEYGEN, "keygen", CONTENT_SETTING_BLOCK, |
| + WebsiteSettingsInfo::SYNCABLE, WhitelistedSchemes(), |
| ValidSettings(CONTENT_SETTING_ALLOW, CONTENT_SETTING_BLOCK), |
| WebsiteSettingsInfo::REQUESTING_ORIGIN_ONLY_SCOPE, |
| + WebsiteSettingsRegistry::DESKTOP | |
| + WebsiteSettingsRegistry::PLATFORM_ANDROID, |
| ContentSettingsInfo::INHERIT_IN_INCOGNITO); |
| Register(CONTENT_SETTINGS_TYPE_BACKGROUND_SYNC, "background-sync", |
| @@ -270,13 +297,16 @@ void ContentSettingsRegistry::Init() { |
| WhitelistedSchemes(), |
| ValidSettings(CONTENT_SETTING_ALLOW, CONTENT_SETTING_BLOCK), |
| WebsiteSettingsInfo::REQUESTING_ORIGIN_ONLY_SCOPE, |
| + WebsiteSettingsRegistry::DESKTOP | |
| + WebsiteSettingsRegistry::PLATFORM_ANDROID, |
| ContentSettingsInfo::INHERIT_IN_INCOGNITO); |
| - Register(CONTENT_SETTINGS_TYPE_AUTOPLAY, "autoplay", |
| - CONTENT_SETTING_ALLOW, WebsiteSettingsInfo::UNSYNCABLE, |
| - WhitelistedSchemes(), |
| + Register(CONTENT_SETTINGS_TYPE_AUTOPLAY, "autoplay", CONTENT_SETTING_ALLOW, |
| + WebsiteSettingsInfo::UNSYNCABLE, WhitelistedSchemes(), |
| ValidSettings(CONTENT_SETTING_ALLOW, CONTENT_SETTING_BLOCK), |
| WebsiteSettingsInfo::REQUESTING_ORIGIN_ONLY_SCOPE, |
| + WebsiteSettingsRegistry::DESKTOP | |
| + WebsiteSettingsRegistry::PLATFORM_ANDROID, |
| ContentSettingsInfo::INHERIT_IN_INCOGNITO); |
| // Content settings that aren't used to store any data. TODO(raymes): use a |
| @@ -287,12 +317,14 @@ void ContentSettingsRegistry::Init() { |
| CONTENT_SETTING_DEFAULT, WebsiteSettingsInfo::UNSYNCABLE, |
| WhitelistedSchemes(), ValidSettings(), |
| WebsiteSettingsInfo::TOP_LEVEL_DOMAIN_ONLY_SCOPE, |
| + WebsiteSettingsRegistry::DESKTOP, |
| ContentSettingsInfo::INHERIT_IN_INCOGNITO); |
| Register(CONTENT_SETTINGS_TYPE_MIXEDSCRIPT, "mixed-script", |
| CONTENT_SETTING_DEFAULT, WebsiteSettingsInfo::UNSYNCABLE, |
| WhitelistedSchemes(), ValidSettings(), |
| WebsiteSettingsInfo::TOP_LEVEL_DOMAIN_ONLY_SCOPE, |
| + WebsiteSettingsRegistry::DESKTOP, |
| ContentSettingsInfo::INHERIT_IN_INCOGNITO); |
| Register(CONTENT_SETTINGS_TYPE_BLUETOOTH_GUARD, "bluetooth-guard", |
| @@ -300,6 +332,8 @@ void ContentSettingsRegistry::Init() { |
| WhitelistedSchemes(), |
| ValidSettings(CONTENT_SETTING_ASK, CONTENT_SETTING_BLOCK), |
| WebsiteSettingsInfo::REQUESTING_ORIGIN_AND_TOP_LEVEL_ORIGIN_SCOPE, |
| + WebsiteSettingsRegistry::DESKTOP | |
| + WebsiteSettingsRegistry::PLATFORM_ANDROID, |
| ContentSettingsInfo::INHERIT_IN_INCOGNITO); |
| } |
| @@ -311,6 +345,7 @@ void ContentSettingsRegistry::Register( |
| const std::vector<std::string>& whitelisted_schemes, |
| const std::set<ContentSetting>& valid_settings, |
| WebsiteSettingsInfo::ScopingType scoping_type, |
| + Platforms platforms, |
| ContentSettingsInfo::IncognitoBehavior incognito_behavior) { |
| // Ensure that nothing has been registered yet for the given type. |
| DCHECK(!website_settings_registry_->Get(type)); |
| @@ -324,8 +359,14 @@ void ContentSettingsRegistry::Register( |
| const WebsiteSettingsInfo* website_settings_info = |
| website_settings_registry_->Register( |
| type, name, std::move(default_value), sync_status, |
| - WebsiteSettingsInfo::NOT_LOSSY, scoping_type, |
| + WebsiteSettingsInfo::NOT_LOSSY, scoping_type, platforms, |
| WebsiteSettingsInfo::INHERIT_IN_INCOGNITO); |
| + |
| + // WebsiteSettingsInfo::Register() will return nullptr if content setting type |
| + // is not used on current platform and don't need to be registered. |
|
raymes
2016/05/30 00:35:58
nit: is not used on the current platform and doesn
lshang
2016/05/30 03:22:11
Done.
|
| + if (!website_settings_info) |
| + return; |
| + |
| DCHECK(!ContainsKey(content_settings_info_, type)); |
| content_settings_info_[type] = base::WrapUnique( |
| new ContentSettingsInfo(website_settings_info, whitelisted_schemes, |