Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_UI_WEBUI_POLICY_UI_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_POLICY_UI_H_ |
| 6 #define CHROME_BROWSER_UI_WEBUI_POLICY_UI_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_POLICY_UI_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/compiler_specific.h" | |
| 11 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 13 #include "base/string16.h" | |
| 14 #include "base/values.h" | |
| 15 #include "chrome/browser/policy/policy_map.h" | |
| 16 #include "chrome/browser/policy/policy_service.h" | 14 #include "chrome/browser/policy/policy_service.h" |
| 17 #include "content/public/browser/web_ui_controller.h" | 15 #include "content/public/browser/web_ui_controller.h" |
| 18 #include "content/public/browser/web_ui_message_handler.h" | 16 #include "content/public/browser/web_ui_message_handler.h" |
| 19 #include "policy/policy_constants.h" | 17 |
| 18 namespace content { | |
| 19 class WebUI; | |
| 20 } | |
| 21 | |
| 22 namespace policy { | |
| 23 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.
| |
| 24 } | |
| 20 | 25 |
| 21 class CloudPolicyStatusProvider; | 26 class CloudPolicyStatusProvider; |
| 22 | 27 |
| 23 // The base class handler of Javascript messages of the about:policy page. | 28 // Base class for the chrome://policy JavaScript message handler. |
| 24 class PolicyUIHandler : public content::WebUIMessageHandler, | 29 class PolicyUIHandlerBase : public content::WebUIMessageHandler, |
| 25 public policy::PolicyService::Observer { | 30 public policy::PolicyService::Observer { |
| 26 public: | 31 public: |
| 27 // Keys expected in a DictionaryValue representing the status of a policy. | 32 PolicyUIHandlerBase(); |
| 28 // Public for testing. | 33 virtual ~PolicyUIHandlerBase(); |
| 29 static const char kLevel[]; | |
| 30 static const char kName[]; | |
| 31 static const char kScope[]; | |
| 32 static const char kSet[]; | |
| 33 static const char kStatus[]; | |
| 34 static const char kValue[]; | |
| 35 | 34 |
| 36 PolicyUIHandler(); | 35 // content::WebUIMessageHandler: |
| 37 virtual ~PolicyUIHandler(); | |
| 38 | |
| 39 // WebUIMessageHandler implementation. | |
| 40 virtual void RegisterMessages() OVERRIDE; | 36 virtual void RegisterMessages() OVERRIDE; |
| 41 | 37 |
| 42 // policy::PolicyService::Observer implementation. | 38 // policy::PolicyService::Observer implementation. |
| 43 virtual void OnPolicyUpdated(policy::PolicyDomain domain, | 39 virtual void OnPolicyUpdated(policy::PolicyDomain domain, |
| 44 const std::string& component_id, | 40 const std::string& component_id, |
| 45 const policy::PolicyMap& previous, | 41 const policy::PolicyMap& previous, |
| 46 const policy::PolicyMap& current) OVERRIDE; | 42 const policy::PolicyMap& current) OVERRIDE; |
| 47 | 43 |
| 48 // Returns a ListValue pointer containing the status information of all | 44 private: |
| 49 // policies defined in |policies|. |any_policies_set| is set to true if | 45 virtual void SendDefinitions() const = 0; |
| 50 // there are policies in the list that were valid, otherwise it's false. | 46 void SendPolicyValues() const; |
| 51 static scoped_ptr<base::ListValue> GetPolicyStatusList( | 47 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.
| |
| 52 const policy::PolicyMap& policies, | |
| 53 bool* any_policies_set); | |
| 54 | 48 |
| 55 private: | 49 void HandleInitialized(const base::ListValue* args); |
| 56 // Callback for the "requestData" message. The parameter |args| is unused. | 50 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.
| |
| 57 void HandleRequestData(const base::ListValue* args); | |
| 58 | 51 |
| 59 // Callback for the "fetchPolicy" message. The parameter |args| is unused. | 52 void OnRefreshPoliciesDone() const; |
| 60 void HandleFetchPolicy(const base::ListValue* args); | |
| 61 | 53 |
| 62 // Callback for completion of a RefreshPolicies call. | 54 policy::PolicyService* GetPolicyService() const; |
| 63 void OnRefreshDone(); | |
| 64 | 55 |
| 65 // Sends policy data to UI. | 56 bool initialized_; |
| 66 void SendDataToUI(); | 57 std::string device_domain_; |
| 67 | 58 base::WeakPtrFactory<PolicyUIHandlerBase> weak_factory_; |
| 68 // Returns the policy service to use. | |
| 69 policy::PolicyService* GetPolicyService(); | |
| 70 | |
| 71 // Returns a DictionaryValue pointer containing information about the status | |
| 72 // of the policy system. The caller acquires ownership of the returned | |
| 73 // DictionaryValue pointer. | |
| 74 base::DictionaryValue* GetStatusData(); | |
| 75 | |
| 76 // Used to post a callback to RefreshPolicies with a WeakPtr to |this|. | |
| 77 base::WeakPtrFactory<PolicyUIHandler> weak_factory_; | |
| 78 | 59 |
| 79 // Providers that supply status dictionaries for user and device policy, | 60 // Providers that supply status dictionaries for user and device policy, |
| 80 // respectively. These are created on initialization time as appropriate for | 61 // respectively. These are created on initialization time as appropriate for |
| 81 // the platform (Chrome OS / desktop) and type of policy that is in effect. | 62 // the platform (Chrome OS / desktop) and type of policy that is in effect. |
| 82 scoped_ptr<CloudPolicyStatusProvider> user_status_provider_; | 63 scoped_ptr<CloudPolicyStatusProvider> user_status_provider_; |
| 83 scoped_ptr<CloudPolicyStatusProvider> device_status_provider_; | 64 scoped_ptr<CloudPolicyStatusProvider> device_status_provider_; |
| 84 | 65 |
| 85 // The domain the device is enrolled to, if applicable. | 66 DISALLOW_COPY_AND_ASSIGN(PolicyUIHandlerBase); |
| 86 string16 enterprise_domain_; | 67 }; |
| 68 | |
| 69 // The JavaScript message handler for the chrome://policy page. | |
| 70 class PolicyUIHandler : public PolicyUIHandlerBase { | |
| 71 public: | |
| 72 PolicyUIHandler(); | |
| 73 virtual ~PolicyUIHandler(); | |
| 74 | |
| 75 private: | |
| 76 virtual void SendDefinitions() const OVERRIDE; | |
| 87 | 77 |
| 88 DISALLOW_COPY_AND_ASSIGN(PolicyUIHandler); | 78 DISALLOW_COPY_AND_ASSIGN(PolicyUIHandler); |
| 89 }; | 79 }; |
| 90 | 80 |
| 91 // The Web UI handler for about:policy. | 81 // 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.
| |
| 92 class PolicyUI : public content::WebUIController { | 82 class PolicyUI : public content::WebUIController { |
| 93 public: | 83 public: |
| 94 explicit PolicyUI(content::WebUI* web_ui); | 84 explicit PolicyUI(content::WebUI* web_ui); |
| 95 virtual ~PolicyUI(); | 85 virtual ~PolicyUI(); |
| 96 | 86 |
| 97 private: | 87 private: |
| 98 DISALLOW_COPY_AND_ASSIGN(PolicyUI); | 88 DISALLOW_COPY_AND_ASSIGN(PolicyUI); |
| 99 }; | 89 }; |
| 100 | 90 |
| 101 #endif // CHROME_BROWSER_UI_WEBUI_POLICY_UI_H_ | 91 #endif // CHROME_BROWSER_UI_WEBUI_POLICY_UI_H_ |
| OLD | NEW |