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

Unified Diff: chrome/browser/policy/policy_service.h

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
« no previous file with comments | « chrome/browser/policy/policy_loader_win_unittest.cc ('k') | chrome/browser/policy/policy_service.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/policy/policy_service.h
diff --git a/chrome/browser/policy/policy_service.h b/chrome/browser/policy/policy_service.h
deleted file mode 100644
index 259f70a276f9fcf9322c5ed252d376313ed656b6..0000000000000000000000000000000000000000
--- a/chrome/browser/policy/policy_service.h
+++ /dev/null
@@ -1,114 +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.
-
-#ifndef CHROME_BROWSER_POLICY_POLICY_SERVICE_H_
-#define CHROME_BROWSER_POLICY_POLICY_SERVICE_H_
-
-#include <map>
-#include <string>
-
-#include "base/basictypes.h"
-#include "base/callback.h"
-#include "components/policy/core/common/policy_map.h"
-#include "components/policy/core/common/policy_namespace.h"
-
-namespace policy {
-
-// 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.
-//
-// The PolicyService is available from BrowserProcess as a global singleton.
-// There is also a PolicyService for browser-wide policies available from
-// BrowserProcess as a global singleton.
-class PolicyService {
- public:
- class Observer {
- public:
- // Invoked whenever policies for the given |ns| namespace are modified.
- // This is only invoked for changes that happen after AddObserver is called.
- // |previous| contains the values of the policies before the update,
- // and |current| contains the current values.
- virtual void OnPolicyUpdated(const PolicyNamespace& ns,
- const PolicyMap& previous,
- const PolicyMap& current) = 0;
-
- // Invoked at most once for each |domain|, when the PolicyService becomes
- // ready. If IsInitializationComplete() is false, then this will be invoked
- // once all the policy providers have finished loading their policies for
- // |domain|.
- virtual void OnPolicyServiceInitialized(PolicyDomain domain) {}
-
- protected:
- virtual ~Observer() {}
- };
-
- virtual ~PolicyService() {}
-
- // Observes changes to all components of the given |domain|.
- virtual void AddObserver(PolicyDomain domain, Observer* observer) = 0;
-
- virtual void RemoveObserver(PolicyDomain domain, Observer* observer) = 0;
-
- virtual const PolicyMap& GetPolicies(const PolicyNamespace& ns) const = 0;
-
- // The PolicyService loads policy from several sources, and some require
- // asynchronous loads. IsInitializationComplete() returns true once all
- // sources have loaded their policies for the given |domain|.
- // It is safe to read policy from the PolicyService even if
- // IsInitializationComplete() is false; there will be an OnPolicyUpdated()
- // notification once new policies become available.
- //
- // OnPolicyServiceInitialized() is called when IsInitializationComplete()
- // becomes true, which happens at most once for each domain.
- // If IsInitializationComplete() is already true for |domain| when an Observer
- // is registered, then that Observer will not receive an
- // OnPolicyServiceInitialized() notification.
- virtual bool IsInitializationComplete(PolicyDomain domain) const = 0;
-
- // Asks the PolicyService to reload policy from all available policy sources.
- // |callback| is invoked once every source has reloaded its policies, and
- // GetPolicies() is guaranteed to return the updated values at that point.
- virtual void RefreshPolicies(const base::Closure& callback) = 0;
-};
-
-// A registrar that only observes changes to particular policies within the
-// PolicyMap for the given policy namespace.
-class PolicyChangeRegistrar : public PolicyService::Observer {
- public:
- typedef base::Callback<void(const Value*, const Value*)> UpdateCallback;
-
- // Observes updates to the given (domain, component_id) namespace in the given
- // |policy_service|, and notifies |observer| whenever any of the registered
- // policy keys changes. Both the |policy_service| and the |observer| must
- // outlive |this|.
- PolicyChangeRegistrar(PolicyService* policy_service,
- const PolicyNamespace& ns);
-
- virtual ~PolicyChangeRegistrar();
-
- // Will invoke |callback| whenever |policy_name| changes its value, as long
- // as this registrar exists.
- // Only one callback can be registed per policy name; a second call with the
- // same |policy_name| will overwrite the previous callback.
- void Observe(const std::string& policy_name, const UpdateCallback& callback);
-
- // Implementation of PolicyService::Observer:
- virtual void OnPolicyUpdated(const PolicyNamespace& ns,
- const PolicyMap& previous,
- const PolicyMap& current) OVERRIDE;
-
- private:
- typedef std::map<std::string, UpdateCallback> CallbackMap;
-
- PolicyService* policy_service_;
- PolicyNamespace ns_;
- CallbackMap callback_map_;
-
- DISALLOW_COPY_AND_ASSIGN(PolicyChangeRegistrar);
-};
-
-} // namespace policy
-
-#endif // CHROME_BROWSER_POLICY_POLICY_SERVICE_H_
« no previous file with comments | « chrome/browser/policy/policy_loader_win_unittest.cc ('k') | chrome/browser/policy/policy_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698