| Index: chrome/browser/configuration_policy_pref_store.cc
|
| diff --git a/chrome/browser/configuration_policy_pref_store.cc b/chrome/browser/configuration_policy_pref_store.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..c883b707ce1b78f474ca083e93dc39cc4d0d2108
|
| --- /dev/null
|
| +++ b/chrome/browser/configuration_policy_pref_store.cc
|
| @@ -0,0 +1,46 @@
|
| +// Copyright (c) 2010 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "chrome/browser/configuration_policy_pref_store.h"
|
| +
|
| +#include "base/logging.h"
|
| +#include "base/values.h"
|
| +#include "chrome/browser/configuration_policy_provider.h"
|
| +#include "chrome/common/pref_names.h"
|
| +
|
| +const ConfigurationPolicyPrefStore::PolicyToPreferenceMapEntry
|
| +ConfigurationPolicyPrefStore::simple_policy_map_[] = {
|
| + { Value::TYPE_STRING, kPolicyHomePage, prefs::kHomePage },
|
| + { Value::TYPE_BOOLEAN, kPolicyHomepageIsNewTabPage,
|
| + prefs::kHomePageIsNewTabPage },
|
| + { Value::TYPE_INTEGER, kPolicyCookiesEnabled, prefs::kCookieBehavior }
|
| +};
|
| +
|
| +ConfigurationPolicyPrefStore::ConfigurationPolicyPrefStore(
|
| + ConfigurationPolicyProvider* provider)
|
| + : provider_(provider),
|
| + prefs_(new DictionaryValue()) {
|
| +}
|
| +
|
| +PrefStore::PrefReadError ConfigurationPolicyPrefStore::ReadPrefs() {
|
| + return provider_->Provide(this) ? PrefStore::PREF_READ_ERROR_NONE :
|
| + PrefStore::PREF_READ_ERROR_OTHER;
|
| +}
|
| +
|
| +void ConfigurationPolicyPrefStore::Apply(PolicyType policy, Value* value) {
|
| + const PolicyToPreferenceMapEntry* end =
|
| + simple_policy_map_ + arraysize(simple_policy_map_);
|
| + for (const PolicyToPreferenceMapEntry* current = simple_policy_map_;
|
| + current != end; ++current) {
|
| + if (current->policy_type == policy) {
|
| + DCHECK(current->value_type == value->GetType());
|
| + prefs_->Set(current->preference_path, value);
|
| + return;
|
| + }
|
| + }
|
| +
|
| + // Other policy implementations go here.
|
| + NOTIMPLEMENTED();
|
| +}
|
| +
|
|
|