| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/configuration_policy_provider.h" | 5 #include "chrome/browser/configuration_policy_provider.h" |
| 6 | 6 |
| 7 #include "base/values.h" | 7 #include "base/values.h" |
| 8 #include "chrome/browser/configuration_policy_store.h" | 8 #include "chrome/browser/configuration_policy_store.h" |
| 9 | 9 |
| 10 namespace { | 10 namespace { |
| 11 | 11 |
| 12 struct PolicyValueTreeMappingEntry { | 12 struct PolicyValueTreeMappingEntry { |
| 13 ConfigurationPolicyStore::PolicyType policy_type; | 13 ConfigurationPolicyStore::PolicyType policy_type; |
| 14 Value::ValueType value_type; | 14 Value::ValueType value_type; |
| 15 const wchar_t* const name; | 15 const wchar_t* const name; |
| 16 }; | 16 }; |
| 17 | 17 |
| 18 const PolicyValueTreeMappingEntry kPolicyValueTreeMapping[] = { | 18 const PolicyValueTreeMappingEntry kPolicyValueTreeMapping[] = { |
| 19 { ConfigurationPolicyStore::kPolicyHomePage, | 19 { ConfigurationPolicyStore::kPolicyHomePage, |
| 20 Value::TYPE_STRING, L"homepage" }, | 20 Value::TYPE_STRING, L"homepage" }, |
| 21 { ConfigurationPolicyStore::kPolicyHomepageIsNewTabPage, | 21 { ConfigurationPolicyStore::kPolicyHomepageIsNewTabPage, |
| 22 Value::TYPE_BOOLEAN, L"homepage_is_newtabpage" }, | 22 Value::TYPE_BOOLEAN, L"homepage_is_newtabpage" }, |
| 23 { ConfigurationPolicyStore::kPolicyCookiesEnabled, | 23 { ConfigurationPolicyStore::kPolicyCookiesMode, |
| 24 Value::TYPE_BOOLEAN, L"cookies_enabled" } | 24 Value::TYPE_INTEGER, L"cookies_enabled" } |
| 25 }; | 25 }; |
| 26 | 26 |
| 27 } | 27 } |
| 28 | 28 |
| 29 void DecodePolicyValueTree(DictionaryValue* policies, | 29 void DecodePolicyValueTree(DictionaryValue* policies, |
| 30 ConfigurationPolicyStore* store) { | 30 ConfigurationPolicyStore* store) { |
| 31 for (size_t i = 0; i < arraysize(kPolicyValueTreeMapping); ++i) { | 31 for (size_t i = 0; i < arraysize(kPolicyValueTreeMapping); ++i) { |
| 32 const PolicyValueTreeMappingEntry& entry(kPolicyValueTreeMapping[i]); | 32 const PolicyValueTreeMappingEntry& entry(kPolicyValueTreeMapping[i]); |
| 33 Value* value; | 33 Value* value; |
| 34 if (policies->Get(entry.name, &value) && value->IsType(entry.value_type)) | 34 if (policies->Get(entry.name, &value) && value->IsType(entry.value_type)) |
| 35 store->Apply(entry.policy_type, value->DeepCopy()); | 35 store->Apply(entry.policy_type, value->DeepCopy()); |
| 36 } | 36 } |
| 37 | 37 |
| 38 // TODO (mnissler) Handle preference overrides once |ConfigurationPolicyStore| | 38 // TODO (mnissler) Handle preference overrides once |ConfigurationPolicyStore| |
| 39 // supports it. | 39 // supports it. |
| 40 } | 40 } |
| OLD | NEW |