| 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 a7ecae85de2080d06b2bb6046459f1fc7f3025f0..1b763757acc362c36f703a242aaebe766c11895f 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,13 @@ 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);
|
| +}
|
| +
|
| void SendMouseClick(int flags) {
|
| ui_controls::MouseButton button = ui_controls::LEFT;
|
| if ((flags & ui::EF_LEFT_MOUSE_BUTTON) ==
|
| @@ -3747,8 +3754,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:
|
| @@ -3770,8 +3776,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:
|
| @@ -5857,17 +5862,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) {
|
| @@ -6325,10 +6325,8 @@ 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();
|
| + g_browser_process->policy_service()->RefreshPolicies(
|
| + base::Bind(SendSuccessReply, AsWeakPtr(), reply_message));
|
| #endif
|
| }
|
|
|
|
|