| Index: chrome/browser/policy/policy_service.h
|
| diff --git a/chrome/browser/policy/policy_service.h b/chrome/browser/policy/policy_service.h
|
| index 5b5f3f33507a61bb6a964191b3c4571bca07e9bd..f414ba0c82caac57c71a0e03bfd2cb1c6d4348c8 100644
|
| --- a/chrome/browser/policy/policy_service.h
|
| +++ b/chrome/browser/policy/policy_service.h
|
| @@ -6,8 +6,11 @@
|
| #define CHROME_BROWSER_POLICY_POLICY_SERVICE_H_
|
| #pragma once
|
|
|
| +#include <map>
|
| #include <string>
|
|
|
| +#include "base/basictypes.h"
|
| +#include "base/callback.h"
|
| #include "chrome/browser/policy/policy_map.h"
|
|
|
| namespace policy {
|
| @@ -75,6 +78,45 @@ class PolicyService {
|
| virtual bool IsInitializationComplete() const = 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,
|
| + PolicyDomain domain,
|
| + const std::string component_id);
|
| +
|
| + 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(PolicyDomain domain,
|
| + const std::string& component_id,
|
| + const PolicyMap& previous,
|
| + const PolicyMap& current) OVERRIDE;
|
| +
|
| + private:
|
| + typedef std::map<std::string, UpdateCallback> CallbackMap;
|
| +
|
| + PolicyService* policy_service_;
|
| + PolicyDomain domain_;
|
| + std::string component_id_;
|
| + CallbackMap callback_map_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(PolicyChangeRegistrar);
|
| +};
|
| +
|
| } // namespace policy
|
|
|
| #endif // CHROME_BROWSER_POLICY_POLICY_SERVICE_H_
|
|
|