| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/scoped_ptr.h" | 9 #include "base/scoped_ptr.h" |
| 10 #include "base/time.h" |
| 10 #include "base/values.h" | 11 #include "base/values.h" |
| 12 #include "chrome/browser/policy/cloud_policy_subsystem.h" |
| 11 #include "chrome/browser/policy/configuration_policy_reader.h" | 13 #include "chrome/browser/policy/configuration_policy_reader.h" |
| 12 #include "chrome/browser/ui/webui/chrome_web_ui.h" | 14 #include "chrome/browser/ui/webui/chrome_web_ui.h" |
| 13 #include "content/common/notification_observer.h" | 15 #include "content/common/notification_observer.h" |
| 14 | 16 |
| 15 // The base class handler of Javascript messages of the about:policy page. | 17 // The base class handler of Javascript messages of the about:policy page. |
| 16 class PolicyUIHandler : public WebUIMessageHandler { | 18 class PolicyUIHandler : public WebUIMessageHandler, |
| 19 public policy::PolicyStatus::Observer { |
| 17 public: | 20 public: |
| 18 PolicyUIHandler(); | 21 PolicyUIHandler(); |
| 19 virtual ~PolicyUIHandler(); | 22 virtual ~PolicyUIHandler(); |
| 20 | 23 |
| 21 // WebUIMessageHandler implementation. | 24 // WebUIMessageHandler implementation. |
| 22 virtual WebUIMessageHandler* Attach(WebUI* web_ui) OVERRIDE; | 25 virtual WebUIMessageHandler* Attach(WebUI* web_ui) OVERRIDE; |
| 23 virtual void RegisterMessages() OVERRIDE; | 26 virtual void RegisterMessages() OVERRIDE; |
| 24 | 27 |
| 28 // policy::ConfigurationPolicyReader::Observer implementation. |
| 29 virtual void OnPolicyValuesChanged() OVERRIDE; |
| 30 |
| 25 private: | 31 private: |
| 26 typedef policy::ConfigurationPolicyReader ConfigurationPolicyReader; | 32 typedef policy::ConfigurationPolicyReader ConfigurationPolicyReader; |
| 33 typedef policy::CloudPolicySubsystem CloudPolicySubsystem; |
| 27 | 34 |
| 28 // Callback for the "requestPolicyData" message. | 35 // Callback for the "requestData" message. |
| 29 void HandleRequestPolicyData(const ListValue* args); | 36 void HandleRequestData(const ListValue* args); |
| 37 |
| 38 // Callback for the "updateFetchTimes" message. |
| 39 void HandleUpdateFetchTimes(const ListValue* args); |
| 40 |
| 41 // Callback for the "fetchPolicy" message. |
| 42 void HandleFetchPolicy(const ListValue* args); |
| 43 |
| 44 // Send requested data to UI. If is_policy_update is true, the data is sent as |
| 45 // a policy update, otherwise it is sent normally. |
| 46 void SendDataToUI(bool is_policy_update); |
| 47 |
| 48 // Returns a DictionaryValue pointer containing information about the status |
| 49 // of the policy system. |
| 50 DictionaryValue* GetStatusData(bool is_policy_update); |
| 51 |
| 52 // Returns the time at which policy was last fetched by the |
| 53 // CloudPolicySubsystem |subsystem| in string form. |
| 54 string16 GetLastFetchTime(CloudPolicySubsystem* subsystem); |
| 55 |
| 56 // Returns the string corresponding to the CloudPolicySubsystem::ErrorDetails |
| 57 // enum value |error_details|. |
| 58 static string16 CreateStatusMessageString( |
| 59 CloudPolicySubsystem::ErrorDetails error_details); |
| 30 | 60 |
| 31 scoped_ptr<policy::PolicyStatus> policy_status_; | 61 scoped_ptr<policy::PolicyStatus> policy_status_; |
| 32 | 62 |
| 33 DISALLOW_COPY_AND_ASSIGN(PolicyUIHandler); | 63 DISALLOW_COPY_AND_ASSIGN(PolicyUIHandler); |
| 34 }; | 64 }; |
| 35 | 65 |
| 36 // The Web UI handler for about:policy. | 66 // The Web UI handler for about:policy. |
| 37 class PolicyUI : public ChromeWebUI { | 67 class PolicyUI : public ChromeWebUI { |
| 38 public: | 68 public: |
| 39 explicit PolicyUI(TabContents* contents); | 69 explicit PolicyUI(TabContents* contents); |
| 40 virtual ~PolicyUI(); | 70 virtual ~PolicyUI(); |
| 41 | 71 |
| 42 private: | 72 private: |
| 43 DISALLOW_COPY_AND_ASSIGN(PolicyUI); | 73 DISALLOW_COPY_AND_ASSIGN(PolicyUI); |
| 44 }; | 74 }; |
| 45 | 75 |
| 46 #endif // CHROME_BROWSER_UI_WEBUI_POLICY_UI_H_ | 76 #endif // CHROME_BROWSER_UI_WEBUI_POLICY_UI_H_ |
| OLD | NEW |