summaryrefslogtreecommitdiffstats
path: root/components/content_settings
diff options
context:
space:
mode:
Diffstat (limited to 'components/content_settings')
-rw-r--r--components/content_settings/core/browser/BUILD.gn2
-rw-r--r--components/content_settings/core/browser/content_settings_override_provider.cc107
-rw-r--r--components/content_settings/core/browser/content_settings_override_provider.h80
-rw-r--r--components/content_settings/core/browser/host_content_settings_map.cc65
-rw-r--r--components/content_settings/core/browser/host_content_settings_map.h31
-rw-r--r--components/content_settings/core/common/pref_names.cc5
-rw-r--r--components/content_settings/core/common/pref_names.h1
7 files changed, 4 insertions, 287 deletions
diff --git a/components/content_settings/core/browser/BUILD.gn b/components/content_settings/core/browser/BUILD.gn
index 1c004f7..173ffd6 100644
--- a/components/content_settings/core/browser/BUILD.gn
+++ b/components/content_settings/core/browser/BUILD.gn
@@ -16,8 +16,6 @@ static_library("browser") {
"content_settings_observer.h",
"content_settings_origin_identifier_value_map.cc",
"content_settings_origin_identifier_value_map.h",
- "content_settings_override_provider.cc",
- "content_settings_override_provider.h",
"content_settings_policy_provider.cc",
"content_settings_policy_provider.h",
"content_settings_pref.cc",
diff --git a/components/content_settings/core/browser/content_settings_override_provider.cc b/components/content_settings/core/browser/content_settings_override_provider.cc
deleted file mode 100644
index ee04dc9..0000000
--- a/components/content_settings/core/browser/content_settings_override_provider.cc
+++ /dev/null
@@ -1,107 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "components/content_settings/core/browser/content_settings_override_provider.h"
-
-#include <string>
-
-#include "base/auto_reset.h"
-#include "base/prefs/pref_service.h"
-#include "base/prefs/scoped_user_pref_update.h"
-#include "base/values.h"
-#include "components/content_settings/core/browser/content_settings_binary_value_map.h"
-#include "components/content_settings/core/browser/content_settings_rule.h"
-#include "components/content_settings/core/browser/content_settings_utils.h"
-#include "components/content_settings/core/common/content_settings.h"
-#include "components/content_settings/core/common/content_settings_pattern.h"
-#include "components/content_settings/core/common/pref_names.h"
-#include "components/pref_registry/pref_registry_syncable.h"
-
-namespace content_settings {
-
-// static
-void OverrideProvider::RegisterProfilePrefs(
- user_prefs::PrefRegistrySyncable* registry) {
- registry->RegisterDictionaryPref(
- prefs::kOverrideContentSettings,
- user_prefs::PrefRegistrySyncable::SYNCABLE_PREF);
-}
-
-OverrideProvider::OverrideProvider(PrefService* prefs, bool incognito)
- : prefs_(prefs), is_incognito_(incognito) {
- DCHECK(prefs_);
-
- // Read global overrides.
- ReadOverrideSettings();
-}
-
-OverrideProvider::~OverrideProvider() {
-}
-
-RuleIterator* OverrideProvider::GetRuleIterator(
- ContentSettingsType content_type,
- const ResourceIdentifier& resource_identifier,
- bool incognito) const {
- scoped_ptr<base::AutoLock> auto_lock(new base::AutoLock(lock_));
- return allowed_settings_.GetRuleIterator(content_type, resource_identifier,
- auto_lock.Pass());
-}
-
-void OverrideProvider::ClearAllContentSettingsRules(
- ContentSettingsType content_type) {
-}
-
-bool OverrideProvider::SetWebsiteSetting(
- const ContentSettingsPattern& primary_pattern,
- const ContentSettingsPattern& secondary_pattern,
- ContentSettingsType content_type,
- const ResourceIdentifier& resource_identifier,
- base::Value* in_value) {
- return false;
-}
-
-void OverrideProvider::ShutdownOnUIThread() {
- DCHECK(prefs_);
- prefs_ = NULL;
-}
-
-void OverrideProvider::SetOverrideSetting(ContentSettingsType content_type,
- bool enabled) {
- DCHECK(thread_checker_.CalledOnValidThread());
- DCHECK(prefs_);
-
- // Disallow incognito to change the state.
- DCHECK(!is_incognito_);
-
- base::AutoLock auto_lock(lock_);
- DictionaryPrefUpdate update(prefs_, prefs::kOverrideContentSettings);
- base::DictionaryValue* default_settings_dictionary = update.Get();
- allowed_settings_.SetContentSettingDisabled(content_type, !enabled);
- if (enabled) {
- default_settings_dictionary->RemoveWithoutPathExpansion(
- GetTypeName(content_type), NULL);
- } else {
- default_settings_dictionary->SetWithoutPathExpansion(
- GetTypeName(content_type), new base::FundamentalValue(true));
- }
-}
-
-bool OverrideProvider::IsEnabled(ContentSettingsType content_type) const {
- base::AutoLock auto_lock(lock_);
- return allowed_settings_.IsContentSettingEnabled(content_type);
-}
-
-void OverrideProvider::ReadOverrideSettings() {
- const base::DictionaryValue* blocked_settings_dictionary =
- prefs_->GetDictionary(prefs::kOverrideContentSettings);
-
- for (int type = 0; type < CONTENT_SETTINGS_NUM_TYPES; ++type) {
- ContentSettingsType content_type = ContentSettingsType(type);
- if (blocked_settings_dictionary->HasKey(GetTypeName(content_type))) {
- allowed_settings_.SetContentSettingDisabled(content_type, true);
- }
- }
-}
-
-} // namespace content_settings
diff --git a/components/content_settings/core/browser/content_settings_override_provider.h b/components/content_settings/core/browser/content_settings_override_provider.h
deleted file mode 100644
index ca61f60..0000000
--- a/components/content_settings/core/browser/content_settings_override_provider.h
+++ /dev/null
@@ -1,80 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_CONTENT_SETTINGS_OVERRIDE_PROVIDER_H_
-#define COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_CONTENT_SETTINGS_OVERRIDE_PROVIDER_H_
-
-#include "base/macros.h"
-#include "base/synchronization/lock.h"
-#include "base/threading/thread_checker.h"
-#include "components/content_settings/core/browser/content_settings_binary_value_map.h"
-#include "components/content_settings/core/browser/content_settings_provider.h"
-#include "components/content_settings/core/common/content_settings_types.h"
-
-class ContentSettingsPattern;
-class PrefService;
-
-namespace user_prefs {
-class PrefRegistrySyncable;
-}
-
-namespace content_settings {
-
-// OverrideProvider contains if certain content settings are enabled or
-// globally disabled. It may only be written to using the UI thread, but may be
-// read on any thread.
-class OverrideProvider : public ProviderInterface {
- public:
- static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
-
- OverrideProvider(PrefService* prefs, bool incognito);
- ~OverrideProvider() override;
-
- // ProviderInterface implementations.
- RuleIterator* GetRuleIterator(ContentSettingsType content_type,
- const ResourceIdentifier& resource_identifier,
- bool incognito) const override;
-
- void ClearAllContentSettingsRules(ContentSettingsType content_type) override;
-
- bool SetWebsiteSetting(const ContentSettingsPattern& primary_pattern,
- const ContentSettingsPattern& secondary_pattern,
- ContentSettingsType content_type,
- const ResourceIdentifier& resource_identifier,
- base::Value* value) override;
-
- void ShutdownOnUIThread() override;
-
- // Sets if a given |content_type| is |enabled|.
- void SetOverrideSetting(ContentSettingsType content_type, bool enabled);
-
- // Returns if |content_type| is enabled. If it is not enabled, the content
- // setting type is considered globally disabled and acts as though it is
- // blocked. If it is enabled, the content setting type's permission is granted
- // by the other providers.
- bool IsEnabled(ContentSettingsType content_type) const;
-
- private:
- // Reads the override settings from the preferences service.
- void ReadOverrideSettings();
-
- // Copies of the pref data, so that we can read it on the IO thread.
- BinaryValueMap allowed_settings_;
-
- PrefService* prefs_;
-
- bool is_incognito_;
-
- // Used around accesses to the |override_content_settings_| object to
- // guarantee thread safety.
- mutable base::Lock lock_;
-
- base::ThreadChecker thread_checker_;
-
- DISALLOW_COPY_AND_ASSIGN(OverrideProvider);
-};
-
-} // namespace content_settings
-
-#endif // COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_CONTENT_SETTINGS_OVERRIDE_PROVIDER_H_
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 b76fd31..d11ca9b 100644
--- a/components/content_settings/core/browser/host_content_settings_map.cc
+++ b/components/content_settings/core/browser/host_content_settings_map.cc
@@ -40,7 +40,6 @@ const char* kProviderNames[] = {
"policy",
"supervised_user",
"extension",
- "override",
"preference",
"default"
};
@@ -62,7 +61,6 @@ content_settings::SettingSource kProviderSourceMap[] = {
content_settings::SETTING_SOURCE_EXTENSION,
content_settings::SETTING_SOURCE_USER,
content_settings::SETTING_SOURCE_USER,
- content_settings::SETTING_SOURCE_USER,
};
static_assert(arraysize(kProviderSourceMap) ==
HostContentSettingsMap::NUM_PROVIDER_TYPES,
@@ -98,9 +96,6 @@ HostContentSettingsMap::HostContentSettingsMap(PrefService* prefs,
new content_settings::DefaultProvider(prefs_, is_off_the_record_);
default_provider->AddObserver(this);
content_settings_providers_[DEFAULT_PROVIDER] = default_provider;
-
- content_settings_providers_[OVERRIDE_PROVIDER] =
- new content_settings::OverrideProvider(prefs_, is_off_the_record_);
}
// static
@@ -112,7 +107,6 @@ void HostContentSettingsMap::RegisterProfilePrefs(
content_settings::DefaultProvider::RegisterProfilePrefs(registry);
content_settings::PrefProvider::RegisterProfilePrefs(registry);
content_settings::PolicyProvider::RegisterProfilePrefs(registry);
- content_settings::OverrideProvider::RegisterProfilePrefs(registry);
}
void HostContentSettingsMap::RegisterProvider(
@@ -160,8 +154,7 @@ ContentSetting HostContentSettingsMap::GetDefaultContentSetting(
for (ConstProviderIterator provider = content_settings_providers_.begin();
provider != content_settings_providers_.end();
++provider) {
- if (provider->first == PREF_PROVIDER ||
- provider->first == OVERRIDE_PROVIDER)
+ if (provider->first == PREF_PROVIDER)
continue;
ContentSetting default_setting =
GetDefaultContentSettingFromProvider(content_type, provider->second);
@@ -199,8 +192,6 @@ void HostContentSettingsMap::GetSettingsForOneType(
for (ConstProviderIterator provider = content_settings_providers_.begin();
provider != content_settings_providers_.end();
++provider) {
- if (provider->first == OVERRIDE_PROVIDER)
- continue;
// For each provider, iterate first the incognito-specific rules, then the
// normal rules.
if (is_off_the_record_) {
@@ -375,52 +366,6 @@ base::Time HostContentSettingsMap::GetLastUsageByPattern(
primary_pattern, secondary_pattern, content_type);
}
-ContentSetting HostContentSettingsMap::GetContentSettingWithoutOverride(
- const GURL& primary_url,
- const GURL& secondary_url,
- ContentSettingsType content_type,
- const std::string& resource_identifier) {
- scoped_ptr<base::Value> value(GetWebsiteSettingWithoutOverride(
- primary_url, secondary_url, content_type, resource_identifier, NULL));
- return content_settings::ValueToContentSetting(value.get());
-}
-
-scoped_ptr<base::Value>
-HostContentSettingsMap::GetWebsiteSettingWithoutOverride(
- const GURL& primary_url,
- const GURL& secondary_url,
- ContentSettingsType content_type,
- const std::string& resource_identifier,
- content_settings::SettingInfo* info) const {
- return GetWebsiteSettingInternal(primary_url,
- secondary_url,
- content_type,
- resource_identifier,
- info,
- false);
-}
-
-void HostContentSettingsMap::SetContentSettingOverride(
- ContentSettingsType content_type,
- bool is_enabled) {
- UsedContentSettingsProviders();
-
- content_settings::OverrideProvider* override =
- static_cast<content_settings::OverrideProvider*>(
- content_settings_providers_[OVERRIDE_PROVIDER]);
- override->SetOverrideSetting(content_type, is_enabled);
-}
-
-bool HostContentSettingsMap::GetContentSettingOverride(
- ContentSettingsType content_type) {
- UsedContentSettingsProviders();
-
- content_settings::OverrideProvider* override =
- static_cast<content_settings::OverrideProvider*>(
- content_settings_providers_[OVERRIDE_PROVIDER]);
- return override->IsEnabled(content_type);
-}
-
void HostContentSettingsMap::AddObserver(content_settings::Observer* observer) {
observers_.AddObserver(observer);
}
@@ -711,8 +656,7 @@ scoped_ptr<base::Value> HostContentSettingsMap::GetWebsiteSetting(
secondary_url,
content_type,
resource_identifier,
- info,
- true);
+ info);
}
// static
@@ -737,8 +681,7 @@ scoped_ptr<base::Value> HostContentSettingsMap::GetWebsiteSettingInternal(
const GURL& secondary_url,
ContentSettingsType content_type,
const std::string& resource_identifier,
- content_settings::SettingInfo* info,
- bool get_override) const {
+ content_settings::SettingInfo* info) const {
// TODO(msramek): MEDIASTREAM is deprecated. Remove this check when all
// references to MEDIASTREAM are removed from the code.
DCHECK_NE(CONTENT_SETTINGS_TYPE_MEDIASTREAM, content_type);
@@ -756,8 +699,6 @@ scoped_ptr<base::Value> HostContentSettingsMap::GetWebsiteSettingInternal(
for (ConstProviderIterator provider = content_settings_providers_.begin();
provider != content_settings_providers_.end();
++provider) {
- if (!get_override && provider->first == OVERRIDE_PROVIDER)
- continue;
scoped_ptr<base::Value> value(
content_settings::GetContentSettingValueAndPatterns(provider->second,
diff --git a/components/content_settings/core/browser/host_content_settings_map.h b/components/content_settings/core/browser/host_content_settings_map.h
index c77192c..b8f6edb 100644
--- a/components/content_settings/core/browser/host_content_settings_map.h
+++ b/components/content_settings/core/browser/host_content_settings_map.h
@@ -19,7 +19,6 @@
#include "base/threading/platform_thread.h"
#include "base/threading/thread_checker.h"
#include "components/content_settings/core/browser/content_settings_observer.h"
-#include "components/content_settings/core/browser/content_settings_override_provider.h"
#include "components/content_settings/core/common/content_settings.h"
#include "components/content_settings/core/common/content_settings_pattern.h"
#include "components/content_settings/core/common/content_settings_types.h"
@@ -34,7 +33,6 @@ class Value;
}
namespace content_settings {
-class OverrideProvider;
class ObservableProvider;
class ProviderInterface;
class PrefProvider;
@@ -56,7 +54,6 @@ class HostContentSettingsMap
POLICY_PROVIDER,
SUPERVISED_PROVIDER,
CUSTOM_EXTENSION_PROVIDER,
- OVERRIDE_PROVIDER,
PREF_PROVIDER,
DEFAULT_PROVIDER,
NUM_PROVIDER_TYPES,
@@ -257,31 +254,6 @@ class HostContentSettingsMap
const ContentSettingsPattern& secondary_pattern,
ContentSettingsType content_type);
- // Returns the content setting without considering the global on/off toggle
- // for the content setting that matches the URLs.
- ContentSetting GetContentSettingWithoutOverride(
- const GURL& primary_url,
- const GURL& secondary_url,
- ContentSettingsType content_type,
- const std::string& resource_identifier);
-
- // Returns the single content setting |value| without considering the
- // global on/off toggle for the content setting that matches the given
- // patterns.
- scoped_ptr<base::Value> GetWebsiteSettingWithoutOverride(
- const GURL& primary_url,
- const GURL& secondary_url,
- ContentSettingsType content_type,
- const std::string& resource_identifier,
- content_settings::SettingInfo* info) const;
-
- // Sets globally if a given |content_type| |is_enabled|.
- void SetContentSettingOverride(ContentSettingsType content_type,
- bool is_enabled);
-
- // Returns if a given |content_type| is enabled.
- bool GetContentSettingOverride(ContentSettingsType content_type);
-
// Adds/removes an observer for content settings changes.
void AddObserver(content_settings::Observer* observer);
void RemoveObserver(content_settings::Observer* observer);
@@ -333,8 +305,7 @@ class HostContentSettingsMap
const GURL& secondary_url,
ContentSettingsType content_type,
const std::string& resource_identifier,
- content_settings::SettingInfo* info,
- bool get_override) const;
+ content_settings::SettingInfo* info) const;
content_settings::PrefProvider* GetPrefProvider();
diff --git a/components/content_settings/core/common/pref_names.cc b/components/content_settings/core/common/pref_names.cc
index 4e78675..71818e2 100644
--- a/components/content_settings/core/common/pref_names.cc
+++ b/components/content_settings/core/common/pref_names.cc
@@ -93,11 +93,6 @@ const char kDefaultDurableStorageSetting[] =
const char kMigratedDefaultMediaStreamSetting[] =
"profile.migrated_default_media_stream_content_settings";
-// Dictionary of content settings that can globally disallow all hosts by
-// default. If a value is set, it means the setting is globally disallowed.
-// If a value is not set, it means the setting is allowed.
-const char kOverrideContentSettings[] = "profile.override_content_settings";
-
// Preferences storing the content settings exceptions.
const char kContentSettingsCookiesPatternPairs[] =
"profile.content_settings.exceptions.cookies";
diff --git a/components/content_settings/core/common/pref_names.h b/components/content_settings/core/common/pref_names.h
index d6a5ce6..67fa3e7 100644
--- a/components/content_settings/core/common/pref_names.h
+++ b/components/content_settings/core/common/pref_names.h
@@ -14,7 +14,6 @@ extern const char kContentSettingsVersion[];
extern const char kContentSettingsPatternPairs[];
extern const char kContentSettingsWindowLastTabIndex[];
extern const char kDefaultContentSettings[];
-extern const char kOverrideContentSettings[];
extern const char kMigratedDefaultContentSettings[];
extern const char kDefaultCookiesSetting[];