OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "chrome/browser/chromeos/policy/device_local_account_policy_provider.h" | 5 #include "chrome/browser/chromeos/policy/device_local_account_policy_provider.h" |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 #include "base/bind.h" | 9 #include "base/bind.h" |
8 #include "base/values.h" | 10 #include "base/values.h" |
9 #include "chrome/browser/chromeos/policy/device_local_account.h" | 11 #include "chrome/browser/chromeos/policy/device_local_account.h" |
10 #include "chrome/browser/chromeos/policy/device_local_account_external_data_mana
ger.h" | 12 #include "chrome/browser/chromeos/policy/device_local_account_external_data_mana
ger.h" |
11 #include "chromeos/dbus/power_policy_controller.h" | 13 #include "chromeos/dbus/power_policy_controller.h" |
12 #include "components/policy/core/common/cloud/cloud_policy_core.h" | 14 #include "components/policy/core/common/cloud/cloud_policy_core.h" |
13 #include "components/policy/core/common/cloud/cloud_policy_service.h" | 15 #include "components/policy/core/common/cloud/cloud_policy_service.h" |
14 #include "components/policy/core/common/cloud/component_cloud_policy_service.h" | 16 #include "components/policy/core/common/cloud/component_cloud_policy_service.h" |
15 #include "components/policy/core/common/policy_bundle.h" | 17 #include "components/policy/core/common/policy_bundle.h" |
16 #include "components/policy/core/common/policy_map.h" | 18 #include "components/policy/core/common/policy_map.h" |
17 #include "components/policy/core/common/policy_namespace.h" | 19 #include "components/policy/core/common/policy_namespace.h" |
18 #include "components/policy/core/common/policy_types.h" | 20 #include "components/policy/core/common/policy_types.h" |
19 #include "policy/policy_constants.h" | 21 #include "policy/policy_constants.h" |
20 | 22 |
21 namespace policy { | 23 namespace policy { |
22 | 24 |
23 DeviceLocalAccountPolicyProvider::DeviceLocalAccountPolicyProvider( | 25 DeviceLocalAccountPolicyProvider::DeviceLocalAccountPolicyProvider( |
24 const std::string& user_id, | 26 const std::string& user_id, |
25 DeviceLocalAccountPolicyService* service, | 27 DeviceLocalAccountPolicyService* service, |
26 scoped_ptr<PolicyMap> chrome_policy_overrides) | 28 scoped_ptr<PolicyMap> chrome_policy_overrides) |
27 : user_id_(user_id), | 29 : user_id_(user_id), |
28 service_(service), | 30 service_(service), |
29 chrome_policy_overrides_(chrome_policy_overrides.Pass()), | 31 chrome_policy_overrides_(std::move(chrome_policy_overrides)), |
30 store_initialized_(false), | 32 store_initialized_(false), |
31 waiting_for_policy_refresh_(false), | 33 waiting_for_policy_refresh_(false), |
32 weak_factory_(this) { | 34 weak_factory_(this) { |
33 service_->AddObserver(this); | 35 service_->AddObserver(this); |
34 UpdateFromBroker(); | 36 UpdateFromBroker(); |
35 } | 37 } |
36 | 38 |
37 DeviceLocalAccountPolicyProvider::~DeviceLocalAccountPolicyProvider() { | 39 DeviceLocalAccountPolicyProvider::~DeviceLocalAccountPolicyProvider() { |
38 service_->RemoveObserver(this); | 40 service_->RemoveObserver(this); |
39 } | 41 } |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 POLICY_LEVEL_MANDATORY, | 91 POLICY_LEVEL_MANDATORY, |
90 POLICY_SCOPE_MACHINE, | 92 POLICY_SCOPE_MACHINE, |
91 POLICY_SOURCE_PUBLIC_SESSION_OVERRIDE, | 93 POLICY_SOURCE_PUBLIC_SESSION_OVERRIDE, |
92 new base::FundamentalValue(false), | 94 new base::FundamentalValue(false), |
93 NULL); | 95 NULL); |
94 } | 96 } |
95 | 97 |
96 scoped_ptr<DeviceLocalAccountPolicyProvider> provider( | 98 scoped_ptr<DeviceLocalAccountPolicyProvider> provider( |
97 new DeviceLocalAccountPolicyProvider(user_id, | 99 new DeviceLocalAccountPolicyProvider(user_id, |
98 device_local_account_policy_service, | 100 device_local_account_policy_service, |
99 chrome_policy_overrides.Pass())); | 101 std::move(chrome_policy_overrides))); |
100 return provider.Pass(); | 102 return provider; |
101 } | 103 } |
102 | 104 |
103 bool DeviceLocalAccountPolicyProvider::IsInitializationComplete( | 105 bool DeviceLocalAccountPolicyProvider::IsInitializationComplete( |
104 PolicyDomain domain) const { | 106 PolicyDomain domain) const { |
105 if (domain == POLICY_DOMAIN_CHROME) | 107 if (domain == POLICY_DOMAIN_CHROME) |
106 return store_initialized_; | 108 return store_initialized_; |
107 if (ComponentCloudPolicyService::SupportsDomain(domain) && | 109 if (ComponentCloudPolicyService::SupportsDomain(domain) && |
108 GetBroker() && GetBroker()->component_policy_service()) { | 110 GetBroker() && GetBroker()->component_policy_service()) { |
109 return GetBroker()->component_policy_service()->is_initialized(); | 111 return GetBroker()->component_policy_service()->is_initialized(); |
110 } | 112 } |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 const PolicyMap::Entry& entry = it->second; | 179 const PolicyMap::Entry& entry = it->second; |
178 chrome_policy.Set(it->first, | 180 chrome_policy.Set(it->first, |
179 entry.level, | 181 entry.level, |
180 entry.scope, | 182 entry.scope, |
181 entry.source, | 183 entry.source, |
182 entry.value->DeepCopy(), | 184 entry.value->DeepCopy(), |
183 nullptr); | 185 nullptr); |
184 } | 186 } |
185 } | 187 } |
186 | 188 |
187 UpdatePolicy(bundle.Pass()); | 189 UpdatePolicy(std::move(bundle)); |
188 } | 190 } |
189 | 191 |
190 } // namespace policy | 192 } // namespace policy |
OLD | NEW |