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

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

Issue 6630001: Allow webdriver users to choose between sending the key events when... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 9 years, 10 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
« no previous file with comments | « no previous file | chrome/test/webdriver/automation.h » ('j') | chrome/test/webdriver/automation.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/automation/testing_automation_provider.cc
===================================================================
--- chrome/browser/automation/testing_automation_provider.cc (revision 76851)
+++ chrome/browser/automation/testing_automation_provider.cc (working copy)
@@ -4655,9 +4655,57 @@
event.isSystemKey = is_system_key;
event.timeStampSeconds = base::Time::Now().ToDoubleT();
event.skip_in_browser = true;
- new InputEventAckNotificationObserver(this, reply_message, event.type);
- browser->GetSelectedTabContents()->render_view_host()->
- ForwardKeyboardEvent(event);
+ bool use_native_events = false;
+ // If useNativeEvents is true, this funciton will call
+ // ui_controls::endKeyPress to the native window handle of the browser,
+ // allowing events to be catched higher up; if false it will send an
+ // event directly to webkit.
+ if (args->GetBoolean("useNativeEvents", &use_native_events)
+ && use_native_events) {
Hironori Bono 2011/03/04 06:25:17 nit: This operator should be the end of the previo
timothe faudot 2011/03/04 06:47:35 Done.
+ // The ui_controls::SendKeyPress function will generate up and down events
+ // from one keycode for us so we only need to send one event to it.
+ // Filtering is done via the RawKeyDown type because it is the one sent by
+ // the current webdriver implementation of WebElement.SendKeys(...).
+ if (event.type == WebKit::WebInputEvent::RawKeyDown) {
+ BrowserWindow* browser_window = browser->window();
+ if (browser_window == NULL) {
Hironori Bono 2011/03/04 06:25:17 nit: browser_window == NULL -> !browser_window
timothe faudot 2011/03/04 06:47:35 Done.
+ AutomationJSONReply reply(this, reply_message);
+ reply.SendError("Could not get the browser window");
+ return;
+ }
+ gfx::NativeWindow window = browser_window->GetNativeHandle();
+ if (window == NULL) {
Hironori Bono 2011/03/04 06:25:17 nit: window == NULL -> !window
timothe faudot 2011/03/04 06:47:35 Done.
+ AutomationJSONReply reply(this, reply_message);
+ reply.SendError("Could not get the browser window handle");
+ return;
+ }
+ if (!ui_controls::SendKeyPress(
+ window, static_cast<ui::KeyboardCode>(event.nativeKeyCode),
+ ((event.modifiers & WebKit::WebInputEvent::ControlKey) ==
+ WebKit::WebInputEvent::ControlKey),
Hironori Bono 2011/03/04 06:25:17 nit: I prefer using a local variable as listed in
timothe faudot 2011/03/04 06:47:35 Done.
+ ((event.modifiers & WebKit::WebInputEvent::ShiftKey) ==
+ WebKit::WebInputEvent::ShiftKey),
+ ((event.modifiers & WebKit::WebInputEvent::AltKey) ==
+ WebKit::WebInputEvent::AltKey),
+ ((event.modifiers & WebKit::WebInputEvent::MetaKey) ==
+ WebKit::WebInputEvent::MetaKey))) {
+ AutomationJSONReply reply(this, reply_message);
+ reply.SendError("Could not send the native key event");
+ return;
+ } else {
+ AutomationJSONReply reply(this, reply_message);
+ reply.SendSuccess(NULL);
+ }
+ } else {
+ // Skip this event by acknowledging it without doing nothing.
+ AutomationJSONReply reply(this, reply_message);
+ reply.SendSuccess(NULL);
+ }
+ } else {
+ new InputEventAckNotificationObserver(this, reply_message, event.type);
+ browser->GetSelectedTabContents()->render_view_host()->
+ ForwardKeyboardEvent(event);
Hironori Bono 2011/03/04 06:25:17 nit: I prefer using an early exit as listed in the
timothe faudot 2011/03/04 06:47:35 Down, also added an early return statement up.
+ }
}
// Sample JSON input: { "command": "GetNTPThumbnailMode" }
@@ -4772,8 +4820,7 @@
section = MENU_THUMB;
} else if (section_name.compare("recently_closed") == 0) {
section = MENU_RECENT;
- }
- else {
+ } else {
reply.SendError(StringPrintf("Unexpected section name: '%s'",
section_name.c_str()));
return;
« no previous file with comments | « no previous file | chrome/test/webdriver/automation.h » ('j') | chrome/test/webdriver/automation.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698