Chromium Code Reviews| Index: chrome/browser/automation/automation_provider_observers.cc |
| diff --git a/chrome/browser/automation/automation_provider_observers.cc b/chrome/browser/automation/automation_provider_observers.cc |
| index 26a5d2d33e198ce428673def235419509eaa5291..2bb2aa9576f6d4151b82f99ad0603a9137c75ed9 100644 |
| --- a/chrome/browser/automation/automation_provider_observers.cc |
| +++ b/chrome/browser/automation/automation_provider_observers.cc |
| @@ -65,6 +65,7 @@ |
| #include "chrome/browser/ui/webui/ntp/most_visited_handler.h" |
| #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" |
| #include "chrome/browser/ui/webui/ntp/recently_closed_tabs_handler.h" |
| +#include "chrome/common/automation_constants.h" |
| #include "chrome/common/automation_messages.h" |
| #include "chrome/common/chrome_notification_types.h" |
| #include "chrome/common/chrome_view_type.h" |
| @@ -1883,6 +1884,73 @@ void PageSnapshotTaker::SendMessage(bool success, |
| delete this; |
| } |
| +AutomationMouseEventProcessor::AutomationMouseEventProcessor( |
| + RenderViewHost* render_view_host, |
| + const AutomationMouseEvent& event, |
| + const CompletionCallback& completion_callback, |
| + const ErrorCallback& error_callback) |
| + : RenderViewHostObserver(render_view_host), |
| + completion_callback_(completion_callback), |
| + error_callback_(error_callback), |
| + has_point_(false) { |
| + registrar_.Add(this, chrome::NOTIFICATION_APP_MODAL_DIALOG_SHOWN, |
| + content::NotificationService::AllSources()); |
| + Send(new AutomationMsg_ProcessMouseEvent(routing_id(), event)); |
| +} |
| + |
| +AutomationMouseEventProcessor::~AutomationMouseEventProcessor() {} |
| + |
| +void AutomationMouseEventProcessor::OnWillProcessMouseEventAt( |
| + const gfx::Point& point) { |
| + has_point_ = true; |
| + point_ = point; |
| +} |
| + |
| +void AutomationMouseEventProcessor::OnProcessMouseEventACK( |
| + bool success, |
| + const std::string& error_msg) { |
| + InvokeCallback(automation::Error(error_msg)); |
| +} |
| + |
| +void AutomationMouseEventProcessor::RenderViewHostDestroyed( |
| + RenderViewHost* host) { |
| + InvokeCallback(automation::Error("The render view host was destroyed")); |
| +} |
| + |
| +bool AutomationMouseEventProcessor::OnMessageReceived( |
| + const IPC::Message& message) { |
| + bool handled = true; |
| + bool msg_is_good = true; |
| + IPC_BEGIN_MESSAGE_MAP_EX(AutomationMouseEventProcessor, message, msg_is_good) |
| + IPC_MESSAGE_HANDLER(AutomationMsg_WillProcessMouseEventAt, |
| + OnWillProcessMouseEventAt) |
| + IPC_MESSAGE_HANDLER(AutomationMsg_ProcessMouseEventACK, |
| + OnProcessMouseEventACK) |
| + IPC_MESSAGE_UNHANDLED(handled = false) |
| + IPC_END_MESSAGE_MAP_EX() |
| + if (!msg_is_good) { |
| + LOG(ERROR) << "Failed to deserialize an IPC message"; |
| + } |
|
dennis_jeffrey
2012/05/09 19:05:36
no need for curly braces
kkania
2012/05/09 19:11:50
You're supposed to be curly braces around macros,
dennis_jeffrey
2012/05/09 19:12:50
Ah, good point. Thanks for letting me know!
|
| + return handled; |
| +} |
| + |
| +void AutomationMouseEventProcessor::Observe( |
| + int type, |
| + const content::NotificationSource& source, |
| + const content::NotificationDetails& details) { |
| + InvokeCallback(automation::Error(automation::kBlockedByModalDialog)); |
| +} |
| + |
| +void AutomationMouseEventProcessor::InvokeCallback( |
| + const automation::Error& error) { |
| + if (has_point_) { |
| + completion_callback_.Run(point_); |
| + } else { |
| + error_callback_.Run(error); |
| + } |
|
dennis_jeffrey
2012/05/09 19:05:36
no need for curly braces in the if/else
kkania
2012/05/09 19:11:50
Done.
|
| + delete this; |
| +} |
| + |
| namespace { |
| // Returns a vector of dictionaries containing information about installed apps, |