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

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: 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
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..01c891bc32a3817aa7682d13c22ec4107854b610 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 =
@@ -119,7 +121,13 @@ void PolicyUIHandler::HandleRequestData(const ListValue* args) {
}
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));
Mattias Nissler (ping if slow) 2012/04/26 11:08:52 Hm, this code still follows the model that the fir
Joao da Silva 2012/04/26 14:43:58 Added a new field to flag this.
}
void PolicyUIHandler::SendDataToUI(bool is_policy_update) {
« chrome/browser/policy/policy_service_impl.cc ('K') | « 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