Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(315)

Side by Side Diff: chrome/browser/chromeos/policy/active_directory_policy_manager.h

Issue 2638623006: Merge {Device,User}ActiveDirectoryPolicyManager into a single class (Closed)
Patch Set: Have factories return unique_ptr Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 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.
4
5 #ifndef CHROME_BROWSER_CHROMEOS_POLICY_ACTIVE_DIRECTORY_POLICY_MANAGER_H_
6 #define CHROME_BROWSER_CHROMEOS_POLICY_ACTIVE_DIRECTORY_POLICY_MANAGER_H_
7
8 #include <memory>
9
10 #include "base/macros.h"
11 #include "base/memory/weak_ptr.h"
12 #include "components/policy/core/common/cloud/cloud_policy_store.h"
13 #include "components/policy/core/common/configuration_policy_provider.h"
14 #include "components/signin/core/account_id/account_id.h"
15
16 namespace policy {
17
18 // ConfigurationPolicyProvider for device or user policy from Active Directory.
19 // The choice of constructor determines whether device or user policy is
20 // provided. The policy is fetched from the Domain Controller by authpolicyd
21 // which stores it in session manager and from where it is loaded by
22 // ActiveDirectoryPolicyManager.
23 class ActiveDirectoryPolicyManager : public ConfigurationPolicyProvider,
24 public CloudPolicyStore::Observer {
25 public:
26 ~ActiveDirectoryPolicyManager() override;
27
28 // Create manager for device policy.
29 static std::unique_ptr<ActiveDirectoryPolicyManager> CreateForDevicePolicy(
30 std::unique_ptr<CloudPolicyStore> store);
31
32 // Create manager for |accound_id| user policy.
33 static std::unique_ptr<ActiveDirectoryPolicyManager> CreateForUserPolicy(
34 const AccountId& account_id,
35 std::unique_ptr<CloudPolicyStore> store);
36
37 // ConfigurationPolicyProvider:
38 void Init(SchemaRegistry* registry) override;
39 void Shutdown() override;
40 bool IsInitializationComplete(PolicyDomain domain) const override;
41 void RefreshPolicies() override;
42
43 // CloudPolicyStore::Observer:
44 void OnStoreLoaded(CloudPolicyStore* cloud_policy_store) override;
45 void OnStoreError(CloudPolicyStore* cloud_policy_store) override;
46
47 CloudPolicyStore* store() const { return store_.get(); }
48
49 private:
50 // |account_id| specifies the user to manage policy for. If |account_id| is
51 // empty, device policy is managed.
52 ActiveDirectoryPolicyManager(const AccountId& account_id,
53 std::unique_ptr<CloudPolicyStore> store);
54
55 // Publishes the policy that's currently cached in the store.
56 void PublishPolicy();
57
58 // Callback from authpolicyd.
59 void OnPolicyRefreshed(bool success);
60
61 const AccountId account_id_;
62 std::unique_ptr<CloudPolicyStore> store_;
63
64 // Must be last member.
65 base::WeakPtrFactory<ActiveDirectoryPolicyManager> weak_ptr_factory_;
66
67 DISALLOW_COPY_AND_ASSIGN(ActiveDirectoryPolicyManager);
68 };
69
70 } // namespace policy
71
72 #endif // CHROME_BROWSER_CHROMEOS_POLICY_ACTIVE_DIRECTORY_POLICY_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698