| OLD | NEW |
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_SUPERVISED_PROVIDER_H_ | 5 #ifndef CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_SUPERVISED_PROVIDER_H_ |
| 6 #define CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_SUPERVISED_PROVIDER_H_ | 6 #define CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_SUPERVISED_PROVIDER_H_ |
| 7 | 7 |
| 8 // A content setting provider that is set by the custodian of a supervised user. | 8 // A content setting provider that is set by the custodian of a supervised user. |
| 9 | 9 |
| 10 #include "base/callback_list.h" | 10 #include "base/callback_list.h" |
| 11 #include "base/synchronization/lock.h" | 11 #include "base/synchronization/lock.h" |
| 12 #include "chrome/browser/profiles/profile.h" | |
| 13 #include "components/content_settings/core/browser/content_settings_binary_value
_map.h" | 12 #include "components/content_settings/core/browser/content_settings_binary_value
_map.h" |
| 14 #include "components/content_settings/core/browser/content_settings_observable_p
rovider.h" | 13 #include "components/content_settings/core/browser/content_settings_observable_p
rovider.h" |
| 15 #include "content/public/browser/notification_observer.h" | |
| 16 #include "content/public/browser/notification_registrar.h" | |
| 17 | 14 |
| 18 class PrefService; | 15 class PrefService; |
| 19 class SupervisedUserSettingsService; | 16 class SupervisedUserSettingsService; |
| 20 | 17 |
| 21 namespace content_settings { | 18 namespace content_settings { |
| 22 | 19 |
| 23 // SupervisedProvider that provides content-settings managed by the custodian | 20 // SupervisedProvider that provides content-settings managed by the custodian |
| 24 // of a supervised user. | 21 // of a supervised user. |
| 25 class SupervisedProvider : public ObservableProvider, | 22 class SupervisedProvider : public ObservableProvider { |
| 26 public content::NotificationObserver { | |
| 27 public: | 23 public: |
| 28 explicit SupervisedProvider( | 24 explicit SupervisedProvider( |
| 29 SupervisedUserSettingsService* supervised_user_settings_service); | 25 SupervisedUserSettingsService* supervised_user_settings_service); |
| 30 ~SupervisedProvider() override; | 26 ~SupervisedProvider() override; |
| 31 | 27 |
| 32 // ProviderInterface implementations. | 28 // ProviderInterface implementations. |
| 33 RuleIterator* GetRuleIterator(ContentSettingsType content_type, | 29 RuleIterator* GetRuleIterator(ContentSettingsType content_type, |
| 34 const ResourceIdentifier& resource_identifier, | 30 const ResourceIdentifier& resource_identifier, |
| 35 bool incognito) const override; | 31 bool incognito) const override; |
| 36 | 32 |
| 37 bool SetWebsiteSetting(const ContentSettingsPattern& primary_pattern, | 33 bool SetWebsiteSetting(const ContentSettingsPattern& primary_pattern, |
| 38 const ContentSettingsPattern& secondary_pattern, | 34 const ContentSettingsPattern& secondary_pattern, |
| 39 ContentSettingsType content_type, | 35 ContentSettingsType content_type, |
| 40 const ResourceIdentifier& resource_identifier, | 36 const ResourceIdentifier& resource_identifier, |
| 41 base::Value* value) override; | 37 base::Value* value) override; |
| 42 | 38 |
| 43 void ClearAllContentSettingsRules(ContentSettingsType content_type) override; | 39 void ClearAllContentSettingsRules(ContentSettingsType content_type) override; |
| 44 | 40 |
| 45 void ShutdownOnUIThread() override; | 41 void ShutdownOnUIThread() override; |
| 46 | 42 |
| 47 // Callback on receiving settings from the supervised user settings service. | 43 // Callback on receiving settings from the supervised user settings service. |
| 48 void OnSupervisedSettingsAvailable(const base::DictionaryValue* settings); | 44 void OnSupervisedSettingsAvailable(const base::DictionaryValue* settings); |
| 49 | 45 |
| 50 // NotificationObserver implementation. | |
| 51 void Observe(int type, | |
| 52 const content::NotificationSource& src, | |
| 53 const content::NotificationDetails& details) override; | |
| 54 | |
| 55 private: | 46 private: |
| 56 BinaryValueMap value_map_; | 47 BinaryValueMap value_map_; |
| 57 | 48 |
| 58 // Used around accesses to the |value_map_| object to guarantee | 49 // Used around accesses to the |value_map_| object to guarantee |
| 59 // thread safety. | 50 // thread safety. |
| 60 mutable base::Lock lock_; | 51 mutable base::Lock lock_; |
| 61 | 52 |
| 62 scoped_ptr<base::CallbackList<void( | 53 scoped_ptr<base::CallbackList<void( |
| 63 const base::DictionaryValue*)>::Subscription> user_settings_subscription_; | 54 const base::DictionaryValue*)>::Subscription> user_settings_subscription_; |
| 64 // This is a pointer instead of a member so we can make sure it is destroyed | |
| 65 // on the UI thread. | |
| 66 scoped_ptr<content::NotificationRegistrar> unsubscriber_registrar_; | |
| 67 | 55 |
| 68 DISALLOW_COPY_AND_ASSIGN(SupervisedProvider); | 56 DISALLOW_COPY_AND_ASSIGN(SupervisedProvider); |
| 69 }; | 57 }; |
| 70 | 58 |
| 71 } // namespace content_settings | 59 } // namespace content_settings |
| 72 | 60 |
| 73 #endif // CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_SUPERVISED_PROVIDER_
H_ | 61 #endif // CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_SUPERVISED_PROVIDER_
H_ |
| OLD | NEW |