Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1104)

Unified Diff: chrome/browser/ui/webui/policy_ui.cc

Issue 10236003: Added RefreshPolicies to PolicyService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/webui/policy_ui.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..b9d6ee2278f2611dccf61bf1646bd01e4a5ef113 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_factory_(this)) {
policy::ConfigurationPolicyReader* managed_platform =
policy::ConfigurationPolicyReader::CreateManagedPlatformPolicyReader();
policy::ConfigurationPolicyReader* managed_cloud =
@@ -111,18 +113,27 @@ void PolicyUIHandler::RegisterMessages() {
}
void PolicyUIHandler::OnPolicyValuesChanged() {
- SendDataToUI(true);
+ SendDataToUI();
}
void PolicyUIHandler::HandleRequestData(const ListValue* args) {
- SendDataToUI(false);
+ SendDataToUI();
}
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::OnRefreshDone,
+ weak_factory_.GetWeakPtr()));
}
-void PolicyUIHandler::SendDataToUI(bool is_policy_update) {
+void PolicyUIHandler::OnRefreshDone() {
+ web_ui()->CallJavascriptFunction("Policy.refreshDone");
+}
+
+void PolicyUIHandler::SendDataToUI() {
DictionaryValue results;
bool any_policies_set;
ListValue* list = policy_status_->GetPolicyStatusList(&any_policies_set);
@@ -130,8 +141,6 @@ void PolicyUIHandler::SendDataToUI(bool is_policy_update) {
results.SetBoolean("anyPoliciesSet", any_policies_set);
DictionaryValue* dict = GetStatusData();
results.Set("status", dict);
- results.SetBoolean("isPolicyUpdate", is_policy_update);
-
web_ui()->CallJavascriptFunction("Policy.returnData", results);
}
« no previous file with comments | « chrome/browser/ui/webui/policy_ui.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698