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

Unified Diff: chrome/browser/automation/automation_provider_observers.cc

Issue 10384023: Determine the element location and click synchronously on the renderer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 7 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/automation_provider_observers.cc
diff --git a/chrome/browser/automation/automation_provider_observers.cc b/chrome/browser/automation/automation_provider_observers.cc
index 26a5d2d33e198ce428673def235419509eaa5291..ba68e020f8e33986f3e36faa777d0c197d4f6f7a 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,65 @@ void PageSnapshotTaker::SendMessage(bool success,
delete this;
}
+MouseEventProcessedObserver::MouseEventProcessedObserver(
+ AutomationProvider* automation,
+ IPC::Message* reply_message,
+ TabContentsWrapper* tab_contents)
+ : automation_(automation->AsWeakPtr()),
+ reply_message_(reply_message),
+ has_point_(false) {
+ registrar_.Add(this, chrome::NOTIFICATION_APP_MODAL_DIALOG_SHOWN,
+ content::NotificationService::AllSources());
+ StartObserving(tab_contents->automation_tab_helper());
+}
+
+MouseEventProcessedObserver::~MouseEventProcessedObserver() {}
+
+void MouseEventProcessedObserver::OnWillProcessMouseEventAt(
+ const gfx::Point& point) {
+ has_point_ = true;
+ point_ = point;
+}
+
+void MouseEventProcessedObserver::OnProcessMouseEventACK(
+ bool success,
+ const std::string& error_msg) {
+ if (success && !has_point_) {
+ SendMessage(false,
+ automation::Error("Received mouse event ACK without a point"));
+ } else {
+ SendMessage(success, automation::Error(error_msg));
+ }
+}
+
+void MouseEventProcessedObserver::Observe(
+ int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) {
+ if (has_point_)
+ SendMessage(true, automation::Error());
dennis_jeffrey 2012/05/08 19:18:49 To make sure I understand correctly: if OnWillProc
kkania 2012/05/09 18:19:59 Yes
+ else
+ SendMessage(false, automation::Error(automation::kBlockedByModalDialog));
+}
+
+void MouseEventProcessedObserver::SendMessage(
+ bool success,
+ const automation::Error& error) {
+ if (automation_) {
+ if (success) {
+ DictionaryValue dict;
+ dict.SetInteger("x", point_.x());
+ dict.SetInteger("y", point_.y());
+ AutomationJSONReply(automation_, reply_message_.release())
+ .SendSuccess(&dict);
+ } else {
+ AutomationJSONReply(automation_, reply_message_.release())
+ .SendError(error);
+ }
+ }
+ delete this;
+}
+
namespace {
// Returns a vector of dictionaries containing information about installed apps,

Powered by Google App Engine
This is Rietveld 408576698