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

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

Issue 1348903007: Revert of Add source column to chrome://policy showing the origins of policies. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
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/chromeos/policy/device_policy_decoder_chromeos.h" 5 #include "chrome/browser/chromeos/policy/device_policy_decoder_chromeos.h"
6 6
7 #include <limits> 7 #include <limits>
8 #include <string> 8 #include <string>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/json/json_reader.h" 11 #include "base/json/json_reader.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/values.h" 13 #include "base/values.h"
14 #include "chrome/browser/browser_process.h" 14 #include "chrome/browser/browser_process.h"
15 #include "chrome/browser/chromeos/policy/device_local_account.h" 15 #include "chrome/browser/chromeos/policy/device_local_account.h"
16 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" 16 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h"
17 #include "chromeos/dbus/dbus_thread_manager.h" 17 #include "chromeos/dbus/dbus_thread_manager.h"
18 #include "chromeos/dbus/update_engine_client.h" 18 #include "chromeos/dbus/update_engine_client.h"
19 #include "chromeos/settings/cros_settings_names.h" 19 #include "chromeos/settings/cros_settings_names.h"
20 #include "components/policy/core/browser/browser_policy_connector.h" 20 #include "components/policy/core/browser/browser_policy_connector.h"
21 #include "components/policy/core/common/external_data_fetcher.h" 21 #include "components/policy/core/common/external_data_fetcher.h"
22 #include "components/policy/core/common/policy_map.h" 22 #include "components/policy/core/common/policy_map.h"
23 #include "components/policy/core/common/policy_types.h"
24 #include "components/policy/core/common/schema.h" 23 #include "components/policy/core/common/schema.h"
25 #include "policy/policy_constants.h" 24 #include "policy/policy_constants.h"
26 #include "third_party/cros_system_api/dbus/service_constants.h" 25 #include "third_party/cros_system_api/dbus/service_constants.h"
27 26
28 using google::protobuf::RepeatedField; 27 using google::protobuf::RepeatedField;
29 using google::protobuf::RepeatedPtrField; 28 using google::protobuf::RepeatedPtrField;
30 29
31 namespace em = enterprise_management; 30 namespace em = enterprise_management;
32 31
33 namespace policy { 32 namespace policy {
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 } 108 }
110 109
111 void DecodeLoginPolicies(const em::ChromeDeviceSettingsProto& policy, 110 void DecodeLoginPolicies(const em::ChromeDeviceSettingsProto& policy,
112 PolicyMap* policies) { 111 PolicyMap* policies) {
113 if (policy.has_guest_mode_enabled()) { 112 if (policy.has_guest_mode_enabled()) {
114 const em::GuestModeEnabledProto& container(policy.guest_mode_enabled()); 113 const em::GuestModeEnabledProto& container(policy.guest_mode_enabled());
115 if (container.has_guest_mode_enabled()) { 114 if (container.has_guest_mode_enabled()) {
116 policies->Set(key::kDeviceGuestModeEnabled, 115 policies->Set(key::kDeviceGuestModeEnabled,
117 POLICY_LEVEL_MANDATORY, 116 POLICY_LEVEL_MANDATORY,
118 POLICY_SCOPE_MACHINE, 117 POLICY_SCOPE_MACHINE,
119 POLICY_SOURCE_CLOUD,
120 new base::FundamentalValue( 118 new base::FundamentalValue(
121 container.guest_mode_enabled()), 119 container.guest_mode_enabled()),
122 NULL); 120 NULL);
123 } 121 }
124 } 122 }
125 123
126 if (policy.has_reboot_on_shutdown()) { 124 if (policy.has_reboot_on_shutdown()) {
127 const em::RebootOnShutdownProto& container(policy.reboot_on_shutdown()); 125 const em::RebootOnShutdownProto& container(policy.reboot_on_shutdown());
128 if (container.has_reboot_on_shutdown()) { 126 if (container.has_reboot_on_shutdown()) {
129 policies->Set(key::kDeviceRebootOnShutdown, POLICY_LEVEL_MANDATORY, 127 policies->Set(key::kDeviceRebootOnShutdown, POLICY_LEVEL_MANDATORY,
130 POLICY_SCOPE_MACHINE, 128 POLICY_SCOPE_MACHINE,
131 POLICY_SOURCE_CLOUD,
132 new base::FundamentalValue(container.reboot_on_shutdown()), 129 new base::FundamentalValue(container.reboot_on_shutdown()),
133 NULL); 130 NULL);
134 } 131 }
135 } 132 }
136 133
137 if (policy.has_show_user_names()) { 134 if (policy.has_show_user_names()) {
138 const em::ShowUserNamesOnSigninProto& container(policy.show_user_names()); 135 const em::ShowUserNamesOnSigninProto& container(policy.show_user_names());
139 if (container.has_show_user_names()) { 136 if (container.has_show_user_names()) {
140 policies->Set(key::kDeviceShowUserNamesOnSignin, 137 policies->Set(key::kDeviceShowUserNamesOnSignin,
141 POLICY_LEVEL_MANDATORY, 138 POLICY_LEVEL_MANDATORY,
142 POLICY_SCOPE_MACHINE, 139 POLICY_SCOPE_MACHINE,
143 POLICY_SOURCE_CLOUD,
144 new base::FundamentalValue( 140 new base::FundamentalValue(
145 container.show_user_names()), 141 container.show_user_names()),
146 NULL); 142 NULL);
147 } 143 }
148 } 144 }
149 145
150 if (policy.has_allow_new_users()) { 146 if (policy.has_allow_new_users()) {
151 const em::AllowNewUsersProto& container(policy.allow_new_users()); 147 const em::AllowNewUsersProto& container(policy.allow_new_users());
152 if (container.has_allow_new_users()) { 148 if (container.has_allow_new_users()) {
153 policies->Set(key::kDeviceAllowNewUsers, 149 policies->Set(key::kDeviceAllowNewUsers,
154 POLICY_LEVEL_MANDATORY, 150 POLICY_LEVEL_MANDATORY,
155 POLICY_SCOPE_MACHINE, 151 POLICY_SCOPE_MACHINE,
156 POLICY_SOURCE_CLOUD,
157 new base::FundamentalValue( 152 new base::FundamentalValue(
158 container.allow_new_users()), 153 container.allow_new_users()),
159 NULL); 154 NULL);
160 } 155 }
161 } 156 }
162 157
163 if (policy.has_user_whitelist()) { 158 if (policy.has_user_whitelist()) {
164 const em::UserWhitelistProto& container(policy.user_whitelist()); 159 const em::UserWhitelistProto& container(policy.user_whitelist());
165 base::ListValue* whitelist = new base::ListValue(); 160 base::ListValue* whitelist = new base::ListValue();
166 RepeatedPtrField<std::string>::const_iterator entry; 161 RepeatedPtrField<std::string>::const_iterator entry;
167 for (entry = container.user_whitelist().begin(); 162 for (entry = container.user_whitelist().begin();
168 entry != container.user_whitelist().end(); 163 entry != container.user_whitelist().end();
169 ++entry) { 164 ++entry) {
170 whitelist->Append(new base::StringValue(*entry)); 165 whitelist->Append(new base::StringValue(*entry));
171 } 166 }
172 policies->Set(key::kDeviceUserWhitelist, 167 policies->Set(key::kDeviceUserWhitelist,
173 POLICY_LEVEL_MANDATORY, 168 POLICY_LEVEL_MANDATORY,
174 POLICY_SCOPE_MACHINE, 169 POLICY_SCOPE_MACHINE,
175 POLICY_SOURCE_CLOUD,
176 whitelist, 170 whitelist,
177 NULL); 171 NULL);
178 } 172 }
179 173
180 if (policy.has_ephemeral_users_enabled()) { 174 if (policy.has_ephemeral_users_enabled()) {
181 const em::EphemeralUsersEnabledProto& container( 175 const em::EphemeralUsersEnabledProto& container(
182 policy.ephemeral_users_enabled()); 176 policy.ephemeral_users_enabled());
183 if (container.has_ephemeral_users_enabled()) { 177 if (container.has_ephemeral_users_enabled()) {
184 policies->Set(key::kDeviceEphemeralUsersEnabled, 178 policies->Set(key::kDeviceEphemeralUsersEnabled,
185 POLICY_LEVEL_MANDATORY, 179 POLICY_LEVEL_MANDATORY,
186 POLICY_SCOPE_MACHINE, 180 POLICY_SCOPE_MACHINE,
187 POLICY_SOURCE_CLOUD,
188 new base::FundamentalValue( 181 new base::FundamentalValue(
189 container.ephemeral_users_enabled()), 182 container.ephemeral_users_enabled()),
190 NULL); 183 NULL);
191 } 184 }
192 } 185 }
193 186
194 if (policy.has_device_local_accounts()) { 187 if (policy.has_device_local_accounts()) {
195 const em::DeviceLocalAccountsProto& container( 188 const em::DeviceLocalAccountsProto& container(
196 policy.device_local_accounts()); 189 policy.device_local_accounts());
197 const RepeatedPtrField<em::DeviceLocalAccountInfoProto>& accounts = 190 const RepeatedPtrField<em::DeviceLocalAccountInfoProto>& accounts =
(...skipping 28 matching lines...) Expand all
226 entry->deprecated_public_session_id()); 219 entry->deprecated_public_session_id());
227 entry_dict->SetIntegerWithoutPathExpansion( 220 entry_dict->SetIntegerWithoutPathExpansion(
228 chromeos::kAccountsPrefDeviceLocalAccountsKeyType, 221 chromeos::kAccountsPrefDeviceLocalAccountsKeyType,
229 DeviceLocalAccount::TYPE_PUBLIC_SESSION); 222 DeviceLocalAccount::TYPE_PUBLIC_SESSION);
230 } 223 }
231 account_list->Append(entry_dict.release()); 224 account_list->Append(entry_dict.release());
232 } 225 }
233 policies->Set(key::kDeviceLocalAccounts, 226 policies->Set(key::kDeviceLocalAccounts,
234 POLICY_LEVEL_MANDATORY, 227 POLICY_LEVEL_MANDATORY,
235 POLICY_SCOPE_MACHINE, 228 POLICY_SCOPE_MACHINE,
236 POLICY_SOURCE_CLOUD,
237 account_list.release(), 229 account_list.release(),
238 NULL); 230 NULL);
239 if (container.has_auto_login_id()) { 231 if (container.has_auto_login_id()) {
240 policies->Set(key::kDeviceLocalAccountAutoLoginId, 232 policies->Set(key::kDeviceLocalAccountAutoLoginId,
241 POLICY_LEVEL_MANDATORY, 233 POLICY_LEVEL_MANDATORY,
242 POLICY_SCOPE_MACHINE, 234 POLICY_SCOPE_MACHINE,
243 POLICY_SOURCE_CLOUD,
244 new base::StringValue(container.auto_login_id()), 235 new base::StringValue(container.auto_login_id()),
245 NULL); 236 NULL);
246 } 237 }
247 if (container.has_auto_login_delay()) { 238 if (container.has_auto_login_delay()) {
248 policies->Set(key::kDeviceLocalAccountAutoLoginDelay, 239 policies->Set(key::kDeviceLocalAccountAutoLoginDelay,
249 POLICY_LEVEL_MANDATORY, 240 POLICY_LEVEL_MANDATORY,
250 POLICY_SCOPE_MACHINE, 241 POLICY_SCOPE_MACHINE,
251 POLICY_SOURCE_CLOUD,
252 DecodeIntegerValue(container.auto_login_delay()).release(), 242 DecodeIntegerValue(container.auto_login_delay()).release(),
253 NULL); 243 NULL);
254 } 244 }
255 if (container.has_enable_auto_login_bailout()) { 245 if (container.has_enable_auto_login_bailout()) {
256 policies->Set(key::kDeviceLocalAccountAutoLoginBailoutEnabled, 246 policies->Set(key::kDeviceLocalAccountAutoLoginBailoutEnabled,
257 POLICY_LEVEL_MANDATORY, 247 POLICY_LEVEL_MANDATORY,
258 POLICY_SCOPE_MACHINE, 248 POLICY_SCOPE_MACHINE,
259 POLICY_SOURCE_CLOUD,
260 new base::FundamentalValue( 249 new base::FundamentalValue(
261 container.enable_auto_login_bailout()), 250 container.enable_auto_login_bailout()),
262 NULL); 251 NULL);
263 } 252 }
264 if (container.has_prompt_for_network_when_offline()) { 253 if (container.has_prompt_for_network_when_offline()) {
265 policies->Set(key::kDeviceLocalAccountPromptForNetworkWhenOffline, 254 policies->Set(key::kDeviceLocalAccountPromptForNetworkWhenOffline,
266 POLICY_LEVEL_MANDATORY, 255 POLICY_LEVEL_MANDATORY,
267 POLICY_SCOPE_MACHINE, 256 POLICY_SCOPE_MACHINE,
268 POLICY_SOURCE_CLOUD,
269 new base::FundamentalValue( 257 new base::FundamentalValue(
270 container.prompt_for_network_when_offline()), 258 container.prompt_for_network_when_offline()),
271 NULL); 259 NULL);
272 } 260 }
273 } 261 }
274 262
275 if (policy.has_supervised_users_settings()) { 263 if (policy.has_supervised_users_settings()) {
276 const em::SupervisedUsersSettingsProto& container = 264 const em::SupervisedUsersSettingsProto& container =
277 policy.supervised_users_settings(); 265 policy.supervised_users_settings();
278 if (container.has_supervised_users_enabled()) { 266 if (container.has_supervised_users_enabled()) {
279 base::Value* value = new base::FundamentalValue( 267 base::Value* value = new base::FundamentalValue(
280 container.supervised_users_enabled()); 268 container.supervised_users_enabled());
281 policies->Set(key::kSupervisedUsersEnabled, 269 policies->Set(key::kSupervisedUsersEnabled,
282 POLICY_LEVEL_MANDATORY, 270 POLICY_LEVEL_MANDATORY,
283 POLICY_SCOPE_MACHINE, 271 POLICY_SCOPE_MACHINE,
284 POLICY_SOURCE_CLOUD,
285 value, 272 value,
286 NULL); 273 NULL);
287 } 274 }
288 } 275 }
289 276
290 if (policy.has_saml_settings()) { 277 if (policy.has_saml_settings()) {
291 const em::SAMLSettingsProto& container(policy.saml_settings()); 278 const em::SAMLSettingsProto& container(policy.saml_settings());
292 if (container.has_transfer_saml_cookies()) { 279 if (container.has_transfer_saml_cookies()) {
293 policies->Set(key::kDeviceTransferSAMLCookies, 280 policies->Set(key::kDeviceTransferSAMLCookies,
294 POLICY_LEVEL_MANDATORY, 281 POLICY_LEVEL_MANDATORY,
295 POLICY_SCOPE_MACHINE, 282 POLICY_SCOPE_MACHINE,
296 POLICY_SOURCE_CLOUD,
297 new base::FundamentalValue( 283 new base::FundamentalValue(
298 container.transfer_saml_cookies()), 284 container.transfer_saml_cookies()),
299 NULL); 285 NULL);
300 } 286 }
301 } 287 }
302 } 288 }
303 289
304 void DecodeNetworkPolicies(const em::ChromeDeviceSettingsProto& policy, 290 void DecodeNetworkPolicies(const em::ChromeDeviceSettingsProto& policy,
305 PolicyMap* policies) { 291 PolicyMap* policies) {
306 if (policy.has_data_roaming_enabled()) { 292 if (policy.has_data_roaming_enabled()) {
307 const em::DataRoamingEnabledProto& container(policy.data_roaming_enabled()); 293 const em::DataRoamingEnabledProto& container(policy.data_roaming_enabled());
308 if (container.has_data_roaming_enabled()) { 294 if (container.has_data_roaming_enabled()) {
309 policies->Set(key::kDeviceDataRoamingEnabled, 295 policies->Set(key::kDeviceDataRoamingEnabled,
310 POLICY_LEVEL_MANDATORY, 296 POLICY_LEVEL_MANDATORY,
311 POLICY_SCOPE_MACHINE, 297 POLICY_SCOPE_MACHINE,
312 POLICY_SOURCE_CLOUD,
313 new base::FundamentalValue( 298 new base::FundamentalValue(
314 container.data_roaming_enabled()), 299 container.data_roaming_enabled()),
315 NULL); 300 NULL);
316 } 301 }
317 } 302 }
318 303
319 if (policy.has_open_network_configuration() && 304 if (policy.has_open_network_configuration() &&
320 policy.open_network_configuration().has_open_network_configuration()) { 305 policy.open_network_configuration().has_open_network_configuration()) {
321 std::string config( 306 std::string config(
322 policy.open_network_configuration().open_network_configuration()); 307 policy.open_network_configuration().open_network_configuration());
323 policies->Set(key::kDeviceOpenNetworkConfiguration, 308 policies->Set(key::kDeviceOpenNetworkConfiguration,
324 POLICY_LEVEL_MANDATORY, 309 POLICY_LEVEL_MANDATORY,
325 POLICY_SCOPE_MACHINE, 310 POLICY_SCOPE_MACHINE,
326 POLICY_SOURCE_CLOUD,
327 new base::StringValue(config), 311 new base::StringValue(config),
328 NULL); 312 NULL);
329 } 313 }
330 } 314 }
331 315
332 void DecodeReportingPolicies(const em::ChromeDeviceSettingsProto& policy, 316 void DecodeReportingPolicies(const em::ChromeDeviceSettingsProto& policy,
333 PolicyMap* policies) { 317 PolicyMap* policies) {
334 if (policy.has_device_reporting()) { 318 if (policy.has_device_reporting()) {
335 const em::DeviceReportingProto& container(policy.device_reporting()); 319 const em::DeviceReportingProto& container(policy.device_reporting());
336 if (container.has_report_version_info()) { 320 if (container.has_report_version_info()) {
337 policies->Set(key::kReportDeviceVersionInfo, 321 policies->Set(key::kReportDeviceVersionInfo,
338 POLICY_LEVEL_MANDATORY, 322 POLICY_LEVEL_MANDATORY,
339 POLICY_SCOPE_MACHINE, 323 POLICY_SCOPE_MACHINE,
340 POLICY_SOURCE_CLOUD,
341 new base::FundamentalValue( 324 new base::FundamentalValue(
342 container.report_version_info()), 325 container.report_version_info()),
343 NULL); 326 NULL);
344 } 327 }
345 if (container.has_report_activity_times()) { 328 if (container.has_report_activity_times()) {
346 policies->Set(key::kReportDeviceActivityTimes, 329 policies->Set(key::kReportDeviceActivityTimes,
347 POLICY_LEVEL_MANDATORY, 330 POLICY_LEVEL_MANDATORY,
348 POLICY_SCOPE_MACHINE, 331 POLICY_SCOPE_MACHINE,
349 POLICY_SOURCE_CLOUD,
350 new base::FundamentalValue( 332 new base::FundamentalValue(
351 container.report_activity_times()), 333 container.report_activity_times()),
352 NULL); 334 NULL);
353 } 335 }
354 if (container.has_report_boot_mode()) { 336 if (container.has_report_boot_mode()) {
355 policies->Set(key::kReportDeviceBootMode, 337 policies->Set(key::kReportDeviceBootMode,
356 POLICY_LEVEL_MANDATORY, 338 POLICY_LEVEL_MANDATORY,
357 POLICY_SCOPE_MACHINE, 339 POLICY_SCOPE_MACHINE,
358 POLICY_SOURCE_CLOUD,
359 new base::FundamentalValue( 340 new base::FundamentalValue(
360 container.report_boot_mode()), 341 container.report_boot_mode()),
361 NULL); 342 NULL);
362 } 343 }
363 if (container.has_report_location()) { 344 if (container.has_report_location()) {
364 policies->Set(key::kReportDeviceLocation, 345 policies->Set(key::kReportDeviceLocation,
365 POLICY_LEVEL_MANDATORY, 346 POLICY_LEVEL_MANDATORY,
366 POLICY_SCOPE_MACHINE, 347 POLICY_SCOPE_MACHINE,
367 POLICY_SOURCE_CLOUD,
368 new base::FundamentalValue( 348 new base::FundamentalValue(
369 container.report_location()), 349 container.report_location()),
370 NULL); 350 NULL);
371 } 351 }
372 if (container.has_report_network_interfaces()) { 352 if (container.has_report_network_interfaces()) {
373 policies->Set(key::kReportDeviceNetworkInterfaces, 353 policies->Set(key::kReportDeviceNetworkInterfaces,
374 POLICY_LEVEL_MANDATORY, 354 POLICY_LEVEL_MANDATORY,
375 POLICY_SCOPE_MACHINE, 355 POLICY_SCOPE_MACHINE,
376 POLICY_SOURCE_CLOUD,
377 new base::FundamentalValue( 356 new base::FundamentalValue(
378 container.report_network_interfaces()), 357 container.report_network_interfaces()),
379 NULL); 358 NULL);
380 } 359 }
381 if (container.has_report_users()) { 360 if (container.has_report_users()) {
382 policies->Set(key::kReportDeviceUsers, 361 policies->Set(key::kReportDeviceUsers,
383 POLICY_LEVEL_MANDATORY, 362 POLICY_LEVEL_MANDATORY,
384 POLICY_SCOPE_MACHINE, 363 POLICY_SCOPE_MACHINE,
385 POLICY_SOURCE_CLOUD,
386 new base::FundamentalValue(container.report_users()), 364 new base::FundamentalValue(container.report_users()),
387 NULL); 365 NULL);
388 } 366 }
389 if (container.has_report_hardware_status()) { 367 if (container.has_report_hardware_status()) {
390 policies->Set(key::kReportDeviceHardwareStatus, 368 policies->Set(key::kReportDeviceHardwareStatus,
391 POLICY_LEVEL_MANDATORY, 369 POLICY_LEVEL_MANDATORY,
392 POLICY_SCOPE_MACHINE, 370 POLICY_SCOPE_MACHINE,
393 POLICY_SOURCE_CLOUD,
394 new base::FundamentalValue( 371 new base::FundamentalValue(
395 container.report_hardware_status()), 372 container.report_hardware_status()),
396 NULL); 373 NULL);
397 } 374 }
398 if (container.has_report_session_status()) { 375 if (container.has_report_session_status()) {
399 policies->Set(key::kReportDeviceSessionStatus, 376 policies->Set(key::kReportDeviceSessionStatus,
400 POLICY_LEVEL_MANDATORY, 377 POLICY_LEVEL_MANDATORY,
401 POLICY_SCOPE_MACHINE, 378 POLICY_SCOPE_MACHINE,
402 POLICY_SOURCE_CLOUD,
403 new base::FundamentalValue( 379 new base::FundamentalValue(
404 container.report_session_status()), 380 container.report_session_status()),
405 NULL); 381 NULL);
406 } 382 }
407 if (container.has_device_status_frequency()) { 383 if (container.has_device_status_frequency()) {
408 policies->Set(key::kReportUploadFrequency, 384 policies->Set(key::kReportUploadFrequency,
409 POLICY_LEVEL_MANDATORY, 385 POLICY_LEVEL_MANDATORY,
410 POLICY_SCOPE_MACHINE, 386 POLICY_SCOPE_MACHINE,
411 POLICY_SOURCE_CLOUD,
412 DecodeIntegerValue( 387 DecodeIntegerValue(
413 container.device_status_frequency()).release(), 388 container.device_status_frequency()).release(),
414 NULL); 389 NULL);
415 } 390 }
416 } 391 }
417 392
418 if (policy.has_device_heartbeat_settings()) { 393 if (policy.has_device_heartbeat_settings()) {
419 const em::DeviceHeartbeatSettingsProto& container( 394 const em::DeviceHeartbeatSettingsProto& container(
420 policy.device_heartbeat_settings()); 395 policy.device_heartbeat_settings());
421 if (container.has_heartbeat_enabled()) { 396 if (container.has_heartbeat_enabled()) {
422 policies->Set(key::kHeartbeatEnabled, 397 policies->Set(key::kHeartbeatEnabled,
423 POLICY_LEVEL_MANDATORY, 398 POLICY_LEVEL_MANDATORY,
424 POLICY_SCOPE_MACHINE, 399 POLICY_SCOPE_MACHINE,
425 POLICY_SOURCE_CLOUD,
426 new base::FundamentalValue( 400 new base::FundamentalValue(
427 container.heartbeat_enabled()), 401 container.heartbeat_enabled()),
428 NULL); 402 NULL);
429 } 403 }
430 if (container.has_heartbeat_frequency()) { 404 if (container.has_heartbeat_frequency()) {
431 policies->Set(key::kHeartbeatFrequency, 405 policies->Set(key::kHeartbeatFrequency,
432 POLICY_LEVEL_MANDATORY, 406 POLICY_LEVEL_MANDATORY,
433 POLICY_SCOPE_MACHINE, 407 POLICY_SCOPE_MACHINE,
434 POLICY_SOURCE_CLOUD,
435 DecodeIntegerValue( 408 DecodeIntegerValue(
436 container.heartbeat_frequency()).release(), 409 container.heartbeat_frequency()).release(),
437 NULL); 410 NULL);
438 } 411 }
439 } 412 }
440 413
441 if (policy.has_device_log_upload_settings()) { 414 if (policy.has_device_log_upload_settings()) {
442 const em::DeviceLogUploadSettingsProto& container( 415 const em::DeviceLogUploadSettingsProto& container(
443 policy.device_log_upload_settings()); 416 policy.device_log_upload_settings());
444 if (container.has_system_log_upload_enabled()) { 417 if (container.has_system_log_upload_enabled()) {
445 policies->Set( 418 policies->Set(
446 key::kLogUploadEnabled, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, 419 key::kLogUploadEnabled, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE,
447 POLICY_SOURCE_CLOUD,
448 new base::FundamentalValue(container.system_log_upload_enabled()), 420 new base::FundamentalValue(container.system_log_upload_enabled()),
449 NULL); 421 NULL);
450 } 422 }
451 } 423 }
452 } 424 }
453 425
454 void DecodeAutoUpdatePolicies(const em::ChromeDeviceSettingsProto& policy, 426 void DecodeAutoUpdatePolicies(const em::ChromeDeviceSettingsProto& policy,
455 PolicyMap* policies) { 427 PolicyMap* policies) {
456 if (policy.has_release_channel()) { 428 if (policy.has_release_channel()) {
457 const em::ReleaseChannelProto& container(policy.release_channel()); 429 const em::ReleaseChannelProto& container(policy.release_channel());
458 if (container.has_release_channel()) { 430 if (container.has_release_channel()) {
459 std::string channel(container.release_channel()); 431 std::string channel(container.release_channel());
460 policies->Set(key::kChromeOsReleaseChannel, 432 policies->Set(key::kChromeOsReleaseChannel,
461 POLICY_LEVEL_MANDATORY, 433 POLICY_LEVEL_MANDATORY,
462 POLICY_SCOPE_MACHINE, 434 POLICY_SCOPE_MACHINE,
463 POLICY_SOURCE_CLOUD,
464 new base::StringValue(channel), 435 new base::StringValue(channel),
465 NULL); 436 NULL);
466 // TODO(dubroy): Once http://crosbug.com/17015 is implemented, we won't 437 // TODO(dubroy): Once http://crosbug.com/17015 is implemented, we won't
467 // have to pass the channel in here, only ping the update engine to tell 438 // have to pass the channel in here, only ping the update engine to tell
468 // it to fetch the channel from the policy. 439 // it to fetch the channel from the policy.
469 chromeos::DBusThreadManager::Get()->GetUpdateEngineClient()-> 440 chromeos::DBusThreadManager::Get()->GetUpdateEngineClient()->
470 SetChannel(channel, false); 441 SetChannel(channel, false);
471 } 442 }
472 if (container.has_release_channel_delegated()) { 443 if (container.has_release_channel_delegated()) {
473 policies->Set(key::kChromeOsReleaseChannelDelegated, 444 policies->Set(key::kChromeOsReleaseChannelDelegated,
474 POLICY_LEVEL_MANDATORY, 445 POLICY_LEVEL_MANDATORY,
475 POLICY_SCOPE_MACHINE, 446 POLICY_SCOPE_MACHINE,
476 POLICY_SOURCE_CLOUD,
477 new base::FundamentalValue( 447 new base::FundamentalValue(
478 container.release_channel_delegated()), 448 container.release_channel_delegated()),
479 NULL); 449 NULL);
480 } 450 }
481 } 451 }
482 452
483 if (policy.has_auto_update_settings()) { 453 if (policy.has_auto_update_settings()) {
484 const em::AutoUpdateSettingsProto& container(policy.auto_update_settings()); 454 const em::AutoUpdateSettingsProto& container(policy.auto_update_settings());
485 if (container.has_update_disabled()) { 455 if (container.has_update_disabled()) {
486 policies->Set(key::kDeviceAutoUpdateDisabled, 456 policies->Set(key::kDeviceAutoUpdateDisabled,
487 POLICY_LEVEL_MANDATORY, 457 POLICY_LEVEL_MANDATORY,
488 POLICY_SCOPE_MACHINE, 458 POLICY_SCOPE_MACHINE,
489 POLICY_SOURCE_CLOUD,
490 new base::FundamentalValue( 459 new base::FundamentalValue(
491 container.update_disabled()), 460 container.update_disabled()),
492 NULL); 461 NULL);
493 } 462 }
494 463
495 if (container.has_target_version_prefix()) { 464 if (container.has_target_version_prefix()) {
496 policies->Set(key::kDeviceTargetVersionPrefix, 465 policies->Set(key::kDeviceTargetVersionPrefix,
497 POLICY_LEVEL_MANDATORY, 466 POLICY_LEVEL_MANDATORY,
498 POLICY_SCOPE_MACHINE, 467 POLICY_SCOPE_MACHINE,
499 POLICY_SOURCE_CLOUD,
500 new base::StringValue( 468 new base::StringValue(
501 container.target_version_prefix()), 469 container.target_version_prefix()),
502 NULL); 470 NULL);
503 } 471 }
504 472
505 // target_version_display_name is not actually a policy, but a display 473 // target_version_display_name is not actually a policy, but a display
506 // string for target_version_prefix, so we ignore it. 474 // string for target_version_prefix, so we ignore it.
507 475
508 if (container.has_scatter_factor_in_seconds()) { 476 if (container.has_scatter_factor_in_seconds()) {
509 policies->Set(key::kDeviceUpdateScatterFactor, 477 policies->Set(key::kDeviceUpdateScatterFactor,
510 POLICY_LEVEL_MANDATORY, 478 POLICY_LEVEL_MANDATORY,
511 POLICY_SCOPE_MACHINE, 479 POLICY_SCOPE_MACHINE,
512 POLICY_SOURCE_CLOUD,
513 new base::FundamentalValue(static_cast<int>( 480 new base::FundamentalValue(static_cast<int>(
514 container.scatter_factor_in_seconds())), 481 container.scatter_factor_in_seconds())),
515 NULL); 482 NULL);
516 } 483 }
517 484
518 if (container.allowed_connection_types_size()) { 485 if (container.allowed_connection_types_size()) {
519 base::ListValue* allowed_connection_types = new base::ListValue(); 486 base::ListValue* allowed_connection_types = new base::ListValue();
520 RepeatedField<int>::const_iterator entry; 487 RepeatedField<int>::const_iterator entry;
521 for (entry = container.allowed_connection_types().begin(); 488 for (entry = container.allowed_connection_types().begin();
522 entry != container.allowed_connection_types().end(); 489 entry != container.allowed_connection_types().end();
523 ++entry) { 490 ++entry) {
524 base::Value* value = DecodeConnectionType(*entry); 491 base::Value* value = DecodeConnectionType(*entry);
525 if (value) 492 if (value)
526 allowed_connection_types->Append(value); 493 allowed_connection_types->Append(value);
527 } 494 }
528 policies->Set(key::kDeviceUpdateAllowedConnectionTypes, 495 policies->Set(key::kDeviceUpdateAllowedConnectionTypes,
529 POLICY_LEVEL_MANDATORY, 496 POLICY_LEVEL_MANDATORY,
530 POLICY_SCOPE_MACHINE, 497 POLICY_SCOPE_MACHINE,
531 POLICY_SOURCE_CLOUD,
532 allowed_connection_types, 498 allowed_connection_types,
533 NULL); 499 NULL);
534 } 500 }
535 501
536 if (container.has_http_downloads_enabled()) { 502 if (container.has_http_downloads_enabled()) {
537 policies->Set( 503 policies->Set(
538 key::kDeviceUpdateHttpDownloadsEnabled, 504 key::kDeviceUpdateHttpDownloadsEnabled,
539 POLICY_LEVEL_MANDATORY, 505 POLICY_LEVEL_MANDATORY,
540 POLICY_SCOPE_MACHINE, 506 POLICY_SCOPE_MACHINE,
541 POLICY_SOURCE_CLOUD,
542 new base::FundamentalValue(container.http_downloads_enabled()), 507 new base::FundamentalValue(container.http_downloads_enabled()),
543 NULL); 508 NULL);
544 } 509 }
545 510
546 if (container.has_reboot_after_update()) { 511 if (container.has_reboot_after_update()) {
547 policies->Set(key::kRebootAfterUpdate, 512 policies->Set(key::kRebootAfterUpdate,
548 POLICY_LEVEL_MANDATORY, 513 POLICY_LEVEL_MANDATORY,
549 POLICY_SCOPE_MACHINE, 514 POLICY_SCOPE_MACHINE,
550 POLICY_SOURCE_CLOUD,
551 new base::FundamentalValue( 515 new base::FundamentalValue(
552 container.reboot_after_update()), 516 container.reboot_after_update()),
553 NULL); 517 NULL);
554 } 518 }
555 519
556 if (container.has_p2p_enabled()) { 520 if (container.has_p2p_enabled()) {
557 policies->Set(key::kDeviceAutoUpdateP2PEnabled, 521 policies->Set(key::kDeviceAutoUpdateP2PEnabled,
558 POLICY_LEVEL_MANDATORY, 522 POLICY_LEVEL_MANDATORY,
559 POLICY_SCOPE_MACHINE, 523 POLICY_SCOPE_MACHINE,
560 POLICY_SOURCE_CLOUD,
561 new base::FundamentalValue(container.p2p_enabled()), 524 new base::FundamentalValue(container.p2p_enabled()),
562 NULL); 525 NULL);
563 } 526 }
564 } 527 }
565 } 528 }
566 529
567 void DecodeAccessibilityPolicies(const em::ChromeDeviceSettingsProto& policy, 530 void DecodeAccessibilityPolicies(const em::ChromeDeviceSettingsProto& policy,
568 PolicyMap* policies) { 531 PolicyMap* policies) {
569 if (policy.has_accessibility_settings()) { 532 if (policy.has_accessibility_settings()) {
570 const em::AccessibilitySettingsProto& 533 const em::AccessibilitySettingsProto&
571 container(policy.accessibility_settings()); 534 container(policy.accessibility_settings());
572 535
573 if (container.has_login_screen_default_large_cursor_enabled()) { 536 if (container.has_login_screen_default_large_cursor_enabled()) {
574 policies->Set( 537 policies->Set(
575 key::kDeviceLoginScreenDefaultLargeCursorEnabled, 538 key::kDeviceLoginScreenDefaultLargeCursorEnabled,
576 POLICY_LEVEL_MANDATORY, 539 POLICY_LEVEL_MANDATORY,
577 POLICY_SCOPE_MACHINE, 540 POLICY_SCOPE_MACHINE,
578 POLICY_SOURCE_CLOUD,
579 new base::FundamentalValue( 541 new base::FundamentalValue(
580 container.login_screen_default_large_cursor_enabled()), 542 container.login_screen_default_large_cursor_enabled()),
581 NULL); 543 NULL);
582 } 544 }
583 545
584 if (container.has_login_screen_default_spoken_feedback_enabled()) { 546 if (container.has_login_screen_default_spoken_feedback_enabled()) {
585 policies->Set( 547 policies->Set(
586 key::kDeviceLoginScreenDefaultSpokenFeedbackEnabled, 548 key::kDeviceLoginScreenDefaultSpokenFeedbackEnabled,
587 POLICY_LEVEL_MANDATORY, 549 POLICY_LEVEL_MANDATORY,
588 POLICY_SCOPE_MACHINE, 550 POLICY_SCOPE_MACHINE,
589 POLICY_SOURCE_CLOUD,
590 new base::FundamentalValue( 551 new base::FundamentalValue(
591 container.login_screen_default_spoken_feedback_enabled()), 552 container.login_screen_default_spoken_feedback_enabled()),
592 NULL); 553 NULL);
593 } 554 }
594 555
595 if (container.has_login_screen_default_high_contrast_enabled()) { 556 if (container.has_login_screen_default_high_contrast_enabled()) {
596 policies->Set( 557 policies->Set(
597 key::kDeviceLoginScreenDefaultHighContrastEnabled, 558 key::kDeviceLoginScreenDefaultHighContrastEnabled,
598 POLICY_LEVEL_MANDATORY, 559 POLICY_LEVEL_MANDATORY,
599 POLICY_SCOPE_MACHINE, 560 POLICY_SCOPE_MACHINE,
600 POLICY_SOURCE_CLOUD,
601 new base::FundamentalValue( 561 new base::FundamentalValue(
602 container.login_screen_default_high_contrast_enabled()), 562 container.login_screen_default_high_contrast_enabled()),
603 NULL); 563 NULL);
604 } 564 }
605 565
606 if (container.has_login_screen_default_screen_magnifier_type()) { 566 if (container.has_login_screen_default_screen_magnifier_type()) {
607 policies->Set( 567 policies->Set(
608 key::kDeviceLoginScreenDefaultScreenMagnifierType, 568 key::kDeviceLoginScreenDefaultScreenMagnifierType,
609 POLICY_LEVEL_MANDATORY, 569 POLICY_LEVEL_MANDATORY,
610 POLICY_SCOPE_MACHINE, 570 POLICY_SCOPE_MACHINE,
611 POLICY_SOURCE_CLOUD,
612 DecodeIntegerValue( 571 DecodeIntegerValue(
613 container.login_screen_default_screen_magnifier_type()).release(), 572 container.login_screen_default_screen_magnifier_type()).release(),
614 NULL); 573 NULL);
615 } 574 }
616 575
617 if (container.has_login_screen_default_virtual_keyboard_enabled()) { 576 if (container.has_login_screen_default_virtual_keyboard_enabled()) {
618 policies->Set( 577 policies->Set(
619 key::kDeviceLoginScreenDefaultVirtualKeyboardEnabled, 578 key::kDeviceLoginScreenDefaultVirtualKeyboardEnabled,
620 POLICY_LEVEL_MANDATORY, 579 POLICY_LEVEL_MANDATORY,
621 POLICY_SCOPE_MACHINE, 580 POLICY_SCOPE_MACHINE,
622 POLICY_SOURCE_CLOUD,
623 new base::FundamentalValue( 581 new base::FundamentalValue(
624 container.login_screen_default_virtual_keyboard_enabled()), 582 container.login_screen_default_virtual_keyboard_enabled()),
625 NULL); 583 NULL);
626 } 584 }
627 } 585 }
628 } 586 }
629 587
630 void DecodeGenericPolicies(const em::ChromeDeviceSettingsProto& policy, 588 void DecodeGenericPolicies(const em::ChromeDeviceSettingsProto& policy,
631 PolicyMap* policies) { 589 PolicyMap* policies) {
632 if (policy.has_device_policy_refresh_rate()) { 590 if (policy.has_device_policy_refresh_rate()) {
633 const em::DevicePolicyRefreshRateProto& container( 591 const em::DevicePolicyRefreshRateProto& container(
634 policy.device_policy_refresh_rate()); 592 policy.device_policy_refresh_rate());
635 if (container.has_device_policy_refresh_rate()) { 593 if (container.has_device_policy_refresh_rate()) {
636 policies->Set( 594 policies->Set(
637 key::kDevicePolicyRefreshRate, 595 key::kDevicePolicyRefreshRate,
638 POLICY_LEVEL_MANDATORY, 596 POLICY_LEVEL_MANDATORY,
639 POLICY_SCOPE_MACHINE, 597 POLICY_SCOPE_MACHINE,
640 POLICY_SOURCE_CLOUD,
641 DecodeIntegerValue(container.device_policy_refresh_rate()).release(), 598 DecodeIntegerValue(container.device_policy_refresh_rate()).release(),
642 NULL); 599 NULL);
643 } 600 }
644 } 601 }
645 602
646 if (policy.has_metrics_enabled()) { 603 if (policy.has_metrics_enabled()) {
647 const em::MetricsEnabledProto& container(policy.metrics_enabled()); 604 const em::MetricsEnabledProto& container(policy.metrics_enabled());
648 if (container.has_metrics_enabled()) { 605 if (container.has_metrics_enabled()) {
649 policies->Set(key::kDeviceMetricsReportingEnabled, 606 policies->Set(key::kDeviceMetricsReportingEnabled,
650 POLICY_LEVEL_MANDATORY, 607 POLICY_LEVEL_MANDATORY,
651 POLICY_SCOPE_MACHINE, 608 POLICY_SCOPE_MACHINE,
652 POLICY_SOURCE_CLOUD,
653 new base::FundamentalValue( 609 new base::FundamentalValue(
654 container.metrics_enabled()), 610 container.metrics_enabled()),
655 NULL); 611 NULL);
656 } 612 }
657 } 613 }
658 614
659 if (policy.has_system_timezone()) { 615 if (policy.has_system_timezone()) {
660 if (policy.system_timezone().has_timezone()) { 616 if (policy.system_timezone().has_timezone()) {
661 policies->Set(key::kSystemTimezone, 617 policies->Set(key::kSystemTimezone,
662 POLICY_LEVEL_MANDATORY, 618 POLICY_LEVEL_MANDATORY,
663 POLICY_SCOPE_MACHINE, 619 POLICY_SCOPE_MACHINE,
664 POLICY_SOURCE_CLOUD,
665 new base::StringValue( 620 new base::StringValue(
666 policy.system_timezone().timezone()), 621 policy.system_timezone().timezone()),
667 NULL); 622 NULL);
668 } 623 }
669 } 624 }
670 625
671 if (policy.has_use_24hour_clock()) { 626 if (policy.has_use_24hour_clock()) {
672 if (policy.use_24hour_clock().has_use_24hour_clock()) { 627 if (policy.use_24hour_clock().has_use_24hour_clock()) {
673 policies->Set(key::kSystemUse24HourClock, 628 policies->Set(key::kSystemUse24HourClock,
674 POLICY_LEVEL_MANDATORY, 629 POLICY_LEVEL_MANDATORY,
675 POLICY_SCOPE_MACHINE, 630 POLICY_SCOPE_MACHINE,
676 POLICY_SOURCE_CLOUD,
677 new base::FundamentalValue( 631 new base::FundamentalValue(
678 policy.use_24hour_clock().use_24hour_clock()), 632 policy.use_24hour_clock().use_24hour_clock()),
679 NULL); 633 NULL);
680 } 634 }
681 } 635 }
682 636
683 if (policy.has_allow_redeem_offers()) { 637 if (policy.has_allow_redeem_offers()) {
684 const em::AllowRedeemChromeOsRegistrationOffersProto& container( 638 const em::AllowRedeemChromeOsRegistrationOffersProto& container(
685 policy.allow_redeem_offers()); 639 policy.allow_redeem_offers());
686 if (container.has_allow_redeem_offers()) { 640 if (container.has_allow_redeem_offers()) {
687 policies->Set(key::kDeviceAllowRedeemChromeOsRegistrationOffers, 641 policies->Set(key::kDeviceAllowRedeemChromeOsRegistrationOffers,
688 POLICY_LEVEL_MANDATORY, 642 POLICY_LEVEL_MANDATORY,
689 POLICY_SCOPE_MACHINE, 643 POLICY_SCOPE_MACHINE,
690 POLICY_SOURCE_CLOUD,
691 new base::FundamentalValue( 644 new base::FundamentalValue(
692 container.allow_redeem_offers()), 645 container.allow_redeem_offers()),
693 NULL); 646 NULL);
694 } 647 }
695 } 648 }
696 649
697 if (policy.has_uptime_limit()) { 650 if (policy.has_uptime_limit()) {
698 const em::UptimeLimitProto& container(policy.uptime_limit()); 651 const em::UptimeLimitProto& container(policy.uptime_limit());
699 if (container.has_uptime_limit()) { 652 if (container.has_uptime_limit()) {
700 policies->Set(key::kUptimeLimit, 653 policies->Set(key::kUptimeLimit,
701 POLICY_LEVEL_MANDATORY, 654 POLICY_LEVEL_MANDATORY,
702 POLICY_SCOPE_MACHINE, 655 POLICY_SCOPE_MACHINE,
703 POLICY_SOURCE_CLOUD,
704 DecodeIntegerValue(container.uptime_limit()).release(), 656 DecodeIntegerValue(container.uptime_limit()).release(),
705 NULL); 657 NULL);
706 } 658 }
707 } 659 }
708 660
709 if (policy.has_start_up_flags()) { 661 if (policy.has_start_up_flags()) {
710 const em::StartUpFlagsProto& container(policy.start_up_flags()); 662 const em::StartUpFlagsProto& container(policy.start_up_flags());
711 base::ListValue* flags = new base::ListValue(); 663 base::ListValue* flags = new base::ListValue();
712 RepeatedPtrField<std::string>::const_iterator entry; 664 RepeatedPtrField<std::string>::const_iterator entry;
713 for (entry = container.flags().begin(); 665 for (entry = container.flags().begin();
714 entry != container.flags().end(); 666 entry != container.flags().end();
715 ++entry) { 667 ++entry) {
716 flags->Append(new base::StringValue(*entry)); 668 flags->Append(new base::StringValue(*entry));
717 } 669 }
718 policies->Set(key::kDeviceStartUpFlags, 670 policies->Set(key::kDeviceStartUpFlags,
719 POLICY_LEVEL_MANDATORY, 671 POLICY_LEVEL_MANDATORY,
720 POLICY_SCOPE_MACHINE, 672 POLICY_SCOPE_MACHINE,
721 POLICY_SOURCE_CLOUD,
722 flags, 673 flags,
723 NULL); 674 NULL);
724 } 675 }
725 676
726 if (policy.has_variations_parameter()) { 677 if (policy.has_variations_parameter()) {
727 if (policy.variations_parameter().has_parameter()) { 678 if (policy.variations_parameter().has_parameter()) {
728 policies->Set(key::kDeviceVariationsRestrictParameter, 679 policies->Set(key::kDeviceVariationsRestrictParameter,
729 POLICY_LEVEL_MANDATORY, 680 POLICY_LEVEL_MANDATORY,
730 POLICY_SCOPE_MACHINE, 681 POLICY_SCOPE_MACHINE,
731 POLICY_SOURCE_CLOUD,
732 new base::StringValue( 682 new base::StringValue(
733 policy.variations_parameter().parameter()), 683 policy.variations_parameter().parameter()),
734 NULL); 684 NULL);
735 } 685 }
736 } 686 }
737 687
738 if (policy.has_attestation_settings()) { 688 if (policy.has_attestation_settings()) {
739 if (policy.attestation_settings().has_attestation_enabled()) { 689 if (policy.attestation_settings().has_attestation_enabled()) {
740 policies->Set(key::kAttestationEnabledForDevice, 690 policies->Set(key::kAttestationEnabledForDevice,
741 POLICY_LEVEL_MANDATORY, 691 POLICY_LEVEL_MANDATORY,
742 POLICY_SCOPE_MACHINE, 692 POLICY_SCOPE_MACHINE,
743 POLICY_SOURCE_CLOUD,
744 new base::FundamentalValue( 693 new base::FundamentalValue(
745 policy.attestation_settings().attestation_enabled()), 694 policy.attestation_settings().attestation_enabled()),
746 NULL); 695 NULL);
747 } 696 }
748 if (policy.attestation_settings().has_content_protection_enabled()) { 697 if (policy.attestation_settings().has_content_protection_enabled()) {
749 policies->Set( 698 policies->Set(
750 key::kAttestationForContentProtectionEnabled, 699 key::kAttestationForContentProtectionEnabled,
751 POLICY_LEVEL_MANDATORY, 700 POLICY_LEVEL_MANDATORY,
752 POLICY_SCOPE_MACHINE, 701 POLICY_SCOPE_MACHINE,
753 POLICY_SOURCE_CLOUD,
754 new base::FundamentalValue( 702 new base::FundamentalValue(
755 policy.attestation_settings().content_protection_enabled()), 703 policy.attestation_settings().content_protection_enabled()),
756 NULL); 704 NULL);
757 } 705 }
758 } 706 }
759 707
760 if (policy.has_login_screen_power_management()) { 708 if (policy.has_login_screen_power_management()) {
761 const em::LoginScreenPowerManagementProto& container( 709 const em::LoginScreenPowerManagementProto& container(
762 policy.login_screen_power_management()); 710 policy.login_screen_power_management());
763 if (container.has_login_screen_power_management()) { 711 if (container.has_login_screen_power_management()) {
764 scoped_ptr<base::Value> decoded_json; 712 scoped_ptr<base::Value> decoded_json;
765 decoded_json = DecodeJsonStringAndDropUnknownBySchema( 713 decoded_json = DecodeJsonStringAndDropUnknownBySchema(
766 container.login_screen_power_management(), 714 container.login_screen_power_management(),
767 key::kDeviceLoginScreenPowerManagement); 715 key::kDeviceLoginScreenPowerManagement);
768 if (decoded_json) { 716 if (decoded_json) {
769 policies->Set(key::kDeviceLoginScreenPowerManagement, 717 policies->Set(key::kDeviceLoginScreenPowerManagement,
770 POLICY_LEVEL_MANDATORY, 718 POLICY_LEVEL_MANDATORY,
771 POLICY_SCOPE_MACHINE, 719 POLICY_SCOPE_MACHINE,
772 POLICY_SOURCE_CLOUD,
773 decoded_json.release(), 720 decoded_json.release(),
774 NULL); 721 NULL);
775 } 722 }
776 } 723 }
777 } 724 }
778 725
779 if (policy.has_system_settings()) { 726 if (policy.has_system_settings()) {
780 const em::SystemSettingsProto& container(policy.system_settings()); 727 const em::SystemSettingsProto& container(policy.system_settings());
781 if (container.has_block_devmode()) { 728 if (container.has_block_devmode()) {
782 policies->Set( 729 policies->Set(
783 key::kDeviceBlockDevmode, 730 key::kDeviceBlockDevmode,
784 POLICY_LEVEL_MANDATORY, 731 POLICY_LEVEL_MANDATORY,
785 POLICY_SCOPE_MACHINE, 732 POLICY_SCOPE_MACHINE,
786 POLICY_SOURCE_CLOUD,
787 new base::FundamentalValue(container.block_devmode()), 733 new base::FundamentalValue(container.block_devmode()),
788 NULL); 734 NULL);
789 } 735 }
790 } 736 }
791 737
792 if (policy.has_extension_cache_size()) { 738 if (policy.has_extension_cache_size()) {
793 const em::ExtensionCacheSizeProto& container(policy.extension_cache_size()); 739 const em::ExtensionCacheSizeProto& container(policy.extension_cache_size());
794 if (container.has_extension_cache_size()) { 740 if (container.has_extension_cache_size()) {
795 policies->Set( 741 policies->Set(
796 key::kExtensionCacheSize, POLICY_LEVEL_MANDATORY, 742 key::kExtensionCacheSize, POLICY_LEVEL_MANDATORY,
797 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, 743 POLICY_SCOPE_MACHINE,
798 DecodeIntegerValue(container.extension_cache_size()).release(), 744 DecodeIntegerValue(container.extension_cache_size()).release(),
799 nullptr); 745 nullptr);
800 } 746 }
801 } 747 }
802 748
803 if (policy.has_login_screen_domain_auto_complete()) { 749 if (policy.has_login_screen_domain_auto_complete()) {
804 const em::LoginScreenDomainAutoCompleteProto& container( 750 const em::LoginScreenDomainAutoCompleteProto& container(
805 policy.login_screen_domain_auto_complete()); 751 policy.login_screen_domain_auto_complete());
806 policies->Set( 752 policies->Set(
807 key::kDeviceLoginScreenDomainAutoComplete, POLICY_LEVEL_MANDATORY, 753 key::kDeviceLoginScreenDomainAutoComplete, POLICY_LEVEL_MANDATORY,
808 POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD, 754 POLICY_SCOPE_MACHINE,
809 new base::StringValue(container.login_screen_domain_auto_complete()), 755 new base::StringValue(container.login_screen_domain_auto_complete()),
810 nullptr); 756 nullptr);
811 } 757 }
812 } 758 }
813 759
814 } // namespace 760 } // namespace
815 761
816 void DecodeDevicePolicy(const em::ChromeDeviceSettingsProto& policy, 762 void DecodeDevicePolicy(const em::ChromeDeviceSettingsProto& policy,
817 PolicyMap* policies) { 763 PolicyMap* policies) {
818 // Decode the various groups of policies. 764 // Decode the various groups of policies.
819 DecodeLoginPolicies(policy, policies); 765 DecodeLoginPolicies(policy, policies);
820 DecodeNetworkPolicies(policy, policies); 766 DecodeNetworkPolicies(policy, policies);
821 DecodeReportingPolicies(policy, policies); 767 DecodeReportingPolicies(policy, policies);
822 DecodeAutoUpdatePolicies(policy, policies); 768 DecodeAutoUpdatePolicies(policy, policies);
823 DecodeAccessibilityPolicies(policy, policies); 769 DecodeAccessibilityPolicies(policy, policies);
824 DecodeGenericPolicies(policy, policies); 770 DecodeGenericPolicies(policy, policies);
825 } 771 }
826 772
827 } // namespace policy 773 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698