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

Side by Side Diff: chrome/browser/policy/device_policy_decoder_chromeos.cc

Issue 10885015: Implement new-style CloudPolicyStore for Chrome OS device policy. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase, fix compilation. Created 8 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/policy/device_policy_decoder_chromeos.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/policy/device_policy_cache.h" 5 #include "chrome/browser/policy/device_policy_decoder_chromeos.h"
6 6
7 #include <limits> 7 #include <limits>
8 #include <string>
9 #include <vector>
10 8
11 #include "base/basictypes.h"
12 #include "base/bind.h"
13 #include "base/callback.h"
14 #include "base/compiler_specific.h"
15 #include "base/logging.h" 9 #include "base/logging.h"
16 #include "base/metrics/histogram.h"
17 #include "base/values.h" 10 #include "base/values.h"
18 #include "chrome/browser/policy/app_pack_updater.h" 11 #include "chrome/browser/policy/app_pack_updater.h"
19 #include "chrome/browser/policy/cloud_policy_data_store.h"
20 #include "chrome/browser/policy/enterprise_install_attributes.h" 12 #include "chrome/browser/policy/enterprise_install_attributes.h"
21 #include "chrome/browser/policy/enterprise_metrics.h"
22 #include "chrome/browser/policy/policy_map.h" 13 #include "chrome/browser/policy/policy_map.h"
23 #include "chrome/browser/policy/proto/chrome_device_policy.pb.h" 14 #include "chrome/browser/policy/proto/chrome_device_policy.pb.h"
24 #include "chrome/browser/policy/proto/device_management_backend.pb.h"
25 #include "chrome/browser/policy/proto/device_management_local.pb.h"
26 #include "chromeos/dbus/dbus_thread_manager.h" 15 #include "chromeos/dbus/dbus_thread_manager.h"
27 #include "chromeos/dbus/update_engine_client.h" 16 #include "chromeos/dbus/update_engine_client.h"
28 #include "google_apis/gaia/gaia_auth_util.h"
29 #include "policy/policy_constants.h" 17 #include "policy/policy_constants.h"
30 #include "third_party/cros_system_api/dbus/service_constants.h" 18 #include "third_party/cros_system_api/dbus/service_constants.h"
31 19
32 using google::protobuf::RepeatedField; 20 using google::protobuf::RepeatedField;
33 using google::protobuf::RepeatedPtrField; 21 using google::protobuf::RepeatedPtrField;
34 22
35 namespace em = enterprise_management; 23 namespace em = enterprise_management;
36 24
25 namespace policy {
26
37 namespace { 27 namespace {
38 28
39 // Decodes a protobuf integer to an IntegerValue. The caller assumes ownership 29 // Decodes a protobuf integer to an IntegerValue. The caller assumes ownership
40 // of the return Value*. Returns NULL in case the input value is out of bounds. 30 // of the return Value*. Returns NULL in case the input value is out of bounds.
41 Value* DecodeIntegerValue(google::protobuf::int64 value) { 31 Value* DecodeIntegerValue(google::protobuf::int64 value) {
42 if (value < std::numeric_limits<int>::min() || 32 if (value < std::numeric_limits<int>::min() ||
43 value > std::numeric_limits<int>::max()) { 33 value > std::numeric_limits<int>::max()) {
44 LOG(WARNING) << "Integer value " << value 34 LOG(WARNING) << "Integer value " << value
45 << " out of numeric limits, ignoring."; 35 << " out of numeric limits, ignoring.";
46 return NULL; 36 return NULL;
(...skipping 10 matching lines...) Expand all
57 flimflam::kTypeBluetooth, 47 flimflam::kTypeBluetooth,
58 flimflam::kTypeCellular, 48 flimflam::kTypeCellular,
59 }; 49 };
60 50
61 if (value < 0 || value >= static_cast<int>(arraysize(kConnectionTypes))) 51 if (value < 0 || value >= static_cast<int>(arraysize(kConnectionTypes)))
62 return NULL; 52 return NULL;
63 53
64 return Value::CreateStringValue(kConnectionTypes[value]); 54 return Value::CreateStringValue(kConnectionTypes[value]);
65 } 55 }
66 56
67 } // namespace 57 void DecodeLoginPolicies(const em::ChromeDeviceSettingsProto& policy,
68 58 PolicyMap* policies) {
69 namespace policy {
70
71 DevicePolicyCache::DevicePolicyCache(
72 CloudPolicyDataStore* data_store,
73 EnterpriseInstallAttributes* install_attributes)
74 : data_store_(data_store),
75 install_attributes_(install_attributes),
76 device_settings_service_(chromeos::DeviceSettingsService::Get()),
77 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)),
78 policy_fetch_pending_(false) {
79 device_settings_service_->AddObserver(this);
80 }
81
82 DevicePolicyCache::DevicePolicyCache(
83 CloudPolicyDataStore* data_store,
84 EnterpriseInstallAttributes* install_attributes,
85 chromeos::DeviceSettingsService* device_settings_service)
86 : data_store_(data_store),
87 install_attributes_(install_attributes),
88 device_settings_service_(device_settings_service),
89 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)),
90 policy_fetch_pending_(false) {
91 device_settings_service_->AddObserver(this);
92 }
93
94 DevicePolicyCache::~DevicePolicyCache() {
95 device_settings_service_->RemoveObserver(this);
96 }
97
98 void DevicePolicyCache::Load() {
99 DeviceSettingsUpdated();
100 }
101
102 bool DevicePolicyCache::SetPolicy(const em::PolicyFetchResponse& policy) {
103 DCHECK(IsReady());
104
105 // Make sure we have an enterprise device.
106 std::string registration_domain(install_attributes_->GetDomain());
107 if (registration_domain.empty()) {
108 LOG(WARNING) << "Refusing to accept policy on non-enterprise device.";
109 UMA_HISTOGRAM_ENUMERATION(kMetricPolicy,
110 kMetricPolicyFetchNonEnterpriseDevice,
111 kMetricPolicySize);
112 InformNotifier(CloudPolicySubsystem::LOCAL_ERROR,
113 CloudPolicySubsystem::POLICY_LOCAL_ERROR);
114 return false;
115 }
116
117 // Check the user this policy is for against the device-locked name.
118 em::PolicyData policy_data;
119 if (!policy_data.ParseFromString(policy.policy_data())) {
120 LOG(WARNING) << "Invalid policy protobuf";
121 UMA_HISTOGRAM_ENUMERATION(kMetricPolicy, kMetricPolicyFetchInvalidPolicy,
122 kMetricPolicySize);
123 InformNotifier(CloudPolicySubsystem::LOCAL_ERROR,
124 CloudPolicySubsystem::POLICY_LOCAL_ERROR);
125 return false;
126 }
127
128 // Existing installations may not have a canonicalized version of the
129 // registration domain in install attributes, so lower-case the data here.
130 if (registration_domain != gaia::ExtractDomainName(policy_data.username())) {
131 LOG(WARNING) << "Refusing policy blob for " << policy_data.username()
132 << " which doesn't match domain " << registration_domain;
133 UMA_HISTOGRAM_ENUMERATION(kMetricPolicy, kMetricPolicyFetchUserMismatch,
134 kMetricPolicySize);
135 InformNotifier(CloudPolicySubsystem::LOCAL_ERROR,
136 CloudPolicySubsystem::POLICY_LOCAL_ERROR);
137 return false;
138 }
139
140 set_last_policy_refresh_time(base::Time::NowFromSystemTime());
141
142 // Start a store operation.
143 policy_fetch_pending_ = true;
144 device_settings_service_->Store(
145 policy.SerializeAsString(),
146 base::Bind(&DevicePolicyCache::PolicyStoreOpCompleted,
147 weak_ptr_factory_.GetWeakPtr()));
148 return true;
149 }
150
151 void DevicePolicyCache::SetUnmanaged() {
152 LOG(WARNING) << "Tried to set DevicePolicyCache to 'unmanaged'!";
153 // This is not supported for DevicePolicyCache.
154 }
155
156 void DevicePolicyCache::SetFetchingDone() {
157 // Don't send the notification just yet if there is a pending policy
158 // store/reload cycle.
159 if (!policy_fetch_pending_)
160 CloudPolicyCacheBase::SetFetchingDone();
161 }
162
163 void DevicePolicyCache::OwnershipStatusChanged() {}
164
165 void DevicePolicyCache::DeviceSettingsUpdated() {
166 DCHECK(CalledOnValidThread());
167 chromeos::DeviceSettingsService::Status status =
168 device_settings_service_->status();
169 const em::PolicyData* policy_data = device_settings_service_->policy_data();
170 if (status == chromeos::DeviceSettingsService::STORE_SUCCESS &&
171 !policy_data) {
172 // Initial policy load is still pending.
173 return;
174 }
175
176 if (!IsReady()) {
177 std::string device_token;
178 InstallInitialPolicy(status, policy_data, &device_token);
179 SetTokenAndFlagReady(device_token);
180 } else { // In other words, IsReady() == true
181 if (status != chromeos::DeviceSettingsService::STORE_SUCCESS ||
182 !policy_data) {
183 if (status == chromeos::DeviceSettingsService::STORE_VALIDATION_ERROR) {
184 UMA_HISTOGRAM_ENUMERATION(kMetricPolicy, kMetricPolicyFetchBadSignature,
185 kMetricPolicySize);
186 InformNotifier(CloudPolicySubsystem::LOCAL_ERROR,
187 CloudPolicySubsystem::SIGNATURE_MISMATCH);
188 } else {
189 UMA_HISTOGRAM_ENUMERATION(kMetricPolicy, kMetricPolicyFetchOtherFailed,
190 kMetricPolicySize);
191 InformNotifier(CloudPolicySubsystem::LOCAL_ERROR,
192 CloudPolicySubsystem::POLICY_LOCAL_ERROR);
193 }
194 } else {
195 em::PolicyFetchResponse policy_response;
196 CHECK(policy_data->SerializeToString(
197 policy_response.mutable_policy_data()));
198 bool ok = SetPolicyInternal(policy_response, NULL, false);
199 if (ok) {
200 UMA_HISTOGRAM_ENUMERATION(kMetricPolicy, kMetricPolicyFetchOK,
201 kMetricPolicySize);
202 }
203 }
204 }
205 }
206
207 bool DevicePolicyCache::DecodePolicyData(const em::PolicyData& policy_data,
208 PolicyMap* policies) {
209 em::ChromeDeviceSettingsProto policy;
210 if (!policy.ParseFromString(policy_data.policy_value())) {
211 LOG(WARNING) << "Failed to parse ChromeDeviceSettingsProto.";
212 return false;
213 }
214 DecodeDevicePolicy(policy, policies);
215 return true;
216 }
217
218 void DevicePolicyCache::PolicyStoreOpCompleted() {
219 DCHECK(CalledOnValidThread());
220 chromeos::DeviceSettingsService::Status status =
221 device_settings_service_->status();
222 if (status != chromeos::DeviceSettingsService::STORE_SUCCESS) {
223 UMA_HISTOGRAM_ENUMERATION(kMetricPolicy, kMetricPolicyStoreFailed,
224 kMetricPolicySize);
225 if (status == chromeos::DeviceSettingsService::STORE_VALIDATION_ERROR) {
226 UMA_HISTOGRAM_ENUMERATION(kMetricPolicy, kMetricPolicyFetchBadSignature,
227 kMetricPolicySize);
228 InformNotifier(CloudPolicySubsystem::LOCAL_ERROR,
229 CloudPolicySubsystem::SIGNATURE_MISMATCH);
230 } else {
231 UMA_HISTOGRAM_ENUMERATION(kMetricPolicy, kMetricPolicyFetchOtherFailed,
232 kMetricPolicySize);
233 InformNotifier(CloudPolicySubsystem::LOCAL_ERROR,
234 CloudPolicySubsystem::POLICY_LOCAL_ERROR);
235 }
236 CheckFetchingDone();
237 return;
238 }
239 UMA_HISTOGRAM_ENUMERATION(kMetricPolicy, kMetricPolicyStoreSucceeded,
240 kMetricPolicySize);
241
242 CheckFetchingDone();
243 }
244
245 void DevicePolicyCache::InstallInitialPolicy(
246 chromeos::DeviceSettingsService::Status status,
247 const em::PolicyData* policy_data,
248 std::string* device_token) {
249 if (status == chromeos::DeviceSettingsService::STORE_NO_POLICY ||
250 status == chromeos::DeviceSettingsService::STORE_KEY_UNAVAILABLE) {
251 InformNotifier(CloudPolicySubsystem::UNENROLLED,
252 CloudPolicySubsystem::NO_DETAILS);
253 return;
254 }
255 if (!policy_data) {
256 LOG(WARNING) << "Failed to parse PolicyData protobuf.";
257 UMA_HISTOGRAM_ENUMERATION(kMetricPolicy, kMetricPolicyLoadFailed,
258 kMetricPolicySize);
259 InformNotifier(CloudPolicySubsystem::LOCAL_ERROR,
260 CloudPolicySubsystem::POLICY_LOCAL_ERROR);
261 return;
262 }
263 if (!policy_data->has_request_token() ||
264 policy_data->request_token().empty()) {
265 SetUnmanagedInternal(base::Time::NowFromSystemTime());
266 InformNotifier(CloudPolicySubsystem::UNMANAGED,
267 CloudPolicySubsystem::NO_DETAILS);
268 // TODO(jkummerow): Reminder: When we want to feed device-wide settings
269 // made by a local owner into this cache, we need to call
270 // SetPolicyInternal() here.
271 return;
272 }
273 if (!policy_data->has_username() || !policy_data->has_device_id()) {
274 UMA_HISTOGRAM_ENUMERATION(kMetricPolicy, kMetricPolicyLoadFailed,
275 kMetricPolicySize);
276 InformNotifier(CloudPolicySubsystem::LOCAL_ERROR,
277 CloudPolicySubsystem::POLICY_LOCAL_ERROR);
278 return;
279 }
280 UMA_HISTOGRAM_ENUMERATION(kMetricPolicy, kMetricPolicyLoadSucceeded,
281 kMetricPolicySize);
282 data_store_->set_user_name(policy_data->username());
283 data_store_->set_device_id(policy_data->device_id());
284 *device_token = policy_data->request_token();
285 base::Time timestamp;
286 em::PolicyFetchResponse policy_response;
287 CHECK(policy_data->SerializeToString(policy_response.mutable_policy_data()));
288 if (SetPolicyInternal(policy_response, &timestamp, true))
289 set_last_policy_refresh_time(timestamp);
290 }
291
292 void DevicePolicyCache::SetTokenAndFlagReady(const std::string& device_token) {
293 // We need to call SetDeviceToken unconditionally to indicate the cache has
294 // finished loading.
295 data_store_->SetDeviceToken(device_token, true);
296 SetReady();
297 }
298
299 void DevicePolicyCache::CheckFetchingDone() {
300 if (policy_fetch_pending_) {
301 CloudPolicyCacheBase::SetFetchingDone();
302 policy_fetch_pending_ = false;
303 }
304 }
305
306 void DevicePolicyCache::DecodeDevicePolicy(
307 const em::ChromeDeviceSettingsProto& policy,
308 PolicyMap* policies) {
309 // Decode the various groups of policies.
310 DecodeLoginPolicies(policy, policies);
311 DecodeKioskPolicies(policy, policies, install_attributes_);
312 DecodeNetworkPolicies(policy, policies, install_attributes_);
313 DecodeReportingPolicies(policy, policies);
314 DecodeAutoUpdatePolicies(policy, policies);
315 DecodeGenericPolicies(policy, policies);
316 }
317
318 // static
319 void DevicePolicyCache::DecodeLoginPolicies(
320 const em::ChromeDeviceSettingsProto& policy,
321 PolicyMap* policies) {
322 if (policy.has_guest_mode_enabled()) { 59 if (policy.has_guest_mode_enabled()) {
323 const em::GuestModeEnabledProto& container(policy.guest_mode_enabled()); 60 const em::GuestModeEnabledProto& container(policy.guest_mode_enabled());
324 if (container.has_guest_mode_enabled()) { 61 if (container.has_guest_mode_enabled()) {
325 policies->Set(key::kDeviceGuestModeEnabled, 62 policies->Set(key::kDeviceGuestModeEnabled,
326 POLICY_LEVEL_MANDATORY, 63 POLICY_LEVEL_MANDATORY,
327 POLICY_SCOPE_MACHINE, 64 POLICY_SCOPE_MACHINE,
328 Value::CreateBooleanValue(container.guest_mode_enabled())); 65 Value::CreateBooleanValue(container.guest_mode_enabled()));
329 } 66 }
330 } 67 }
331 68
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 if (container.has_ephemeral_users_enabled()) { 109 if (container.has_ephemeral_users_enabled()) {
373 policies->Set(key::kDeviceEphemeralUsersEnabled, 110 policies->Set(key::kDeviceEphemeralUsersEnabled,
374 POLICY_LEVEL_MANDATORY, 111 POLICY_LEVEL_MANDATORY,
375 POLICY_SCOPE_MACHINE, 112 POLICY_SCOPE_MACHINE,
376 Value::CreateBooleanValue( 113 Value::CreateBooleanValue(
377 container.ephemeral_users_enabled())); 114 container.ephemeral_users_enabled()));
378 } 115 }
379 } 116 }
380 } 117 }
381 118
382 // static 119 void DecodeKioskPolicies(const em::ChromeDeviceSettingsProto& policy,
383 void DevicePolicyCache::DecodeKioskPolicies( 120 PolicyMap* policies,
384 const em::ChromeDeviceSettingsProto& policy, 121 EnterpriseInstallAttributes* install_attributes) {
385 PolicyMap* policies,
386 EnterpriseInstallAttributes* install_attributes) {
387 // No policies if this is not KIOSK. 122 // No policies if this is not KIOSK.
388 if (install_attributes->GetMode() != DEVICE_MODE_KIOSK) 123 if (install_attributes->GetMode() != DEVICE_MODE_KIOSK)
389 return; 124 return;
390 125
391 if (policy.has_forced_logout_timeouts()) { 126 if (policy.has_forced_logout_timeouts()) {
392 const em::ForcedLogoutTimeoutsProto& container( 127 const em::ForcedLogoutTimeoutsProto& container(
393 policy.forced_logout_timeouts()); 128 policy.forced_logout_timeouts());
394 if (container.has_idle_logout_timeout()) { 129 if (container.has_idle_logout_timeout()) {
395 policies->Set(key::kDeviceIdleLogoutTimeout, 130 policies->Set(key::kDeviceIdleLogoutTimeout,
396 POLICY_LEVEL_MANDATORY, 131 POLICY_LEVEL_MANDATORY,
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 for (int i = 0; i < container.app_id_size(); ++i) 183 for (int i = 0; i < container.app_id_size(); ++i)
449 pinned_apps_list->Append(Value::CreateStringValue(container.app_id(i))); 184 pinned_apps_list->Append(Value::CreateStringValue(container.app_id(i)));
450 185
451 policies->Set(key::kPinnedLauncherApps, 186 policies->Set(key::kPinnedLauncherApps,
452 POLICY_LEVEL_RECOMMENDED, 187 POLICY_LEVEL_RECOMMENDED,
453 POLICY_SCOPE_MACHINE, 188 POLICY_SCOPE_MACHINE,
454 pinned_apps_list); 189 pinned_apps_list);
455 } 190 }
456 } 191 }
457 192
458 // static 193 void DecodeNetworkPolicies(const em::ChromeDeviceSettingsProto& policy,
459 void DevicePolicyCache::DecodeNetworkPolicies( 194 PolicyMap* policies,
460 const em::ChromeDeviceSettingsProto& policy, 195 EnterpriseInstallAttributes* install_attributes) {
461 PolicyMap* policies,
462 EnterpriseInstallAttributes* install_attributes) {
463 if (policy.has_device_proxy_settings()) { 196 if (policy.has_device_proxy_settings()) {
464 const em::DeviceProxySettingsProto& container( 197 const em::DeviceProxySettingsProto& container(
465 policy.device_proxy_settings()); 198 policy.device_proxy_settings());
466 scoped_ptr<DictionaryValue> proxy_settings(new DictionaryValue); 199 scoped_ptr<DictionaryValue> proxy_settings(new DictionaryValue);
467 if (container.has_proxy_mode()) 200 if (container.has_proxy_mode())
468 proxy_settings->SetString(key::kProxyMode, container.proxy_mode()); 201 proxy_settings->SetString(key::kProxyMode, container.proxy_mode());
469 if (container.has_proxy_server()) 202 if (container.has_proxy_server())
470 proxy_settings->SetString(key::kProxyServer, container.proxy_server()); 203 proxy_settings->SetString(key::kProxyServer, container.proxy_server());
471 if (container.has_proxy_pac_url()) 204 if (container.has_proxy_pac_url())
472 proxy_settings->SetString(key::kProxyPacUrl, container.proxy_pac_url()); 205 proxy_settings->SetString(key::kProxyPacUrl, container.proxy_pac_url());
(...skipping 30 matching lines...) Expand all
503 policy.open_network_configuration().has_open_network_configuration()) { 236 policy.open_network_configuration().has_open_network_configuration()) {
504 std::string config( 237 std::string config(
505 policy.open_network_configuration().open_network_configuration()); 238 policy.open_network_configuration().open_network_configuration());
506 policies->Set(key::kDeviceOpenNetworkConfiguration, 239 policies->Set(key::kDeviceOpenNetworkConfiguration,
507 POLICY_LEVEL_MANDATORY, 240 POLICY_LEVEL_MANDATORY,
508 POLICY_SCOPE_MACHINE, 241 POLICY_SCOPE_MACHINE,
509 Value::CreateStringValue(config)); 242 Value::CreateStringValue(config));
510 } 243 }
511 } 244 }
512 245
513 // static 246 void DecodeReportingPolicies(const em::ChromeDeviceSettingsProto& policy,
514 void DevicePolicyCache::DecodeReportingPolicies( 247 PolicyMap* policies) {
515 const em::ChromeDeviceSettingsProto& policy,
516 PolicyMap* policies) {
517 if (policy.has_device_reporting()) { 248 if (policy.has_device_reporting()) {
518 const em::DeviceReportingProto& container(policy.device_reporting()); 249 const em::DeviceReportingProto& container(policy.device_reporting());
519 if (container.has_report_version_info()) { 250 if (container.has_report_version_info()) {
520 policies->Set(key::kReportDeviceVersionInfo, 251 policies->Set(key::kReportDeviceVersionInfo,
521 POLICY_LEVEL_MANDATORY, 252 POLICY_LEVEL_MANDATORY,
522 POLICY_SCOPE_MACHINE, 253 POLICY_SCOPE_MACHINE,
523 Value::CreateBooleanValue(container.report_version_info())); 254 Value::CreateBooleanValue(container.report_version_info()));
524 } 255 }
525 if (container.has_report_activity_times()) { 256 if (container.has_report_activity_times()) {
526 policies->Set(key::kReportDeviceActivityTimes, 257 policies->Set(key::kReportDeviceActivityTimes,
(...skipping 10 matching lines...) Expand all
537 } 268 }
538 if (container.has_report_location()) { 269 if (container.has_report_location()) {
539 policies->Set(key::kReportDeviceLocation, 270 policies->Set(key::kReportDeviceLocation,
540 POLICY_LEVEL_MANDATORY, 271 POLICY_LEVEL_MANDATORY,
541 POLICY_SCOPE_MACHINE, 272 POLICY_SCOPE_MACHINE,
542 Value::CreateBooleanValue(container.report_location())); 273 Value::CreateBooleanValue(container.report_location()));
543 } 274 }
544 } 275 }
545 } 276 }
546 277
547 // static 278 void DecodeAutoUpdatePolicies(const em::ChromeDeviceSettingsProto& policy,
548 void DevicePolicyCache::DecodeAutoUpdatePolicies( 279 PolicyMap* policies) {
549 const em::ChromeDeviceSettingsProto& policy,
550 PolicyMap* policies) {
551 if (policy.has_release_channel()) { 280 if (policy.has_release_channel()) {
552 const em::ReleaseChannelProto& container(policy.release_channel()); 281 const em::ReleaseChannelProto& container(policy.release_channel());
553 if (container.has_release_channel()) { 282 if (container.has_release_channel()) {
554 std::string channel(container.release_channel()); 283 std::string channel(container.release_channel());
555 policies->Set(key::kChromeOsReleaseChannel, 284 policies->Set(key::kChromeOsReleaseChannel,
556 POLICY_LEVEL_MANDATORY, 285 POLICY_LEVEL_MANDATORY,
557 POLICY_SCOPE_MACHINE, 286 POLICY_SCOPE_MACHINE,
558 Value::CreateStringValue(channel)); 287 Value::CreateStringValue(channel));
559 // TODO(dubroy): Once http://crosbug.com/17015 is implemented, we won't 288 // TODO(dubroy): Once http://crosbug.com/17015 is implemented, we won't
560 // have to pass the channel in here, only ping the update engine to tell 289 // have to pass the channel in here, only ping the update engine to tell
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
610 allowed_connection_types->Append(value); 339 allowed_connection_types->Append(value);
611 } 340 }
612 policies->Set(key::kDeviceUpdateAllowedConnectionTypes, 341 policies->Set(key::kDeviceUpdateAllowedConnectionTypes,
613 POLICY_LEVEL_MANDATORY, 342 POLICY_LEVEL_MANDATORY,
614 POLICY_SCOPE_MACHINE, 343 POLICY_SCOPE_MACHINE,
615 allowed_connection_types); 344 allowed_connection_types);
616 } 345 }
617 } 346 }
618 } 347 }
619 348
620 // static 349 void DecodeGenericPolicies(const em::ChromeDeviceSettingsProto& policy,
621 void DevicePolicyCache::DecodeGenericPolicies( 350 PolicyMap* policies) {
622 const em::ChromeDeviceSettingsProto& policy,
623 PolicyMap* policies) {
624 if (policy.has_device_policy_refresh_rate()) { 351 if (policy.has_device_policy_refresh_rate()) {
625 const em::DevicePolicyRefreshRateProto& container( 352 const em::DevicePolicyRefreshRateProto& container(
626 policy.device_policy_refresh_rate()); 353 policy.device_policy_refresh_rate());
627 if (container.has_device_policy_refresh_rate()) { 354 if (container.has_device_policy_refresh_rate()) {
628 policies->Set(key::kDevicePolicyRefreshRate, 355 policies->Set(key::kDevicePolicyRefreshRate,
629 POLICY_LEVEL_MANDATORY, 356 POLICY_LEVEL_MANDATORY,
630 POLICY_SCOPE_MACHINE, 357 POLICY_SCOPE_MACHINE,
631 DecodeIntegerValue(container.device_policy_refresh_rate())); 358 DecodeIntegerValue(container.device_policy_refresh_rate()));
632 } 359 }
633 } 360 }
(...skipping 29 matching lines...) Expand all
663 if (policy.system_timezone().has_timezone()) { 390 if (policy.system_timezone().has_timezone()) {
664 policies->Set(key::kSystemTimezone, 391 policies->Set(key::kSystemTimezone,
665 POLICY_LEVEL_MANDATORY, 392 POLICY_LEVEL_MANDATORY,
666 POLICY_SCOPE_MACHINE, 393 POLICY_SCOPE_MACHINE,
667 Value::CreateStringValue( 394 Value::CreateStringValue(
668 policy.system_timezone().timezone())); 395 policy.system_timezone().timezone()));
669 } 396 }
670 } 397 }
671 } 398 }
672 399
400 } // namespace
401
402 void DecodeDevicePolicy(const em::ChromeDeviceSettingsProto& policy,
403 PolicyMap* policies,
404 EnterpriseInstallAttributes* install_attributes) {
405 // Decode the various groups of policies.
406 DecodeLoginPolicies(policy, policies);
407 DecodeKioskPolicies(policy, policies, install_attributes);
408 DecodeNetworkPolicies(policy, policies, install_attributes);
409 DecodeReportingPolicies(policy, policies);
410 DecodeAutoUpdatePolicies(policy, policies);
411 DecodeGenericPolicies(policy, policies);
412 }
413
673 } // namespace policy 414 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/policy/device_policy_decoder_chromeos.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698