Chromium Code Reviews| Index: chrome/browser/ui/webui/policy_ui.h |
| diff --git a/chrome/browser/ui/webui/policy_ui.h b/chrome/browser/ui/webui/policy_ui.h |
| index c9d653258e62118d20d2160b2f6b2edf4727f751..941c76ceece3e8fd5887dc7544a0d837e2aff6ba 100644 |
| --- a/chrome/browser/ui/webui/policy_ui.h |
| +++ b/chrome/browser/ui/webui/policy_ui.h |
| @@ -8,35 +8,31 @@ |
| #include <string> |
| #include "base/basictypes.h" |
| +#include "base/compiler_specific.h" |
| #include "base/memory/scoped_ptr.h" |
| #include "base/memory/weak_ptr.h" |
| -#include "base/string16.h" |
| -#include "base/values.h" |
| -#include "chrome/browser/policy/policy_map.h" |
| #include "chrome/browser/policy/policy_service.h" |
| #include "content/public/browser/web_ui_controller.h" |
| #include "content/public/browser/web_ui_message_handler.h" |
| -#include "policy/policy_constants.h" |
| + |
| +namespace content { |
| +class WebUI; |
| +} |
| + |
| +namespace policy { |
| +class PolicyService; |
|
Mattias Nissler (ping if slow)
2013/01/30 16:34:59
This is #included
bartfab (slow)
2013/01/31 14:24:17
Done.
|
| +} |
| class CloudPolicyStatusProvider; |
| -// The base class handler of Javascript messages of the about:policy page. |
| -class PolicyUIHandler : public content::WebUIMessageHandler, |
| - public policy::PolicyService::Observer { |
| +// Base class for the chrome://policy JavaScript message handler. |
| +class PolicyUIHandlerBase : public content::WebUIMessageHandler, |
| + public policy::PolicyService::Observer { |
| public: |
| - // Keys expected in a DictionaryValue representing the status of a policy. |
| - // Public for testing. |
| - static const char kLevel[]; |
| - static const char kName[]; |
| - static const char kScope[]; |
| - static const char kSet[]; |
| - static const char kStatus[]; |
| - static const char kValue[]; |
| - |
| - PolicyUIHandler(); |
| - virtual ~PolicyUIHandler(); |
| + PolicyUIHandlerBase(); |
| + virtual ~PolicyUIHandlerBase(); |
| - // WebUIMessageHandler implementation. |
| + // content::WebUIMessageHandler: |
| virtual void RegisterMessages() OVERRIDE; |
| // policy::PolicyService::Observer implementation. |
| @@ -45,36 +41,21 @@ class PolicyUIHandler : public content::WebUIMessageHandler, |
| const policy::PolicyMap& previous, |
| const policy::PolicyMap& current) OVERRIDE; |
| - // Returns a ListValue pointer containing the status information of all |
| - // policies defined in |policies|. |any_policies_set| is set to true if |
| - // there are policies in the list that were valid, otherwise it's false. |
| - static scoped_ptr<base::ListValue> GetPolicyStatusList( |
| - const policy::PolicyMap& policies, |
| - bool* any_policies_set); |
| - |
| private: |
| - // Callback for the "requestData" message. The parameter |args| is unused. |
| - void HandleRequestData(const base::ListValue* args); |
| - |
| - // Callback for the "fetchPolicy" message. The parameter |args| is unused. |
| - void HandleFetchPolicy(const base::ListValue* args); |
| - |
| - // Callback for completion of a RefreshPolicies call. |
| - void OnRefreshDone(); |
| + virtual void SendDefinitions() const = 0; |
| + void SendPolicyValues() const; |
| + void SendStatus() const; |
|
Mattias Nissler (ping if slow)
2013/01/30 16:34:59
These could use some documentation
bartfab (slow)
2013/01/31 14:24:17
Done.
|
| - // Sends policy data to UI. |
| - void SendDataToUI(); |
| + void HandleInitialized(const base::ListValue* args); |
| + void HandleReloadPolicies(const base::ListValue* args); |
|
Mattias Nissler (ping if slow)
2013/01/30 16:34:59
forward-declare ListValue
bartfab (slow)
2013/01/31 14:24:17
Done.
|
| - // Returns the policy service to use. |
| - policy::PolicyService* GetPolicyService(); |
| + void OnRefreshPoliciesDone() const; |
| - // Returns a DictionaryValue pointer containing information about the status |
| - // of the policy system. The caller acquires ownership of the returned |
| - // DictionaryValue pointer. |
| - base::DictionaryValue* GetStatusData(); |
| + policy::PolicyService* GetPolicyService() const; |
| - // Used to post a callback to RefreshPolicies with a WeakPtr to |this|. |
| - base::WeakPtrFactory<PolicyUIHandler> weak_factory_; |
| + bool initialized_; |
| + std::string device_domain_; |
| + base::WeakPtrFactory<PolicyUIHandlerBase> weak_factory_; |
| // Providers that supply status dictionaries for user and device policy, |
| // respectively. These are created on initialization time as appropriate for |
| @@ -82,13 +63,22 @@ class PolicyUIHandler : public content::WebUIMessageHandler, |
| scoped_ptr<CloudPolicyStatusProvider> user_status_provider_; |
| scoped_ptr<CloudPolicyStatusProvider> device_status_provider_; |
| - // The domain the device is enrolled to, if applicable. |
| - string16 enterprise_domain_; |
| + DISALLOW_COPY_AND_ASSIGN(PolicyUIHandlerBase); |
| +}; |
| + |
| +// The JavaScript message handler for the chrome://policy page. |
| +class PolicyUIHandler : public PolicyUIHandlerBase { |
| + public: |
| + PolicyUIHandler(); |
| + virtual ~PolicyUIHandler(); |
| + |
| + private: |
| + virtual void SendDefinitions() const OVERRIDE; |
| DISALLOW_COPY_AND_ASSIGN(PolicyUIHandler); |
| }; |
| -// The Web UI handler for about:policy. |
| +// The Web UI handler for the chrome://policy page. |
|
Mattias Nissler (ping if slow)
2013/01/30 16:34:59
s/handler/controller/
bartfab (slow)
2013/01/31 14:24:17
Done.
|
| class PolicyUI : public content::WebUIController { |
| public: |
| explicit PolicyUI(content::WebUI* web_ui); |