summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjoaodasilva@chromium.org <joaodasilva@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-07 14:11:01 +0000
committerjoaodasilva@chromium.org <joaodasilva@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-07 14:11:01 +0000
commite9ad1c39baa8c8a5d7d052d3eb352f25cb8fde10 (patch)
tree13c1d2b5ead60e767659606cf5f59f863650f71e
parentcf541d8073e614739e9fb6b2b3bdad3146168800 (diff)
downloadchromium_src-e9ad1c39baa8c8a5d7d052d3eb352f25cb8fde10.zip
chromium_src-e9ad1c39baa8c8a5d7d052d3eb352f25cb8fde10.tar.gz
chromium_src-e9ad1c39baa8c8a5d7d052d3eb352f25cb8fde10.tar.bz2
Removed the PolicyDefinitionList from the ConfigurationPolicyProvider interface.
Also deleted some files left behind when the linux and mac providers were refactored. BUG=130918 TEST=nothing breaks Review URL: https://chromiumcodereview.appspot.com/10545033 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@141008 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/policy/async_policy_provider.cc7
-rw-r--r--chrome/browser/policy/async_policy_provider.h3
-rw-r--r--chrome/browser/policy/async_policy_provider_unittest.cc3
-rw-r--r--chrome/browser/policy/browser_policy_connector.cc14
-rw-r--r--chrome/browser/policy/cloud_policy_provider.cc4
-rw-r--r--chrome/browser/policy/cloud_policy_provider.h1
-rw-r--r--chrome/browser/policy/cloud_policy_provider_unittest.cc1
-rw-r--r--chrome/browser/policy/config_dir_policy_loader.h2
-rw-r--r--chrome/browser/policy/config_dir_policy_loader_unittest.cc2
-rw-r--r--chrome/browser/policy/config_dir_policy_provider.cc163
-rw-r--r--chrome/browser/policy/config_dir_policy_provider_unittest.cc248
-rw-r--r--chrome/browser/policy/configuration_policy_provider.cc5
-rw-r--r--chrome/browser/policy/configuration_policy_provider.h11
-rw-r--r--chrome/browser/policy/configuration_policy_provider_mac.cc183
-rw-r--r--chrome/browser/policy/configuration_policy_provider_mac_unittest.cc316
-rw-r--r--chrome/browser/policy/mock_configuration_policy_provider.cc4
-rw-r--r--chrome/browser/policy/policy_loader_mac_unittest.cc5
-rw-r--r--chrome/browser/policy/policy_loader_win_unittest.cc2
-rw-r--r--chrome/browser/policy/proxy_policy_provider.cc5
-rw-r--r--chrome/browser/policy/user_cloud_policy_manager.cc8
-rw-r--r--chrome/browser/policy/user_cloud_policy_manager.h3
-rw-r--r--chrome/browser/policy/user_cloud_policy_manager_unittest.cc6
22 files changed, 24 insertions, 972 deletions
diff --git a/chrome/browser/policy/async_policy_provider.cc b/chrome/browser/policy/async_policy_provider.cc
index 012de5a..eb66d9b 100644
--- a/chrome/browser/policy/async_policy_provider.cc
+++ b/chrome/browser/policy/async_policy_provider.cc
@@ -24,11 +24,8 @@ void Nop() {}
} // namespace
-AsyncPolicyProvider::AsyncPolicyProvider(
- const PolicyDefinitionList* policy_list,
- scoped_ptr<AsyncPolicyLoader> loader)
- : ConfigurationPolicyProvider(policy_list),
- loader_(loader.release()),
+AsyncPolicyProvider::AsyncPolicyProvider(scoped_ptr<AsyncPolicyLoader> loader)
+ : loader_(loader.release()),
ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) {
// The FILE thread isn't ready early during startup. Post a task to the
// current loop to resume initialization on FILE once the loops are spinning.
diff --git a/chrome/browser/policy/async_policy_provider.h b/chrome/browser/policy/async_policy_provider.h
index 329266b..ce72c7e 100644
--- a/chrome/browser/policy/async_policy_provider.h
+++ b/chrome/browser/policy/async_policy_provider.h
@@ -28,8 +28,7 @@ class PolicyBundle;
class AsyncPolicyProvider : public ConfigurationPolicyProvider,
public base::NonThreadSafe {
public:
- AsyncPolicyProvider(const PolicyDefinitionList* policy_list,
- scoped_ptr<AsyncPolicyLoader> loader);
+ explicit AsyncPolicyProvider(scoped_ptr<AsyncPolicyLoader> loader);
virtual ~AsyncPolicyProvider();
// ConfigurationPolicyProvider implementation.
diff --git a/chrome/browser/policy/async_policy_provider_unittest.cc b/chrome/browser/policy/async_policy_provider_unittest.cc
index d41ca91..be0d810 100644
--- a/chrome/browser/policy/async_policy_provider_unittest.cc
+++ b/chrome/browser/policy/async_policy_provider_unittest.cc
@@ -102,8 +102,7 @@ void AsyncPolicyProviderTest::SetUp() {
EXPECT_CALL(*loader_, MockLoad()).WillOnce(Return(&initial_bundle_));
provider_.reset(
- new AsyncPolicyProvider(GetChromePolicyDefinitionList(),
- scoped_ptr<AsyncPolicyLoader>(loader_)));
+ new AsyncPolicyProvider(scoped_ptr<AsyncPolicyLoader>(loader_)));
// Verify that the initial load is done synchronously:
EXPECT_TRUE(provider_->policies().Equals(initial_bundle_));
diff --git a/chrome/browser/policy/browser_policy_connector.cc b/chrome/browser/policy/browser_policy_connector.cc
index e396545..322bd83 100644
--- a/chrome/browser/policy/browser_policy_connector.cc
+++ b/chrome/browser/policy/browser_policy_connector.cc
@@ -137,11 +137,9 @@ void BrowserPolicyConnector::Init() {
if (!command_line->HasSwitch(switches::kEnableCloudPolicyService)) {
managed_cloud_provider_.reset(new CloudPolicyProvider(
this,
- GetChromePolicyDefinitionList(),
POLICY_LEVEL_MANDATORY));
recommended_cloud_provider_.reset(new CloudPolicyProvider(
this,
- GetChromePolicyDefinitionList(),
POLICY_LEVEL_RECOMMENDED));
}
}
@@ -553,22 +551,22 @@ void BrowserPolicyConnector::CompleteInitialization() {
}
// static
-ConfigurationPolicyProvider*
- BrowserPolicyConnector::CreatePlatformProvider() {
- const PolicyDefinitionList* policy_list = GetChromePolicyDefinitionList();
+ConfigurationPolicyProvider* BrowserPolicyConnector::CreatePlatformProvider() {
#if defined(OS_WIN)
+ const PolicyDefinitionList* policy_list = GetChromePolicyDefinitionList();
scoped_ptr<AsyncPolicyLoader> loader(new PolicyLoaderWin(policy_list));
- return new AsyncPolicyProvider(policy_list, loader.Pass());
+ return new AsyncPolicyProvider(loader.Pass());
#elif defined(OS_MACOSX)
+ const PolicyDefinitionList* policy_list = GetChromePolicyDefinitionList();
scoped_ptr<AsyncPolicyLoader> loader(
new PolicyLoaderMac(policy_list, new MacPreferences()));
- return new AsyncPolicyProvider(policy_list, loader.Pass());
+ return new AsyncPolicyProvider(loader.Pass());
#elif defined(OS_POSIX)
FilePath config_dir_path;
if (PathService::Get(chrome::DIR_POLICY_FILES, &config_dir_path)) {
scoped_ptr<AsyncPolicyLoader> loader(
new ConfigDirPolicyLoader(config_dir_path, POLICY_SCOPE_MACHINE));
- return new AsyncPolicyProvider(policy_list, loader.Pass());
+ return new AsyncPolicyProvider(loader.Pass());
} else {
return NULL;
}
diff --git a/chrome/browser/policy/cloud_policy_provider.cc b/chrome/browser/policy/cloud_policy_provider.cc
index c28bba9d..f921b8a 100644
--- a/chrome/browser/policy/cloud_policy_provider.cc
+++ b/chrome/browser/policy/cloud_policy_provider.cc
@@ -13,10 +13,8 @@ namespace policy {
CloudPolicyProvider::CloudPolicyProvider(
BrowserPolicyConnector* browser_policy_connector,
- const PolicyDefinitionList* policy_list,
PolicyLevel level)
- : ConfigurationPolicyProvider(policy_list),
- browser_policy_connector_(browser_policy_connector),
+ : browser_policy_connector_(browser_policy_connector),
level_(level),
initialization_complete_(false) {
for (size_t i = 0; i < CACHE_SIZE; ++i)
diff --git a/chrome/browser/policy/cloud_policy_provider.h b/chrome/browser/policy/cloud_policy_provider.h
index dd2566a..8205f25 100644
--- a/chrome/browser/policy/cloud_policy_provider.h
+++ b/chrome/browser/policy/cloud_policy_provider.h
@@ -23,7 +23,6 @@ class CloudPolicyProvider : public ConfigurationPolicyProvider,
public CloudPolicyCacheBase::Observer {
public:
CloudPolicyProvider(BrowserPolicyConnector* browser_policy_connector,
- const PolicyDefinitionList* policy_list,
PolicyLevel level);
virtual ~CloudPolicyProvider();
diff --git a/chrome/browser/policy/cloud_policy_provider_unittest.cc b/chrome/browser/policy/cloud_policy_provider_unittest.cc
index 7e9a655..1947556 100644
--- a/chrome/browser/policy/cloud_policy_provider_unittest.cc
+++ b/chrome/browser/policy/cloud_policy_provider_unittest.cc
@@ -59,7 +59,6 @@ class CloudPolicyProviderTest : public testing::Test {
protected:
CloudPolicyProviderTest()
: cloud_policy_provider_(&browser_policy_connector_,
- GetChromePolicyDefinitionList(),
POLICY_LEVEL_MANDATORY) {}
void SetUp() OVERRIDE {
diff --git a/chrome/browser/policy/config_dir_policy_loader.h b/chrome/browser/policy/config_dir_policy_loader.h
index f9cc0f8..38cd7c2 100644
--- a/chrome/browser/policy/config_dir_policy_loader.h
+++ b/chrome/browser/policy/config_dir_policy_loader.h
@@ -17,8 +17,6 @@ class Value;
namespace policy {
-struct PolicyDefinitionList;
-
// A policy loader implementation backed by a set of files in a given
// directory. The files should contain JSON-formatted policy settings. They are
// merged together and the result is returned in a PolicyBundle.
diff --git a/chrome/browser/policy/config_dir_policy_loader_unittest.cc b/chrome/browser/policy/config_dir_policy_loader_unittest.cc
index 6811629..6c996d8 100644
--- a/chrome/browser/policy/config_dir_policy_loader_unittest.cc
+++ b/chrome/browser/policy/config_dir_policy_loader_unittest.cc
@@ -73,7 +73,7 @@ ConfigurationPolicyProvider* TestHarness::CreateProvider(
const PolicyDefinitionList* policy_definition_list) {
scoped_ptr<AsyncPolicyLoader> loader(
new ConfigDirPolicyLoader(test_dir(), POLICY_SCOPE_MACHINE));
- return new AsyncPolicyProvider(policy_definition_list, loader.Pass());
+ return new AsyncPolicyProvider(loader.Pass());
}
void TestHarness::InstallEmptyPolicy() {
diff --git a/chrome/browser/policy/config_dir_policy_provider.cc b/chrome/browser/policy/config_dir_policy_provider.cc
deleted file mode 100644
index c86fa50..0000000
--- a/chrome/browser/policy/config_dir_policy_provider.cc
+++ /dev/null
@@ -1,163 +0,0 @@
-// Copyright (c) 2012 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/config_dir_policy_provider.h"
-
-#include <algorithm>
-#include <set>
-#include <string>
-
-#include "base/file_path.h"
-#include "base/file_util.h"
-#include "base/json/json_file_value_serializer.h"
-#include "base/logging.h"
-#include "base/platform_file.h"
-#include "base/stl_util.h"
-#include "chrome/browser/policy/policy_bundle.h"
-
-namespace policy {
-
-ConfigDirPolicyProviderDelegate::ConfigDirPolicyProviderDelegate(
- const FilePath& config_dir,
- PolicyLevel level,
- PolicyScope scope)
- : FileBasedPolicyProvider::ProviderDelegate(config_dir),
- level_(level),
- scope_(scope) {}
-
-scoped_ptr<PolicyBundle> ConfigDirPolicyProviderDelegate::Load() {
- // Enumerate the files and sort them lexicographically.
- std::set<FilePath> files;
- file_util::FileEnumerator file_enumerator(config_file_path(), false,
- file_util::FileEnumerator::FILES);
- for (FilePath config_file_path = file_enumerator.Next();
- !config_file_path.empty(); config_file_path = file_enumerator.Next())
- files.insert(config_file_path);
-
- // Start with an empty dictionary and merge the files' contents.
- // The files are processed in reverse order because |MergeFrom| gives priority
- // to existing keys, but the ConfigDirPolicyProvider gives priority to the
- // last file in lexicographic order.
- scoped_ptr<PolicyBundle> bundle(new PolicyBundle());
- for (std::set<FilePath>::reverse_iterator config_file_iter = files.rbegin();
- config_file_iter != files.rend(); ++config_file_iter) {
- JSONFileValueSerializer deserializer(*config_file_iter);
- deserializer.set_allow_trailing_comma(true);
- int error_code = 0;
- std::string error_msg;
- scoped_ptr<base::Value> value(
- deserializer.Deserialize(&error_code, &error_msg));
- if (!value.get()) {
- LOG(WARNING) << "Failed to read configuration file "
- << config_file_iter->value() << ": " << error_msg;
- continue;
- }
- base::DictionaryValue* dictionary_value = NULL;
- if (!value->GetAsDictionary(&dictionary_value)) {
- LOG(WARNING) << "Expected JSON dictionary in configuration file "
- << config_file_iter->value();
- continue;
- }
-
- // Detach the "3rdparty" node.
- base::Value* third_party = NULL;
- if (dictionary_value->Remove("3rdparty", &third_party)) {
- Merge3rdPartyPolicy(bundle.get(), third_party);
- delete third_party;
- }
-
- // Add chrome policy.
- PolicyMap policy_map;
- policy_map.LoadFrom(dictionary_value, level_, scope_);
- bundle->Get(POLICY_DOMAIN_CHROME, "").MergeFrom(policy_map);
- }
-
- return bundle.Pass();
-}
-
-base::Time ConfigDirPolicyProviderDelegate::GetLastModification() {
- base::Time last_modification = base::Time();
- base::PlatformFileInfo file_info;
-
- // If the path does not exist or points to a directory, it's safe to load.
- if (!file_util::GetFileInfo(config_file_path(), &file_info) ||
- !file_info.is_directory) {
- return last_modification;
- }
-
- // Enumerate the files and find the most recent modification timestamp.
- file_util::FileEnumerator file_enumerator(config_file_path(),
- false,
- file_util::FileEnumerator::FILES);
- for (FilePath config_file = file_enumerator.Next();
- !config_file.empty();
- config_file = file_enumerator.Next()) {
- if (file_util::GetFileInfo(config_file, &file_info) &&
- !file_info.is_directory) {
- last_modification = std::max(last_modification, file_info.last_modified);
- }
- }
-
- return last_modification;
-}
-
-void ConfigDirPolicyProviderDelegate::Merge3rdPartyPolicy(
- PolicyBundle* bundle,
- const base::Value* value) {
- // The first-level entries in |value| are PolicyDomains. The second-level
- // entries are component IDs, and the third-level entries are the policies
- // for that domain/component namespace.
-
- const base::DictionaryValue* domains_dictionary;
- if (!value->GetAsDictionary(&domains_dictionary)) {
- LOG(WARNING) << "3rdparty value is not a dictionary!";
- return;
- }
-
- // Helper to lookup a domain given its string name.
- std::map<std::string, PolicyDomain> supported_domains;
- supported_domains["extensions"] = POLICY_DOMAIN_EXTENSIONS;
-
- for (base::DictionaryValue::Iterator domains_it(*domains_dictionary);
- domains_it.HasNext(); domains_it.Advance()) {
- if (!ContainsKey(supported_domains, domains_it.key())) {
- LOG(WARNING) << "Unsupported 3rd party policy domain: "
- << domains_it.key();
- continue;
- }
-
- const base::DictionaryValue* components_dictionary;
- if (!domains_it.value().GetAsDictionary(&components_dictionary)) {
- LOG(WARNING) << "3rdparty/" << domains_it.key()
- << " value is not a dictionary!";
- continue;
- }
-
- PolicyDomain domain = supported_domains[domains_it.key()];
- for (base::DictionaryValue::Iterator components_it(*components_dictionary);
- components_it.HasNext(); components_it.Advance()) {
- const base::DictionaryValue* policy_dictionary;
- if (!components_it.value().GetAsDictionary(&policy_dictionary)) {
- LOG(WARNING) << "3rdparty/" << domains_it.key() << "/"
- << components_it.key() << " value is not a dictionary!";
- continue;
- }
-
- PolicyMap policy;
- policy.LoadFrom(policy_dictionary, level_, scope_);
- bundle->Get(domain, components_it.key()).MergeFrom(policy);
- }
- }
-}
-
-ConfigDirPolicyProvider::ConfigDirPolicyProvider(
- const PolicyDefinitionList* policy_list,
- PolicyLevel level,
- PolicyScope scope,
- const FilePath& config_dir)
- : FileBasedPolicyProvider(
- policy_list,
- new ConfigDirPolicyProviderDelegate(config_dir, level, scope)) {}
-
-} // namespace policy
diff --git a/chrome/browser/policy/config_dir_policy_provider_unittest.cc b/chrome/browser/policy/config_dir_policy_provider_unittest.cc
deleted file mode 100644
index 84ce467..0000000
--- a/chrome/browser/policy/config_dir_policy_provider_unittest.cc
+++ /dev/null
@@ -1,248 +0,0 @@
-// Copyright (c) 2012 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 "base/compiler_specific.h"
-#include "base/file_util.h"
-#include "base/json/json_string_value_serializer.h"
-#include "base/message_loop.h"
-#include "base/scoped_temp_dir.h"
-#include "base/string_number_conversions.h"
-#include "base/values.h"
-#include "chrome/browser/policy/config_dir_policy_provider.h"
-#include "chrome/browser/policy/configuration_policy_provider_test.h"
-#include "chrome/browser/policy/policy_bundle.h"
-#include "chrome/browser/policy/policy_map.h"
-
-namespace policy {
-
-namespace {
-
-class TestHarness : public PolicyProviderTestHarness {
- public:
- TestHarness();
- virtual ~TestHarness();
-
- virtual void SetUp() OVERRIDE;
-
- virtual ConfigurationPolicyProvider* CreateProvider(
- const PolicyDefinitionList* policy_definition_list) OVERRIDE;
-
- virtual void InstallEmptyPolicy() OVERRIDE;
- virtual void InstallStringPolicy(const std::string& policy_name,
- const std::string& policy_value) OVERRIDE;
- virtual void InstallIntegerPolicy(const std::string& policy_name,
- int policy_value) OVERRIDE;
- virtual void InstallBooleanPolicy(const std::string& policy_name,
- bool policy_value) OVERRIDE;
- virtual void InstallStringListPolicy(
- const std::string& policy_name,
- const base::ListValue* policy_value) OVERRIDE;
- virtual void InstallDictionaryPolicy(
- const std::string& policy_name,
- const base::DictionaryValue* policy_value) OVERRIDE;
-
- const FilePath& test_dir() { return test_dir_.path(); }
-
- // JSON-encode a dictionary and write it to a file.
- void WriteConfigFile(const base::DictionaryValue& dict,
- const std::string& file_name);
-
- static PolicyProviderTestHarness* Create();
-
- private:
- ScopedTempDir test_dir_;
-
- DISALLOW_COPY_AND_ASSIGN(TestHarness);
-};
-
-TestHarness::TestHarness()
- : PolicyProviderTestHarness(POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE) {}
-
-TestHarness::~TestHarness() {}
-
-void TestHarness::SetUp() {
- ASSERT_TRUE(test_dir_.CreateUniqueTempDir());
-}
-
-ConfigurationPolicyProvider* TestHarness::CreateProvider(
- const PolicyDefinitionList* policy_definition_list) {
- return new ConfigDirPolicyProvider(policy_definition_list,
- POLICY_LEVEL_MANDATORY,
- POLICY_SCOPE_MACHINE,
- test_dir());
-}
-
-void TestHarness::InstallEmptyPolicy() {
- base::DictionaryValue dict;
- WriteConfigFile(dict, "policy");
-}
-
-void TestHarness::InstallStringPolicy(const std::string& policy_name,
- const std::string& policy_value) {
- base::DictionaryValue dict;
- dict.SetString(policy_name, policy_value);
- WriteConfigFile(dict, "policy");
-}
-
-void TestHarness::InstallIntegerPolicy(const std::string& policy_name,
- int policy_value) {
- base::DictionaryValue dict;
- dict.SetInteger(policy_name, policy_value);
- WriteConfigFile(dict, "policy");
-}
-
-void TestHarness::InstallBooleanPolicy(const std::string& policy_name,
- bool policy_value) {
- base::DictionaryValue dict;
- dict.SetBoolean(policy_name, policy_value);
- WriteConfigFile(dict, "policy");
-}
-
-void TestHarness::InstallStringListPolicy(const std::string& policy_name,
- const base::ListValue* policy_value) {
- base::DictionaryValue dict;
- dict.Set(policy_name, policy_value->DeepCopy());
- WriteConfigFile(dict, "policy");
-}
-
-void TestHarness::InstallDictionaryPolicy(
- const std::string& policy_name,
- const base::DictionaryValue* policy_value) {
- base::DictionaryValue dict;
- dict.Set(policy_name, policy_value->DeepCopy());
- WriteConfigFile(dict, "policy");
-}
-
-void TestHarness::WriteConfigFile(const base::DictionaryValue& dict,
- const std::string& file_name) {
- std::string data;
- JSONStringValueSerializer serializer(&data);
- serializer.Serialize(dict);
- const FilePath file_path(test_dir().AppendASCII(file_name));
- ASSERT_TRUE(file_util::WriteFile(file_path, data.c_str(), data.size()));
-}
-
-// static
-PolicyProviderTestHarness* TestHarness::Create() {
- return new TestHarness();
-}
-
-} // namespace
-
-// Instantiate abstract test case for basic policy reading tests.
-INSTANTIATE_TEST_CASE_P(
- ConfigDirPolicyProviderTest,
- ConfigurationPolicyProviderTest,
- testing::Values(TestHarness::Create));
-
-// Some tests that exercise special functionality in ConfigDirPolicyLoader.
-class ConfigDirPolicyLoaderTest : public testing::Test {
- protected:
- void SetUp() {
- harness_.SetUp();
- }
-
- TestHarness harness_;
-};
-
-// The preferences dictionary is expected to be empty when there are no files to
-// load.
-TEST_F(ConfigDirPolicyLoaderTest, ReadPrefsEmpty) {
- ConfigDirPolicyProviderDelegate loader(harness_.test_dir(),
- POLICY_LEVEL_MANDATORY,
- POLICY_SCOPE_MACHINE);
- scoped_ptr<PolicyBundle> bundle(loader.Load());
- ASSERT_TRUE(bundle.get());
- const PolicyBundle kEmptyBundle;
- EXPECT_TRUE(bundle->Equals(kEmptyBundle));
-}
-
-// Reading from a non-existent directory should result in an empty preferences
-// dictionary.
-TEST_F(ConfigDirPolicyLoaderTest, ReadPrefsNonExistentDirectory) {
- FilePath non_existent_dir(
- harness_.test_dir().Append(FILE_PATH_LITERAL("not_there")));
- ConfigDirPolicyProviderDelegate loader(non_existent_dir,
- POLICY_LEVEL_MANDATORY,
- POLICY_SCOPE_MACHINE);
- scoped_ptr<PolicyBundle> bundle(loader.Load());
- ASSERT_TRUE(bundle.get());
- const PolicyBundle kEmptyBundle;
- EXPECT_TRUE(bundle->Equals(kEmptyBundle));
-}
-
-// Test merging values from different files.
-TEST_F(ConfigDirPolicyLoaderTest, ReadPrefsMergePrefs) {
- // Write a bunch of data files in order to increase the chance to detect the
- // provider not respecting lexicographic ordering when reading them. Since the
- // filesystem may return files in arbitrary order, there is no way to be sure,
- // but this is better than nothing.
- base::DictionaryValue test_dict_bar;
- test_dict_bar.SetString("HomepageLocation", "http://bar.com");
- for (unsigned int i = 1; i <= 4; ++i)
- harness_.WriteConfigFile(test_dict_bar, base::IntToString(i));
- base::DictionaryValue test_dict_foo;
- test_dict_foo.SetString("HomepageLocation", "http://foo.com");
- harness_.WriteConfigFile(test_dict_foo, "9");
- for (unsigned int i = 5; i <= 8; ++i)
- harness_.WriteConfigFile(test_dict_bar, base::IntToString(i));
-
- ConfigDirPolicyProviderDelegate loader(harness_.test_dir(),
- POLICY_LEVEL_MANDATORY,
- POLICY_SCOPE_USER);
- scoped_ptr<PolicyBundle> bundle(loader.Load());
- ASSERT_TRUE(bundle.get());
- PolicyBundle expected_bundle;
- expected_bundle.Get(POLICY_DOMAIN_CHROME, "")
- .LoadFrom(&test_dict_foo, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER);
- EXPECT_TRUE(bundle->Equals(expected_bundle));
-}
-
-// Tests loading of policy for 3rd parties.
-TEST_F(ConfigDirPolicyLoaderTest, Load3rdParty) {
- base::DictionaryValue policy_dict;
- policy_dict.SetBoolean("bool", true);
- policy_dict.SetString("str", "string value");
- policy_dict.SetDouble("double", 123.456);
- policy_dict.SetInteger("int", 789);
-
- base::ListValue* list = new base::ListValue();
- for (int i = 0; i < 5; ++i) {
- base::DictionaryValue* dict = new base::DictionaryValue();
- dict->SetInteger("subdictindex", i);
- dict->Set("subdict", policy_dict.DeepCopy());
- list->Append(dict);
- }
- policy_dict.Set("list", list);
-
- base::DictionaryValue json_dict;
- // Merge |policy_dict|, which will become the chrome policies.
- json_dict.MergeDictionary(&policy_dict);
- json_dict.Set("3rdparty.extensions.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
- policy_dict.DeepCopy());
- json_dict.Set("3rdparty.extensions.bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
- policy_dict.DeepCopy());
-
- harness_.WriteConfigFile(json_dict, "policy.json");
- ConfigDirPolicyProviderDelegate loader(harness_.test_dir(),
- POLICY_LEVEL_MANDATORY,
- POLICY_SCOPE_USER);
- scoped_ptr<PolicyBundle> bundle(loader.Load());
- ASSERT_TRUE(bundle.get());
- PolicyMap expected_policy;
- expected_policy.LoadFrom(&policy_dict,
- POLICY_LEVEL_MANDATORY,
- POLICY_SCOPE_USER);
- PolicyBundle expected_bundle;
- expected_bundle.Get(POLICY_DOMAIN_CHROME, "").CopyFrom(expected_policy);
- expected_bundle.Get(POLICY_DOMAIN_EXTENSIONS,
- "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
- .CopyFrom(expected_policy);
- expected_bundle.Get(POLICY_DOMAIN_EXTENSIONS,
- "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb")
- .CopyFrom(expected_policy);
- EXPECT_TRUE(bundle->Equals(expected_bundle));
-}
-
-} // namespace policy
diff --git a/chrome/browser/policy/configuration_policy_provider.cc b/chrome/browser/policy/configuration_policy_provider.cc
index fd90b17..e34a9d2 100644
--- a/chrome/browser/policy/configuration_policy_provider.cc
+++ b/chrome/browser/policy/configuration_policy_provider.cc
@@ -68,10 +68,7 @@ ConfigurationPolicyProvider::Observer::~Observer() {}
void ConfigurationPolicyProvider::Observer::OnProviderGoingAway(
ConfigurationPolicyProvider* provider) {}
-ConfigurationPolicyProvider::ConfigurationPolicyProvider(
- const PolicyDefinitionList* policy_list)
- : policy_definition_list_(policy_list) {
-}
+ConfigurationPolicyProvider::ConfigurationPolicyProvider() {}
ConfigurationPolicyProvider::~ConfigurationPolicyProvider() {
FOR_EACH_OBSERVER(ConfigurationPolicyProvider::Observer,
diff --git a/chrome/browser/policy/configuration_policy_provider.h b/chrome/browser/policy/configuration_policy_provider.h
index d7b0e02..2def640 100644
--- a/chrome/browser/policy/configuration_policy_provider.h
+++ b/chrome/browser/policy/configuration_policy_provider.h
@@ -13,8 +13,6 @@
namespace policy {
-struct PolicyDefinitionList;
-
// A mostly-abstract super class for platform-specific policy providers.
// Platform-specific policy providers (Windows Group Policy, gconf,
// etc.) should implement a subclass of this class.
@@ -27,7 +25,7 @@ class ConfigurationPolicyProvider {
virtual void OnProviderGoingAway(ConfigurationPolicyProvider* provider);
};
- explicit ConfigurationPolicyProvider(const PolicyDefinitionList* policy_list);
+ ConfigurationPolicyProvider();
virtual ~ConfigurationPolicyProvider();
@@ -52,10 +50,6 @@ class ConfigurationPolicyProvider {
// The observers are notified after the policies are updated.
void UpdatePolicy(scoped_ptr<PolicyBundle> bundle);
- const PolicyDefinitionList* policy_definition_list() const {
- return policy_definition_list_;
- }
-
private:
friend class ConfigurationPolicyObserverRegistrar;
@@ -65,9 +59,6 @@ class ConfigurationPolicyProvider {
// The policies currently configured at this provider.
PolicyBundle policy_bundle_;
- // Contains the default mapping from policy values to the actual names.
- const PolicyDefinitionList* policy_definition_list_;
-
ObserverList<Observer, true> observer_list_;
DISALLOW_COPY_AND_ASSIGN(ConfigurationPolicyProvider);
diff --git a/chrome/browser/policy/configuration_policy_provider_mac.cc b/chrome/browser/policy/configuration_policy_provider_mac.cc
deleted file mode 100644
index 046bc42..0000000
--- a/chrome/browser/policy/configuration_policy_provider_mac.cc
+++ /dev/null
@@ -1,183 +0,0 @@
-// Copyright (c) 2012 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/configuration_policy_provider_mac.h"
-
-#include <string>
-
-#include "base/file_path.h"
-#include "base/file_util.h"
-#include "base/mac/foundation_util.h"
-#include "base/mac/scoped_cftyperef.h"
-#include "base/path_service.h"
-#include "base/platform_file.h"
-#include "base/sys_string_conversions.h"
-#include "base/values.h"
-#include "chrome/browser/policy/policy_bundle.h"
-#include "chrome/browser/policy/policy_map.h"
-#include "chrome/browser/preferences_mac.h"
-#include "chrome/common/chrome_paths.h"
-#include "policy/policy_constants.h"
-
-using base::mac::CFCast;
-using base::mac::ScopedCFTypeRef;
-
-namespace policy {
-
-namespace {
-
-FilePath GetManagedPolicyPath() {
- // This constructs the path to the plist file in which Mac OS X stores the
- // managed preference for the application. This is undocumented and therefore
- // fragile, but if it doesn't work out, FileBasedPolicyLoader has a task that
- // polls periodically in order to reload managed preferences later even if we
- // missed the change.
- FilePath path;
- if (!PathService::Get(chrome::DIR_MANAGED_PREFS, &path))
- return FilePath();
-
- CFBundleRef bundle(CFBundleGetMainBundle());
- if (!bundle)
- return FilePath();
-
- CFStringRef bundle_id = CFBundleGetIdentifier(bundle);
- if (!bundle_id)
- return FilePath();
-
- return path.Append(base::SysCFStringRefToUTF8(bundle_id) + ".plist");
-}
-
-// Callback function for CFDictionaryApplyFunction. |key| and |value| are an
-// entry of the CFDictionary that should be converted into an equivalent entry
-// in the DictionaryValue in |context|.
-void DictionaryEntryToValue(const void* key, const void* value, void* context) {
- if (CFStringRef cf_key = CFCast<CFStringRef>(key)) {
- base::Value* converted =
- MacPreferencesPolicyProviderDelegate::CreateValueFromProperty(
- static_cast<CFPropertyListRef>(value));
- if (converted) {
- const std::string string = base::SysCFStringRefToUTF8(cf_key);
- static_cast<base::DictionaryValue *>(context)->Set(string, converted);
- }
- }
-}
-
-// Callback function for CFArrayApplyFunction. |value| is an entry of the
-// CFArray that should be converted into an equivalent entry in the ListValue
-// in |context|.
-void ArrayEntryToValue(const void* value, void* context) {
- base::Value* converted =
- MacPreferencesPolicyProviderDelegate::CreateValueFromProperty(
- static_cast<CFPropertyListRef>(value));
- if (converted)
- static_cast<base::ListValue *>(context)->Append(converted);
-}
-
-} // namespace
-
-MacPreferencesPolicyProviderDelegate::MacPreferencesPolicyProviderDelegate(
- MacPreferences* preferences,
- const PolicyDefinitionList* policy_list)
- : FileBasedPolicyProvider::ProviderDelegate(GetManagedPolicyPath()),
- policy_list_(policy_list),
- preferences_(preferences) {}
-
-MacPreferencesPolicyProviderDelegate::~MacPreferencesPolicyProviderDelegate() {}
-
-scoped_ptr<PolicyBundle> MacPreferencesPolicyProviderDelegate::Load() {
- preferences_->AppSynchronize(kCFPreferencesCurrentApplication);
- scoped_ptr<PolicyBundle> bundle(new PolicyBundle());
- PolicyMap& chrome_policy = bundle->Get(POLICY_DOMAIN_CHROME, std::string());
-
- const PolicyDefinitionList::Entry* current;
- for (current = policy_list_->begin; current != policy_list_->end; ++current) {
- base::mac::ScopedCFTypeRef<CFStringRef> name(
- base::SysUTF8ToCFStringRef(current->name));
- base::mac::ScopedCFTypeRef<CFPropertyListRef> value(
- preferences_->CopyAppValue(name, kCFPreferencesCurrentApplication));
- if (!value.get())
- continue;
- bool forced =
- preferences_->AppValueIsForced(name, kCFPreferencesCurrentApplication);
- PolicyLevel level = forced ? POLICY_LEVEL_MANDATORY :
- POLICY_LEVEL_RECOMMENDED;
- // TODO(joaodasilva): figure the policy scope.
- base::Value* policy = CreateValueFromProperty(value);
- if (policy)
- chrome_policy.Set(current->name, level, POLICY_SCOPE_USER, policy);
- }
-
- return bundle.Pass();
-}
-
-base::Time MacPreferencesPolicyProviderDelegate::GetLastModification() {
- base::PlatformFileInfo file_info;
- if (!file_util::GetFileInfo(config_file_path(), &file_info) ||
- file_info.is_directory) {
- return base::Time();
- }
-
- return file_info.last_modified;
-}
-
-// static
-base::Value* MacPreferencesPolicyProviderDelegate::CreateValueFromProperty(
- CFPropertyListRef property) {
- if (CFCast<CFNullRef>(property))
- return base::Value::CreateNullValue();
-
- if (CFBooleanRef boolean = CFCast<CFBooleanRef>(property))
- return base::Value::CreateBooleanValue(CFBooleanGetValue(boolean));
-
- if (CFNumberRef number = CFCast<CFNumberRef>(property)) {
- // CFNumberGetValue() converts values implicitly when the conversion is not
- // lossy. Check the type before trying to convert.
- if (CFNumberIsFloatType(number)) {
- double double_value;
- if (CFNumberGetValue(number, kCFNumberDoubleType, &double_value))
- return base::Value::CreateDoubleValue(double_value);
- } else {
- int int_value;
- if (CFNumberGetValue(number, kCFNumberIntType, &int_value))
- return base::Value::CreateIntegerValue(int_value);
- }
- }
-
- if (CFStringRef string = CFCast<CFStringRef>(property))
- return base::Value::CreateStringValue(base::SysCFStringRefToUTF8(string));
-
- if (CFDictionaryRef dict = CFCast<CFDictionaryRef>(property)) {
- base::DictionaryValue* dict_value = new base::DictionaryValue();
- CFDictionaryApplyFunction(dict, DictionaryEntryToValue, dict_value);
- return dict_value;
- }
-
- if (CFArrayRef array = CFCast<CFArrayRef>(property)) {
- base::ListValue* list_value = new base::ListValue();
- CFArrayApplyFunction(array,
- CFRangeMake(0, CFArrayGetCount(array)),
- ArrayEntryToValue,
- list_value);
- return list_value;
- }
-
- return NULL;
-}
-
-ConfigurationPolicyProviderMac::ConfigurationPolicyProviderMac(
- const PolicyDefinitionList* policy_list)
- : FileBasedPolicyProvider(
- policy_list,
- new MacPreferencesPolicyProviderDelegate(new MacPreferences(),
- policy_list)) {}
-
-ConfigurationPolicyProviderMac::ConfigurationPolicyProviderMac(
- const PolicyDefinitionList* policy_list,
- MacPreferences* preferences)
- : FileBasedPolicyProvider(
- policy_list,
- new MacPreferencesPolicyProviderDelegate(preferences,
- policy_list)) {}
-
-} // namespace policy
diff --git a/chrome/browser/policy/configuration_policy_provider_mac_unittest.cc b/chrome/browser/policy/configuration_policy_provider_mac_unittest.cc
deleted file mode 100644
index 9414f22..0000000
--- a/chrome/browser/policy/configuration_policy_provider_mac_unittest.cc
+++ /dev/null
@@ -1,316 +0,0 @@
-// Copyright (c) 2012 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 <CoreFoundation/CoreFoundation.h>
-
-#include "base/basictypes.h"
-#include "base/mac/scoped_cftyperef.h"
-#include "base/sys_string_conversions.h"
-#include "base/values.h"
-#include "chrome/browser/policy/asynchronous_policy_test_base.h"
-#include "chrome/browser/policy/configuration_policy_provider_mac.h"
-#include "chrome/browser/policy/configuration_policy_provider_test.h"
-#include "chrome/browser/policy/policy_bundle.h"
-#include "chrome/browser/policy/policy_map.h"
-#include "chrome/browser/preferences_mock_mac.h"
-#include "policy/policy_constants.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-using base::mac::ScopedCFTypeRef;
-
-namespace policy {
-
-namespace {
-
-// Converts a base::Value to the equivalent CFPropertyListRef.
-// The returned value is owned by the caller.
-CFPropertyListRef CreatePropertyFromValue(const base::Value* value) {
- switch (value->GetType()) {
- case base::Value::TYPE_NULL:
- return kCFNull;
-
- case base::Value::TYPE_BOOLEAN: {
- bool bool_value;
- if (value->GetAsBoolean(&bool_value))
- return bool_value ? kCFBooleanTrue : kCFBooleanFalse;
- break;
- }
-
- case base::Value::TYPE_INTEGER: {
- int int_value;
- if (value->GetAsInteger(&int_value)) {
- return CFNumberCreate(
- kCFAllocatorDefault, kCFNumberIntType, &int_value);
- }
- break;
- }
-
- case base::Value::TYPE_DOUBLE: {
- double double_value;
- if (value->GetAsDouble(&double_value)) {
- return CFNumberCreate(
- kCFAllocatorDefault, kCFNumberDoubleType, &double_value);
- }
- break;
- }
-
- case base::Value::TYPE_STRING: {
- std::string string_value;
- if (value->GetAsString(&string_value))
- return base::SysUTF8ToCFStringRef(string_value);
- break;
- }
-
- case base::Value::TYPE_DICTIONARY: {
- const base::DictionaryValue* dict_value;
- if (value->GetAsDictionary(&dict_value)) {
- // |dict| is owned by the caller.
- CFMutableDictionaryRef dict =
- CFDictionaryCreateMutable(kCFAllocatorDefault,
- dict_value->size(),
- &kCFTypeDictionaryKeyCallBacks,
- &kCFTypeDictionaryValueCallBacks);
- for (base::DictionaryValue::Iterator iterator(*dict_value);
- iterator.HasNext(); iterator.Advance()) {
- // CFDictionaryAddValue() retains both |key| and |value|, so make sure
- // the references are balanced.
- ScopedCFTypeRef<CFStringRef> key(
- base::SysUTF8ToCFStringRef(iterator.key()));
- ScopedCFTypeRef<CFPropertyListRef> cf_value(
- CreatePropertyFromValue(&iterator.value()));
- if (cf_value)
- CFDictionaryAddValue(dict, key, cf_value);
- }
- return dict;
- }
- break;
- }
-
- case base::Value::TYPE_LIST: {
- const base::ListValue* list;
- if (value->GetAsList(&list)) {
- CFMutableArrayRef array =
- CFArrayCreateMutable(NULL, list->GetSize(), &kCFTypeArrayCallBacks);
- for (base::ListValue::const_iterator it(list->begin());
- it != list->end(); ++it) {
- // CFArrayAppendValue() retains |value|, so make sure the reference
- // created by CreatePropertyFromValue() is released.
- ScopedCFTypeRef<CFPropertyListRef> cf_value(
- CreatePropertyFromValue(*it));
- if (cf_value)
- CFArrayAppendValue(array, cf_value);
- }
- return array;
- }
- break;
- }
-
- case base::Value::TYPE_BINARY:
- // This type isn't converted (though it can be represented as CFData)
- // because there's no equivalent JSON type, and policy values can only
- // take valid JSON values.
- break;
- }
-
- return NULL;
-}
-
-class TestHarness : public PolicyProviderTestHarness {
- public:
- TestHarness();
- virtual ~TestHarness();
-
- virtual void SetUp() OVERRIDE;
-
- virtual ConfigurationPolicyProvider* CreateProvider(
- const PolicyDefinitionList* policy_definition_list) OVERRIDE;
-
- virtual void InstallEmptyPolicy() OVERRIDE;
- virtual void InstallStringPolicy(const std::string& policy_name,
- const std::string& policy_value) OVERRIDE;
- virtual void InstallIntegerPolicy(const std::string& policy_name,
- int policy_value) OVERRIDE;
- virtual void InstallBooleanPolicy(const std::string& policy_name,
- bool policy_value) OVERRIDE;
- virtual void InstallStringListPolicy(
- const std::string& policy_name,
- const base::ListValue* policy_value) OVERRIDE;
- virtual void InstallDictionaryPolicy(
- const std::string& policy_name,
- const base::DictionaryValue* policy_value) OVERRIDE;
-
- static PolicyProviderTestHarness* Create();
-
- private:
- MockPreferences* prefs_;
-
- DISALLOW_COPY_AND_ASSIGN(TestHarness);
-};
-
-TestHarness::TestHarness()
- : PolicyProviderTestHarness(POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER) {}
-
-TestHarness::~TestHarness() {}
-
-void TestHarness::SetUp() {}
-
-ConfigurationPolicyProvider* TestHarness::CreateProvider(
- const PolicyDefinitionList* policy_definition_list) {
- prefs_ = new MockPreferences();
- return new ConfigurationPolicyProviderMac(policy_definition_list, prefs_);
-}
-
-void TestHarness::InstallEmptyPolicy() {}
-
-void TestHarness::InstallStringPolicy(const std::string& policy_name,
- const std::string& policy_value) {
- ScopedCFTypeRef<CFStringRef> name(base::SysUTF8ToCFStringRef(policy_name));
- ScopedCFTypeRef<CFStringRef> value(base::SysUTF8ToCFStringRef(policy_value));
- prefs_->AddTestItem(name, value, true);
-}
-
-void TestHarness::InstallIntegerPolicy(const std::string& policy_name,
- int policy_value) {
- ScopedCFTypeRef<CFStringRef> name(base::SysUTF8ToCFStringRef(policy_name));
- ScopedCFTypeRef<CFNumberRef> value(
- CFNumberCreate(NULL, kCFNumberIntType, &policy_value));
- prefs_->AddTestItem(name, value, true);
-}
-
-void TestHarness::InstallBooleanPolicy(const std::string& policy_name,
- bool policy_value) {
- ScopedCFTypeRef<CFStringRef> name(base::SysUTF8ToCFStringRef(policy_name));
- prefs_->AddTestItem(name,
- policy_value ? kCFBooleanTrue : kCFBooleanFalse,
- true);
-}
-
-void TestHarness::InstallStringListPolicy(const std::string& policy_name,
- const base::ListValue* policy_value) {
- ScopedCFTypeRef<CFStringRef> name(base::SysUTF8ToCFStringRef(policy_name));
- ScopedCFTypeRef<CFPropertyListRef> array(
- CreatePropertyFromValue(policy_value));
- ASSERT_TRUE(array);
- prefs_->AddTestItem(name, array, true);
-}
-
-void TestHarness::InstallDictionaryPolicy(
- const std::string& policy_name,
- const base::DictionaryValue* policy_value) {
- ScopedCFTypeRef<CFStringRef> name(base::SysUTF8ToCFStringRef(policy_name));
- ScopedCFTypeRef<CFPropertyListRef> dict(
- CreatePropertyFromValue(policy_value));
- ASSERT_TRUE(dict);
- prefs_->AddTestItem(name, dict, true);
-}
-
-// static
-PolicyProviderTestHarness* TestHarness::Create() {
- return new TestHarness();
-}
-
-} // namespace
-
-// Instantiate abstract test case for basic policy reading tests.
-INSTANTIATE_TEST_CASE_P(
- ConfigurationPolicyProviderMacTest,
- ConfigurationPolicyProviderTest,
- testing::Values(TestHarness::Create));
-
-// Special test cases for some mac preferences details.
-class ConfigurationPolicyProviderMacTest : public AsynchronousPolicyTestBase {
- protected:
- ConfigurationPolicyProviderMacTest()
- : prefs_(new MockPreferences()),
- provider_(&test_policy_definitions::kList, prefs_) {}
- virtual ~ConfigurationPolicyProviderMacTest() {}
-
- MockPreferences* prefs_;
- ConfigurationPolicyProviderMac provider_;
-};
-
-TEST_F(ConfigurationPolicyProviderMacTest, Invalid) {
- ScopedCFTypeRef<CFStringRef> name(
- base::SysUTF8ToCFStringRef(test_policy_definitions::kKeyString));
- const char buffer[] = "binary \xde\xad\xbe\xef data";
- ScopedCFTypeRef<CFDataRef> invalid_data(
- CFDataCreate(kCFAllocatorDefault,
- reinterpret_cast<const UInt8 *>(buffer),
- arraysize(buffer)));
- ASSERT_TRUE(invalid_data);
- prefs_->AddTestItem(name, invalid_data.get(), true);
- prefs_->AddTestItem(name, invalid_data.get(), false);
-
- // Make the provider read the updated |prefs_|.
- provider_.RefreshPolicies();
- loop_.RunAllPending();
- const PolicyBundle kEmptyBundle;
- EXPECT_TRUE(provider_.policies().Equals(kEmptyBundle));
-}
-
-TEST_F(ConfigurationPolicyProviderMacTest, TestNonForcedValue) {
- ScopedCFTypeRef<CFStringRef> name(
- base::SysUTF8ToCFStringRef(test_policy_definitions::kKeyString));
- ScopedCFTypeRef<CFPropertyListRef> test_value(
- base::SysUTF8ToCFStringRef("string value"));
- ASSERT_TRUE(test_value.get());
- prefs_->AddTestItem(name, test_value.get(), false);
-
- // Make the provider read the updated |prefs_|.
- provider_.RefreshPolicies();
- loop_.RunAllPending();
- PolicyBundle expected_bundle;
- expected_bundle.Get(POLICY_DOMAIN_CHROME, "")
- .Set(test_policy_definitions::kKeyString, POLICY_LEVEL_RECOMMENDED,
- POLICY_SCOPE_USER, base::Value::CreateStringValue("string value"));
- EXPECT_TRUE(provider_.policies().Equals(expected_bundle));
-}
-
-TEST_F(ConfigurationPolicyProviderMacTest, TestConversions) {
- base::DictionaryValue root;
-
- // base::Value::TYPE_NULL
- root.Set("null", base::Value::CreateNullValue());
-
- // base::Value::TYPE_BOOLEAN
- root.SetBoolean("false", false);
- root.SetBoolean("true", true);
-
- // base::Value::TYPE_INTEGER
- root.SetInteger("int", 123);
- root.SetInteger("zero", 0);
-
- // base::Value::TYPE_DOUBLE
- root.SetDouble("double", 123.456);
- root.SetDouble("zerod", 0.0);
-
- // base::Value::TYPE_STRING
- root.SetString("string", "the fox jumps over something");
- root.SetString("empty", "");
-
- // base::Value::TYPE_LIST
- base::ListValue list;
- root.Set("emptyl", list.DeepCopy());
- for (base::DictionaryValue::Iterator it(root); it.HasNext(); it.Advance())
- list.Append(it.value().DeepCopy());
- EXPECT_EQ(root.size(), list.GetSize());
- list.Append(root.DeepCopy());
- root.Set("list", list.DeepCopy());
-
- // base::Value::TYPE_DICTIONARY
- base::DictionaryValue dict;
- root.Set("emptyd", dict.DeepCopy());
- // Very meta.
- root.Set("dict", root.DeepCopy());
-
- ScopedCFTypeRef<CFPropertyListRef> property(CreatePropertyFromValue(&root));
- ASSERT_TRUE(property);
- scoped_ptr<base::Value> value(
- MacPreferencesPolicyProviderDelegate::CreateValueFromProperty(property));
- ASSERT_TRUE(value.get());
-
- EXPECT_TRUE(root.Equals(value.get()));
-}
-
-} // namespace policy
diff --git a/chrome/browser/policy/mock_configuration_policy_provider.cc b/chrome/browser/policy/mock_configuration_policy_provider.cc
index d2e95d8..5dcfcb3 100644
--- a/chrome/browser/policy/mock_configuration_policy_provider.cc
+++ b/chrome/browser/policy/mock_configuration_policy_provider.cc
@@ -8,12 +8,10 @@
#include "base/memory/scoped_ptr.h"
#include "chrome/browser/policy/policy_bundle.h"
-#include "policy/policy_constants.h"
namespace policy {
-MockConfigurationPolicyProvider::MockConfigurationPolicyProvider()
- : ConfigurationPolicyProvider(GetChromePolicyDefinitionList()) {}
+MockConfigurationPolicyProvider::MockConfigurationPolicyProvider() {}
MockConfigurationPolicyProvider::~MockConfigurationPolicyProvider() {}
diff --git a/chrome/browser/policy/policy_loader_mac_unittest.cc b/chrome/browser/policy/policy_loader_mac_unittest.cc
index 51a31c8..4d90a3e 100644
--- a/chrome/browser/policy/policy_loader_mac_unittest.cc
+++ b/chrome/browser/policy/policy_loader_mac_unittest.cc
@@ -160,7 +160,7 @@ ConfigurationPolicyProvider* TestHarness::CreateProvider(
prefs_ = new MockPreferences();
scoped_ptr<AsyncPolicyLoader> loader(
new PolicyLoaderMac(policy_definition_list, prefs_));
- return new AsyncPolicyProvider(policy_definition_list, loader.Pass());
+ return new AsyncPolicyProvider(loader.Pass());
}
void TestHarness::InstallEmptyPolicy() {}
@@ -226,8 +226,7 @@ class PolicyLoaderMacTest : public PolicyTestBase {
PolicyLoaderMacTest()
: prefs_(new MockPreferences()),
loader_(new PolicyLoaderMac(&test_policy_definitions::kList, prefs_)),
- provider_(&test_policy_definitions::kList,
- scoped_ptr<AsyncPolicyLoader>(loader_)) {}
+ provider_(scoped_ptr<AsyncPolicyLoader>(loader_)) {}
virtual ~PolicyLoaderMacTest() {}
MockPreferences* prefs_;
diff --git a/chrome/browser/policy/policy_loader_win_unittest.cc b/chrome/browser/policy/policy_loader_win_unittest.cc
index 949392e..5a0beeb 100644
--- a/chrome/browser/policy/policy_loader_win_unittest.cc
+++ b/chrome/browser/policy/policy_loader_win_unittest.cc
@@ -142,7 +142,7 @@ void TestHarness::SetUp() {}
ConfigurationPolicyProvider* TestHarness::CreateProvider(
const PolicyDefinitionList* policy_list) {
scoped_ptr<AsyncPolicyLoader> loader(new PolicyLoaderWin(policy_list));
- return new AsyncPolicyProvider(policy_list, loader.Pass());
+ return new AsyncPolicyProvider(loader.Pass());
}
void TestHarness::InstallEmptyPolicy() {}
diff --git a/chrome/browser/policy/proxy_policy_provider.cc b/chrome/browser/policy/proxy_policy_provider.cc
index a019b08..d1db4c1 100644
--- a/chrome/browser/policy/proxy_policy_provider.cc
+++ b/chrome/browser/policy/proxy_policy_provider.cc
@@ -4,12 +4,9 @@
#include "chrome/browser/policy/proxy_policy_provider.h"
-#include "policy/policy_constants.h"
-
namespace policy {
-ProxyPolicyProvider::ProxyPolicyProvider()
- : ConfigurationPolicyProvider(GetChromePolicyDefinitionList()) {}
+ProxyPolicyProvider::ProxyPolicyProvider() {}
ProxyPolicyProvider::~ProxyPolicyProvider() {}
diff --git a/chrome/browser/policy/user_cloud_policy_manager.cc b/chrome/browser/policy/user_cloud_policy_manager.cc
index 693f036..ccbc55d 100644
--- a/chrome/browser/policy/user_cloud_policy_manager.cc
+++ b/chrome/browser/policy/user_cloud_policy_manager.cc
@@ -16,7 +16,6 @@
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
-#include "policy/policy_constants.h"
#if defined(OS_CHROMEOS)
#include "chrome/browser/policy/user_cloud_policy_store_chromeos.h"
@@ -43,11 +42,9 @@ const FilePath::CharType kPolicyCacheFile[] = FILE_PATH_LITERAL("Policy");
} // namespace
UserCloudPolicyManager::UserCloudPolicyManager(
- const PolicyDefinitionList* policy_list,
scoped_ptr<CloudPolicyStore> store,
bool wait_for_policy_fetch)
- : ConfigurationPolicyProvider(policy_list),
- wait_for_policy_fetch_(wait_for_policy_fetch),
+ : wait_for_policy_fetch_(wait_for_policy_fetch),
wait_for_policy_refresh_(false),
store_(store.Pass()) {
store_->Load();
@@ -78,8 +75,7 @@ scoped_ptr<UserCloudPolicyManager> UserCloudPolicyManager::Create(
chromeos::DBusThreadManager::Get()->GetSessionManagerClient(),
token_cache_file, policy_cache_file));
return scoped_ptr<UserCloudPolicyManager>(
- new UserCloudPolicyManager(GetChromePolicyDefinitionList(),
- store.Pass(), wait_for_policy_fetch));
+ new UserCloudPolicyManager(store.Pass(), wait_for_policy_fetch));
}
#endif
diff --git a/chrome/browser/policy/user_cloud_policy_manager.h b/chrome/browser/policy/user_cloud_policy_manager.h
index 4c0b55f..e845f2f 100644
--- a/chrome/browser/policy/user_cloud_policy_manager.h
+++ b/chrome/browser/policy/user_cloud_policy_manager.h
@@ -30,8 +30,7 @@ class UserCloudPolicyManager : public ConfigurationPolicyProvider,
public:
// If |wait_for_policy| fetch is true, IsInitializationComplete() will return
// false as long as there hasn't been a successful policy fetch.
- UserCloudPolicyManager(const PolicyDefinitionList* policy_list,
- scoped_ptr<CloudPolicyStore> store,
+ UserCloudPolicyManager(scoped_ptr<CloudPolicyStore> store,
bool wait_for_policy_fetch);
virtual ~UserCloudPolicyManager();
diff --git a/chrome/browser/policy/user_cloud_policy_manager_unittest.cc b/chrome/browser/policy/user_cloud_policy_manager_unittest.cc
index 498192f..3ce71c1 100644
--- a/chrome/browser/policy/user_cloud_policy_manager_unittest.cc
+++ b/chrome/browser/policy/user_cloud_policy_manager_unittest.cc
@@ -75,8 +75,7 @@ ConfigurationPolicyProvider* TestHarness::CreateProvider(
store_ = new MockCloudPolicyStore();
store_->NotifyStoreLoaded();
EXPECT_CALL(*store_, Load());
- return new UserCloudPolicyManager(policy_definition_list,
- scoped_ptr<CloudPolicyStore>(store_).Pass(),
+ return new UserCloudPolicyManager(scoped_ptr<CloudPolicyStore>(store_).Pass(),
false);
}
@@ -159,8 +158,7 @@ class UserCloudPolicyManagerTest : public testing::Test {
store_ = new MockCloudPolicyStore();
EXPECT_CALL(*store_, Load());
manager_.reset(
- new UserCloudPolicyManager(policy::GetChromePolicyDefinitionList(),
- scoped_ptr<CloudPolicyStore>(store_).Pass(),
+ new UserCloudPolicyManager(scoped_ptr<CloudPolicyStore>(store_).Pass(),
wait_for_policy_fetch));
registrar_.Init(manager_.get(), &observer_);
}