Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable motion sensors and background sync by default #2802

Merged
merged 3 commits into from
Sep 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,38 +1,66 @@
#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)*/ \
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)*/ \
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
Original file line number Diff line number Diff line change
@@ -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
fmarier marked this conversation as resolved.
Show resolved Hide resolved
+++ 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(

This file was deleted.