| 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/configuration_policy_handler_chromeos.h
" | 5 #include "chrome/browser/chromeos/policy/configuration_policy_handler_chromeos.h
" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | |
| 9 #include <string> | 8 #include <string> |
| 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/callback.h" | 12 #include "base/callback.h" |
| 13 #include "base/json/json_reader.h" | 13 #include "base/json/json_reader.h" |
| 14 #include "base/json/json_writer.h" | 14 #include "base/json/json_writer.h" |
| 15 #include "base/logging.h" | 15 #include "base/logging.h" |
| 16 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
| 17 #include "base/prefs/pref_value_map.h" | 17 #include "base/prefs/pref_value_map.h" |
| 18 #include "base/strings/string_number_conversions.h" | 18 #include "base/strings/string_number_conversions.h" |
| 19 #include "base/strings/string_util.h" | 19 #include "base/strings/string_util.h" |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 base::DictionaryValue global_network_config; | 248 base::DictionaryValue global_network_config; |
| 249 chromeos::onc::ParseAndValidateOncForImport(onc_blob, | 249 chromeos::onc::ParseAndValidateOncForImport(onc_blob, |
| 250 onc_source_, | 250 onc_source_, |
| 251 "", | 251 "", |
| 252 network_configs.get(), | 252 network_configs.get(), |
| 253 &global_network_config, | 253 &global_network_config, |
| 254 &certificates); | 254 &certificates); |
| 255 | 255 |
| 256 // Currently, only the per-network configuration is stored in a pref. Ignore | 256 // Currently, only the per-network configuration is stored in a pref. Ignore |
| 257 // |global_network_config| and |certificates|. | 257 // |global_network_config| and |certificates|. |
| 258 prefs->SetValue(pref_path_, network_configs.Pass()); | 258 prefs->SetValue(pref_path_, std::move(network_configs)); |
| 259 } | 259 } |
| 260 | 260 |
| 261 void NetworkConfigurationPolicyHandler::PrepareForDisplaying( | 261 void NetworkConfigurationPolicyHandler::PrepareForDisplaying( |
| 262 PolicyMap* policies) const { | 262 PolicyMap* policies) const { |
| 263 const PolicyMap::Entry* entry = policies->Get(policy_name()); | 263 const PolicyMap::Entry* entry = policies->Get(policy_name()); |
| 264 if (!entry) | 264 if (!entry) |
| 265 return; | 265 return; |
| 266 base::Value* sanitized_config = SanitizeNetworkConfig(entry->value); | 266 base::Value* sanitized_config = SanitizeNetworkConfig(entry->value); |
| 267 if (!sanitized_config) | 267 if (!sanitized_config) |
| 268 sanitized_config = base::Value::CreateNullValue().release(); | 268 sanitized_config = base::Value::CreateNullValue().release(); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 scoped_ptr<base::ListValue> pinned_apps_list(new base::ListValue()); | 322 scoped_ptr<base::ListValue> pinned_apps_list(new base::ListValue()); |
| 323 for (base::ListValue::const_iterator entry(policy_list->begin()); | 323 for (base::ListValue::const_iterator entry(policy_list->begin()); |
| 324 entry != policy_list->end(); ++entry) { | 324 entry != policy_list->end(); ++entry) { |
| 325 std::string id; | 325 std::string id; |
| 326 if ((*entry)->GetAsString(&id)) { | 326 if ((*entry)->GetAsString(&id)) { |
| 327 base::DictionaryValue* app_dict = new base::DictionaryValue(); | 327 base::DictionaryValue* app_dict = new base::DictionaryValue(); |
| 328 app_dict->SetString(ash::kPinnedAppsPrefAppIDPath, id); | 328 app_dict->SetString(ash::kPinnedAppsPrefAppIDPath, id); |
| 329 pinned_apps_list->Append(app_dict); | 329 pinned_apps_list->Append(app_dict); |
| 330 } | 330 } |
| 331 } | 331 } |
| 332 prefs->SetValue(pref_path(), pinned_apps_list.Pass()); | 332 prefs->SetValue(pref_path(), std::move(pinned_apps_list)); |
| 333 } | 333 } |
| 334 } | 334 } |
| 335 | 335 |
| 336 ScreenMagnifierPolicyHandler::ScreenMagnifierPolicyHandler() | 336 ScreenMagnifierPolicyHandler::ScreenMagnifierPolicyHandler() |
| 337 : IntRangePolicyHandlerBase(key::kScreenMagnifierType, | 337 : IntRangePolicyHandlerBase(key::kScreenMagnifierType, |
| 338 0, ui::MAGNIFIER_FULL, false) { | 338 0, ui::MAGNIFIER_FULL, false) { |
| 339 } | 339 } |
| 340 | 340 |
| 341 ScreenMagnifierPolicyHandler::~ScreenMagnifierPolicyHandler() { | 341 ScreenMagnifierPolicyHandler::~ScreenMagnifierPolicyHandler() { |
| 342 } | 342 } |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 410 return; | 410 return; |
| 411 const base::DictionaryValue* dict = NULL; | 411 const base::DictionaryValue* dict = NULL; |
| 412 if (!policy_value->GetAsDictionary(&dict)) { | 412 if (!policy_value->GetAsDictionary(&dict)) { |
| 413 NOTREACHED(); | 413 NOTREACHED(); |
| 414 return; | 414 return; |
| 415 } | 415 } |
| 416 scoped_ptr<base::Value> value; | 416 scoped_ptr<base::Value> value; |
| 417 | 417 |
| 418 value = GetValue(dict, kScreenDimDelayAC); | 418 value = GetValue(dict, kScreenDimDelayAC); |
| 419 if (value) | 419 if (value) |
| 420 prefs->SetValue(prefs::kPowerAcScreenDimDelayMs, value.Pass()); | 420 prefs->SetValue(prefs::kPowerAcScreenDimDelayMs, std::move(value)); |
| 421 value = GetValue(dict, kScreenOffDelayAC); | 421 value = GetValue(dict, kScreenOffDelayAC); |
| 422 if (value) | 422 if (value) |
| 423 prefs->SetValue(prefs::kPowerAcScreenOffDelayMs, value.Pass()); | 423 prefs->SetValue(prefs::kPowerAcScreenOffDelayMs, std::move(value)); |
| 424 value = GetValue(dict, kIdleWarningDelayAC); | 424 value = GetValue(dict, kIdleWarningDelayAC); |
| 425 if (value) | 425 if (value) |
| 426 prefs->SetValue(prefs::kPowerAcIdleWarningDelayMs, value.Pass()); | 426 prefs->SetValue(prefs::kPowerAcIdleWarningDelayMs, std::move(value)); |
| 427 value = GetValue(dict, kIdleDelayAC); | 427 value = GetValue(dict, kIdleDelayAC); |
| 428 if (value) | 428 if (value) |
| 429 prefs->SetValue(prefs::kPowerAcIdleDelayMs, value.Pass()); | 429 prefs->SetValue(prefs::kPowerAcIdleDelayMs, std::move(value)); |
| 430 value = GetAction(dict, kIdleActionAC); | 430 value = GetAction(dict, kIdleActionAC); |
| 431 if (value) | 431 if (value) |
| 432 prefs->SetValue(prefs::kPowerAcIdleAction, value.Pass()); | 432 prefs->SetValue(prefs::kPowerAcIdleAction, std::move(value)); |
| 433 | 433 |
| 434 value = GetValue(dict, kScreenDimDelayBattery); | 434 value = GetValue(dict, kScreenDimDelayBattery); |
| 435 if (value) | 435 if (value) |
| 436 prefs->SetValue(prefs::kPowerBatteryScreenDimDelayMs, value.Pass()); | 436 prefs->SetValue(prefs::kPowerBatteryScreenDimDelayMs, std::move(value)); |
| 437 value = GetValue(dict, kScreenOffDelayBattery); | 437 value = GetValue(dict, kScreenOffDelayBattery); |
| 438 if (value) | 438 if (value) |
| 439 prefs->SetValue(prefs::kPowerBatteryScreenOffDelayMs, value.Pass()); | 439 prefs->SetValue(prefs::kPowerBatteryScreenOffDelayMs, std::move(value)); |
| 440 value = GetValue(dict, kIdleWarningDelayBattery); | 440 value = GetValue(dict, kIdleWarningDelayBattery); |
| 441 if (value) | 441 if (value) |
| 442 prefs->SetValue(prefs::kPowerBatteryIdleWarningDelayMs, value.Pass()); | 442 prefs->SetValue(prefs::kPowerBatteryIdleWarningDelayMs, std::move(value)); |
| 443 value = GetValue(dict, kIdleDelayBattery); | 443 value = GetValue(dict, kIdleDelayBattery); |
| 444 if (value) | 444 if (value) |
| 445 prefs->SetValue(prefs::kPowerBatteryIdleDelayMs, value.Pass()); | 445 prefs->SetValue(prefs::kPowerBatteryIdleDelayMs, std::move(value)); |
| 446 value = GetAction(dict, kIdleActionBattery); | 446 value = GetAction(dict, kIdleActionBattery); |
| 447 if (value) | 447 if (value) |
| 448 prefs->SetValue(prefs::kPowerBatteryIdleAction, value.Pass()); | 448 prefs->SetValue(prefs::kPowerBatteryIdleAction, std::move(value)); |
| 449 } | 449 } |
| 450 | 450 |
| 451 ScreenLockDelayPolicyHandler::ScreenLockDelayPolicyHandler( | 451 ScreenLockDelayPolicyHandler::ScreenLockDelayPolicyHandler( |
| 452 const Schema& chrome_schema) | 452 const Schema& chrome_schema) |
| 453 : SchemaValidatingPolicyHandler( | 453 : SchemaValidatingPolicyHandler( |
| 454 key::kScreenLockDelays, | 454 key::kScreenLockDelays, |
| 455 chrome_schema.GetKnownProperty(key::kScreenLockDelays), | 455 chrome_schema.GetKnownProperty(key::kScreenLockDelays), |
| 456 SCHEMA_ALLOW_UNKNOWN) { | 456 SCHEMA_ALLOW_UNKNOWN) { |
| 457 } | 457 } |
| 458 | 458 |
| 459 ScreenLockDelayPolicyHandler::~ScreenLockDelayPolicyHandler() { | 459 ScreenLockDelayPolicyHandler::~ScreenLockDelayPolicyHandler() { |
| 460 } | 460 } |
| 461 | 461 |
| 462 void ScreenLockDelayPolicyHandler::ApplyPolicySettings( | 462 void ScreenLockDelayPolicyHandler::ApplyPolicySettings( |
| 463 const PolicyMap& policies, | 463 const PolicyMap& policies, |
| 464 PrefValueMap* prefs) { | 464 PrefValueMap* prefs) { |
| 465 scoped_ptr<base::Value> policy_value; | 465 scoped_ptr<base::Value> policy_value; |
| 466 if (!CheckAndGetValue(policies, NULL, &policy_value)) | 466 if (!CheckAndGetValue(policies, NULL, &policy_value)) |
| 467 return; | 467 return; |
| 468 const base::DictionaryValue* dict = NULL; | 468 const base::DictionaryValue* dict = NULL; |
| 469 if (!policy_value->GetAsDictionary(&dict)) { | 469 if (!policy_value->GetAsDictionary(&dict)) { |
| 470 NOTREACHED(); | 470 NOTREACHED(); |
| 471 return; | 471 return; |
| 472 } | 472 } |
| 473 scoped_ptr<base::Value> value; | 473 scoped_ptr<base::Value> value; |
| 474 | 474 |
| 475 value = GetValue(dict, kScreenLockDelayAC); | 475 value = GetValue(dict, kScreenLockDelayAC); |
| 476 if (value) | 476 if (value) |
| 477 prefs->SetValue(prefs::kPowerAcScreenLockDelayMs, value.Pass()); | 477 prefs->SetValue(prefs::kPowerAcScreenLockDelayMs, std::move(value)); |
| 478 value = GetValue(dict, kScreenLockDelayBattery); | 478 value = GetValue(dict, kScreenLockDelayBattery); |
| 479 if (value) | 479 if (value) |
| 480 prefs->SetValue(prefs::kPowerBatteryScreenLockDelayMs, value.Pass()); | 480 prefs->SetValue(prefs::kPowerBatteryScreenLockDelayMs, std::move(value)); |
| 481 } | 481 } |
| 482 | 482 |
| 483 } // namespace policy | 483 } // namespace policy |
| OLD | NEW |