diff options
author | knn <knn@chromium.org> | 2015-03-04 12:42:43 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-03-04 20:43:27 +0000 |
commit | 95221ffe02b9d0782202d80cf86766686afab13a (patch) | |
tree | b29e6c1d128c70419b070a5fc3be7efc549b9f26 | |
parent | 9e621293154d1419c1e270c923237958ef70a091 (diff) | |
download | chromium_src-95221ffe02b9d0782202d80cf86766686afab13a.zip chromium_src-95221ffe02b9d0782202d80cf86766686afab13a.tar.gz chromium_src-95221ffe02b9d0782202d80cf86766686afab13a.tar.bz2 |
Add a HostContentSettingsMap layer for Supervised Users.
Added a layer for Supervised Users in the HostContentSettingsMap.
As this only needs functionality to block the entire content setting
(for now), it is similar to the existing OverrideProvider.
Reorganized the common code between the two providers.
Updated the helper methods in PrefServiceBridge to check the
HostContentSettingsMap instead of Preferences when checking whether it
is managed by the custodian.
BUG=455646
BUG=455640
Review URL: https://codereview.chromium.org/902833003
Cr-Commit-Position: refs/heads/master@{#319121}
17 files changed, 334 insertions, 52 deletions
diff --git a/chrome/browser/android/preferences/pref_service_bridge.cc b/chrome/browser/android/preferences/pref_service_bridge.cc index 4512ce6..1ba7a70 100644 --- a/chrome/browser/android/preferences/pref_service_bridge.cc +++ b/chrome/browser/android/preferences/pref_service_bridge.cc @@ -104,6 +104,17 @@ bool IsContentSettingManaged(ContentSettingsType content_settings_type) { return provider == HostContentSettingsMap::POLICY_PROVIDER; } +bool IsContentSettingManagedByCustodian( + ContentSettingsType content_settings_type) { + std::string source; + HostContentSettingsMap* content_settings = + GetOriginalProfile()->GetHostContentSettingsMap(); + content_settings->GetDefaultContentSetting(content_settings_type, &source); + HostContentSettingsMap::ProviderType provider = + content_settings->GetProviderTypeFromSource(source); + return provider == HostContentSettingsMap::SUPERVISED_PROVIDER; +} + bool IsContentSettingUserModifiable(ContentSettingsType content_settings_type) { std::string source; HostContentSettingsMap* content_settings = @@ -230,8 +241,7 @@ static jboolean GetAllowLocationUserModifiable(JNIEnv* env, jobject obj) { } static jboolean GetAllowLocationManagedByCustodian(JNIEnv* env, jobject obj) { - return GetPrefService()->IsPreferenceManagedByCustodian( - prefs::kGeolocationEnabled); + return IsContentSettingManagedByCustodian(CONTENT_SETTINGS_TYPE_GEOLOCATION); } static jboolean GetResolveNavigationErrorEnabled(JNIEnv* env, jobject obj) { @@ -477,12 +487,7 @@ static jboolean GetCameraMicUserModifiable(JNIEnv* env, jobject obj) { } static jboolean GetCameraMicManagedByCustodian(JNIEnv* env, jobject obj) { - PrefService* prefs = GetPrefService(); - if (prefs->IsPreferenceManagedByCustodian(prefs::kVideoCaptureAllowed)) - return true; - if (prefs->IsPreferenceManagedByCustodian(prefs::kAudioCaptureAllowed)) - return true; - return false; + return IsContentSettingManagedByCustodian(CONTENT_SETTINGS_TYPE_MEDIASTREAM); } static jboolean GetAutologinEnabled(JNIEnv* env, jobject obj) { diff --git a/chrome/browser/content_settings/content_settings_supervised_provider.cc b/chrome/browser/content_settings/content_settings_supervised_provider.cc new file mode 100644 index 0000000..f448a0d --- /dev/null +++ b/chrome/browser/content_settings/content_settings_supervised_provider.cc @@ -0,0 +1,101 @@ +// Copyright (c) 2015 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 "chrome/browser/content_settings/content_settings_supervised_provider.h" + +#include <string> +#include <vector> + +#include "chrome/browser/supervised_user/supervised_user_constants.h" +#include "chrome/browser/supervised_user/supervised_user_settings_service.h" + +namespace { + +struct ContentSettingsFromSupervisedSettingsEntry { + const char* setting_name; + ContentSettingsType content_type; +}; + +const ContentSettingsFromSupervisedSettingsEntry + kContentSettingsFromSupervisedSettingsMap[] = { + { + supervised_users::kGeolocationDisabled, + CONTENT_SETTINGS_TYPE_GEOLOCATION, + }, { + supervised_users::kCameraMicDisabled, + CONTENT_SETTINGS_TYPE_MEDIASTREAM, + } +}; + +} // namespace + +namespace content_settings { + +SupervisedProvider::SupervisedProvider( + SupervisedUserSettingsService* supervised_user_settings_service) + : weak_ptr_factory_(this) { + supervised_user_settings_service->Subscribe(base::Bind( + &content_settings::SupervisedProvider::OnSupervisedSettingsAvailable, + weak_ptr_factory_.GetWeakPtr())); +} + +SupervisedProvider::~SupervisedProvider() { +} + +RuleIterator* SupervisedProvider::GetRuleIterator( + ContentSettingsType content_type, + const ResourceIdentifier& resource_identifier, + bool incognito) const { + scoped_ptr<base::AutoLock> auto_lock(new base::AutoLock(lock_)); + return value_map_.GetRuleIterator(content_type, resource_identifier, + auto_lock.Pass()); +} + +void SupervisedProvider::OnSupervisedSettingsAvailable( + const base::DictionaryValue* settings) { + if (!settings) + return; + std::vector<ContentSettingsType> to_notify; + // Entering locked scope to update content settings. + { + base::AutoLock auto_lock(lock_); + bool new_value, old_value; + for (const auto& entry : kContentSettingsFromSupervisedSettingsMap) { + if (settings->GetBoolean(entry.setting_name, &new_value)) { + old_value = !value_map_.IsContentSettingEnabled(entry.content_type); + if (new_value != old_value) { + to_notify.push_back(entry.content_type); + value_map_.SetContentSettingDisabled(entry.content_type, new_value); + } + } + } + } + for (const auto& notification : to_notify) { + NotifyObservers(ContentSettingsPattern(), ContentSettingsPattern(), + notification, std::string()); + } +} + +// Since the SupervisedProvider is a read only content settings provider, all +// methods of the ProviderInterface that set or delete any settings do nothing. +bool SupervisedProvider::SetWebsiteSetting( + const ContentSettingsPattern& primary_pattern, + const ContentSettingsPattern& secondary_pattern, + ContentSettingsType content_type, + const ResourceIdentifier& resource_identifier, + base::Value* value) { + return false; +} + +void SupervisedProvider::ClearAllContentSettingsRules( + ContentSettingsType content_type) { +} + +void SupervisedProvider::ShutdownOnUIThread() { + DCHECK(CalledOnValidThread()); + RemoveAllObservers(); + weak_ptr_factory_.InvalidateWeakPtrs(); +} + +} // namespace content_settings diff --git a/chrome/browser/content_settings/content_settings_supervised_provider.h b/chrome/browser/content_settings/content_settings_supervised_provider.h new file mode 100644 index 0000000..3a3ee13 --- /dev/null +++ b/chrome/browser/content_settings/content_settings_supervised_provider.h @@ -0,0 +1,59 @@ +// Copyright (c) 2015 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 CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_SUPERVISED_PROVIDER_H_ +#define CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_SUPERVISED_PROVIDER_H_ + +// A content setting provider that is set by the custodian of a supervised user. + +#include "base/synchronization/lock.h" +#include "components/content_settings/core/browser/content_settings_binary_value_map.h" +#include "components/content_settings/core/browser/content_settings_observable_provider.h" + +class PrefService; +class SupervisedUserSettingsService; + +namespace content_settings { + +// SupervisedProvider that provides content-settings managed by the custodian +// of a supervised user. +class SupervisedProvider : public ObservableProvider { + public: + explicit SupervisedProvider( + SupervisedUserSettingsService* supervised_user_settings_service); + ~SupervisedProvider() override; + + // ProviderInterface implementations. + RuleIterator* GetRuleIterator(ContentSettingsType content_type, + const ResourceIdentifier& resource_identifier, + bool incognito) const override; + + bool SetWebsiteSetting(const ContentSettingsPattern& primary_pattern, + const ContentSettingsPattern& secondary_pattern, + ContentSettingsType content_type, + const ResourceIdentifier& resource_identifier, + base::Value* value) override; + + void ClearAllContentSettingsRules(ContentSettingsType content_type) override; + + void ShutdownOnUIThread() override; + + // Callback on receiving settings from the supervised user settings service. + void OnSupervisedSettingsAvailable(const base::DictionaryValue* settings); + + private: + BinaryValueMap value_map_; + + // Used around accesses to the |value_map_| object to guarantee + // thread safety. + mutable base::Lock lock_; + + base::WeakPtrFactory<SupervisedProvider> weak_ptr_factory_; + + DISALLOW_COPY_AND_ASSIGN(SupervisedProvider); +}; + +} // namespace content_settings + +#endif // CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_SUPERVISED_PROVIDER_H_ diff --git a/chrome/browser/profiles/off_the_record_profile_impl.cc b/chrome/browser/profiles/off_the_record_profile_impl.cc index e998faf..d78b314 100644 --- a/chrome/browser/profiles/off_the_record_profile_impl.cc +++ b/chrome/browser/profiles/off_the_record_profile_impl.cc @@ -80,6 +80,12 @@ #include "extensions/common/extension.h" #endif +#if defined(ENABLE_SUPERVISED_USERS) +#include "chrome/browser/content_settings/content_settings_supervised_provider.h" +#include "chrome/browser/supervised_user/supervised_user_settings_service.h" +#include "chrome/browser/supervised_user/supervised_user_settings_service_factory.h" +#endif + using content::BrowserThread; using content::DownloadManagerDelegate; using content::HostZoomMap; @@ -392,6 +398,15 @@ HostContentSettingsMap* OffTheRecordProfileImpl::GetHostContentSettingsMap() { host_content_settings_map_.get()); } #endif +#if defined(ENABLE_SUPERVISED_USERS) + SupervisedUserSettingsService* supervised_service = + SupervisedUserSettingsServiceFactory::GetForProfile(this); + scoped_ptr<content_settings::SupervisedProvider> supervised_provider( + new content_settings::SupervisedProvider(supervised_service)); + host_content_settings_map_->RegisterProvider( + HostContentSettingsMap::SUPERVISED_PROVIDER, + supervised_provider.Pass()); +#endif } return host_content_settings_map_.get(); } diff --git a/chrome/browser/profiles/profile_impl.cc b/chrome/browser/profiles/profile_impl.cc index ae8aa8a..aa365dd 100644 --- a/chrome/browser/profiles/profile_impl.cc +++ b/chrome/browser/profiles/profile_impl.cc @@ -143,6 +143,7 @@ #endif #if defined(ENABLE_SUPERVISED_USERS) +#include "chrome/browser/content_settings/content_settings_supervised_provider.h" #include "chrome/browser/supervised_user/supervised_user_constants.h" #include "chrome/browser/supervised_user/supervised_user_settings_service.h" #include "chrome/browser/supervised_user/supervised_user_settings_service_factory.h" @@ -475,7 +476,7 @@ ProfileImpl::ProfileImpl( BrowserContextDependencyManager::GetInstance()-> RegisterProfilePrefsForServices(this, pref_registry_.get()); - SupervisedUserSettingsService* supervised_user_settings = NULL; + SupervisedUserSettingsService* supervised_user_settings = nullptr; #if defined(ENABLE_SUPERVISED_USERS) supervised_user_settings = SupervisedUserSettingsServiceFactory::GetForProfile(this); @@ -1040,6 +1041,15 @@ HostContentSettingsMap* ProfileImpl::GetHostContentSettingsMap() { DCHECK_CURRENTLY_ON(BrowserThread::UI); if (!host_content_settings_map_.get()) { host_content_settings_map_ = new HostContentSettingsMap(GetPrefs(), false); +#if defined(ENABLE_SUPERVISED_USERS) + SupervisedUserSettingsService* supervised_user_settings = + SupervisedUserSettingsServiceFactory::GetForProfile(this); + scoped_ptr<content_settings::SupervisedProvider> supervised_provider( + new content_settings::SupervisedProvider(supervised_user_settings)); + host_content_settings_map_->RegisterProvider( + HostContentSettingsMap::SUPERVISED_PROVIDER, + supervised_provider.Pass()); +#endif } return host_content_settings_map_.get(); } diff --git a/chrome/browser/supervised_user/supervised_user_constants.cc b/chrome/browser/supervised_user/supervised_user_constants.cc index a51b61c..889577c 100644 --- a/chrome/browser/supervised_user/supervised_user_constants.cc +++ b/chrome/browser/supervised_user/supervised_user_constants.cc @@ -6,13 +6,13 @@ namespace supervised_users { -const char kCameraMicAllowed[] = "CameraMicAllowed"; +const char kCameraMicDisabled[] = "CameraMicDisabled"; const char kContentPackDefaultFilteringBehavior[] = "ContentPackDefaultFilteringBehavior"; const char kContentPackManualBehaviorHosts[] = "ContentPackManualBehaviorHosts"; const char kContentPackManualBehaviorURLs[] = "ContentPackManualBehaviorURLs"; const char kForceSafeSearch[] = "ForceSafeSearch"; -const char kGeolocationAllowed[] = "GeolocationAllowed"; +const char kGeolocationDisabled[] = "GeolocationDisabled"; const char kRecordHistory[] = "RecordHistory"; const char kSigninAllowed[] = "SigninAllowed"; const char kUserName[] = "UserName"; diff --git a/chrome/browser/supervised_user/supervised_user_constants.h b/chrome/browser/supervised_user/supervised_user_constants.h index f72430b..e4aa3a0 100644 --- a/chrome/browser/supervised_user/supervised_user_constants.h +++ b/chrome/browser/supervised_user/supervised_user_constants.h @@ -9,12 +9,12 @@ namespace supervised_users { // Keys for supervised user settings. These are configured remotely and mapped // to preferences by the SupervisedUserPrefStore. -extern const char kCameraMicAllowed[]; +extern const char kCameraMicDisabled[]; extern const char kContentPackDefaultFilteringBehavior[]; extern const char kContentPackManualBehaviorHosts[]; extern const char kContentPackManualBehaviorURLs[]; extern const char kForceSafeSearch[]; -extern const char kGeolocationAllowed[]; +extern const char kGeolocationDisabled[]; extern const char kRecordHistory[]; extern const char kSigninAllowed[]; extern const char kUserName[]; diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index 82c0e6b..80e3ab9 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -2590,6 +2590,8 @@ 'browser/ssl/ssl_error_info.h', ], 'chrome_browser_supervised_user_sources': [ + 'browser/content_settings/content_settings_supervised_provider.cc', + 'browser/content_settings/content_settings_supervised_provider.h', 'browser/supervised_user/child_accounts/child_account_feedback_reporter_android.cc', 'browser/supervised_user/child_accounts/child_account_feedback_reporter_android.h', 'browser/supervised_user/child_accounts/child_account_service.cc', diff --git a/components/content_settings.gypi b/components/content_settings.gypi index c6700f6..6e7f0b2 100644 --- a/components/content_settings.gypi +++ b/components/content_settings.gypi @@ -22,6 +22,8 @@ ], 'sources': [ # Note: sources list duplicated in GN build. + 'content_settings/core/browser/content_settings_binary_value_map.cc', + 'content_settings/core/browser/content_settings_binary_value_map.h', 'content_settings/core/browser/content_settings_client.h', 'content_settings/core/browser/content_settings_default_provider.cc', 'content_settings/core/browser/content_settings_default_provider.h', diff --git a/components/content_settings/core/browser/BUILD.gn b/components/content_settings/core/browser/BUILD.gn index a321cbb..667b5bc 100644 --- a/components/content_settings/core/browser/BUILD.gn +++ b/components/content_settings/core/browser/BUILD.gn @@ -9,6 +9,8 @@ static_library("browser") { "content_settings_default_provider.h", "content_settings_details.cc", "content_settings_details.h", + "content_settings_binary_value_map.cc", + "content_settings_binary_value_map.h", "content_settings_observable_provider.cc", "content_settings_observable_provider.h", "content_settings_observer.h", diff --git a/components/content_settings/core/browser/content_settings_binary_value_map.cc b/components/content_settings/core/browser/content_settings_binary_value_map.cc new file mode 100644 index 0000000..136d3874 --- /dev/null +++ b/components/content_settings/core/browser/content_settings_binary_value_map.cc @@ -0,0 +1,65 @@ +// Copyright (c) 2015 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_binary_value_map.h" + +#include "base/synchronization/lock.h" +#include "components/content_settings/core/browser/content_settings_rule.h" +#include "components/content_settings/core/common/content_settings.h" + +namespace content_settings { + +namespace { + +class RuleIteratorBinary : public RuleIterator { + public: + explicit RuleIteratorBinary(bool is_enabled, + scoped_ptr<base::AutoLock> auto_lock) + : is_done_(is_enabled), auto_lock_(auto_lock.Pass()) {} + + bool HasNext() const override { return !is_done_; } + + Rule Next() override { + DCHECK(!is_done_); + is_done_ = true; + return Rule(ContentSettingsPattern::Wildcard(), + ContentSettingsPattern::Wildcard(), + new base::FundamentalValue(CONTENT_SETTING_BLOCK)); + } + + private: + bool is_done_; + scoped_ptr<base::AutoLock> auto_lock_; +}; + +} // namespace + +BinaryValueMap::BinaryValueMap() { + for (bool& enabled : is_enabled_) { + enabled = true; + } +} + +RuleIterator* BinaryValueMap::GetRuleIterator( + ContentSettingsType content_type, + const ResourceIdentifier& resource_identifier, + scoped_ptr<base::AutoLock> auto_lock) const { + if (resource_identifier.empty()) { + return new RuleIteratorBinary(IsContentSettingEnabled(content_type), + auto_lock.Pass()); + } + return new EmptyRuleIterator(); +} + +void BinaryValueMap::SetContentSettingDisabled(ContentSettingsType content_type, + bool is_disabled) { + is_enabled_[content_type] = !is_disabled; +} + +bool BinaryValueMap::IsContentSettingEnabled( + ContentSettingsType content_type) const { + return is_enabled_[content_type]; +} + +} // namespace content_settings diff --git a/components/content_settings/core/browser/content_settings_binary_value_map.h b/components/content_settings/core/browser/content_settings_binary_value_map.h new file mode 100644 index 0000000..3416a13 --- /dev/null +++ b/components/content_settings/core/browser/content_settings_binary_value_map.h @@ -0,0 +1,39 @@ +// Copyright (c) 2015 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_BINARY_VALUE_MAP_H_ +#define 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" + +namespace base { +class AutoLock; +} // namespace base + +namespace content_settings { + +class RuleIterator; + +// A simplified value map that can be used to disable or enable the entire +// Content Setting. The default behaviour is enabling the Content Setting if +// it is not set explicitly. +class BinaryValueMap { + public: + BinaryValueMap(); + + RuleIterator* GetRuleIterator(ContentSettingsType content_type, + const ResourceIdentifier& resource_identifier, + scoped_ptr<base::AutoLock> lock) const; + void SetContentSettingDisabled(ContentSettingsType content_type, + bool disabled); + bool IsContentSettingEnabled(ContentSettingsType content_type) const; + + private: + bool is_enabled_[CONTENT_SETTINGS_NUM_TYPES]; +}; + +} // namespace content_settings + +#endif // COMPONENTS_CONTENT_SETTINGS_CORE_BROWSER_CONTENT_SETTINGS_BINARY_VALUE_MAP_H_ diff --git a/components/content_settings/core/browser/content_settings_override_provider.cc b/components/content_settings/core/browser/content_settings_override_provider.cc index edb36a5..ee04dc9 100644 --- a/components/content_settings/core/browser/content_settings_override_provider.cc +++ b/components/content_settings/core/browser/content_settings_override_provider.cc @@ -10,6 +10,7 @@ #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" @@ -19,28 +20,6 @@ namespace content_settings { -namespace { - -class OverrideRuleIterator : public RuleIterator { - public: - explicit OverrideRuleIterator(bool is_allowed) : is_done_(is_allowed) {} - - bool HasNext() const override { return !is_done_; } - - Rule Next() override { - DCHECK(!is_done_); - is_done_ = true; - return Rule(ContentSettingsPattern::Wildcard(), - ContentSettingsPattern::Wildcard(), - new base::FundamentalValue(CONTENT_SETTING_BLOCK)); - } - - private: - bool is_done_; -}; - -} // namespace - // static void OverrideProvider::RegisterProfilePrefs( user_prefs::PrefRegistrySyncable* registry) { @@ -64,11 +43,9 @@ RuleIterator* OverrideProvider::GetRuleIterator( ContentSettingsType content_type, const ResourceIdentifier& resource_identifier, bool incognito) const { - base::AutoLock lock(lock_); - if (resource_identifier.empty()) { - return new OverrideRuleIterator(allowed_settings_[content_type]); - } - return new EmptyRuleIterator(); + scoped_ptr<base::AutoLock> auto_lock(new base::AutoLock(lock_)); + return allowed_settings_.GetRuleIterator(content_type, resource_identifier, + auto_lock.Pass()); } void OverrideProvider::ClearAllContentSettingsRules( @@ -97,23 +74,22 @@ void OverrideProvider::SetOverrideSetting(ContentSettingsType content_type, // Disallow incognito to change the state. DCHECK(!is_incognito_); - base::AutoLock lock(lock_); + 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) { - allowed_settings_[content_type] = true; default_settings_dictionary->RemoveWithoutPathExpansion( GetTypeName(content_type), NULL); } else { - allowed_settings_[content_type] = false; default_settings_dictionary->SetWithoutPathExpansion( GetTypeName(content_type), new base::FundamentalValue(true)); } } bool OverrideProvider::IsEnabled(ContentSettingsType content_type) const { - base::AutoLock lock(lock_); - return allowed_settings_[content_type]; + base::AutoLock auto_lock(lock_); + return allowed_settings_.IsContentSettingEnabled(content_type); } void OverrideProvider::ReadOverrideSettings() { @@ -121,9 +97,10 @@ void OverrideProvider::ReadOverrideSettings() { prefs_->GetDictionary(prefs::kOverrideContentSettings); for (int type = 0; type < CONTENT_SETTINGS_NUM_TYPES; ++type) { - ContentSettingsType content_setting = ContentSettingsType(type); - allowed_settings_[content_setting] = - !blocked_settings_dictionary->HasKey(GetTypeName(content_setting)); + ContentSettingsType content_type = ContentSettingsType(type); + if (blocked_settings_dictionary->HasKey(GetTypeName(content_type))) { + allowed_settings_.SetContentSettingDisabled(content_type, true); + } } } diff --git a/components/content_settings/core/browser/content_settings_override_provider.h b/components/content_settings/core/browser/content_settings_override_provider.h index 08f3052..ca61f60 100644 --- a/components/content_settings/core/browser/content_settings_override_provider.h +++ b/components/content_settings/core/browser/content_settings_override_provider.h @@ -8,6 +8,7 @@ #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" @@ -59,7 +60,7 @@ class OverrideProvider : public ProviderInterface { void ReadOverrideSettings(); // Copies of the pref data, so that we can read it on the IO thread. - bool allowed_settings_[CONTENT_SETTINGS_NUM_TYPES]; + BinaryValueMap allowed_settings_; PrefService* prefs_; 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 386de0c..fa67b20 100644 --- a/components/content_settings/core/browser/host_content_settings_map.cc +++ b/components/content_settings/core/browser/host_content_settings_map.cc @@ -38,6 +38,7 @@ typedef std::pair<std::string, std::string> StringPair; const char* kProviderNames[] = { "platform_app", "policy", + "supervised_user", "extension", "override", "preference", @@ -57,6 +58,7 @@ const char kExtensionScheme[] = "chrome-extension"; content_settings::SettingSource kProviderSourceMap[] = { content_settings::SETTING_SOURCE_EXTENSION, content_settings::SETTING_SOURCE_POLICY, + content_settings::SETTING_SOURCE_SUPERVISED, content_settings::SETTING_SOURCE_EXTENSION, content_settings::SETTING_SOURCE_USER, content_settings::SETTING_SOURCE_USER, 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 285aaa8..547b0e2 100644 --- a/components/content_settings/core/browser/host_content_settings_map.h +++ b/components/content_settings/core/browser/host_content_settings_map.h @@ -54,6 +54,7 @@ class HostContentSettingsMap // TODO(mukai): find the solution. INTERNAL_EXTENSION_PROVIDER = 0, POLICY_PROVIDER, + SUPERVISED_PROVIDER, CUSTOM_EXTENSION_PROVIDER, OVERRIDE_PROVIDER, PREF_PROVIDER, diff --git a/components/content_settings/core/common/content_settings.h b/components/content_settings/core/common/content_settings.h index ae9fb93..7f49a8c 100644 --- a/components/content_settings/core/common/content_settings.h +++ b/components/content_settings/core/common/content_settings.h @@ -60,15 +60,16 @@ struct RendererContentSettingRules { namespace content_settings { // Enum containing the various source for content settings. Settings can be -// set by policy, extension or the user. Certain (internal) schemes are -// whilelisted. For whilelisted schemes the source is -// |SETTING_SOURCE_WHITELIST|. +// set by policy, extension, the user or by the custodian of a supervised user. +// Certain (internal) schemes are whilelisted. For whilelisted schemes the +// source is |SETTING_SOURCE_WHITELIST|. enum SettingSource { SETTING_SOURCE_NONE, SETTING_SOURCE_POLICY, SETTING_SOURCE_EXTENSION, SETTING_SOURCE_USER, SETTING_SOURCE_WHITELIST, + SETTING_SOURCE_SUPERVISED, }; // |SettingInfo| provides meta data for content setting values. |source| |