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

Unified Diff: chrome/browser/automation/testing_automation_provider.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
Index: chrome/browser/automation/testing_automation_provider.cc
diff --git a/chrome/browser/automation/testing_automation_provider.cc b/chrome/browser/automation/testing_automation_provider.cc
index 15aae3e3be9d94ed442b3c5e98a09654978c8f29..8d1a45bc2da2d36441d7680be8dff4670f94328b 100644
--- a/chrome/browser/automation/testing_automation_provider.cc
+++ b/chrome/browser/automation/testing_automation_provider.cc
@@ -150,7 +150,7 @@
#include "webkit/plugins/webplugininfo.h"
#if defined(ENABLE_CONFIGURATION_POLICY)
-#include "chrome/browser/policy/browser_policy_connector.h"
+#include "chrome/browser/policy/policy_service.h"
#include "policy/policy_constants.h"
#endif
@@ -186,6 +186,18 @@ using content::WebContents;
namespace {
+// Helper to reply asynchronously if |automation| is still valid.
+void SendSuccessReply(base::WeakPtr<AutomationProvider> automation,
+ IPC::Message* reply_message) {
+ if (automation)
+ AutomationJSONReply(automation.get(), reply_message).SendSuccess(NULL);
+}
+
+// Helper to resolve the overloading of PostTask.
+void PostTask(BrowserThread::ID id, const base::Closure& callback) {
+ BrowserThread::PostTask(id, FROM_HERE, callback);
+}
+
void SendMouseClick(int flags) {
ui_controls::MouseButton button = ui_controls::LEFT;
if ((flags & ui::EF_LEFT_MOUSE_BUTTON) ==
@@ -3751,8 +3763,7 @@ void TestingAutomationProvider::EnablePlugin(Browser* browser,
}
plugin_prefs->EnablePlugin(
true, FilePath(path),
- base::Bind(&TestingAutomationProvider::SendSuccessReply, this,
- reply_message));
+ base::Bind(SendSuccessReply, AsWeakPtr(), reply_message));
}
// Sample json input:
@@ -3774,8 +3785,7 @@ void TestingAutomationProvider::DisablePlugin(Browser* browser,
}
plugin_prefs->EnablePlugin(
false, FilePath(path),
- base::Bind(&TestingAutomationProvider::SendSuccessReply, this,
- reply_message));
+ base::Bind(SendSuccessReply, AsWeakPtr(), reply_message));
}
// Sample json input:
@@ -5894,17 +5904,12 @@ void TestingAutomationProvider::SendOSLevelKeyEventToTab(
if (!ui_controls::SendKeyPressNotifyWhenDone(
window, static_cast<ui::KeyboardCode>(keycode),
control, shift, alt, meta,
- base::Bind(&TestingAutomationProvider::SendSuccessReply, this,
- reply_message))) {
+ base::Bind(SendSuccessReply, AsWeakPtr(), reply_message))) {
AutomationJSONReply(this, reply_message)
.SendError("Could not send the native key event");
}
}
-void TestingAutomationProvider::SendSuccessReply(IPC::Message* reply_message) {
- AutomationJSONReply(this, reply_message).SendSuccess(NULL);
-}
-
void TestingAutomationProvider::ProcessWebMouseEvent(
DictionaryValue* args,
IPC::Message* reply_message) {
@@ -6362,10 +6367,18 @@ void TestingAutomationProvider::RefreshPolicies(
AutomationJSONReply(this, reply_message).SendError(
"Configuration Policy disabled");
#else
- policy::BrowserPolicyConnector* connector =
- g_browser_process->browser_policy_connector();
- new PolicyUpdatesObserver(this, reply_message, connector);
- connector->RefreshPolicies();
+ // Some policies (e.g. URLBlacklist) post tasks to other message loops
+ // before they start enforcing updated policy values; make sure those tasks
+ // have finished after a policy update.
+ // Updates of the URLBlacklist are done on IO, after building the blacklist
+ // on FILE, which is initiated from IO.
+ base::Closure reply =
+ base::Bind(SendSuccessReply, AsWeakPtr(), reply_message);
+ g_browser_process->policy_service()->RefreshPolicies(
+ base::Bind(PostTask, BrowserThread::IO,
+ base::Bind(PostTask, BrowserThread::FILE,
+ base::Bind(PostTask, BrowserThread::IO,
+ base::Bind(PostTask, BrowserThread::UI, reply)))));
#endif
}
« no previous file with comments | « chrome/browser/automation/testing_automation_provider.h ('k') | chrome/browser/chromeos/login/existing_user_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698