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