diff --git a/chromium_src/components/content_settings/core/browser/content_settings_registry.cc b/chromium_src/components/content_settings/core/browser/content_settings_registry.cc index 3f996b054d86..ab91906cf04b 100644 --- a/chromium_src/components/content_settings/core/browser/content_settings_registry.cc +++ b/chromium_src/components/content_settings/core/browser/content_settings_registry.cc @@ -1,38 +1,71 @@ -#include "../../../../../../components/content_settings/core/browser/content_settings_registry.cc" - -namespace content_settings { - -void ContentSettingsRegistry::BraveInit() { - // Add CONTENT_SETTING_ASK and make it default for autoplay - content_settings_info_.erase(CONTENT_SETTINGS_TYPE_AUTOPLAY); - website_settings_registry_->UnRegister(CONTENT_SETTINGS_TYPE_AUTOPLAY); - Register(CONTENT_SETTINGS_TYPE_AUTOPLAY, "autoplay", CONTENT_SETTING_BLOCK, - WebsiteSettingsInfo::UNSYNCABLE, WhitelistedSchemes(), - ValidSettings(CONTENT_SETTING_ALLOW, CONTENT_SETTING_BLOCK, - CONTENT_SETTING_ASK), - WebsiteSettingsInfo::SINGLE_ORIGIN_ONLY_SCOPE, - WebsiteSettingsRegistry::DESKTOP | - WebsiteSettingsRegistry::PLATFORM_ANDROID, - ContentSettingsInfo::INHERIT_IN_INCOGNITO, - ContentSettingsInfo::PERSISTENT, - ContentSettingsInfo::EXCEPTIONS_ON_SECURE_AND_INSECURE_ORIGINS); +/* Copyright (c) 2019 The Brave Authors. All rights reserved. + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this file, + * You can obtain one at https://mozilla.org/MPL/2.0/. */ - // Change plugins default to CONTENT_SETTING_BLOCK - content_settings_info_.erase(CONTENT_SETTINGS_TYPE_PLUGINS); - website_settings_registry_->UnRegister(CONTENT_SETTINGS_TYPE_PLUGINS); - Register( - CONTENT_SETTINGS_TYPE_PLUGINS, "plugins", - CONTENT_SETTING_BLOCK, WebsiteSettingsInfo::SYNCABLE, - WhitelistedSchemes(kChromeUIScheme, kChromeDevToolsScheme), - ValidSettings(CONTENT_SETTING_ALLOW, CONTENT_SETTING_BLOCK, - CONTENT_SETTING_ASK, - CONTENT_SETTING_DETECT_IMPORTANT_CONTENT), - WebsiteSettingsInfo::SINGLE_ORIGIN_WITH_EMBEDDED_EXCEPTIONS_SCOPE, - WebsiteSettingsRegistry::DESKTOP | - WebsiteSettingsRegistry::PLATFORM_ANDROID, - ContentSettingsInfo::INHERIT_IN_INCOGNITO, - ContentSettingsInfo::EPHEMERAL, - ContentSettingsInfo::EXCEPTIONS_ON_SECURE_AND_INSECURE_ORIGINS); +#define BRAVE_INIT { \ + /* Add CONTENT_SETTING_ASK and make it default for autoplay*/ \ + content_settings_info_.erase(CONTENT_SETTINGS_TYPE_AUTOPLAY); \ + website_settings_registry_->UnRegister(CONTENT_SETTINGS_TYPE_AUTOPLAY); \ + Register(CONTENT_SETTINGS_TYPE_AUTOPLAY, "autoplay", CONTENT_SETTING_BLOCK, \ + WebsiteSettingsInfo::UNSYNCABLE, WhitelistedSchemes(), \ + ValidSettings(CONTENT_SETTING_ALLOW, CONTENT_SETTING_BLOCK, \ + CONTENT_SETTING_ASK), \ + WebsiteSettingsInfo::SINGLE_ORIGIN_ONLY_SCOPE, \ + WebsiteSettingsRegistry::DESKTOP | \ + WebsiteSettingsRegistry::PLATFORM_ANDROID, \ + ContentSettingsInfo::INHERIT_IN_INCOGNITO, \ + ContentSettingsInfo::PERSISTENT, \ + ContentSettingsInfo::EXCEPTIONS_ON_SECURE_AND_INSECURE_ORIGINS); \ + \ + /* Change plugins default to CONTENT_SETTING_BLOCK*/ \ + content_settings_info_.erase(CONTENT_SETTINGS_TYPE_PLUGINS); \ + website_settings_registry_->UnRegister(CONTENT_SETTINGS_TYPE_PLUGINS); \ + Register( \ + CONTENT_SETTINGS_TYPE_PLUGINS, "plugins", \ + CONTENT_SETTING_BLOCK, WebsiteSettingsInfo::SYNCABLE, \ + WhitelistedSchemes(kChromeUIScheme, kChromeDevToolsScheme), \ + ValidSettings(CONTENT_SETTING_ALLOW, CONTENT_SETTING_BLOCK, \ + CONTENT_SETTING_ASK, \ + CONTENT_SETTING_DETECT_IMPORTANT_CONTENT), \ + WebsiteSettingsInfo::SINGLE_ORIGIN_WITH_EMBEDDED_EXCEPTIONS_SCOPE, \ + WebsiteSettingsRegistry::DESKTOP | \ + WebsiteSettingsRegistry::PLATFORM_ANDROID, \ + ContentSettingsInfo::INHERIT_IN_INCOGNITO, \ + ContentSettingsInfo::EPHEMERAL, \ + ContentSettingsInfo::EXCEPTIONS_ON_SECURE_AND_INSECURE_ORIGINS); \ + \ + /* Disable background sync by default (brave/brave-browser#4709)*/ \ + content_settings_info_.erase(CONTENT_SETTINGS_TYPE_BACKGROUND_SYNC); \ + website_settings_registry_->UnRegister( \ + CONTENT_SETTINGS_TYPE_BACKGROUND_SYNC); \ + Register( \ + CONTENT_SETTINGS_TYPE_BACKGROUND_SYNC, "background-sync", \ + CONTENT_SETTING_BLOCK, WebsiteSettingsInfo::UNSYNCABLE, \ + WhitelistedSchemes(), \ + ValidSettings(CONTENT_SETTING_ALLOW, CONTENT_SETTING_BLOCK), \ + WebsiteSettingsInfo::SINGLE_ORIGIN_ONLY_SCOPE, \ + WebsiteSettingsRegistry::DESKTOP | \ + WebsiteSettingsRegistry::PLATFORM_ANDROID, \ + ContentSettingsInfo::INHERIT_IN_INCOGNITO, \ + ContentSettingsInfo::PERSISTENT, \ + ContentSettingsInfo::EXCEPTIONS_ON_SECURE_ORIGINS_ONLY); \ + \ + /* Disable motion sensors by default (brave/brave-browser#4789)*/ \ + content_settings_info_.erase(CONTENT_SETTINGS_TYPE_SENSORS); \ + website_settings_registry_->UnRegister(CONTENT_SETTINGS_TYPE_SENSORS); \ + Register( \ + CONTENT_SETTINGS_TYPE_SENSORS, "sensors", CONTENT_SETTING_BLOCK, \ + WebsiteSettingsInfo::UNSYNCABLE, WhitelistedSchemes(), \ + ValidSettings(CONTENT_SETTING_ALLOW, CONTENT_SETTING_BLOCK), \ + WebsiteSettingsInfo::SINGLE_ORIGIN_ONLY_SCOPE, \ + WebsiteSettingsRegistry::DESKTOP | \ + WebsiteSettingsRegistry::PLATFORM_ANDROID, \ + ContentSettingsInfo::INHERIT_IN_INCOGNITO, \ + ContentSettingsInfo::PERSISTENT, \ + ContentSettingsInfo::EXCEPTIONS_ON_SECURE_AND_INSECURE_ORIGINS); \ } -} // namespace content_settings +#include "../../../../../../components/content_settings/core/browser/content_settings_registry.cc" + +#undef BRAVE_INIT diff --git a/patches/components-content_settings-core-browser-content_settings_registry.cc.patch b/patches/components-content_settings-core-browser-content_settings_registry.cc.patch index 1773f443ab16..9d3bbe625da9 100644 --- a/patches/components-content_settings-core-browser-content_settings_registry.cc.patch +++ b/patches/components-content_settings-core-browser-content_settings_registry.cc.patch @@ -1,12 +1,12 @@ diff --git a/components/content_settings/core/browser/content_settings_registry.cc b/components/content_settings/core/browser/content_settings_registry.cc -index dc67564cd90fb1964de545b933ac5104dbfbc785..d9ca4251e5e9606566dcd88ba5f76f1dca0759cd 100644 +index dc67564cd90fb1964de545b933ac5104dbfbc785..95ce90bc2960359d65433038b225c6f3cf53d996 100644 --- a/components/content_settings/core/browser/content_settings_registry.cc +++ b/components/content_settings/core/browser/content_settings_registry.cc @@ -491,6 +491,7 @@ void ContentSettingsRegistry::Init() { ContentSettingsInfo::INHERIT_IF_LESS_PERMISSIVE, ContentSettingsInfo::PERSISTENT, ContentSettingsInfo::EXCEPTIONS_ON_SECURE_ORIGINS_ONLY); -+ BraveInit(); ++ BRAVE_INIT } void ContentSettingsRegistry::Register( diff --git a/patches/components-content_settings-core-browser-content_settings_registry.h.patch b/patches/components-content_settings-core-browser-content_settings_registry.h.patch deleted file mode 100644 index 33d2d60b1568..000000000000 --- a/patches/components-content_settings-core-browser-content_settings_registry.h.patch +++ /dev/null @@ -1,12 +0,0 @@ -diff --git a/components/content_settings/core/browser/content_settings_registry.h b/components/content_settings/core/browser/content_settings_registry.h -index 20c43a7ee297e2ddea849d903f5e12608e303095..4cc4e4b2bfff6231d80027c32a9d9598eb03a434 100644 ---- a/components/content_settings/core/browser/content_settings_registry.h -+++ b/components/content_settings/core/browser/content_settings_registry.h -@@ -53,6 +53,7 @@ class ContentSettingsRegistry { - ~ContentSettingsRegistry(); - - void Init(); -+ void BraveInit(); - - typedef uint32_t Platforms; -