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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_SUPERVISED_PROVIDER_H_
6 #define CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_SUPERVISED_PROVIDER_H_
8 // A content setting provider that is set by the custodian of a supervised user.
10 #include "base/callback_list.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"
14 #include "components/content_settings/core/browser/content_settings_observable_provider.h"
15 #include "content/public/browser/notification_observer.h"
16 #include "content/public/browser/notification_registrar.h"
19 class SupervisedUserSettingsService
;
21 namespace content_settings
{
23 // SupervisedProvider that provides content-settings managed by the custodian
24 // of a supervised user.
25 class SupervisedProvider
: public ObservableProvider
,
26 public content::NotificationObserver
{
28 explicit SupervisedProvider(
29 SupervisedUserSettingsService
* supervised_user_settings_service
);
30 ~SupervisedProvider() override
;
32 // ProviderInterface implementations.
33 RuleIterator
* GetRuleIterator(ContentSettingsType content_type
,
34 const ResourceIdentifier
& resource_identifier
,
35 bool incognito
) const override
;
37 bool SetWebsiteSetting(const ContentSettingsPattern
& primary_pattern
,
38 const ContentSettingsPattern
& secondary_pattern
,
39 ContentSettingsType content_type
,
40 const ResourceIdentifier
& resource_identifier
,
41 base::Value
* value
) override
;
43 void ClearAllContentSettingsRules(ContentSettingsType content_type
) override
;
45 void ShutdownOnUIThread() override
;
47 // Callback on receiving settings from the supervised user settings service.
48 void OnSupervisedSettingsAvailable(const base::DictionaryValue
* settings
);
50 // NotificationObserver implementation.
51 void Observe(int type
,
52 const content::NotificationSource
& src
,
53 const content::NotificationDetails
& details
) override
;
56 BinaryValueMap value_map_
;
58 // Used around accesses to the |value_map_| object to guarantee
60 mutable base::Lock lock_
;
62 scoped_ptr
<base::CallbackList
<void(
63 const base::DictionaryValue
*)>::Subscription
> user_settings_subscription_
;
64 // This is a pointer instead of a member so we can make sure it is destroyed
66 scoped_ptr
<content::NotificationRegistrar
> unsubscriber_registrar_
;
68 DISALLOW_COPY_AND_ASSIGN(SupervisedProvider
);
71 } // namespace content_settings
73 #endif // CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_SUPERVISED_PROVIDER_H_