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

Side by Side Diff: chrome/browser/chromeos/policy/device_ad_policy_manager.cc

Issue 2486813002: Add DeviceADPolicyManager to provide AD policy. (Closed)
Patch Set: Created 4 years, 1 month 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 #include "chrome/browser/chromeos/policy/device_ad_policy_manager.h"
6
7 #include <utility>
8
9 #include "base/memory/ptr_util.h"
10
11 namespace policy {
12
13 DeviceADPolicyManager::DeviceADPolicyManager(
14 std::unique_ptr<CloudPolicyStore> store)
15 : store_(std::move(store)) {}
16
17 DeviceADPolicyManager::~DeviceADPolicyManager() {}
18
19 void DeviceADPolicyManager::Init(SchemaRegistry* registry) {
20 ConfigurationPolicyProvider::Init(registry);
21
22 store_->AddObserver(this);
23 PublishPolicy();
24 if (!store_->is_initialized()) {
25 store_->Load();
26 }
27 }
28
29 void DeviceADPolicyManager::Shutdown() {
30 store_->RemoveObserver(this);
31 ConfigurationPolicyProvider::Shutdown();
32 }
33
34 bool DeviceADPolicyManager::IsInitializationComplete(
35 PolicyDomain domain) const {
36 if (domain == POLICY_DOMAIN_CHROME)
37 return store_->is_initialized();
38 return true;
39 }
40
41 void DeviceADPolicyManager::RefreshPolicies() {
42 store_->Load();
43 }
44
45 void DeviceADPolicyManager::OnStoreLoaded(
46 CloudPolicyStore* cloud_policy_store) {
47 DCHECK_EQ(store_.get(), cloud_policy_store);
emaxx 2016/11/11 15:25:08 nit: #include "base/logging.h"
Thiemo Nagel 2016/11/16 19:11:01 Done.
48 PublishPolicy();
49 }
50
51 void DeviceADPolicyManager::OnStoreError(CloudPolicyStore* cloud_policy_store) {
52 DCHECK_EQ(store_.get(), cloud_policy_store);
53 // Publish policy (even though it hasn't changed) in order to signal load
54 // complete on the ConfigurationPolicyProvider interface. Technically, this is
55 // only required on the first load, but doesn't hurt in any case.
56 PublishPolicy();
57 }
58
59 void DeviceADPolicyManager::PublishPolicy() {
60 if (!store_->is_initialized()) {
61 return;
62 }
63 std::unique_ptr<PolicyBundle> bundle = base::MakeUnique<PolicyBundle>();
emaxx 2016/11/11 15:25:08 nit: #include "components/policy/core/common/polic
Thiemo Nagel 2016/11/16 19:11:01 Done.
64 PolicyMap& policy_map =
65 bundle->Get(PolicyNamespace(POLICY_DOMAIN_CHROME, std::string()));
emaxx 2016/11/11 15:25:08 nit: #include <string>
Thiemo Nagel 2016/11/16 19:11:01 Done.
66 policy_map.CopyFrom(store_->policy_map());
67
68 // Overwrite the source which is POLICY_SOURCE_CLOUD by default.
69 // TODO(tnagel): Rename CloudPolicyStore to PolicyStore and make the source
emaxx 2016/11/11 15:25:08 Just a point from my perspective: there are other
Thiemo Nagel 2016/11/16 19:11:01 AD is not cloud, very often it's on-premise server
70 // configurable, then drop PolicyMap::SetSourceForAll().
71 policy_map.SetSourceForAll(POLICY_SOURCE_ACTIVE_DIRECTORY);
emaxx 2016/11/11 15:25:08 nit: #include "components/policy/core/common/polic
Thiemo Nagel 2016/11/16 19:11:01 Done.
72 UpdatePolicy(std::move(bundle));
73 }
74
75 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698