blob: c883b707ce1b78f474ca083e93dc39cc4d0d2108 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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();
}
|