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

Unified Diff: chrome/browser/policy/test/policy_test_utils.cc

Issue 109743002: Move policy code into components/policy. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: moar fixes Created 7 years 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/test/policy_test_utils.cc
diff --git a/chrome/browser/policy/test/policy_test_utils.cc b/chrome/browser/policy/test/policy_test_utils.cc
deleted file mode 100644
index 2915abd84ec0e1f8d86726ac7e701f574da3a0c8..0000000000000000000000000000000000000000
--- a/chrome/browser/policy/test/policy_test_utils.cc
+++ /dev/null
@@ -1,139 +0,0 @@
-// Copyright 2013 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/test/policy_test_utils.h"
-
-#include <string>
-
-#include "base/bind.h"
-#include "base/bind_helpers.h"
-#include "base/callback.h"
-#include "base/json/json_writer.h"
-#include "base/logging.h"
-#include "base/values.h"
-#include "components/policy/core/common/policy_bundle.h"
-
-namespace policy {
-
-PolicyDetailsMap::PolicyDetailsMap() {}
-
-PolicyDetailsMap::~PolicyDetailsMap() {}
-
-GetChromePolicyDetailsCallback PolicyDetailsMap::GetCallback() const {
- return base::Bind(&PolicyDetailsMap::Lookup, base::Unretained(this));
-}
-
-void PolicyDetailsMap::SetDetails(const std::string& policy,
- const PolicyDetails* details) {
- map_[policy] = details;
-}
-
-const PolicyDetails* PolicyDetailsMap::Lookup(const std::string& policy) const {
- PolicyDetailsMapping::const_iterator it = map_.find(policy);
- return it == map_.end() ? NULL : it->second;
-}
-
-bool PolicyServiceIsEmpty(const PolicyService* service) {
- const PolicyMap& map = service->GetPolicies(
- PolicyNamespace(POLICY_DOMAIN_CHROME, std::string()));
- if (!map.empty()) {
- base::DictionaryValue dict;
- for (PolicyMap::const_iterator it = map.begin(); it != map.end(); ++it)
- dict.SetWithoutPathExpansion(it->first, it->second.value->DeepCopy());
- LOG(WARNING) << "There are pre-existing policies in this machine: " << dict;
- }
- return map.empty();
-}
-
-} // namespace policy
-
-std::ostream& operator<<(std::ostream& os,
- const policy::PolicyBundle& bundle) {
- os << "{" << std::endl;
- for (policy::PolicyBundle::const_iterator iter = bundle.begin();
- iter != bundle.end(); ++iter) {
- os << " \"" << iter->first << "\": " << *iter->second << "," << std::endl;
- }
- os << "}";
- return os;
-}
-
-std::ostream& operator<<(std::ostream& os, policy::PolicyScope scope) {
- switch (scope) {
- case policy::POLICY_SCOPE_USER: {
- os << "POLICY_SCOPE_USER";
- break;
- }
- case policy::POLICY_SCOPE_MACHINE: {
- os << "POLICY_SCOPE_MACHINE";
- break;
- }
- default: {
- os << "POLICY_SCOPE_UNKNOWN(" << int(scope) << ")";
- }
- }
- return os;
-}
-
-std::ostream& operator<<(std::ostream& os, policy::PolicyLevel level) {
- switch (level) {
- case policy::POLICY_LEVEL_RECOMMENDED: {
- os << "POLICY_LEVEL_RECOMMENDED";
- break;
- }
- case policy::POLICY_LEVEL_MANDATORY: {
- os << "POLICY_LEVEL_MANDATORY";
- break;
- }
- default: {
- os << "POLICY_LEVEL_UNKNOWN(" << int(level) << ")";
- }
- }
- return os;
-}
-
-std::ostream& operator<<(std::ostream& os, policy::PolicyDomain domain) {
- switch (domain) {
- case policy::POLICY_DOMAIN_CHROME: {
- os << "POLICY_DOMAIN_CHROME";
- break;
- }
- case policy::POLICY_DOMAIN_EXTENSIONS: {
- os << "POLICY_DOMAIN_EXTENSIONS";
- break;
- }
- default: {
- os << "POLICY_DOMAIN_UNKNOWN(" << int(domain) << ")";
- }
- }
- return os;
-}
-
-std::ostream& operator<<(std::ostream& os, const policy::PolicyMap& policies) {
- os << "{" << std::endl;
- for (policy::PolicyMap::const_iterator iter = policies.begin();
- iter != policies.end(); ++iter) {
- os << " \"" << iter->first << "\": " << iter->second << "," << std::endl;
- }
- os << "}";
- return os;
-}
-
-std::ostream& operator<<(std::ostream& os, const policy::PolicyMap::Entry& e) {
- std::string value;
- base::JSONWriter::WriteWithOptions(e.value,
- base::JSONWriter::OPTIONS_PRETTY_PRINT,
- &value);
- os << "{" << std::endl
- << " \"level\": " << e.level << "," << std::endl
- << " \"scope\": " << e.scope << "," << std::endl
- << " \"value\": " << value
- << "}";
- return os;
-}
-
-std::ostream& operator<<(std::ostream& os, const policy::PolicyNamespace& ns) {
- os << ns.domain << "/" << ns.component_id;
- return os;
-}
« no previous file with comments | « chrome/browser/policy/test/policy_test_utils.h ('k') | chrome/browser/policy/url_blacklist_policy_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698