Chromium Code Reviews| 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; | |
|
James Hawkins
2011/09/05 22:10:38
I'm not a fan of these typedefs. They're essential
simo
2011/09/07 12:18:16
Done.
| |
| 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); |
|
James Hawkins
2011/09/05 22:10:38
Document the param. Specify unused if it's unused.
simo
2011/09/07 12:18:16
Done.
| |
| 37 | |
| 38 // Callback for the "fetchPolicy" message. | |
| 39 void HandleFetchPolicy(const ListValue* args); | |
| 40 | |
| 41 // Send requested data to UI. If is_policy_update is true, the data is sent as | |
| 42 // a policy update, otherwise it is sent normally. | |
| 43 void SendDataToUI(bool is_policy_update); | |
| 44 | |
| 45 // Returns a DictionaryValue pointer containing information about the status | |
| 46 // of the policy system. | |
| 47 DictionaryValue* GetStatusData(); | |
| 48 | |
| 49 // Fetches policy if the appropriate device tokens are available. Returns | |
| 50 // true, if any policy was fetched (device or user), returns true. Returns | |
|
James Hawkins
2011/09/05 22:10:38
You specified 'returns true' twice.
simo
2011/09/07 12:18:16
Done.
| |
| 51 // false otherwise. | |
| 52 bool FetchPolicyIfTokensAvailable(); | |
| 53 | |
| 54 // Returns the time at which policy was last fetched by the | |
| 55 // CloudPolicySubsystem |subsystem| in string form. | |
| 56 string16 GetLastFetchTime(CloudPolicySubsystem* subsystem); | |
| 57 | |
| 58 // Gets device ids for for both device and user policy and writes them to | |
| 59 // |result|. | |
|
James Hawkins
2011/09/05 22:10:38
s/result/results/. Should document whether |result
simo
2011/09/07 12:18:16
I have changed the method signature.
| |
| 60 void GetDeviceIds(DictionaryValue* results); | |
| 61 | |
| 62 // Gets policy fetch intervals for both device and user policy and writes them | |
| 63 // to |result|. | |
| 64 void GetPolicyFetchIntervals(DictionaryValue* results); | |
| 65 | |
| 66 // Returns the string corresponding to the CloudPolicySubsystem::ErrorDetails | |
| 67 // enum value |error_details|. | |
| 68 static string16 CreateStatusMessageString( | |
| 69 CloudPolicySubsystem::ErrorDetails error_details); | |
| 30 | 70 |
| 31 scoped_ptr<policy::PolicyStatus> policy_status_; | 71 scoped_ptr<policy::PolicyStatus> policy_status_; |
| 32 | 72 |
| 33 DISALLOW_COPY_AND_ASSIGN(PolicyUIHandler); | 73 DISALLOW_COPY_AND_ASSIGN(PolicyUIHandler); |
| 34 }; | 74 }; |
| 35 | 75 |
| 36 // The Web UI handler for about:policy. | 76 // The Web UI handler for about:policy. |
| 37 class PolicyUI : public ChromeWebUI { | 77 class PolicyUI : public ChromeWebUI { |
| 38 public: | 78 public: |
| 39 explicit PolicyUI(TabContents* contents); | 79 explicit PolicyUI(TabContents* contents); |
| 40 virtual ~PolicyUI(); | 80 virtual ~PolicyUI(); |
| 41 | 81 |
| 42 private: | 82 private: |
| 43 DISALLOW_COPY_AND_ASSIGN(PolicyUI); | 83 DISALLOW_COPY_AND_ASSIGN(PolicyUI); |
| 44 }; | 84 }; |
| 45 | 85 |
| 46 #endif // CHROME_BROWSER_UI_WEBUI_POLICY_UI_H_ | 86 #endif // CHROME_BROWSER_UI_WEBUI_POLICY_UI_H_ |
| OLD | NEW |