diff options
author | joaodasilva@chromium.org <joaodasilva@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-30 13:50:04 +0000 |
---|---|---|
committer | joaodasilva@chromium.org <joaodasilva@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-30 13:50:04 +0000 |
commit | 6a28e0af2a2624e0ebddde8cd3c89d33d58e7479 (patch) | |
tree | 7d60e756e356c0ecb049447251b46cdb81f0ddfc | |
parent | 61418efa678b45ebdbf057b0bc6cae8a0ca796fc (diff) | |
download | chromium_src-6a28e0af2a2624e0ebddde8cd3c89d33d58e7479.zip chromium_src-6a28e0af2a2624e0ebddde8cd3c89d33d58e7479.tar.gz chromium_src-6a28e0af2a2624e0ebddde8cd3c89d33d58e7479.tar.bz2 |
Move the PolicyDomain and PolicyNamespace types to the policy component.
Also refactored the files that use these types, so that they don't need to
include the policy_service.h anymore. In some cases this was a circular
dependency (e.g. PolicyBundle).
BUG=271392
Review URL: https://codereview.chromium.org/50613003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@231824 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/chromeos/policy/device_local_account_policy_provider.cc | 2 | ||||
-rw-r--r-- | chrome/browser/policy/async_policy_loader.h | 2 | ||||
-rw-r--r-- | chrome/browser/policy/cloud/component_cloud_policy_service.h | 2 | ||||
-rw-r--r-- | chrome/browser/policy/cloud/component_cloud_policy_store.h | 2 | ||||
-rw-r--r-- | chrome/browser/policy/cloud/component_cloud_policy_updater.cc | 2 | ||||
-rw-r--r-- | chrome/browser/policy/configuration_policy_provider.h | 2 | ||||
-rw-r--r-- | chrome/browser/policy/policy_bundle.cc | 1 | ||||
-rw-r--r-- | chrome/browser/policy/policy_bundle.h | 5 | ||||
-rw-r--r-- | chrome/browser/policy/policy_domain_descriptor.h | 2 | ||||
-rw-r--r-- | chrome/browser/policy/policy_service.cc | 32 | ||||
-rw-r--r-- | chrome/browser/policy/policy_service.h | 34 | ||||
-rw-r--r-- | components/policy.gypi | 14 | ||||
-rw-r--r-- | components/policy/core/common/policy_namespace.cc | 41 | ||||
-rw-r--r-- | components/policy/core/common/policy_namespace.h | 49 | ||||
-rw-r--r-- | components/policy/stub_to_remove.cc | 6 |
15 files changed, 107 insertions, 89 deletions
diff --git a/chrome/browser/chromeos/policy/device_local_account_policy_provider.cc b/chrome/browser/chromeos/policy/device_local_account_policy_provider.cc index 4381ce4..8f331df 100644 --- a/chrome/browser/chromeos/policy/device_local_account_policy_provider.cc +++ b/chrome/browser/chromeos/policy/device_local_account_policy_provider.cc @@ -8,7 +8,7 @@ #include "chrome/browser/policy/cloud/cloud_policy_core.h" #include "chrome/browser/policy/cloud/cloud_policy_service.h" #include "chrome/browser/policy/policy_bundle.h" -#include "chrome/browser/policy/policy_service.h" +#include "components/policy/core/common/policy_namespace.h" namespace policy { diff --git a/chrome/browser/policy/async_policy_loader.h b/chrome/browser/policy/async_policy_loader.h index 2da0a33..57f346c 100644 --- a/chrome/browser/policy/async_policy_loader.h +++ b/chrome/browser/policy/async_policy_loader.h @@ -12,7 +12,7 @@ #include "base/memory/scoped_ptr.h" #include "base/memory/weak_ptr.h" #include "base/time/time.h" -#include "chrome/browser/policy/policy_service.h" +#include "components/policy/core/common/policy_namespace.h" namespace base { class SequencedTaskRunner; diff --git a/chrome/browser/policy/cloud/component_cloud_policy_service.h b/chrome/browser/policy/cloud/component_cloud_policy_service.h index dbe3913..876739c 100644 --- a/chrome/browser/policy/cloud/component_cloud_policy_service.h +++ b/chrome/browser/policy/cloud/component_cloud_policy_service.h @@ -18,7 +18,7 @@ #include "chrome/browser/policy/cloud/cloud_policy_client.h" #include "chrome/browser/policy/cloud/cloud_policy_store.h" #include "chrome/browser/policy/policy_bundle.h" -#include "chrome/browser/policy/policy_service.h" +#include "components/policy/core/common/policy_namespace.h" namespace base { class SequencedTaskRunner; diff --git a/chrome/browser/policy/cloud/component_cloud_policy_store.h b/chrome/browser/policy/cloud/component_cloud_policy_store.h index 5b4a0bc..3e5285e 100644 --- a/chrome/browser/policy/cloud/component_cloud_policy_store.h +++ b/chrome/browser/policy/cloud/component_cloud_policy_store.h @@ -13,7 +13,7 @@ #include "base/memory/scoped_ptr.h" #include "base/threading/non_thread_safe.h" #include "chrome/browser/policy/policy_bundle.h" -#include "chrome/browser/policy/policy_service.h" +#include "components/policy/core/common/policy_namespace.h" namespace enterprise_management { class ExternalPolicyData; diff --git a/chrome/browser/policy/cloud/component_cloud_policy_updater.cc b/chrome/browser/policy/cloud/component_cloud_policy_updater.cc index 5423361..28c4d68 100644 --- a/chrome/browser/policy/cloud/component_cloud_policy_updater.cc +++ b/chrome/browser/policy/cloud/component_cloud_policy_updater.cc @@ -13,9 +13,9 @@ #include "base/strings/string_number_conversions.h" #include "chrome/browser/policy/cloud/component_cloud_policy_store.h" #include "chrome/browser/policy/cloud/external_policy_data_fetcher.h" -#include "chrome/browser/policy/policy_service.h" #include "chrome/browser/policy/proto/cloud/chrome_extension_policy.pb.h" #include "chrome/browser/policy/proto/cloud/device_management_backend.pb.h" +#include "components/policy/core/common/policy_namespace.h" namespace em = enterprise_management; diff --git a/chrome/browser/policy/configuration_policy_provider.h b/chrome/browser/policy/configuration_policy_provider.h index 2d7372a..3fef214 100644 --- a/chrome/browser/policy/configuration_policy_provider.h +++ b/chrome/browser/policy/configuration_policy_provider.h @@ -10,7 +10,7 @@ #include "base/memory/scoped_ptr.h" #include "base/observer_list.h" #include "chrome/browser/policy/policy_bundle.h" -#include "chrome/browser/policy/policy_service.h" +#include "components/policy/core/common/policy_namespace.h" namespace policy { diff --git a/chrome/browser/policy/policy_bundle.cc b/chrome/browser/policy/policy_bundle.cc index eecca17..90e4a0a 100644 --- a/chrome/browser/policy/policy_bundle.cc +++ b/chrome/browser/policy/policy_bundle.cc @@ -6,7 +6,6 @@ #include "base/logging.h" #include "base/stl_util.h" -#include "chrome/browser/policy/policy_map.h" namespace policy { diff --git a/chrome/browser/policy/policy_bundle.h b/chrome/browser/policy/policy_bundle.h index a7149ca..339d6b4 100644 --- a/chrome/browser/policy/policy_bundle.h +++ b/chrome/browser/policy/policy_bundle.h @@ -9,12 +9,11 @@ #include <string> #include "base/basictypes.h" -#include "chrome/browser/policy/policy_service.h" +#include "chrome/browser/policy/policy_map.h" +#include "components/policy/core/common/policy_namespace.h" namespace policy { -class PolicyMap; - // Maps policy namespaces to PolicyMaps. class PolicyBundle { public: diff --git a/chrome/browser/policy/policy_domain_descriptor.h b/chrome/browser/policy/policy_domain_descriptor.h index 2106633..6293900 100644 --- a/chrome/browser/policy/policy_domain_descriptor.h +++ b/chrome/browser/policy/policy_domain_descriptor.h @@ -11,7 +11,7 @@ #include "base/basictypes.h" #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" -#include "chrome/browser/policy/policy_service.h" +#include "components/policy/core/common/policy_namespace.h" #include "components/policy/core/common/schema.h" namespace policy { diff --git a/chrome/browser/policy/policy_service.cc b/chrome/browser/policy/policy_service.cc index 0f65c3b..cd07867 100644 --- a/chrome/browser/policy/policy_service.cc +++ b/chrome/browser/policy/policy_service.cc @@ -8,38 +8,6 @@ namespace policy { -PolicyNamespace::PolicyNamespace() {} - -PolicyNamespace::PolicyNamespace(PolicyDomain domain, - const std::string& component_id) - : domain(domain), - component_id(component_id) {} - -PolicyNamespace::PolicyNamespace(const PolicyNamespace& other) - : domain(other.domain), - component_id(other.component_id) {} - -PolicyNamespace::~PolicyNamespace() {} - -PolicyNamespace& PolicyNamespace::operator=(const PolicyNamespace& other) { - domain = other.domain; - component_id = other.component_id; - return *this; -} - -bool PolicyNamespace::operator<(const PolicyNamespace& other) const { - return domain < other.domain || - (domain == other.domain && component_id < other.component_id); -} - -bool PolicyNamespace::operator==(const PolicyNamespace& other) const { - return domain == other.domain && component_id == other.component_id; -} - -bool PolicyNamespace::operator!=(const PolicyNamespace& other) const { - return !(*this == other); -} - PolicyChangeRegistrar::PolicyChangeRegistrar(PolicyService* policy_service, const PolicyNamespace& ns) : policy_service_(policy_service), diff --git a/chrome/browser/policy/policy_service.h b/chrome/browser/policy/policy_service.h index 1d8d135..b6c6c0e 100644 --- a/chrome/browser/policy/policy_service.h +++ b/chrome/browser/policy/policy_service.h @@ -12,44 +12,12 @@ #include "base/callback.h" #include "base/memory/ref_counted.h" #include "chrome/browser/policy/policy_map.h" +#include "components/policy/core/common/policy_namespace.h" namespace policy { class PolicyDomainDescriptor; -// Policies are namespaced by a (PolicyDomain, ID) pair. The meaning of the ID -// string depends on the domain; for example, if the PolicyDomain is -// "extensions" then the ID identifies the extension that the policies control. -enum PolicyDomain { - // The component ID for chrome policies is always the empty string. - POLICY_DOMAIN_CHROME, - - // The extensions policy domain is a work in progress. Included here for - // tests. - POLICY_DOMAIN_EXTENSIONS, - - // Must be the last entry. - POLICY_DOMAIN_SIZE, -}; - -// Groups a policy domain and a component ID in a single object representing -// a policy namespace. Objects of this class can be used as keys in std::maps. -struct PolicyNamespace { - public: - PolicyNamespace(); - PolicyNamespace(PolicyDomain domain, const std::string& component_id); - PolicyNamespace(const PolicyNamespace& other); - ~PolicyNamespace(); - - PolicyNamespace& operator=(const PolicyNamespace& other); - bool operator<(const PolicyNamespace& other) const; - bool operator==(const PolicyNamespace& other) const; - bool operator!=(const PolicyNamespace& other) const; - - PolicyDomain domain; - std::string component_id; -}; - // The PolicyService merges policies from all available sources, taking into // account their priorities. Policy clients can retrieve policy for their domain // and register for notifications on policy updates. diff --git a/components/policy.gypi b/components/policy.gypi index 77fe110..32aed7e 100644 --- a/components/policy.gypi +++ b/components/policy.gypi @@ -20,6 +20,8 @@ 'conditions': [ ['configuration_policy==1', { 'sources': [ + 'policy/core/common/policy_namespace.cc', + 'policy/core/common/policy_namespace.h', 'policy/core/common/policy_pref_names.cc', 'policy/core/common/policy_pref_names.h', 'policy/core/common/policy_switches.cc', @@ -30,14 +32,12 @@ 'policy/policy_export.h', ], }, { # configuration_policy==0 - # The target 'policy_component' always exists. Later it will include - # some stubs when configuration_policy==0. For now this stub file is - # compiled so that an output is produced, otherwise the shared build - # breaks on iOS. - # TODO(joaodasilva): remove this comment and the temporary stub after - # moving one of the real stubs. http://crbug.com/271392 + # Some of the policy code is always enabled, so that other parts of + # Chrome can always interface with the PolicyService without having + # to #ifdef on ENABLE_CONFIGURATION_POLICY. 'sources': [ - 'policy/stub_to_remove.cc', + 'policy/core/common/policy_namespace.cc', + 'policy/core/common/policy_namespace.h', ], }], ], diff --git a/components/policy/core/common/policy_namespace.cc b/components/policy/core/common/policy_namespace.cc new file mode 100644 index 0000000..0fac9ca --- /dev/null +++ b/components/policy/core/common/policy_namespace.cc @@ -0,0 +1,41 @@ +// 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 "components/policy/core/common/policy_namespace.h" + +namespace policy { + +PolicyNamespace::PolicyNamespace() {} + +PolicyNamespace::PolicyNamespace(PolicyDomain domain, + const std::string& component_id) + : domain(domain), + component_id(component_id) {} + +PolicyNamespace::PolicyNamespace(const PolicyNamespace& other) + : domain(other.domain), + component_id(other.component_id) {} + +PolicyNamespace::~PolicyNamespace() {} + +PolicyNamespace& PolicyNamespace::operator=(const PolicyNamespace& other) { + domain = other.domain; + component_id = other.component_id; + return *this; +} + +bool PolicyNamespace::operator<(const PolicyNamespace& other) const { + return domain < other.domain || + (domain == other.domain && component_id < other.component_id); +} + +bool PolicyNamespace::operator==(const PolicyNamespace& other) const { + return domain == other.domain && component_id == other.component_id; +} + +bool PolicyNamespace::operator!=(const PolicyNamespace& other) const { + return !(*this == other); +} + +} // namespace policy diff --git a/components/policy/core/common/policy_namespace.h b/components/policy/core/common/policy_namespace.h new file mode 100644 index 0000000..4d8cf1c --- /dev/null +++ b/components/policy/core/common/policy_namespace.h @@ -0,0 +1,49 @@ +// 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. + +#ifndef COMPONENTS_POLICY_CORE_COMMON_POLICY_NAMESPACE_H_ +#define COMPONENTS_POLICY_CORE_COMMON_POLICY_NAMESPACE_H_ + +#include <string> + +#include "components/policy/policy_export.h" + +namespace policy { + +// Policies are namespaced by a (PolicyDomain, ID) pair. The meaning of the ID +// string depends on the domain; for example, if the PolicyDomain is +// "extensions" then the ID identifies the extension that the policies control. +enum POLICY_EXPORT PolicyDomain { + // The component ID for chrome policies is always the empty string. + POLICY_DOMAIN_CHROME, + + // The extensions policy domain is a work in progress. Included here for + // tests. + POLICY_DOMAIN_EXTENSIONS, + + // Must be the last entry. + POLICY_DOMAIN_SIZE, +}; + +// Groups a policy domain and a component ID in a single object representing +// a policy namespace. Objects of this class can be used as keys in std::maps. +struct POLICY_EXPORT PolicyNamespace { + public: + PolicyNamespace(); + PolicyNamespace(PolicyDomain domain, const std::string& component_id); + PolicyNamespace(const PolicyNamespace& other); + ~PolicyNamespace(); + + PolicyNamespace& operator=(const PolicyNamespace& other); + bool operator<(const PolicyNamespace& other) const; + bool operator==(const PolicyNamespace& other) const; + bool operator!=(const PolicyNamespace& other) const; + + PolicyDomain domain; + std::string component_id; +}; + +} // namespace policy + +#endif // COMPONENTS_POLICY_CORE_COMMON_POLICY_NAMESPACE_H_ diff --git a/components/policy/stub_to_remove.cc b/components/policy/stub_to_remove.cc deleted file mode 100644 index 6e352ac..0000000 --- a/components/policy/stub_to_remove.cc +++ /dev/null @@ -1,6 +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. - -// TODO(joaodasilva): remove this file and update the comment on policy.gypi. -// http://crbug.com/271392 |