summaryrefslogtreecommitdiffstats
path: root/chrome/browser/content_settings/content_settings_supervised_provider.h
blob: 3a3ee1314689b92efa660b9ed31f2dcab1da1b49 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
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_