Chromium Code Reviews| Index: chrome/browser/policy/configuration_policy_reader.h |
| diff --git a/chrome/browser/policy/configuration_policy_reader.h b/chrome/browser/policy/configuration_policy_reader.h |
| index 372ff286b7e2db12dc02b6ab6655f4182ff0d90e..118a8e16254cb8b2f69d00ba1db52518ef72c680 100644 |
| --- a/chrome/browser/policy/configuration_policy_reader.h |
| +++ b/chrome/browser/policy/configuration_policy_reader.h |
| @@ -6,6 +6,7 @@ |
| #define CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_READER_H_ |
| #pragma once |
| +#include "base/observer_list.h" |
| #include "base/scoped_ptr.h" |
| #include "base/values.h" |
| #include "chrome/browser/policy/configuration_policy_provider.h" |
| @@ -21,6 +22,12 @@ class ConfigurationPolicyStatusKeeper; |
| // about:policy UI. |
| class ConfigurationPolicyReader : public ConfigurationPolicyProvider::Observer { |
| public: |
| + class Observer { |
|
James Hawkins
2011/09/05 22:10:38
Document this class.
simo
2011/09/07 12:18:16
Done.
|
| + public: |
| + virtual ~Observer() {} |
|
James Hawkins
2011/09/05 22:10:38
Make the destructor protected.
simo
2011/09/07 12:18:16
Done.
|
| + virtual void OnPolicyValuesChanged() = 0; |
|
James Hawkins
2011/09/05 22:10:38
Document this method.
simo
2011/09/07 12:18:16
Done.
|
| + }; |
| + |
| ConfigurationPolicyReader(ConfigurationPolicyProvider* provider, |
| PolicyStatusInfo::PolicyLevel policy_level); |
| virtual ~ConfigurationPolicyReader(); |
| @@ -29,21 +36,21 @@ class ConfigurationPolicyReader : public ConfigurationPolicyProvider::Observer { |
| virtual void OnUpdatePolicy(); |
| virtual void OnProviderGoingAway(); |
| + // Methods to handle Observers. |
| + void AddObserver(Observer* observer); |
|
James Hawkins
2011/09/05 22:10:38
Comment on the ownership and NULL-ability of |obse
simo
2011/09/07 12:18:16
Done.
|
| + void RemoveObserver(Observer* observer); |
| + |
| // Creates a ConfigurationPolicyReader that reads managed platform policy. |
| - static ConfigurationPolicyReader* |
| - CreateManagedPlatformPolicyReader(); |
| + static ConfigurationPolicyReader* CreateManagedPlatformPolicyReader(); |
| // Creates a ConfigurationPolicyReader that reads managed cloud policy. |
| - static ConfigurationPolicyReader* |
| - CreateManagedCloudPolicyReader(); |
| + static ConfigurationPolicyReader* CreateManagedCloudPolicyReader(); |
| // Creates a ConfigurationPolicyReader that reads recommended platform policy. |
| - static ConfigurationPolicyReader* |
| - CreateRecommendedPlatformPolicyReader(); |
| + static ConfigurationPolicyReader* CreateRecommendedPlatformPolicyReader(); |
| // Creates a ConfigurationPolicyReader that reads recommended cloud policy. |
| - static ConfigurationPolicyReader* |
| - CreateRecommendedCloudPolicyReader(); |
| + static ConfigurationPolicyReader* CreateRecommendedCloudPolicyReader(); |
| // Returns a pointer to a DictionaryValue object containing policy status |
| // information for the UI. Ownership of the return value is acquired by the |
| @@ -70,6 +77,8 @@ class ConfigurationPolicyReader : public ConfigurationPolicyProvider::Observer { |
| // Current policy status. |
| scoped_ptr<ConfigurationPolicyStatusKeeper> policy_keeper_; |
| + ObserverList<Observer, true> observers_; |
|
James Hawkins
2011/09/05 22:10:38
Document this var.
simo
2011/09/07 12:18:16
Done.
|
| + |
| ConfigurationPolicyObserverRegistrar registrar_; |
| DISALLOW_COPY_AND_ASSIGN(ConfigurationPolicyReader); |
| @@ -80,12 +89,19 @@ class ConfigurationPolicyReader : public ConfigurationPolicyProvider::Observer { |
| // about:policy UI can display. |
| class PolicyStatus { |
| public: |
| + typedef ConfigurationPolicyReader::Observer Observer; |
| PolicyStatus(ConfigurationPolicyReader* managed_platform, |
| ConfigurationPolicyReader* managed_cloud, |
| ConfigurationPolicyReader* recommended_platform, |
| ConfigurationPolicyReader* recommended_cloud); |
| ~PolicyStatus(); |
| + // Adds an observer to each one of the ConfigurationPolicyReaders. |
| + void AddObserver(Observer* observer) const; |
| + |
| + // Removes an observer from each one of the ConfigurationPolicyReaders. |
| + void RemoveObserver(Observer* observer) const; |
| + |
| // Returns a ListValue pointer containing the status information of all |
| // policies supported by the client. |any_policies_sent| is set to true if |
| // there are policies in the list that were sent by a provider, otherwise |
| @@ -105,7 +121,7 @@ class PolicyStatus { |
| // |list| as it is returned by the different ConfigurationPolicyReader |
| // objects. Returns true if a policy was added and false otherwise. |
| bool AddPolicyFromReaders(ConfigurationPolicyType policy, |
| - ListValue* list) const; |
| + ListValue* list) const; |
| scoped_ptr<ConfigurationPolicyReader> managed_platform_; |
| scoped_ptr<ConfigurationPolicyReader> managed_cloud_; |