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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/policy/mock_configuration_policy_reader.cc
diff --git a/chrome/browser/policy/mock_configuration_policy_reader.cc b/chrome/browser/policy/mock_configuration_policy_reader.cc
new file mode 100644
index 0000000000000000000000000000000000000000..500b25180641ef2a4bef4daf8723bfd9af8e5585
--- /dev/null
+++ b/chrome/browser/policy/mock_configuration_policy_reader.cc
@@ -0,0 +1,61 @@
+// Copyright (c) 2011 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/policy/mock_configuration_policy_reader.h"
+
+#include "base/logging.h"
+
+namespace policy {
+
+MockConfigurationPolicyReader::MockConfigurationPolicyReader(
+ ConfigurationPolicyProvider* provider,
+ PolicyStatusInfo::PolicyLevel policy_level)
+ : ConfigurationPolicyReader(provider, policy_level) {
+
+ if (!provider->Provide(this))
+ LOG(WARNING) << "Failed to get policy from provider.";
+}
+
+MockConfigurationPolicyReader::~MockConfigurationPolicyReader() {
+ ClearMap();
+}
+
+void MockConfigurationPolicyReader::OnUpdatePolicy() {
+ ClearMap();
+ if (!provider_->Provide(this))
+ LOG(WARNING) << "Failed to get policy from provider.";
+}
+
+DictionaryValue* MockConfigurationPolicyReader::GetPolicyStatus(
+ ConfigurationPolicyType policy) const {
+ PolicyStatusMap::const_iterator entry = policy_map_.find(policy);
+ return entry != policy_map_.end() ?
+ (entry->second)->GetDictionaryValue() : NULL;
+}
+
+// ConfigurationPolicyStoreInterface methods.
+void MockConfigurationPolicyReader::Apply(
+ ConfigurationPolicyType policy, base::Value* value) {
+ string16 name = PolicyStatus::GetPolicyName(policy);
+
+ if (name == string16()) {
+ NOTREACHED();
+ }
+ PolicyStatusInfo* info = new PolicyStatusInfo(name,
+ PolicyStatusInfo::USER,
+ policy_level_,
+ value,
+ PolicyStatusInfo::ENFORCED,
+ string16());
+ policy_map_[policy] = info;
+}
+
+void MockConfigurationPolicyReader::ClearMap() {
+ PolicyStatusMap::iterator entry = policy_map_.begin();
+ for (; entry != policy_map_.end(); ++entry)
+ delete entry->second;
+ policy_map_.clear();
+}
+
+} // namespace policy

Powered by Google App Engine
This is Rietveld 408576698