| 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_pref_store.h" | 5 #include "chrome/browser/configuration_policy_pref_store.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "chrome/browser/configuration_policy_provider.h" | 9 #include "chrome/browser/configuration_policy_provider.h" |
| 10 #include "chrome/common/pref_names.h" | 10 #include "chrome/common/pref_names.h" |
| 11 | 11 |
| 12 const ConfigurationPolicyPrefStore::PolicyToPreferenceMapEntry | 12 const ConfigurationPolicyPrefStore::PolicyToPreferenceMapEntry |
| 13 ConfigurationPolicyPrefStore::simple_policy_map_[] = { | 13 ConfigurationPolicyPrefStore::simple_policy_map_[] = { |
| 14 { Value::TYPE_STRING, kPolicyHomePage, prefs::kHomePage }, | 14 { Value::TYPE_STRING, kPolicyHomePage, prefs::kHomePage }, |
| 15 { Value::TYPE_BOOLEAN, kPolicyHomepageIsNewTabPage, | 15 { Value::TYPE_BOOLEAN, kPolicyHomepageIsNewTabPage, |
| 16 prefs::kHomePageIsNewTabPage }, | 16 prefs::kHomePageIsNewTabPage }, |
| 17 { Value::TYPE_INTEGER, kPolicyCookiesEnabled, prefs::kCookieBehavior } | 17 { Value::TYPE_INTEGER, kPolicyCookiesMode, prefs::kCookieBehavior } |
| 18 }; | 18 }; |
| 19 | 19 |
| 20 ConfigurationPolicyPrefStore::ConfigurationPolicyPrefStore( | 20 ConfigurationPolicyPrefStore::ConfigurationPolicyPrefStore( |
| 21 ConfigurationPolicyProvider* provider) | 21 ConfigurationPolicyProvider* provider) |
| 22 : provider_(provider), | 22 : provider_(provider), |
| 23 prefs_(new DictionaryValue()) { | 23 prefs_(new DictionaryValue()) { |
| 24 } | 24 } |
| 25 | 25 |
| 26 PrefStore::PrefReadError ConfigurationPolicyPrefStore::ReadPrefs() { | 26 PrefStore::PrefReadError ConfigurationPolicyPrefStore::ReadPrefs() { |
| 27 return provider_->Provide(this) ? PrefStore::PREF_READ_ERROR_NONE : | 27 return provider_->Provide(this) ? PrefStore::PREF_READ_ERROR_NONE : |
| 28 PrefStore::PREF_READ_ERROR_OTHER; | 28 PrefStore::PREF_READ_ERROR_OTHER; |
| 29 } | 29 } |
| 30 | 30 |
| 31 void ConfigurationPolicyPrefStore::Apply(PolicyType policy, Value* value) { | 31 void ConfigurationPolicyPrefStore::Apply(PolicyType policy, Value* value) { |
| 32 const PolicyToPreferenceMapEntry* end = | 32 const PolicyToPreferenceMapEntry* end = |
| 33 simple_policy_map_ + arraysize(simple_policy_map_); | 33 simple_policy_map_ + arraysize(simple_policy_map_); |
| 34 for (const PolicyToPreferenceMapEntry* current = simple_policy_map_; | 34 for (const PolicyToPreferenceMapEntry* current = simple_policy_map_; |
| 35 current != end; ++current) { | 35 current != end; ++current) { |
| 36 if (current->policy_type == policy) { | 36 if (current->policy_type == policy) { |
| 37 DCHECK(current->value_type == value->GetType()); | 37 DCHECK(current->value_type == value->GetType()); |
| 38 prefs_->Set(current->preference_path, value); | 38 prefs_->Set(current->preference_path, value); |
| 39 return; | 39 return; |
| 40 } | 40 } |
| 41 } | 41 } |
| 42 | 42 |
| 43 // Other policy implementations go here. | 43 // Other policy implementations go here. |
| 44 NOTIMPLEMENTED(); | 44 NOTIMPLEMENTED(); |
| 45 } | 45 } |
| 46 | 46 |
| OLD | NEW |