Skip to content

Commit

Permalink
Merge pull request #3553 from brave/francois-disable-sensors-backgrou…
Browse files Browse the repository at this point in the history
…nd-sync

Disable motion sensors and background sync by default
  • Loading branch information
fmarier committed Oct 1, 2019
2 parents 2a3b0c4 + 2026542 commit e325ae9
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 49 deletions.
Original file line number Diff line number Diff line change
@@ -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
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
+++ 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.

0 comments on commit e325ae9

Please sign in to comment.