Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(387)

Side by Side Diff: chrome/browser/policy/mock_configuration_policy_reader.cc

Issue 7585036: First CL for the about:policy page. This only implements the policy section of the page. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created MockConfigurationPolicyReader and fixed other nits. Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2011 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/policy/mock_configuration_policy_reader.h"
6
7 #include "base/logging.h"
8
9 namespace policy {
10
11 MockConfigurationPolicyReader::MockConfigurationPolicyReader(
12 ConfigurationPolicyProvider* provider,
13 PolicyStatusInfo::PolicyLevel policy_level)
14 : ConfigurationPolicyReader(provider, policy_level) {
15
16 if (!provider->Provide(this))
17 LOG(WARNING) << "Failed to get policy from provider.";
18 }
19
20 MockConfigurationPolicyReader::~MockConfigurationPolicyReader() {
21 ClearMap();
22 }
23
24 void MockConfigurationPolicyReader::OnUpdatePolicy() {
25 ClearMap();
26 if (!provider_->Provide(this))
27 LOG(WARNING) << "Failed to get policy from provider.";
28 }
29
30 DictionaryValue* MockConfigurationPolicyReader::GetPolicyStatus(
31 ConfigurationPolicyType policy) const {
32 PolicyStatusMap::const_iterator entry = policy_map_.find(policy);
33 return entry != policy_map_.end() ?
34 (entry->second)->GetDictionaryValue() : NULL;
35 }
36
37 // ConfigurationPolicyStoreInterface methods.
38 void MockConfigurationPolicyReader::Apply(
39 ConfigurationPolicyType policy, base::Value* value) {
40 string16 name = PolicyStatus::GetPolicyName(policy);
41
42 if (name == string16()) {
43 NOTREACHED();
44 }
45 PolicyStatusInfo* info = new PolicyStatusInfo(name,
46 PolicyStatusInfo::USER,
47 policy_level_,
48 value,
49 PolicyStatusInfo::ENFORCED,
50 string16());
51 policy_map_[policy] = info;
52 }
53
54 void MockConfigurationPolicyReader::ClearMap() {
55 PolicyStatusMap::iterator entry = policy_map_.begin();
56 for (; entry != policy_map_.end(); ++entry)
57 delete entry->second;
58 policy_map_.clear();
59 }
60
61 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698