Chromium Code Reviews| Index: chrome/browser/ui/webui/policy_ui.cc |
| diff --git a/chrome/browser/ui/webui/policy_ui.cc b/chrome/browser/ui/webui/policy_ui.cc |
| index 68ce463a1ad9d861dcf0fa44d8e936566668d9f4..677be9e99fa764924ea4b2ad524a539e40ac4ea2 100644 |
| --- a/chrome/browser/ui/webui/policy_ui.cc |
| +++ b/chrome/browser/ui/webui/policy_ui.cc |
| @@ -12,6 +12,7 @@ |
| #include "chrome/browser/policy/browser_policy_connector.h" |
| #include "chrome/browser/policy/cloud_policy_cache_base.h" |
| #include "chrome/browser/policy/cloud_policy_data_store.h" |
| +#include "chrome/browser/policy/policy_service.h" |
| #include "chrome/browser/prefs/pref_service.h" |
| #include "chrome/browser/profiles/profile.h" |
| #include "chrome/browser/ui/webui/chrome_url_data_manager.h" |
| @@ -78,7 +79,8 @@ ChromeWebUIDataSource* CreatePolicyUIHTMLSource() { |
| // |
| //////////////////////////////////////////////////////////////////////////////// |
| -PolicyUIHandler::PolicyUIHandler() { |
| +PolicyUIHandler::PolicyUIHandler() |
| + : ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) { |
| policy::ConfigurationPolicyReader* managed_platform = |
| policy::ConfigurationPolicyReader::CreateManagedPlatformPolicyReader(); |
| policy::ConfigurationPolicyReader* managed_cloud = |
| @@ -111,18 +113,25 @@ void PolicyUIHandler::RegisterMessages() { |
| } |
| void PolicyUIHandler::OnPolicyValuesChanged() { |
| - SendDataToUI(true); |
| + SendDataToUI(true, false); |
| } |
| void PolicyUIHandler::HandleRequestData(const ListValue* args) { |
| - SendDataToUI(false); |
| + SendDataToUI(false, false); |
| } |
| void PolicyUIHandler::HandleFetchPolicy(const ListValue* args) { |
| - g_browser_process->browser_policy_connector()->RefreshPolicies(); |
| + // Fetching policy can potentially take a while due to cloud policy fetches. |
| + // Use a WeakPtr to make sure the callback is invalidated if the tab is closed |
| + // before the fetching completes. |
| + g_browser_process->policy_service()->RefreshPolicies( |
| + base::Bind(&PolicyUIHandler::SendDataToUI, |
| + weak_ptr_factory_.GetWeakPtr(), |
| + true, true)); |
| } |
| -void PolicyUIHandler::SendDataToUI(bool is_policy_update) { |
| +void PolicyUIHandler::SendDataToUI(bool is_policy_update, |
| + bool is_refresh_done) { |
|
Mattias Nissler (ping if slow)
2012/04/27 09:03:27
I feel it's odd to multiplex all the different sig
Joao da Silva
2012/04/27 11:24:12
I've removed the booleans from SendDataToUI. The U
|
| DictionaryValue results; |
| bool any_policies_set; |
| ListValue* list = policy_status_->GetPolicyStatusList(&any_policies_set); |
| @@ -131,6 +140,7 @@ void PolicyUIHandler::SendDataToUI(bool is_policy_update) { |
| DictionaryValue* dict = GetStatusData(); |
| results.Set("status", dict); |
| results.SetBoolean("isPolicyUpdate", is_policy_update); |
| + results.SetBoolean("isRefreshDone", is_refresh_done); |
| web_ui()->CallJavascriptFunction("Policy.returnData", results); |
| } |