diff options
Diffstat (limited to 'chrome/browser')
34 files changed, 96 insertions, 1743 deletions
diff --git a/chrome/browser/accessibility/accessibility_win_browsertest.cc b/chrome/browser/accessibility/accessibility_win_browsertest.cc index 79c3c99..d8945a0 100644 --- a/chrome/browser/accessibility/accessibility_win_browsertest.cc +++ b/chrome/browser/accessibility/accessibility_win_browsertest.cc @@ -8,7 +8,6 @@ #include "base/memory/scoped_ptr.h" #include "base/utf_string_conversions.h" #include "base/win/scoped_comptr.h" -#include "chrome/browser/automation/ui_controls.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_window.h" #include "chrome/common/url_constants.h" @@ -22,6 +21,7 @@ #include "content/test/test_renderer_host.h" #include "third_party/iaccessible2/ia2_api_all.h" #include "third_party/isimpledom/ISimpleDOMNode.h" +#include "ui/ui_controls/ui_controls.h" using content::OpenURLParams; using content::Referrer; diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc index 52dd9bd..e55cc0c 100644 --- a/chrome/browser/automation/automation_provider.cc +++ b/chrome/browser/automation/automation_provider.cc @@ -34,7 +34,6 @@ #include "chrome/browser/automation/automation_resource_message_filter.h" #include "chrome/browser/automation/automation_tab_tracker.h" #include "chrome/browser/automation/automation_window_tracker.h" -#include "chrome/browser/automation/ui_controls.h" #include "chrome/browser/bookmarks/bookmark_model.h" #include "chrome/browser/bookmarks/bookmark_storage.h" #include "chrome/browser/browser_process.h" diff --git a/chrome/browser/automation/automation_provider_gtk.cc b/chrome/browser/automation/automation_provider_gtk.cc index 46f407a..0eb72d0 100644 --- a/chrome/browser/automation/automation_provider_gtk.cc +++ b/chrome/browser/automation/automation_provider_gtk.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -12,7 +12,6 @@ #include "base/utf_string_conversions.h" #include "chrome/browser/automation/automation_browser_tracker.h" #include "chrome/browser/automation/automation_window_tracker.h" -#include "chrome/browser/automation/ui_controls.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/gtk/browser_window_gtk.h" #include "chrome/browser/ui/gtk/gtk_util.h" @@ -20,6 +19,7 @@ #include "chrome/common/automation_messages.h" #include "ui/gfx/point.h" #include "ui/gfx/rect.h" +#include "ui/ui_controls/ui_controls.h" namespace { @@ -79,8 +79,8 @@ void AutomationProvider::WindowSimulateDrag( ui_controls::LEFT, ui_controls::DOWN, move_chain_cb); ui_controls::SendMouseMoveNotifyWhenDone(x + drag_path[0].x(), - y + drag_path[0].y(), - move_chain_cb); + y + drag_path[0].y(), + move_chain_cb); } else { AutomationMsg_WindowDrag::WriteReplyParams(reply_message, false); Send(reply_message); diff --git a/chrome/browser/automation/automation_provider_win.cc b/chrome/browser/automation/automation_provider_win.cc index e348c29..4587a4d 100644 --- a/chrome/browser/automation/automation_provider_win.cc +++ b/chrome/browser/automation/automation_provider_win.cc @@ -12,7 +12,6 @@ #include "chrome/browser/automation/automation_browser_tracker.h" #include "chrome/browser/automation/automation_tab_tracker.h" #include "chrome/browser/automation/automation_window_tracker.h" -#include "chrome/browser/automation/ui_controls.h" #include "chrome/browser/external_tab_container_win.h" #include "chrome/browser/printing/print_view_manager.h" #include "chrome/browser/profiles/profile.h" @@ -28,6 +27,7 @@ #include "content/public/browser/web_contents.h" #include "content/public/common/page_zoom.h" #include "ui/base/keycodes/keyboard_codes.h" +#include "ui/ui_controls/ui_controls.h" #include "ui/views/focus/accelerator_handler.h" #include "ui/views/widget/root_view.h" diff --git a/chrome/browser/automation/testing_automation_provider.cc b/chrome/browser/automation/testing_automation_provider.cc index 8d2139c..d44f6a9 100644 --- a/chrome/browser/automation/testing_automation_provider.cc +++ b/chrome/browser/automation/testing_automation_provider.cc @@ -38,7 +38,6 @@ #include "chrome/browser/automation/automation_tab_tracker.h" #include "chrome/browser/automation/automation_util.h" #include "chrome/browser/automation/automation_window_tracker.h" -#include "chrome/browser/automation/ui_controls.h" #include "chrome/browser/bookmarks/bookmark_model.h" #include "chrome/browser/bookmarks/bookmark_storage.h" #include "chrome/browser/browser_process.h" @@ -142,6 +141,7 @@ #include "ui/base/events.h" #include "ui/base/keycodes/keyboard_codes.h" #include "ui/base/ui_base_types.h" +#include "ui/ui_controls/ui_controls.h" #include "webkit/glue/webdropdata.h" #include "webkit/plugins/webplugininfo.h" diff --git a/chrome/browser/automation/testing_automation_provider_gtk.cc b/chrome/browser/automation/testing_automation_provider_gtk.cc index 6263a96..7256ca7 100644 --- a/chrome/browser/automation/testing_automation_provider_gtk.cc +++ b/chrome/browser/automation/testing_automation_provider_gtk.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -9,8 +9,8 @@ #include "base/logging.h" #include "base/utf_string_conversions.h" #include "chrome/browser/automation/automation_window_tracker.h" -#include "chrome/browser/ui/gtk/gtk_util.h" #include "chrome/browser/ui/gtk/view_id_util.h" +#include "ui/base/gtk/gtk_screen_util.h" void TestingAutomationProvider::ActivateWindow(int handle) { NOTIMPLEMENTED(); @@ -49,7 +49,7 @@ void TestingAutomationProvider::WindowGetViewBounds(int handle, *bounds = gfx::Rect(allocation.width, allocation.height); gint x, y; if (screen_coordinates) { - gfx::Point point = gtk_util::GetWidgetScreenPosition(widget); + gfx::Point point = ui::GetWidgetScreenPosition(widget); x = point.x(); y = point.y(); } else { diff --git a/chrome/browser/automation/ui_controls.h b/chrome/browser/automation/ui_controls.h deleted file mode 100644 index 270e18d..0000000 --- a/chrome/browser/automation/ui_controls.h +++ /dev/null @@ -1,107 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_AUTOMATION_UI_CONTROLS_H_ -#define CHROME_BROWSER_AUTOMATION_UI_CONTROLS_H_ -#pragma once - -#include "build/build_config.h" - -#if defined(OS_WIN) -#include <wtypes.h> -#endif - -#include "base/callback_forward.h" -#include "ui/base/keycodes/keyboard_codes.h" -#include "ui/gfx/native_widget_types.h" -#include "ui/gfx/point.h" - -#if defined(TOOLKIT_VIEWS) -namespace views { -class View; -} -#endif - -namespace ui_controls { - -// Many of the functions in this class include a variant that takes a Closure. -// The version that takes a Closure waits until the generated event is -// processed. Once the generated event is processed the Closure is Run (and -// deleted). Note that this is a somewhat fragile process in that any event of -// the correct type (key down, mouse click, etc.) will trigger the Closure to be -// run. Hence a usage such as -// -// SendKeyPress(...); -// SendKeyPressNotifyWhenDone(..., task); -// -// might trigger |task| early. -// -// Note: Windows does not currently do anything with the |window| argument for -// these functions, so passing NULL is ok. - -// Send a key press with/without modifier keys. -// -// If you're writing a test chances are you want the variant in ui_test_utils. -// See it for details. -bool SendKeyPress(gfx::NativeWindow window, - ui::KeyboardCode key, - bool control, - bool shift, - bool alt, - bool command); -bool SendKeyPressNotifyWhenDone(gfx::NativeWindow window, - ui::KeyboardCode key, - bool control, - bool shift, - bool alt, - bool command, - const base::Closure& task); - -// Simulate a mouse move. (x,y) are absolute screen coordinates. -bool SendMouseMove(long x, long y); -bool SendMouseMoveNotifyWhenDone(long x, long y, const base::Closure& task); - -enum MouseButton { - LEFT = 0, - MIDDLE, - RIGHT, -}; - -// Used to indicate the state of the button when generating events. -enum MouseButtonState { - UP = 1, - DOWN = 2 -}; - -// Sends a mouse down and/or up message. The click will be sent to wherever -// the cursor currently is, so be sure to move the cursor before calling this -// (and be sure the cursor has arrived!). -bool SendMouseEvents(MouseButton type, int state); -bool SendMouseEventsNotifyWhenDone(MouseButton type, int state, - const base::Closure& task); -// Same as SendMouseEvents with UP | DOWN. -bool SendMouseClick(MouseButton type); - -// A combination of SendMouseMove to the middle of the view followed by -// SendMouseEvents. -void MoveMouseToCenterAndPress( -#if defined(TOOLKIT_VIEWS) - views::View* view, -#elif defined(TOOLKIT_GTK) - GtkWidget* widget, -#elif defined(OS_MACOSX) - NSView* view, -#endif - MouseButton button, - int state, - const base::Closure& task); - -#if defined(TOOLKIT_VIEWS) -// Runs |closure| after processing all pending ui events. -void RunClosureAfterAllPendingUIEvents(const base::Closure& closure); -#endif - -} // ui_controls - -#endif // CHROME_BROWSER_AUTOMATION_UI_CONTROLS_H_ diff --git a/chrome/browser/automation/ui_controls_aurawin.cc b/chrome/browser/automation/ui_controls_aurawin.cc deleted file mode 100644 index 7860d18..0000000 --- a/chrome/browser/automation/ui_controls_aurawin.cc +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/automation/ui_controls.h" - -#include "ash/shell.h" -#include "base/logging.h" -#include "base/message_loop.h" -#include "chrome/browser/automation/ui_controls_internal.h" -#include "ui/aura/root_window.h" -#include "ui/views/view.h" - -namespace ui_controls { - -bool SendKeyPress(gfx::NativeWindow window, - ui::KeyboardCode key, - bool control, - bool shift, - bool alt, - bool command) { - DCHECK(!command); // No command key on Aura - return internal::SendKeyPressImpl(window, key, control, shift, alt, - base::Closure()); -} - -bool SendKeyPressNotifyWhenDone(gfx::NativeWindow window, - ui::KeyboardCode key, - bool control, - bool shift, - bool alt, - bool command, - const base::Closure& task) { - DCHECK(!command); // No command key on Aura - return internal::SendKeyPressImpl(window, key, control, shift, alt, task); -} - -bool SendMouseMove(long x, long y) { - gfx::Point point(x, y); - ash::Shell::GetRootWindow()->ConvertPointToNativeScreen(&point); - return internal::SendMouseMoveImpl(point.x(), point.y(), base::Closure()); -} - -bool SendMouseMoveNotifyWhenDone(long x, long y, const base::Closure& task) { - gfx::Point point(x, y); - ash::Shell::GetRootWindow()->ConvertPointToNativeScreen(&point); - return internal::SendMouseMoveImpl(point.x(), point.y(), task); -} - -bool SendMouseEvents(MouseButton type, int state) { - return internal::SendMouseEventsImpl(type, state, base::Closure()); -} - -bool SendMouseEventsNotifyWhenDone(MouseButton type, int state, - const base::Closure& task) { - return internal::SendMouseEventsImpl(type, state, task); -} - -bool SendMouseClick(MouseButton type) { - return SendMouseEvents(type, UP | DOWN); -} - -void MoveMouseToCenterAndPress(views::View* view, - MouseButton button, - int state, - const base::Closure& task) { - DCHECK(view); - DCHECK(view->GetWidget()); - gfx::Point view_center(view->width() / 2, view->height() / 2); - views::View::ConvertPointToScreen(view, &view_center); - SendMouseMove(view_center.x(), view_center.y()); - SendMouseEventsNotifyWhenDone(button, state, task); -} - -void RunClosureAfterAllPendingUIEvents(const base::Closure& task) { - // On windows, posting UI events is synchronous so just post the closure. - MessageLoopForUI::current()->PostTask(FROM_HERE, task); -} - -} // namespace ui_controls diff --git a/chrome/browser/automation/ui_controls_aurax11.cc b/chrome/browser/automation/ui_controls_aurax11.cc deleted file mode 100644 index d3abf05..0000000 --- a/chrome/browser/automation/ui_controls_aurax11.cc +++ /dev/null @@ -1,245 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/automation/ui_controls.h" - -#include <X11/keysym.h> -#include <X11/Xlib.h> - -// X macro fail. -#if defined(RootWindow) -#undef RootWindow -#endif - -#include "ash/shell.h" -#include "base/callback.h" -#include "base/logging.h" -#include "base/message_pump_x.h" -#include "chrome/browser/automation/ui_controls_internal.h" -#include "ui/aura/root_window.h" -#include "ui/base/keycodes/keyboard_code_conversion_x.h" -#include "ui/views/view.h" - -namespace { - -// Mask of the buttons currently down. -unsigned button_down_mask = 0; - -// Event waiter executes the specified closure|when a matching event -// is found. -// TODO(oshima): Move this to base. -class EventWaiter : public MessageLoopForUI::Observer { - public: - typedef bool (*EventWaiterMatcher)(const base::NativeEvent& event); - - EventWaiter(const base::Closure& closure, EventWaiterMatcher matcher) - : closure_(closure), - matcher_(matcher) { - MessageLoopForUI::current()->AddObserver(this); - } - - virtual ~EventWaiter() { - MessageLoopForUI::current()->RemoveObserver(this); - } - - // MessageLoop::Observer implementation: - virtual base::EventStatus WillProcessEvent( - const base::NativeEvent& event) OVERRIDE { - if ((*matcher_)(event)) { - MessageLoop::current()->PostTask(FROM_HERE, closure_); - delete this; - } - return base::EVENT_CONTINUE; - } - - virtual void DidProcessEvent(const base::NativeEvent& event) OVERRIDE { - } - - private: - base::Closure closure_; - EventWaiterMatcher matcher_; - DISALLOW_COPY_AND_ASSIGN(EventWaiter); -}; - -// Latest mouse pointer location set by SendMouseMoveNotifyWhenDone. -int g_current_x = -1000; -int g_current_y = -1000; - -// Returns atom that indidates that the XEvent is marker event. -Atom MarkerEventAtom() { - return XInternAtom(base::MessagePumpX::GetDefaultXDisplay(), - "marker_event", - False); -} - -// Returns true when the event is a marker event. -bool Matcher(const base::NativeEvent& event) { - return event->xany.type == ClientMessage && - event->xclient.message_type == MarkerEventAtom(); -} - -} // namespace - -namespace ui_controls { - -bool SendKeyPress(gfx::NativeWindow window, - ui::KeyboardCode key, - bool control, - bool shift, - bool alt, - bool command) { - DCHECK(!command); // No command key on Aura - return SendKeyPressNotifyWhenDone( - window, key, control, shift, alt, command, base::Closure()); -} - -void SetKeycodeAndSendThenMask(XEvent* xevent, - KeySym keysym, - unsigned int mask) { - xevent->xkey.keycode = - XKeysymToKeycode(base::MessagePumpX::GetDefaultXDisplay(), - keysym); - ash::Shell::GetRootWindow()->PostNativeEvent(xevent); - xevent->xkey.state |= mask; -} - -void UnmaskAndSetKeycodeThenSend(XEvent* xevent, - unsigned int mask, - KeySym keysym) { - xevent->xkey.state ^= mask; - xevent->xkey.keycode = - XKeysymToKeycode(base::MessagePumpX::GetDefaultXDisplay(), - keysym); - ash::Shell::GetRootWindow()->PostNativeEvent(xevent); -} - -bool SendKeyPressNotifyWhenDone(gfx::NativeWindow window, - ui::KeyboardCode key, - bool control, - bool shift, - bool alt, - bool command, - const base::Closure& closure) { - DCHECK(!command); // No command key on Aura - XEvent xevent = {0}; - xevent.xkey.type = KeyPress; - if (control) - SetKeycodeAndSendThenMask(&xevent, XK_Control_L, ControlMask); - if (shift) - SetKeycodeAndSendThenMask(&xevent, XK_Shift_L, ShiftMask); - if (alt) - SetKeycodeAndSendThenMask(&xevent, XK_Alt_L, Mod1Mask); - xevent.xkey.keycode = - XKeysymToKeycode(base::MessagePumpX::GetDefaultXDisplay(), - ui::XKeysymForWindowsKeyCode(key, shift)); - ash::Shell::GetRootWindow()->PostNativeEvent(&xevent); - - // Send key release events. - xevent.xkey.type = KeyRelease; - ash::Shell::GetRootWindow()->PostNativeEvent(&xevent); - if (alt) - UnmaskAndSetKeycodeThenSend(&xevent, Mod1Mask, XK_Alt_L); - if (shift) - UnmaskAndSetKeycodeThenSend(&xevent, ShiftMask, XK_Shift_L); - if (control) - UnmaskAndSetKeycodeThenSend(&xevent, ControlMask, XK_Control_L); - DCHECK(!xevent.xkey.state); - RunClosureAfterAllPendingUIEvents(closure); - return true; -} - -bool SendMouseMove(long x, long y) { - return SendMouseMoveNotifyWhenDone(x, y, base::Closure()); -} - -bool SendMouseMoveNotifyWhenDone(long x, long y, const base::Closure& closure) { - XEvent xevent = {0}; - XMotionEvent* xmotion = &xevent.xmotion; - xmotion->type = MotionNotify; - g_current_x = xmotion->x = x; - g_current_y = xmotion->y = y; - xmotion->state = button_down_mask; - xmotion->same_screen = True; - // RootWindow will take care of other necessary fields. - ash::Shell::GetRootWindow()->PostNativeEvent(&xevent); - RunClosureAfterAllPendingUIEvents(closure); - return true; -} - -bool SendMouseEvents(MouseButton type, int state) { - return SendMouseEventsNotifyWhenDone(type, state, base::Closure()); -} - -bool SendMouseEventsNotifyWhenDone(MouseButton type, - int state, - const base::Closure& closure) { - XEvent xevent = {0}; - XButtonEvent* xbutton = &xevent.xbutton; - DCHECK_NE(g_current_x, -1000); - DCHECK_NE(g_current_y, -1000); - xbutton->x = g_current_x; - xbutton->y = g_current_y; - xbutton->same_screen = True; - switch (type) { - case LEFT: - xbutton->button = Button1; - xbutton->state = Button1Mask; - break; - case MIDDLE: - xbutton->button = Button2; - xbutton->state = Button2Mask; - break; - case RIGHT: - xbutton->button = Button3; - xbutton->state = Button3Mask; - break; - } - // RootWindow will take care of other necessary fields. - - aura::RootWindow* root_window = ash::Shell::GetRootWindow(); - if (state & DOWN) { - xevent.xbutton.type = ButtonPress; - root_window->PostNativeEvent(&xevent); - button_down_mask |= xbutton->state; - } - if (state & UP) { - xevent.xbutton.type = ButtonRelease; - root_window->PostNativeEvent(&xevent); - button_down_mask = (button_down_mask | xbutton->state) ^ xbutton->state; - } - RunClosureAfterAllPendingUIEvents(closure); - return true; -} - -bool SendMouseClick(MouseButton type) { - return SendMouseEvents(type, UP | DOWN); -} - -void MoveMouseToCenterAndPress(views::View* view, MouseButton button, - int state, const base::Closure& closure) { - DCHECK(view); - DCHECK(view->GetWidget()); - gfx::Point view_center(view->width() / 2, view->height() / 2); - views::View::ConvertPointToScreen(view, &view_center); - SendMouseMove(view_center.x(), view_center.y()); - SendMouseEventsNotifyWhenDone(button, state, closure); -} - -void RunClosureAfterAllPendingUIEvents(const base::Closure& closure) { - if (closure.is_null()) - return; - static XEvent* marker_event = NULL; - if (!marker_event) { - marker_event = new XEvent(); - marker_event->xclient.type = ClientMessage; - marker_event->xclient.display = NULL; - marker_event->xclient.window = None; - marker_event->xclient.format = 8; - } - marker_event->xclient.message_type = MarkerEventAtom(); - ash::Shell::GetRootWindow()->PostNativeEvent(marker_event); - new EventWaiter(closure, &Matcher); -} - -} // namespace ui_controls diff --git a/chrome/browser/automation/ui_controls_gtk.cc b/chrome/browser/automation/ui_controls_gtk.cc deleted file mode 100644 index 8826609..0000000 --- a/chrome/browser/automation/ui_controls_gtk.cc +++ /dev/null @@ -1,322 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/automation/ui_controls.h" - -#include <gdk/gdkkeysyms.h> -#include <gtk/gtk.h> - -#include "base/bind.h" -#include "base/logging.h" -#include "base/message_loop.h" -#include "chrome/browser/automation/ui_controls_internal.h" -#include "chrome/browser/ui/gtk/gtk_util.h" -#include "chrome/common/automation_constants.h" -#include "ui/base/gtk/event_synthesis_gtk.h" -#include "ui/gfx/rect.h" - -#if defined(TOOLKIT_VIEWS) -#include "ui/views/view.h" -#include "ui/views/widget/widget.h" -#endif - -namespace { - -// static -guint32 XTimeNow() { - struct timespec ts; - clock_gettime(CLOCK_MONOTONIC, &ts); - return ts.tv_sec * 1000 + ts.tv_nsec / 1000000; -} - -class EventWaiter : public MessageLoopForUI::Observer { - public: - EventWaiter(const base::Closure& task, GdkEventType type, int count) - : task_(task), - type_(type), - count_(count) { - MessageLoopForUI::current()->AddObserver(this); - } - - virtual ~EventWaiter() { - MessageLoopForUI::current()->RemoveObserver(this); - } - - // MessageLoop::Observer implementation: - virtual void WillProcessEvent(GdkEvent* event) OVERRIDE { - if ((event->type == type_) && (--count_ == 0)) { - // At the time we're invoked the event has not actually been processed. - // Use PostTask to make sure the event has been processed before - // notifying. - // NOTE: if processing a message results in running a nested message - // loop, then DidProcessEvent isn't immediately sent. As such, we do - // the processing in WillProcessEvent rather than DidProcessEvent. - MessageLoop::current()->PostTask(FROM_HERE, task_); - delete this; - } - } - - virtual void DidProcessEvent(GdkEvent* event) OVERRIDE { - // No-op. - } - - private: - base::Closure task_; - GdkEventType type_; - // The number of events of this type to wait for. - int count_; -}; - -void FakeAMouseMotionEvent(gint x, gint y) { - GdkEvent* event = gdk_event_new(GDK_MOTION_NOTIFY); - - event->motion.send_event = false; - event->motion.time = XTimeNow(); - - GtkWidget* grab_widget = gtk_grab_get_current(); - if (grab_widget) { - // If there is a grab, we need to target all events at it regardless of - // what widget the mouse is over. - event->motion.window = gtk_widget_get_window(grab_widget); - } else { - event->motion.window = gdk_window_at_pointer(&x, &y); - } - g_object_ref(event->motion.window); - gint window_x, window_y; - gdk_window_get_origin(event->motion.window, &window_x, &window_y); - event->motion.x = x - window_x; - event->motion.y = y - window_y; - event->motion.x_root = x; - event->motion.y_root = y; - - event->motion.device = gdk_device_get_core_pointer(); - event->type = GDK_MOTION_NOTIFY; - - gdk_event_put(event); - gdk_event_free(event); -} - -} // namespace - -namespace ui_controls { - -bool SendKeyPress(gfx::NativeWindow window, - ui::KeyboardCode key, - bool control, - bool shift, - bool alt, - bool command) { - DCHECK(!command); // No command key on Linux - GdkWindow* event_window = NULL; - GtkWidget* grab_widget = gtk_grab_get_current(); - if (grab_widget) { - // If there is a grab, send all events to the grabbed widget. - event_window = gtk_widget_get_window(grab_widget); - } else if (window) { - event_window = gtk_widget_get_window(GTK_WIDGET(window)); - } else { - // No target was specified. Send the events to the active toplevel. - GList* windows = gtk_window_list_toplevels(); - for (GList* element = windows; element; element = g_list_next(element)) { - GtkWindow* this_window = GTK_WINDOW(element->data); - if (gtk_window_is_active(this_window)) { - event_window = gtk_widget_get_window(GTK_WIDGET(this_window)); - break; - } - } - g_list_free(windows); - } - if (!event_window) { - NOTREACHED() << "Window not specified and none is active"; - return false; - } - - std::vector<GdkEvent*> events; - ui::SynthesizeKeyPressEvents(event_window, key, control, shift, alt, &events); - for (std::vector<GdkEvent*>::iterator iter = events.begin(); - iter != events.end(); ++iter) { - gdk_event_put(*iter); - // gdk_event_put appends a copy of the event. - gdk_event_free(*iter); - } - - return true; -} - -bool SendKeyPressNotifyWhenDone(gfx::NativeWindow window, - ui::KeyboardCode key, - bool control, - bool shift, - bool alt, - bool command, - const base::Closure& task) { - DCHECK(!command); // No command key on Linux - int release_count = 1; - if (control) - release_count++; - if (shift) - release_count++; - if (alt) - release_count++; - // This object will delete itself after running |task|. - new EventWaiter(task, GDK_KEY_RELEASE, release_count); - return SendKeyPress(window, key, control, shift, alt, command); -} - -bool SendMouseMove(long x, long y) { - gdk_display_warp_pointer(gdk_display_get_default(), gdk_screen_get_default(), - x, y); - // Sometimes gdk_display_warp_pointer fails to send back any indication of - // the move, even though it succesfully moves the server cursor. We fake it in - // order to get drags to work. - FakeAMouseMotionEvent(x, y); - return true; -} - -bool SendMouseMoveNotifyWhenDone(long x, long y, const base::Closure& task) { - bool rv = SendMouseMove(x, y); - new EventWaiter(task, GDK_MOTION_NOTIFY, 1); - return rv; -} - -bool SendMouseEvents(MouseButton type, int state) { - GdkEvent* event = gdk_event_new(GDK_BUTTON_PRESS); - - event->button.send_event = false; - event->button.time = XTimeNow(); - - gint x, y; - GtkWidget* grab_widget = gtk_grab_get_current(); - if (grab_widget) { - // If there is a grab, we need to target all events at it regardless of - // what widget the mouse is over. - event->button.window = gtk_widget_get_window(grab_widget); - gdk_window_get_pointer(event->button.window, &x, &y, NULL); - } else { - event->button.window = gdk_window_at_pointer(&x, &y); - CHECK(event->button.window); - } - - g_object_ref(event->button.window); - event->button.x = x; - event->button.y = y; - gint origin_x, origin_y; - gdk_window_get_origin(event->button.window, &origin_x, &origin_y); - event->button.x_root = x + origin_x; - event->button.y_root = y + origin_y; - - event->button.axes = NULL; - GdkModifierType modifier; - gdk_window_get_pointer(event->button.window, NULL, NULL, &modifier); - event->button.state = modifier; - event->button.button = type == LEFT ? 1 : (type == MIDDLE ? 2 : 3); - event->button.device = gdk_device_get_core_pointer(); - - event->button.type = GDK_BUTTON_PRESS; - if (state & DOWN) - gdk_event_put(event); - - // Also send a release event. - GdkEvent* release_event = gdk_event_copy(event); - release_event->button.type = GDK_BUTTON_RELEASE; - release_event->button.time++; - if (state & UP) - gdk_event_put(release_event); - - gdk_event_free(event); - gdk_event_free(release_event); - - return false; -} - -bool SendMouseEventsNotifyWhenDone(MouseButton type, - int state, - const base::Closure& task) { - bool rv = SendMouseEvents(type, state); - GdkEventType wait_type; - if (state & UP) { - wait_type = GDK_BUTTON_RELEASE; - } else { - if (type == LEFT) - wait_type = GDK_BUTTON_PRESS; - else if (type == MIDDLE) - wait_type = GDK_2BUTTON_PRESS; - else - wait_type = GDK_3BUTTON_PRESS; - } - new EventWaiter(task, wait_type, 1); - return rv; -} - -bool SendMouseClick(MouseButton type) { - return SendMouseEvents(type, UP | DOWN); -} - -#if defined(TOOLKIT_VIEWS) - -#if defined(OS_LINUX) && !defined(USE_AURA) -void OnConfigure(GtkWidget* gtk_widget, GdkEvent* event, gpointer data) { - views::Widget* widget = static_cast<views::Widget*>(data); - gfx::Rect actual = widget->GetWindowScreenBounds(); - gfx::Rect desired = widget->GetRootView()->bounds(); - if (actual.size() == desired.size()) - MessageLoop::current()->Quit(); -} - -void SynchronizeWidgetSize(views::Widget* widget) { - // If the actual window size and desired window size - // are different, wait until the window is resized - // to desired size. - gfx::Rect actual = widget->GetWindowScreenBounds(); - gfx::Rect desired = widget->GetRootView()->bounds(); - if (actual.size() != desired.size()) { - // Listen to configure-event that is emitted when an window gets - // resized. - GtkWidget* gtk_widget = widget->GetNativeView(); - g_signal_connect(gtk_widget, "configure-event", - G_CALLBACK(&OnConfigure), widget); - MessageLoop::current()->Run(); - } -} -#endif - -void MoveMouseToCenterAndPress(views::View* view, - MouseButton button, - int state, - const base::Closure& task) { -#if defined(OS_LINUX) - // X is asynchronous and we need to wait until the window gets - // resized to desired size. - SynchronizeWidgetSize(view->GetWidget()); -#endif - - gfx::Point view_center(view->width() / 2, view->height() / 2); - views::View::ConvertPointToScreen(view, &view_center); - SendMouseMoveNotifyWhenDone( - view_center.x(), view_center.y(), - base::Bind(&ui_controls::internal::ClickTask, button, state, task)); -} -#else -void MoveMouseToCenterAndPress(GtkWidget* widget, - MouseButton button, - int state, - const base::Closure& task) { - gfx::Rect bounds = gtk_util::GetWidgetScreenBounds(widget); - SendMouseMoveNotifyWhenDone( - bounds.x() + bounds.width() / 2, - bounds.y() + bounds.height() / 2, - base::Bind(&ui_controls::internal::ClickTask, button, state, task)); -} -#endif - -#if defined(TOOLKIT_VIEWS) -void RunClosureAfterAllPendingUIEvents(const base::Closure& task) { - // Send noop event and run task. - int x, y; - gdk_window_at_pointer(&x, &y); - SendMouseMoveNotifyWhenDone(x, y, task); -} -#endif - -} // namespace ui_controls diff --git a/chrome/browser/automation/ui_controls_internal.cc b/chrome/browser/automation/ui_controls_internal.cc deleted file mode 100644 index 9765b1b..0000000 --- a/chrome/browser/automation/ui_controls_internal.cc +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/automation/ui_controls_internal.h" - -#include "base/callback.h" - -namespace ui_controls { -namespace internal { - -void ClickTask(MouseButton button, int state, const base::Closure& followup) { - if (!followup.is_null()) - SendMouseEventsNotifyWhenDone(button, state, followup); - else - SendMouseEvents(button, state); -} - -} // namespace internal -} // namespace ui_controls diff --git a/chrome/browser/automation/ui_controls_internal.h b/chrome/browser/automation/ui_controls_internal.h deleted file mode 100644 index f16de36..0000000 --- a/chrome/browser/automation/ui_controls_internal.h +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_AUTOMATION_UI_CONTROLS_INTERNAL_H_ -#define CHROME_BROWSER_AUTOMATION_UI_CONTROLS_INTERNAL_H_ - -#include "base/callback_forward.h" -#include "chrome/browser/automation/ui_controls.h" - -namespace ui_controls { -namespace internal { - -// A utility function to send a mouse click event in a closure. It's shared by -// ui_controls_linux.cc and ui_controls_mac.cc -void ClickTask(MouseButton button, int state, const base::Closure& followup); - -#if defined(OS_WIN) -// A utility functions for windows to send key or mouse events and -// run the task. -bool SendKeyPressImpl(gfx::NativeWindow window, - ui::KeyboardCode key, - bool control, - bool shift, - bool alt, - const base::Closure& task); -bool SendMouseMoveImpl(long x, long y, const base::Closure& task); -bool SendMouseEventsImpl(MouseButton type, - int state, - const base::Closure& task); -void RunClosureAfterAllPendingUITasksImpl(const base::Closure& task); -#endif - -} // namespace internal -} // namespace ui_controls - -#endif // CHROME_BROWSER_AUTOMATION_UI_CONTROLS_INTERNAL_H_ diff --git a/chrome/browser/automation/ui_controls_internal_win.cc b/chrome/browser/automation/ui_controls_internal_win.cc deleted file mode 100644 index 34e7646..0000000 --- a/chrome/browser/automation/ui_controls_internal_win.cc +++ /dev/null @@ -1,352 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/automation/ui_controls_internal.h" - -#include "base/bind.h" -#include "base/callback.h" -#include "base/logging.h" -#include "base/memory/ref_counted.h" -#include "base/message_loop.h" -#include "ui/base/keycodes/keyboard_code_conversion_win.h" -#include "ui/base/keycodes/keyboard_codes.h" - -#if defined(USE_AURA) -#include "ui/aura/root_window.h" -#include "ui/aura/window.h" -#endif - -namespace { - -// InputDispatcher ------------------------------------------------------------ - -// InputDispatcher is used to listen for a mouse/keyboard event. When the -// appropriate event is received the task is notified. -class InputDispatcher : public base::RefCounted<InputDispatcher> { - public: - InputDispatcher(const base::Closure& task, WPARAM message_waiting_for); - - // Invoked from the hook. If mouse_message matches message_waiting_for_ - // MatchingMessageFound is invoked. - void DispatchedMessage(WPARAM mouse_message); - - // Invoked when a matching event is found. Uninstalls the hook and schedules - // an event that notifies the task. - void MatchingMessageFound(); - - private: - friend class base::RefCounted<InputDispatcher>; - - ~InputDispatcher(); - - // Notifies the task and release this (which should delete it). - void NotifyTask(); - - // The task we notify. - base::Closure task_; - - // Message we're waiting for. Not used for keyboard events. - const WPARAM message_waiting_for_; - - DISALLOW_COPY_AND_ASSIGN(InputDispatcher); -}; - -// Have we installed the hook? -bool installed_hook_ = false; - -// Return value from SetWindowsHookEx. -HHOOK next_hook_ = NULL; - -// If a hook is installed, this is the dispatcher. -InputDispatcher* current_dispatcher_ = NULL; - -// Callback from hook when a mouse message is received. -LRESULT CALLBACK MouseHook(int n_code, WPARAM w_param, LPARAM l_param) { - HHOOK next_hook = next_hook_; - if (n_code == HC_ACTION) { - DCHECK(current_dispatcher_); - current_dispatcher_->DispatchedMessage(w_param); - } - return CallNextHookEx(next_hook, n_code, w_param, l_param); -} - -// Callback from hook when a key message is received. -LRESULT CALLBACK KeyHook(int n_code, WPARAM w_param, LPARAM l_param) { - HHOOK next_hook = next_hook_; - if (n_code == HC_ACTION) { - DCHECK(current_dispatcher_); - if (l_param & (1 << 30)) { - // Only send on key up. - current_dispatcher_->MatchingMessageFound(); - } - } - return CallNextHookEx(next_hook, n_code, w_param, l_param); -} - -// Installs dispatcher as the current hook. -void InstallHook(InputDispatcher* dispatcher, bool key_hook) { - DCHECK(!installed_hook_); - current_dispatcher_ = dispatcher; - installed_hook_ = true; - if (key_hook) { - next_hook_ = SetWindowsHookEx(WH_KEYBOARD, &KeyHook, NULL, - GetCurrentThreadId()); - } else { - // NOTE: I originally tried WH_CALLWNDPROCRET, but for some reason I - // didn't get a mouse message like I do with MouseHook. - next_hook_ = SetWindowsHookEx(WH_MOUSE, &MouseHook, NULL, - GetCurrentThreadId()); - } - DCHECK(next_hook_); -} - -// Uninstalls the hook set in InstallHook. -void UninstallHook(InputDispatcher* dispatcher) { - if (current_dispatcher_ == dispatcher) { - installed_hook_ = false; - current_dispatcher_ = NULL; - UnhookWindowsHookEx(next_hook_); - } -} - -InputDispatcher::InputDispatcher(const base::Closure& task, - UINT message_waiting_for) - : task_(task), message_waiting_for_(message_waiting_for) { - InstallHook(this, message_waiting_for == WM_KEYUP); -} - -InputDispatcher::~InputDispatcher() { - // Make sure the hook isn't installed. - UninstallHook(this); -} - -void InputDispatcher::DispatchedMessage(WPARAM message) { - if (message == message_waiting_for_) - MatchingMessageFound(); -} - -void InputDispatcher::MatchingMessageFound() { - UninstallHook(this); - // At the time we're invoked the event has not actually been processed. - // Use PostTask to make sure the event has been processed before notifying. - MessageLoop::current()->PostTask( - FROM_HERE, base::Bind(&InputDispatcher::NotifyTask, this)); -} - -void InputDispatcher::NotifyTask() { - task_.Run(); - Release(); -} - -// Private functions ---------------------------------------------------------- - -// Populate the INPUT structure with the appropriate keyboard event -// parameters required by SendInput -bool FillKeyboardInput(ui::KeyboardCode key, INPUT* input, bool key_up) { - memset(input, 0, sizeof(INPUT)); - input->type = INPUT_KEYBOARD; - input->ki.wVk = ui::WindowsKeyCodeForKeyboardCode(key); - input->ki.dwFlags = key_up ? KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP : - KEYEVENTF_EXTENDEDKEY; - - return true; -} - -// Send a key event (up/down) -bool SendKeyEvent(ui::KeyboardCode key, bool up) { - INPUT input = { 0 }; - - if (!FillKeyboardInput(key, &input, up)) - return false; - - if (!::SendInput(1, &input, sizeof(INPUT))) - return false; - - return true; -} - -} // namespace - -namespace ui_controls { -namespace internal { - -bool SendKeyPressImpl(gfx::NativeWindow native_window, - ui::KeyboardCode key, - bool control, - bool shift, - bool alt, - const base::Closure& task) { - // SendInput only works as we expect it if one of our windows is the - // foreground window already. -#if defined(USE_AURA) - HWND window = native_window->GetRootWindow()->GetAcceleratedWidget(); -#else - HWND window = native_window; -#endif - HWND target_window = (::GetActiveWindow() && - ::GetWindow(::GetActiveWindow(), GW_OWNER) == window) ? - ::GetActiveWindow() : - window; - if (window && ::GetForegroundWindow() != target_window) - return false; - - scoped_refptr<InputDispatcher> dispatcher( - !task.is_null() ? new InputDispatcher(task, WM_KEYUP) : NULL); - - // If a pop-up menu is open, it won't receive events sent using SendInput. - // Check for a pop-up menu using its window class (#32768) and if one - // exists, send the key event directly there. - HWND popup_menu = ::FindWindow(L"#32768", 0); - if (popup_menu != NULL && popup_menu == ::GetTopWindow(NULL)) { - WPARAM w_param = ui::WindowsKeyCodeForKeyboardCode(key); - LPARAM l_param = 0; - ::SendMessage(popup_menu, WM_KEYDOWN, w_param, l_param); - ::SendMessage(popup_menu, WM_KEYUP, w_param, l_param); - - if (dispatcher.get()) - dispatcher->AddRef(); - return true; - } - - INPUT input[8] = { 0 }; // 8, assuming all the modifiers are activated. - - UINT i = 0; - if (control) { - if (!FillKeyboardInput(ui::VKEY_CONTROL, &input[i], false)) - return false; - i++; - } - - if (shift) { - if (!FillKeyboardInput(ui::VKEY_SHIFT, &input[i], false)) - return false; - i++; - } - - if (alt) { - if (!FillKeyboardInput(ui::VKEY_MENU, &input[i], false)) - return false; - i++; - } - - if (!FillKeyboardInput(key, &input[i], false)) - return false; - i++; - - if (!FillKeyboardInput(key, &input[i], true)) - return false; - i++; - - if (alt) { - if (!FillKeyboardInput(ui::VKEY_MENU, &input[i], true)) - return false; - i++; - } - - if (shift) { - if (!FillKeyboardInput(ui::VKEY_SHIFT, &input[i], true)) - return false; - i++; - } - - if (control) { - if (!FillKeyboardInput(ui::VKEY_CONTROL, &input[i], true)) - return false; - i++; - } - - if (::SendInput(i, input, sizeof(INPUT)) != i) - return false; - - if (dispatcher.get()) - dispatcher->AddRef(); - - return true; -} - -bool SendMouseMoveImpl(long x, long y, const base::Closure& task) { - // First check if the mouse is already there. - POINT current_pos; - ::GetCursorPos(¤t_pos); - if (x == current_pos.x && y == current_pos.y) { - if (!task.is_null()) - MessageLoop::current()->PostTask(FROM_HERE, task); - return true; - } - - INPUT input = { 0 }; - - int screen_width = ::GetSystemMetrics(SM_CXSCREEN) - 1; - int screen_height = ::GetSystemMetrics(SM_CYSCREEN) - 1; - LONG pixel_x = static_cast<LONG>(x * (65535.0f / screen_width)); - LONG pixel_y = static_cast<LONG>(y * (65535.0f / screen_height)); - - input.type = INPUT_MOUSE; - input.mi.dwFlags = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE; - input.mi.dx = pixel_x; - input.mi.dy = pixel_y; - - scoped_refptr<InputDispatcher> dispatcher( - !task.is_null() ? new InputDispatcher(task, WM_MOUSEMOVE) : NULL); - - if (!::SendInput(1, &input, sizeof(INPUT))) - return false; - - if (dispatcher.get()) - dispatcher->AddRef(); - - return true; -} - -bool SendMouseEventsImpl(MouseButton type, int state, - const base::Closure& task) { - DWORD down_flags = MOUSEEVENTF_ABSOLUTE; - DWORD up_flags = MOUSEEVENTF_ABSOLUTE; - UINT last_event; - - switch (type) { - case LEFT: - down_flags |= MOUSEEVENTF_LEFTDOWN; - up_flags |= MOUSEEVENTF_LEFTUP; - last_event = (state & UP) ? WM_LBUTTONUP : WM_LBUTTONDOWN; - break; - - case MIDDLE: - down_flags |= MOUSEEVENTF_MIDDLEDOWN; - up_flags |= MOUSEEVENTF_MIDDLEUP; - last_event = (state & UP) ? WM_MBUTTONUP : WM_MBUTTONDOWN; - break; - - case RIGHT: - down_flags |= MOUSEEVENTF_RIGHTDOWN; - up_flags |= MOUSEEVENTF_RIGHTUP; - last_event = (state & UP) ? WM_RBUTTONUP : WM_RBUTTONDOWN; - break; - - default: - NOTREACHED(); - return false; - } - - scoped_refptr<InputDispatcher> dispatcher( - !task.is_null() ? new InputDispatcher(task, last_event) : NULL); - - INPUT input = { 0 }; - input.type = INPUT_MOUSE; - input.mi.dwFlags = down_flags; - if ((state & DOWN) && !::SendInput(1, &input, sizeof(INPUT))) - return false; - - input.mi.dwFlags = up_flags; - if ((state & UP) && !::SendInput(1, &input, sizeof(INPUT))) - return false; - - if (dispatcher.get()) - dispatcher->AddRef(); - - return true; -} - -} // namespace internal -} // namespace ui_controls diff --git a/chrome/browser/automation/ui_controls_mac.mm b/chrome/browser/automation/ui_controls_mac.mm deleted file mode 100644 index 110f467..0000000 --- a/chrome/browser/automation/ui_controls_mac.mm +++ /dev/null @@ -1,387 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/automation/ui_controls.h" - -#import <Cocoa/Cocoa.h> -#include <mach/mach_time.h> -#include <vector> - -#include "base/bind.h" -#include "base/callback.h" -#include "base/message_loop.h" -#include "chrome/browser/automation/ui_controls_internal.h" -#include "content/public/browser/browser_thread.h" -#include "ui/base/keycodes/keyboard_code_conversion_mac.h" - -using content::BrowserThread; - -// Implementation details: We use [NSApplication sendEvent:] instead -// of [NSApplication postEvent:atStart:] so that the event gets sent -// immediately. This lets us run the post-event task right -// immediately as well. Unfortunately I cannot subclass NSEvent (it's -// probably a class cluster) to allow other easy answers. For -// example, if I could subclass NSEvent, I could run the Task in it's -// dealloc routine (which necessarily happens after the event is -// dispatched). Unlike Linux, Mac does not have message loop -// observer/notification. Unlike windows, I cannot post non-events -// into the event queue. (I can post other kinds of tasks but can't -// guarantee their order with regards to events). - -// But [NSApplication sendEvent:] causes a problem when sending mouse click -// events. Because in order to handle mouse drag, when processing a mouse -// click event, the application may want to retrieve the next event -// synchronously by calling NSApplication's nextEventMatchingMask method. -// In this case, [NSApplication sendEvent:] causes deadlock. -// So we need to use [NSApplication postEvent:atStart:] for mouse click -// events. In order to notify the caller correctly after all events has been -// processed, we setup a task to watch for the event queue time to time and -// notify the caller as soon as there is no event in the queue. -// -// TODO(suzhe): -// 1. Investigate why using [NSApplication postEvent:atStart:] for keyboard -// events causes BrowserKeyEventsTest.CommandKeyEvents to fail. -// See http://crbug.com/49270 -// 2. On OSX 10.6, [NSEvent addLocalMonitorForEventsMatchingMask:handler:] may -// be used, so that we don't need to poll the event queue time to time. - -namespace { - -// From -// http://stackoverflow.com/questions/1597383/cgeventtimestamp-to-nsdate -// Which credits Apple sample code for this routine. -uint64_t UpTimeInNanoseconds(void) { - uint64_t time; - uint64_t timeNano; - static mach_timebase_info_data_t sTimebaseInfo; - - time = mach_absolute_time(); - - // Convert to nanoseconds. - - // If this is the first time we've run, get the timebase. - // We can use denom == 0 to indicate that sTimebaseInfo is - // uninitialised because it makes no sense to have a zero - // denominator is a fraction. - if (sTimebaseInfo.denom == 0) { - (void) mach_timebase_info(&sTimebaseInfo); - } - - // This could overflow; for testing needs we probably don't care. - timeNano = time * sTimebaseInfo.numer / sTimebaseInfo.denom; - return timeNano; -} - -NSTimeInterval TimeIntervalSinceSystemStartup() { - return UpTimeInNanoseconds() / 1000000000.0; -} - -// Creates and returns an autoreleased key event. -NSEvent* SynthesizeKeyEvent(NSWindow* window, - bool keyDown, - ui::KeyboardCode keycode, - NSUInteger flags) { - unichar character; - unichar characterIgnoringModifiers; - int macKeycode = ui::MacKeyCodeForWindowsKeyCode( - keycode, flags, &character, &characterIgnoringModifiers); - - if (macKeycode < 0) - return nil; - - NSString* charactersIgnoringModifiers = - [[[NSString alloc] initWithCharacters:&characterIgnoringModifiers - length:1] - autorelease]; - NSString* characters = - [[[NSString alloc] initWithCharacters:&character length:1] autorelease]; - - NSEventType type = (keyDown ? NSKeyDown : NSKeyUp); - - // Modifier keys generate NSFlagsChanged event rather than - // NSKeyDown/NSKeyUp events. - if (keycode == ui::VKEY_CONTROL || keycode == ui::VKEY_SHIFT || - keycode == ui::VKEY_MENU || keycode == ui::VKEY_COMMAND) - type = NSFlagsChanged; - - // For events other than mouse moved, [event locationInWindow] is - // UNDEFINED if the event is not NSMouseMoved. Thus, the (0,0) - // location should be fine. - NSEvent* event = - [NSEvent keyEventWithType:type - location:NSMakePoint(0, 0) - modifierFlags:flags - timestamp:TimeIntervalSinceSystemStartup() - windowNumber:[window windowNumber] - context:nil - characters:characters - charactersIgnoringModifiers:charactersIgnoringModifiers - isARepeat:NO - keyCode:(unsigned short)macKeycode]; - - return event; -} - -// Creates the proper sequence of autoreleased key events for a key down + up. -void SynthesizeKeyEventsSequence(NSWindow* window, - ui::KeyboardCode keycode, - bool control, - bool shift, - bool alt, - bool command, - std::vector<NSEvent*>* events) { - NSEvent* event = nil; - NSUInteger flags = 0; - if (control) { - flags |= NSControlKeyMask; - event = SynthesizeKeyEvent(window, true, ui::VKEY_CONTROL, flags); - DCHECK(event); - events->push_back(event); - } - if (shift) { - flags |= NSShiftKeyMask; - event = SynthesizeKeyEvent(window, true, ui::VKEY_SHIFT, flags); - DCHECK(event); - events->push_back(event); - } - if (alt) { - flags |= NSAlternateKeyMask; - event = SynthesizeKeyEvent(window, true, ui::VKEY_MENU, flags); - DCHECK(event); - events->push_back(event); - } - if (command) { - flags |= NSCommandKeyMask; - event = SynthesizeKeyEvent(window, true, ui::VKEY_COMMAND, flags); - DCHECK(event); - events->push_back(event); - } - - event = SynthesizeKeyEvent(window, true, keycode, flags); - DCHECK(event); - events->push_back(event); - event = SynthesizeKeyEvent(window, false, keycode, flags); - DCHECK(event); - events->push_back(event); - - if (command) { - flags &= ~NSCommandKeyMask; - event = SynthesizeKeyEvent(window, false, ui::VKEY_COMMAND, flags); - DCHECK(event); - events->push_back(event); - } - if (alt) { - flags &= ~NSAlternateKeyMask; - event = SynthesizeKeyEvent(window, false, ui::VKEY_MENU, flags); - DCHECK(event); - events->push_back(event); - } - if (shift) { - flags &= ~NSShiftKeyMask; - event = SynthesizeKeyEvent(window, false, ui::VKEY_SHIFT, flags); - DCHECK(event); - events->push_back(event); - } - if (control) { - flags &= ~NSControlKeyMask; - event = SynthesizeKeyEvent(window, false, ui::VKEY_CONTROL, flags); - DCHECK(event); - events->push_back(event); - } -} - -// A helper function to watch for the event queue. The specific task will be -// fired when there is no more event in the queue. -void EventQueueWatcher(const base::Closure& task) { - NSEvent* event = [NSApp nextEventMatchingMask:NSAnyEventMask - untilDate:nil - inMode:NSDefaultRunLoopMode - dequeue:NO]; - // If there is still event in the queue, then we need to check again. - if (event) { - MessageLoop::current()->PostTask( - FROM_HERE, - base::Bind(&EventQueueWatcher, task)); - } else { - MessageLoop::current()->PostTask(FROM_HERE, task); - } -} - -// Stores the current mouse location on the screen. So that we can use it -// when firing keyboard and mouse click events. -NSPoint g_mouse_location = { 0, 0 }; - -} // anonymous namespace - -namespace ui_controls { - -bool SendKeyPress(gfx::NativeWindow window, - ui::KeyboardCode key, - bool control, - bool shift, - bool alt, - bool command) { - return SendKeyPressNotifyWhenDone(window, key, - control, shift, alt, command, - base::Closure()); -} - -// Win and Linux implement a SendKeyPress() this as a -// SendKeyPressAndRelease(), so we should as well (despite the name). -bool SendKeyPressNotifyWhenDone(gfx::NativeWindow window, - ui::KeyboardCode key, - bool control, - bool shift, - bool alt, - bool command, - const base::Closure& task) { - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - - std::vector<NSEvent*> events; - SynthesizeKeyEventsSequence( - window, key, control, shift, alt, command, &events); - - // TODO(suzhe): Using [NSApplication postEvent:atStart:] here causes - // BrowserKeyEventsTest.CommandKeyEvents to fail. See http://crbug.com/49270 - // But using [NSApplication sendEvent:] should be safe for keyboard events, - // because until now, no code wants to retrieve the next event when handling - // a keyboard event. - for (std::vector<NSEvent*>::iterator iter = events.begin(); - iter != events.end(); ++iter) - [[NSApplication sharedApplication] sendEvent:*iter]; - - if (!task.is_null()) { - MessageLoop::current()->PostTask( - FROM_HERE, base::Bind(&EventQueueWatcher, task)); - } - - return true; -} - -bool SendMouseMove(long x, long y) { - return SendMouseMoveNotifyWhenDone(x, y, base::Closure()); -} - -// Input position is in screen coordinates. However, NSMouseMoved -// events require them window-relative, so we adjust. We *DO* flip -// the coordinate space, so input events can be the same for all -// platforms. E.g. (0,0) is upper-left. -bool SendMouseMoveNotifyWhenDone(long x, long y, const base::Closure& task) { - NSWindow* window = [[NSApplication sharedApplication] keyWindow]; - CGFloat screenHeight = - [[[NSScreen screens] objectAtIndex:0] frame].size.height; - g_mouse_location = NSMakePoint(x, screenHeight - y); // flip! - NSPoint pointInWindow = g_mouse_location; - if (window) - pointInWindow = [window convertScreenToBase:pointInWindow]; - NSTimeInterval timestamp = TimeIntervalSinceSystemStartup(); - - NSEvent* event = - [NSEvent mouseEventWithType:NSMouseMoved - location:pointInWindow - modifierFlags:0 - timestamp:timestamp - windowNumber:[window windowNumber] - context:nil - eventNumber:0 - clickCount:0 - pressure:0.0]; - [[NSApplication sharedApplication] postEvent:event atStart:NO]; - - if (!task.is_null()) { - MessageLoop::current()->PostTask( - FROM_HERE, base::Bind(&EventQueueWatcher, task)); - } - - return true; -} - -bool SendMouseEvents(MouseButton type, int state) { - return SendMouseEventsNotifyWhenDone(type, state, base::Closure()); -} - -bool SendMouseEventsNotifyWhenDone(MouseButton type, int state, - const base::Closure& task) { - // On windows it appears state can be (UP|DOWN). It is unclear if - // that'll happen here but prepare for it just in case. - if (state == (UP|DOWN)) { - return (SendMouseEventsNotifyWhenDone(type, DOWN, base::Closure()) && - SendMouseEventsNotifyWhenDone(type, UP, task)); - } - NSEventType etype = 0; - if (type == LEFT) { - if (state == UP) { - etype = NSLeftMouseUp; - } else { - etype = NSLeftMouseDown; - } - } else if (type == MIDDLE) { - if (state == UP) { - etype = NSOtherMouseUp; - } else { - etype = NSOtherMouseDown; - } - } else if (type == RIGHT) { - if (state == UP) { - etype = NSRightMouseUp; - } else { - etype = NSRightMouseDown; - } - } else { - return false; - } - NSWindow* window = [[NSApplication sharedApplication] keyWindow]; - NSPoint pointInWindow = g_mouse_location; - if (window) - pointInWindow = [window convertScreenToBase:pointInWindow]; - - NSEvent* event = - [NSEvent mouseEventWithType:etype - location:pointInWindow - modifierFlags:0 - timestamp:TimeIntervalSinceSystemStartup() - windowNumber:[window windowNumber] - context:nil - eventNumber:0 - clickCount:1 - pressure:(state == DOWN ? 1.0 : 0.0 )]; - [[NSApplication sharedApplication] postEvent:event atStart:NO]; - - if (!task.is_null()) { - MessageLoop::current()->PostTask( - FROM_HERE, base::Bind(&EventQueueWatcher, task)); - } - - return true; -} - -bool SendMouseClick(MouseButton type) { - return SendMouseEventsNotifyWhenDone(type, UP|DOWN, base::Closure()); -} - -void MoveMouseToCenterAndPress( - NSView* view, - MouseButton button, - int state, - const base::Closure& task) { - DCHECK(view); - NSWindow* window = [view window]; - DCHECK(window); - NSScreen* screen = [window screen]; - DCHECK(screen); - - // Converts the center position of the view into the coordinates accepted - // by SendMouseMoveNotifyWhenDone() method. - NSRect bounds = [view bounds]; - NSPoint center = NSMakePoint(NSMidX(bounds), NSMidY(bounds)); - center = [view convertPoint:center toView:nil]; - center = [window convertBaseToScreen:center]; - center = NSMakePoint(center.x, [screen frame].size.height - center.y); - - SendMouseMoveNotifyWhenDone( - center.x, center.y, - base::Bind(&ui_controls::internal::ClickTask, button, state, task)); -} - -} // ui_controls diff --git a/chrome/browser/automation/ui_controls_win.cc b/chrome/browser/automation/ui_controls_win.cc deleted file mode 100644 index 57ce337..0000000 --- a/chrome/browser/automation/ui_controls_win.cc +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/automation/ui_controls.h" - -#include "base/callback.h" -#include "base/message_loop.h" -#include "chrome/browser/automation/ui_controls_internal.h" -#include "ui/gfx/point.h" -#include "ui/views/view.h" - -namespace ui_controls { - -bool SendKeyPress(gfx::NativeWindow window, - ui::KeyboardCode key, - bool control, - bool shift, - bool alt, - bool command) { - DCHECK(!command); // No command key on Windows - return internal::SendKeyPressImpl(window, key, control, shift, alt, - base::Closure()); -} - -bool SendKeyPressNotifyWhenDone(gfx::NativeWindow window, - ui::KeyboardCode key, - bool control, - bool shift, - bool alt, - bool command, - const base::Closure& task) { - DCHECK(!command); // No command key on Windows - return internal::SendKeyPressImpl(window, key, control, shift, alt, task); -} - -bool SendMouseMove(long x, long y) { - return internal::SendMouseMoveImpl(x, y, base::Closure()); -} - -bool SendMouseMoveNotifyWhenDone(long x, long y, const base::Closure& task) { - return internal::SendMouseMoveImpl(x, y, task); -} - -bool SendMouseEvents(MouseButton type, int state) { - return internal::SendMouseEventsImpl(type, state, base::Closure()); -} - -bool SendMouseEventsNotifyWhenDone(MouseButton type, int state, - const base::Closure& task) { - return internal::SendMouseEventsImpl(type, state, task); -} - -bool SendMouseClick(MouseButton type) { - return internal::SendMouseEventsImpl(type, UP | DOWN, base::Closure()); -} - -void MoveMouseToCenterAndPress(views::View* view, - MouseButton button, - int state, - const base::Closure& task) { - DCHECK(view); - DCHECK(view->GetWidget()); - gfx::Point view_center(view->width() / 2, view->height() / 2); - views::View::ConvertPointToScreen(view, &view_center); - SendMouseMove(view_center.x(), view_center.y()); - SendMouseEventsNotifyWhenDone(button, state, task); -} - -void RunClosureAfterAllPendingUIEvents(const base::Closure& closure) { - // On windows, posting UI events is synchronous so just post the closure. - MessageLoopForUI::current()->PostTask(FROM_HERE, closure); -} - -} // ui_controls diff --git a/chrome/browser/chromeos/login/screen_locker_browsertest.cc b/chrome/browser/chromeos/login/screen_locker_browsertest.cc index 06b3608..594f7fc 100644 --- a/chrome/browser/chromeos/login/screen_locker_browsertest.cc +++ b/chrome/browser/chromeos/login/screen_locker_browsertest.cc @@ -5,7 +5,6 @@ #include "base/command_line.h" #include "base/memory/scoped_ptr.h" #include "base/message_loop.h" -#include "chrome/browser/automation/ui_controls.h" #include "chrome/browser/chromeos/cros/cros_in_process_browser_test.h" #include "chrome/browser/chromeos/dbus/mock_dbus_thread_manager.h" #include "chrome/browser/chromeos/dbus/mock_power_manager_client.h" @@ -23,6 +22,7 @@ #include "content/public/browser/notification_service.h" #include "testing/gmock/include/gmock/gmock.h" #include "testing/gtest/include/gtest/gtest.h" +#include "ui/ui_controls/ui_controls.h" #include "ui/views/widget/widget.h" #if defined(TOOLKIT_USES_GTK) diff --git a/chrome/browser/printing/print_dialog_cloud_uitest.cc b/chrome/browser/printing/print_dialog_cloud_uitest.cc index 1245464..9ae5e52 100644 --- a/chrome/browser/printing/print_dialog_cloud_uitest.cc +++ b/chrome/browser/printing/print_dialog_cloud_uitest.cc @@ -31,6 +31,7 @@ #include "net/url_request/url_request_filter.h" #include "net/url_request/url_request_test_job.h" #include "net/url_request/url_request_test_util.h" +#include "ui/ui_controls/ui_controls.h" using content::BrowserThread; diff --git a/chrome/browser/ui/gtk/bookmarks/bookmark_utils_gtk.cc b/chrome/browser/ui/gtk/bookmarks/bookmark_utils_gtk.cc index a3bf332..af1d856 100644 --- a/chrome/browser/ui/gtk/bookmarks/bookmark_utils_gtk.cc +++ b/chrome/browser/ui/gtk/bookmarks/bookmark_utils_gtk.cc @@ -17,7 +17,7 @@ #include "chrome/browser/ui/gtk/theme_service_gtk.h" #include "ui/base/dragdrop/gtk_dnd_util.h" #include "ui/base/gtk/gtk_hig_constants.h" -#include "ui/base/gtk/gtk_screen_utils.h" +#include "ui/base/gtk/gtk_screen_util.h" #include "ui/base/resource/resource_bundle.h" #include "ui/base/text/text_elider.h" #include "ui/gfx/canvas_skia_paint.h" diff --git a/chrome/browser/ui/gtk/browser_window_gtk.cc b/chrome/browser/ui/gtk/browser_window_gtk.cc index d52242c..a456d24 100644 --- a/chrome/browser/ui/gtk/browser_window_gtk.cc +++ b/chrome/browser/ui/gtk/browser_window_gtk.cc @@ -92,6 +92,7 @@ #include "grit/ui_resources.h" #include "ui/base/gtk/gtk_floating_container.h" #include "ui/base/gtk/gtk_hig_constants.h" +#include "ui/base/gtk/gtk_screen_util.h" #include "ui/base/keycodes/keyboard_codes.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/resource/resource_bundle.h" @@ -1240,7 +1241,7 @@ void BrowserWindowGtk::HideInstant() { } gfx::Rect BrowserWindowGtk::GetInstantBounds() { - return gtk_util::GetWidgetScreenBounds(contents_container_->widget()); + return ui::GetWidgetScreenBounds(contents_container_->widget()); } WindowOpenDisposition BrowserWindowGtk::GetDispositionForPopupBounds( diff --git a/chrome/browser/ui/gtk/confirm_bubble_view.cc b/chrome/browser/ui/gtk/confirm_bubble_view.cc index ebbfc54..60d8d5c 100644 --- a/chrome/browser/ui/gtk/confirm_bubble_view.cc +++ b/chrome/browser/ui/gtk/confirm_bubble_view.cc @@ -17,6 +17,7 @@ #include "chrome/browser/ui/gtk/theme_service_gtk.h" #include "grit/theme_resources.h" #include "ui/base/gtk/gtk_hig_constants.h" +#include "ui/base/gtk/gtk_screen_util.h" #include "ui/base/resource/resource_bundle.h" #include "ui/gfx/image/image.h" @@ -136,7 +137,7 @@ void ConfirmBubbleView::Show() { } // Show a bubble consisting of the above widgets under the anchor point. - gfx::Rect rect = gtk_util::GetWidgetScreenBounds(anchor_); + gfx::Rect rect = ui::GetWidgetScreenBounds(anchor_); rect.set_x(anchor_point_.x() - rect.x()); rect.set_y(anchor_point_.y() - rect.y()); rect.set_width(0); diff --git a/chrome/browser/ui/gtk/download/download_shelf_gtk.cc b/chrome/browser/ui/gtk/download/download_shelf_gtk.cc index 63cc302..f2c637e 100644 --- a/chrome/browser/ui/gtk/download/download_shelf_gtk.cc +++ b/chrome/browser/ui/gtk/download/download_shelf_gtk.cc @@ -24,6 +24,7 @@ #include "grit/theme_resources.h" #include "grit/theme_resources_standard.h" #include "grit/ui_resources_standard.h" +#include "ui/base/gtk/gtk_screen_util.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/resource/resource_bundle.h" #include "ui/gfx/gtk_util.h" @@ -372,7 +373,7 @@ bool DownloadShelfGtk::IsCursorInShelfZone( GtkAllocation allocation; gtk_widget_get_allocation(shelf_.get(), &allocation); - gfx::Rect bounds(gtk_util::GetWidgetScreenPosition(shelf_.get()), + gfx::Rect bounds(ui::GetWidgetScreenPosition(shelf_.get()), gfx::Size(allocation.width, allocation.height)); // Negative insets expand the rectangle. We only expand the top. diff --git a/chrome/browser/ui/gtk/gtk_util.cc b/chrome/browser/ui/gtk/gtk_util.cc index cbf2286..d7f9fc8 100644 --- a/chrome/browser/ui/gtk/gtk_util.cc +++ b/chrome/browser/ui/gtk/gtk_util.cc @@ -36,6 +36,7 @@ #include "ui/base/events.h" #include "ui/base/gtk/gtk_compat.h" #include "ui/base/gtk/gtk_hig_constants.h" +#include "ui/base/gtk/gtk_screen_util.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/resource/resource_bundle.h" #include "ui/base/text/text_elider.h" @@ -544,37 +545,6 @@ void UndoForceFontSize(GtkWidget* widget) { gtk_widget_modify_font(widget, NULL); } -gfx::Point GetWidgetScreenPosition(GtkWidget* widget) { - GdkWindow* window = gtk_widget_get_window(widget); - - if (!window) { - NOTREACHED() << "Must only be called on realized widgets."; - return gfx::Point(0, 0); - } - - gint x, y; - gdk_window_get_origin(window, &x, &y); - - if (!gtk_widget_get_has_window(widget)) { - GtkAllocation allocation; - gtk_widget_get_allocation(widget, &allocation); - x += allocation.x; - y += allocation.y; - } - - return gfx::Point(x, y); -} - -gfx::Rect GetWidgetScreenBounds(GtkWidget* widget) { - gfx::Point position = GetWidgetScreenPosition(widget); - - GtkAllocation allocation; - gtk_widget_get_allocation(widget, &allocation); - - return gfx::Rect(position.x(), position.y(), - allocation.width, allocation.height); -} - gfx::Size GetWidgetSize(GtkWidget* widget) { GtkRequisition size; gtk_widget_size_request(widget, &size); @@ -585,7 +555,7 @@ void ConvertWidgetPointToScreen(GtkWidget* widget, gfx::Point* p) { DCHECK(widget); DCHECK(p); - gfx::Point position = GetWidgetScreenPosition(widget); + gfx::Point position = ui::GetWidgetScreenPosition(widget); p->SetPoint(p->x() + position.x(), p->y() + position.y()); } diff --git a/chrome/browser/ui/gtk/gtk_util.h b/chrome/browser/ui/gtk/gtk_util.h index fe74fe0..da11470 100644 --- a/chrome/browser/ui/gtk/gtk_util.h +++ b/chrome/browser/ui/gtk/gtk_util.h @@ -110,12 +110,6 @@ void ForceFontSizePixels(GtkWidget* widget, double size_pixels); // even if ForceFontSizePixels() was never called. void UndoForceFontSize(GtkWidget* widget); -// Gets the position of a gtk widget in screen coordinates. -gfx::Point GetWidgetScreenPosition(GtkWidget* widget); - -// Returns the bounds of the specified widget in screen coordinates. -gfx::Rect GetWidgetScreenBounds(GtkWidget* widget); - // Retuns size of the |widget| without window manager decorations. gfx::Size GetWidgetSize(GtkWidget* widget); diff --git a/chrome/browser/ui/gtk/omnibox/omnibox_popup_view_gtk.cc b/chrome/browser/ui/gtk/omnibox/omnibox_popup_view_gtk.cc index 39e1bc9..fcdf76c 100644 --- a/chrome/browser/ui/gtk/omnibox/omnibox_popup_view_gtk.cc +++ b/chrome/browser/ui/gtk/omnibox/omnibox_popup_view_gtk.cc @@ -30,6 +30,7 @@ #include "grit/theme_resources.h" #include "ui/base/gtk/gtk_compat.h" #include "ui/base/gtk/gtk_hig_constants.h" +#include "ui/base/gtk/gtk_screen_util.h" #include "ui/base/gtk/gtk_windowing.h" #include "ui/gfx/color_utils.h" #include "ui/gfx/font.h" @@ -372,7 +373,7 @@ gfx::Rect OmniboxPopupViewGtk::GetTargetBounds() { if (!gtk_widget_get_realized(window_)) return gfx::Rect(); - gfx::Rect retval = gtk_util::GetWidgetScreenBounds(window_); + gfx::Rect retval = ui::GetWidgetScreenBounds(window_); // The widget bounds don't update synchronously so may be out of sync with // our last size request. diff --git a/chrome/browser/ui/gtk/tabs/dragged_tab_controller_gtk.cc b/chrome/browser/ui/gtk/tabs/dragged_tab_controller_gtk.cc index 9824131..c68435f 100644 --- a/chrome/browser/ui/gtk/tabs/dragged_tab_controller_gtk.cc +++ b/chrome/browser/ui/gtk/tabs/dragged_tab_controller_gtk.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -21,6 +21,7 @@ #include "content/public/browser/notification_source.h" #include "content/public/browser/notification_types.h" #include "content/public/browser/web_contents.h" +#include "ui/base/gtk/gtk_screen_util.h" #include "ui/gfx/screen.h" using content::OpenURLParams; @@ -376,7 +377,7 @@ TabStripGtk* DraggedTabControllerGtk::GetTabStripIfItContains( // Make sure the specified screen point is actually within the bounds of the // specified tabstrip... gfx::Rect tabstrip_bounds = - gtk_util::GetWidgetScreenBounds(tabstrip->tabstrip_.get()); + ui::GetWidgetScreenBounds(tabstrip->tabstrip_.get()); if (screen_point.x() < tabstrip_bounds.right() && screen_point.x() >= tabstrip_bounds.x()) { // TODO(beng): make this be relative to the start position of the mouse for @@ -421,7 +422,7 @@ void DraggedTabControllerGtk::Attach(TabStripGtk* attached_tabstrip, GtkWidget* parent_window = gtk_widget_get_parent( gtk_widget_get_parent(attached_tabstrip_->tabstrip_.get())); - gfx::Rect window_bounds = gtk_util::GetWidgetScreenBounds(parent_window); + gfx::Rect window_bounds = ui::GetWidgetScreenBounds(parent_window); dragged_view_->Attach(static_cast<int>(floor(selected_width + 0.5)), TabGtk::GetMiniWidth(), window_bounds.width()); @@ -504,7 +505,7 @@ void DraggedTabControllerGtk::Detach() { gfx::Point DraggedTabControllerGtk::ConvertScreenPointToTabStripPoint( TabStripGtk* tabstrip, const gfx::Point& screen_point) { gfx::Point tabstrip_screen_point = - gtk_util::GetWidgetScreenPosition(tabstrip->tabstrip_.get()); + ui::GetWidgetScreenPosition(tabstrip->tabstrip_.get()); return screen_point.Subtract(tabstrip_screen_point); } @@ -576,7 +577,7 @@ gfx::Point DraggedTabControllerGtk::GetDraggedViewPoint( // If we're not attached, we just use x and y from above. if (attached_tabstrip_) { gfx::Rect tabstrip_bounds = - gtk_util::GetWidgetScreenBounds(attached_tabstrip_->tabstrip_.get()); + ui::GetWidgetScreenBounds(attached_tabstrip_->tabstrip_.get()); // Snap the dragged tab to the tabstrip if we are attached, detaching // only when the mouse position (screen_point) exceeds the screen bounds // of the tabstrip. @@ -820,7 +821,7 @@ gfx::Rect DraggedTabControllerGtk::GetAnimateBounds() { gfx::Rect bounds = tab->GetRequisition(); GtkWidget* widget = tab->widget(); GtkWidget* parent = gtk_widget_get_parent(widget); - gfx::Point point = gtk_util::GetWidgetScreenPosition(parent); + gfx::Point point = ui::GetWidgetScreenPosition(parent); bounds.Offset(point); return gfx::Rect(bounds.x(), bounds.y(), diff --git a/chrome/browser/ui/gtk/tabs/dragged_view_gtk.cc b/chrome/browser/ui/gtk/tabs/dragged_view_gtk.cc index 5f7d433..ac144c5 100644 --- a/chrome/browser/ui/gtk/tabs/dragged_view_gtk.cc +++ b/chrome/browser/ui/gtk/tabs/dragged_view_gtk.cc @@ -24,7 +24,7 @@ #include "content/public/browser/render_view_host.h" #include "content/public/browser/web_contents.h" #include "third_party/skia/include/core/SkShader.h" -#include "ui/base/gtk/gtk_screen_utils.h" +#include "ui/base/gtk/gtk_screen_util.h" #include "ui/base/x/x11_util.h" #include "ui/gfx/gtk_util.h" diff --git a/chrome/browser/ui/gtk/tabs/tab_renderer_gtk.cc b/chrome/browser/ui/gtk/tabs/tab_renderer_gtk.cc index b0ef46a..26bb2a8 100644 --- a/chrome/browser/ui/gtk/tabs/tab_renderer_gtk.cc +++ b/chrome/browser/ui/gtk/tabs/tab_renderer_gtk.cc @@ -31,6 +31,7 @@ #include "ui/base/animation/slide_animation.h" #include "ui/base/animation/throb_animation.h" #include "ui/base/gtk/gtk_compat.h" +#include "ui/base/gtk/gtk_screen_util.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/resource/resource_bundle.h" #include "ui/gfx/canvas_skia_paint.h" @@ -96,8 +97,8 @@ const int kCloseButtonHorzFuzz = 5; // Gets the bounds of |widget| relative to |parent|. gfx::Rect GetWidgetBoundsRelativeToParent(GtkWidget* parent, GtkWidget* widget) { - gfx::Point parent_pos = gtk_util::GetWidgetScreenPosition(parent); - gfx::Point widget_pos = gtk_util::GetWidgetScreenPosition(widget); + gfx::Point parent_pos = ui::GetWidgetScreenPosition(parent); + gfx::Point widget_pos = ui::GetWidgetScreenPosition(widget); GtkAllocation allocation; gtk_widget_get_allocation(widget, &allocation); diff --git a/chrome/browser/ui/gtk/tabs/tab_strip_gtk.cc b/chrome/browser/ui/gtk/tabs/tab_strip_gtk.cc index 455dedf..6e96072 100644 --- a/chrome/browser/ui/gtk/tabs/tab_strip_gtk.cc +++ b/chrome/browser/ui/gtk/tabs/tab_strip_gtk.cc @@ -38,7 +38,7 @@ #include "ui/base/animation/slide_animation.h" #include "ui/base/dragdrop/gtk_dnd_util.h" #include "ui/base/gtk/gtk_compat.h" -#include "ui/base/gtk/gtk_screen_utils.h" +#include "ui/base/gtk/gtk_screen_util.h" #include "ui/base/resource/resource_bundle.h" #include "ui/gfx/gtk_util.h" #include "ui/gfx/image/image.h" diff --git a/chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc b/chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc index cc7a60f..fea3fd8 100644 --- a/chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc +++ b/chrome/browser/ui/views/bookmarks/bookmark_bar_view_test.cc @@ -8,7 +8,6 @@ #include "base/string_number_conversions.h" #include "base/utf_string_conversions.h" #include "chrome/app/chrome_command_ids.h" -#include "chrome/browser/automation/ui_controls.h" #include "chrome/browser/bookmarks/bookmark_model.h" #include "chrome/browser/bookmarks/bookmark_utils.h" #include "chrome/browser/prefs/pref_service.h" @@ -28,6 +27,7 @@ #include "ui/base/accessibility/accessibility_types.h" #include "ui/base/clipboard/clipboard.h" #include "ui/base/keycodes/keyboard_codes.h" +#include "ui/ui_controls/ui_controls.h" #include "ui/views/controls/button/menu_button.h" #include "ui/views/controls/button/text_button.h" #include "ui/views/controls/menu/menu_controller.h" @@ -303,7 +303,7 @@ class BookmarkBarViewTest1 : public BookmarkBarViewEventTestBase { // Move the mouse to the first folder on the bookmark bar and press the // mouse. views::TextButton* button = GetBookmarkButton(0); - ui_controls::MoveMouseToCenterAndPress(button, ui_controls::LEFT, + ui_test_utils::MoveMouseToCenterAndPress(button, ui_controls::LEFT, ui_controls::DOWN | ui_controls::UP, CreateEventTask(this, &BookmarkBarViewTest1::Step2)); } @@ -324,7 +324,7 @@ class BookmarkBarViewTest1 : public BookmarkBarViewEventTestBase { views::MenuItemView* menu_to_select = menu->GetSubmenu()->GetMenuItemAt(0); - ui_controls::MoveMouseToCenterAndPress(menu_to_select, ui_controls::LEFT, + ui_test_utils::MoveMouseToCenterAndPress(menu_to_select, ui_controls::LEFT, ui_controls::DOWN | ui_controls::UP, CreateEventTask(this, &BookmarkBarViewTest1::Step3)); } @@ -356,7 +356,7 @@ class BookmarkBarViewTest2 : public BookmarkBarViewEventTestBase { // Move the mouse to the first folder on the bookmark bar and press the // mouse. views::TextButton* button = GetBookmarkButton(0); - ui_controls::MoveMouseToCenterAndPress(button, ui_controls::LEFT, + ui_test_utils::MoveMouseToCenterAndPress(button, ui_controls::LEFT, ui_controls::DOWN | ui_controls::UP, CreateEventTask(this, &BookmarkBarViewTest2::Step2)); } @@ -406,7 +406,7 @@ class BookmarkBarViewTest3 : public BookmarkBarViewEventTestBase { // Move the mouse to the first folder on the bookmark bar and press the // mouse. views::MenuButton* button = bb_view_->other_bookmarked_button(); - ui_controls::MoveMouseToCenterAndPress(button, ui_controls::LEFT, + ui_test_utils::MoveMouseToCenterAndPress(button, ui_controls::LEFT, ui_controls::DOWN | ui_controls::UP, CreateEventTask(this, &BookmarkBarViewTest3::Step2)); } @@ -423,7 +423,7 @@ class BookmarkBarViewTest3 : public BookmarkBarViewEventTestBase { ASSERT_TRUE(child_menu != NULL); // Click on second child, which has a submenu. - ui_controls::MoveMouseToCenterAndPress(child_menu, ui_controls::LEFT, + ui_test_utils::MoveMouseToCenterAndPress(child_menu, ui_controls::LEFT, ui_controls::DOWN | ui_controls::UP, CreateEventTask(this, &BookmarkBarViewTest3::Step3)); } @@ -440,7 +440,7 @@ class BookmarkBarViewTest3 : public BookmarkBarViewEventTestBase { // Click on third child, which has a submenu too. child_menu = menu->GetSubmenu()->GetMenuItemAt(2); ASSERT_TRUE(child_menu != NULL); - ui_controls::MoveMouseToCenterAndPress(child_menu, ui_controls::LEFT, + ui_test_utils::MoveMouseToCenterAndPress(child_menu, ui_controls::LEFT, ui_controls::DOWN | ui_controls::UP, CreateEventTask(this, &BookmarkBarViewTest3::Step4)); } @@ -513,7 +513,7 @@ class BookmarkBarViewTest4 : public BookmarkBarViewEventTestBase { // Move the mouse to the first folder on the bookmark bar and press the // mouse. views::TextButton* button = bb_view_->other_bookmarked_button(); - ui_controls::MoveMouseToCenterAndPress(button, ui_controls::LEFT, + ui_test_utils::MoveMouseToCenterAndPress(button, ui_controls::LEFT, ui_controls::DOWN | ui_controls::UP, CreateEventTask(this, &BookmarkBarViewTest4::Step2)); } @@ -530,7 +530,7 @@ class BookmarkBarViewTest4 : public BookmarkBarViewEventTestBase { ASSERT_TRUE(child_menu != NULL); // Right click on the first child to get its context menu. - ui_controls::MoveMouseToCenterAndPress(child_menu, ui_controls::RIGHT, + ui_test_utils::MoveMouseToCenterAndPress(child_menu, ui_controls::RIGHT, ui_controls::DOWN | ui_controls::UP, base::Closure()); // Step3 will be invoked by ContextMenuNotificationObserver. } @@ -543,7 +543,8 @@ class BookmarkBarViewTest4 : public BookmarkBarViewEventTestBase { ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); // Select the first menu item (open). - ui_controls::MoveMouseToCenterAndPress(menu->GetSubmenu()->GetMenuItemAt(0), + ui_test_utils::MoveMouseToCenterAndPress( + menu->GetSubmenu()->GetMenuItemAt(0), ui_controls::LEFT, ui_controls::DOWN | ui_controls::UP, CreateEventTask(this, &BookmarkBarViewTest4::Step4)); } @@ -568,7 +569,7 @@ class BookmarkBarViewTest5 : public BookmarkBarViewEventTestBase { // Move the mouse to the first folder on the bookmark bar and press the // mouse. views::TextButton* button = GetBookmarkButton(0); - ui_controls::MoveMouseToCenterAndPress(button, ui_controls::LEFT, + ui_test_utils::MoveMouseToCenterAndPress(button, ui_controls::LEFT, ui_controls::DOWN | ui_controls::UP, CreateEventTask(this, &BookmarkBarViewTest5::Step2)); } @@ -585,7 +586,7 @@ class BookmarkBarViewTest5 : public BookmarkBarViewEventTestBase { ASSERT_TRUE(child_menu != NULL); // Move mouse to center of menu and press button. - ui_controls::MoveMouseToCenterAndPress(child_menu, ui_controls::LEFT, + ui_test_utils::MoveMouseToCenterAndPress(child_menu, ui_controls::LEFT, ui_controls::DOWN, CreateEventTask(this, &BookmarkBarViewTest5::Step3)); } @@ -635,7 +636,7 @@ class BookmarkBarViewTest6 : public BookmarkBarViewEventTestBase { virtual void DoTestOnMessageLoop() { // Press the mouse button on the overflow button. Don't release it though. views::TextButton* button = bb_view_->overflow_button(); - ui_controls::MoveMouseToCenterAndPress(button, ui_controls::LEFT, + ui_test_utils::MoveMouseToCenterAndPress(button, ui_controls::LEFT, ui_controls::DOWN, CreateEventTask(this, &BookmarkBarViewTest6::Step2)); } @@ -651,7 +652,7 @@ class BookmarkBarViewTest6 : public BookmarkBarViewEventTestBase { ASSERT_TRUE(child_menu != NULL); // Move mouse to center of menu and release mouse. - ui_controls::MoveMouseToCenterAndPress(child_menu, ui_controls::LEFT, + ui_test_utils::MoveMouseToCenterAndPress(child_menu, ui_controls::LEFT, ui_controls::UP, CreateEventTask(this, &BookmarkBarViewTest6::Step3)); } @@ -676,7 +677,7 @@ class BookmarkBarViewTest7 : public BookmarkBarViewEventTestBase { // Move the mouse to the first folder on the bookmark bar and press the // mouse. views::TextButton* button = GetBookmarkButton(0); - ui_controls::MoveMouseToCenterAndPress(button, ui_controls::LEFT, + ui_test_utils::MoveMouseToCenterAndPress(button, ui_controls::LEFT, ui_controls::DOWN | ui_controls::UP, CreateEventTask(this, &BookmarkBarViewTest7::Step2)); } @@ -693,7 +694,7 @@ class BookmarkBarViewTest7 : public BookmarkBarViewEventTestBase { ASSERT_TRUE(child_menu != NULL); // Move mouse to center of menu and press button. - ui_controls::MoveMouseToCenterAndPress(child_menu, ui_controls::LEFT, + ui_test_utils::MoveMouseToCenterAndPress(child_menu, ui_controls::LEFT, ui_controls::DOWN, CreateEventTask(this, &BookmarkBarViewTest7::Step3)); } @@ -749,7 +750,7 @@ class BookmarkBarViewTest8 : public BookmarkBarViewEventTestBase { // Move the mouse to the first folder on the bookmark bar and press the // mouse. views::TextButton* button = GetBookmarkButton(0); - ui_controls::MoveMouseToCenterAndPress(button, ui_controls::LEFT, + ui_test_utils::MoveMouseToCenterAndPress(button, ui_controls::LEFT, ui_controls::DOWN | ui_controls::UP, CreateEventTask(this, &BookmarkBarViewTest8::Step2)); } @@ -766,7 +767,7 @@ class BookmarkBarViewTest8 : public BookmarkBarViewEventTestBase { ASSERT_TRUE(child_menu != NULL); // Move mouse to center of menu and press button. - ui_controls::MoveMouseToCenterAndPress(child_menu, ui_controls::LEFT, + ui_test_utils::MoveMouseToCenterAndPress(child_menu, ui_controls::LEFT, ui_controls::DOWN, CreateEventTask(this, &BookmarkBarViewTest8::Step3)); } @@ -807,7 +808,7 @@ class BookmarkBarViewTest8 : public BookmarkBarViewEventTestBase { views::MenuItemView* target_menu = drop_menu->GetSubmenu()->GetMenuItemAt(1); - ui_controls::MoveMouseToCenterAndPress( + ui_test_utils::MoveMouseToCenterAndPress( target_menu, ui_controls::LEFT, ui_controls::UP, CreateEventTask(this, &BookmarkBarViewTest8::Step6)); } @@ -834,7 +835,7 @@ class BookmarkBarViewTest9 : public BookmarkBarViewEventTestBase { // Move the mouse to the first folder on the bookmark bar and press the // mouse. views::TextButton* button = GetBookmarkButton(0); - ui_controls::MoveMouseToCenterAndPress(button, ui_controls::LEFT, + ui_test_utils::MoveMouseToCenterAndPress(button, ui_controls::LEFT, ui_controls::DOWN | ui_controls::UP, CreateEventTask(this, &BookmarkBarViewTest9::Step2)); } @@ -902,7 +903,7 @@ class BookmarkBarViewTest10 : public BookmarkBarViewEventTestBase { // Move the mouse to the first folder on the bookmark bar and press the // mouse. views::TextButton* button = GetBookmarkButton(0); - ui_controls::MoveMouseToCenterAndPress(button, ui_controls::LEFT, + ui_test_utils::MoveMouseToCenterAndPress(button, ui_controls::LEFT, ui_controls::DOWN | ui_controls::UP, CreateEventTask(this, &BookmarkBarViewTest10::Step2)); MessageLoop::current()->RunAllPending(); @@ -1017,7 +1018,7 @@ class BookmarkBarViewTest11 : public BookmarkBarViewEventTestBase { // Move the mouse to the first folder on the bookmark bar and press the // mouse. views::TextButton* button = bb_view_->other_bookmarked_button(); - ui_controls::MoveMouseToCenterAndPress(button, ui_controls::LEFT, + ui_test_utils::MoveMouseToCenterAndPress(button, ui_controls::LEFT, ui_controls::DOWN | ui_controls::UP, CreateEventTask(this, &BookmarkBarViewTest11::Step2)); } @@ -1034,7 +1035,7 @@ class BookmarkBarViewTest11 : public BookmarkBarViewEventTestBase { ASSERT_TRUE(child_menu != NULL); // Right click on the first child to get its context menu. - ui_controls::MoveMouseToCenterAndPress(child_menu, ui_controls::RIGHT, + ui_test_utils::MoveMouseToCenterAndPress(child_menu, ui_controls::RIGHT, ui_controls::DOWN | ui_controls::UP, base::Closure()); // Step3 will be invoked by ContextMenuNotificationObserver. } @@ -1084,7 +1085,7 @@ class BookmarkBarViewTest12 : public BookmarkBarViewEventTestBase { virtual void DoTestOnMessageLoop() { // Open up the other folder. views::TextButton* button = bb_view_->other_bookmarked_button(); - ui_controls::MoveMouseToCenterAndPress(button, ui_controls::LEFT, + ui_test_utils::MoveMouseToCenterAndPress(button, ui_controls::LEFT, ui_controls::DOWN | ui_controls::UP, CreateEventTask(this, &BookmarkBarViewTest12::Step2)); bookmark_utils::num_urls_before_prompting = 1; @@ -1106,7 +1107,7 @@ class BookmarkBarViewTest12 : public BookmarkBarViewEventTestBase { ASSERT_TRUE(child_menu != NULL); // Right click on the second child (a folder) to get its context menu. - ui_controls::MoveMouseToCenterAndPress(child_menu, ui_controls::RIGHT, + ui_test_utils::MoveMouseToCenterAndPress(child_menu, ui_controls::RIGHT, ui_controls::DOWN | ui_controls::UP, CreateEventTask(this, &BookmarkBarViewTest12::Step3)); } @@ -1120,7 +1121,7 @@ class BookmarkBarViewTest12 : public BookmarkBarViewEventTestBase { views::MenuItemView* child_menu = menu->GetSubmenu()->GetMenuItemAt(0); ASSERT_TRUE(child_menu != NULL); - ui_controls::MoveMouseToCenterAndPress(child_menu, ui_controls::LEFT, + ui_test_utils::MoveMouseToCenterAndPress(child_menu, ui_controls::LEFT, ui_controls::DOWN | ui_controls::UP, base::Closure()); // Delay until we send tab, otherwise the message box doesn't appear @@ -1172,7 +1173,7 @@ class BookmarkBarViewTest13 : public BookmarkBarViewEventTestBase { // Move the mouse to the first folder on the bookmark bar and press the // mouse. views::TextButton* button = bb_view_->other_bookmarked_button(); - ui_controls::MoveMouseToCenterAndPress(button, ui_controls::LEFT, + ui_test_utils::MoveMouseToCenterAndPress(button, ui_controls::LEFT, ui_controls::DOWN | ui_controls::UP, CreateEventTask(this, &BookmarkBarViewTest13::Step2)); } @@ -1189,7 +1190,7 @@ class BookmarkBarViewTest13 : public BookmarkBarViewEventTestBase { ASSERT_TRUE(child_menu != NULL); // Right click on the first child to get its context menu. - ui_controls::MoveMouseToCenterAndPress(child_menu, ui_controls::RIGHT, + ui_test_utils::MoveMouseToCenterAndPress(child_menu, ui_controls::RIGHT, ui_controls::DOWN | ui_controls::UP, base::Closure()); // Step3 will be invoked by ContextMenuNotificationObserver. } @@ -1214,7 +1215,7 @@ class BookmarkBarViewTest13 : public BookmarkBarViewEventTestBase { // Click on the separator. Clicking on the separator shouldn't visually // change anything. - ui_controls::MoveMouseToCenterAndPress(separator_view, + ui_test_utils::MoveMouseToCenterAndPress(separator_view, ui_controls::LEFT, ui_controls::DOWN | ui_controls::UP, CreateEventTask(this, &BookmarkBarViewTest13::Step4)); } @@ -1227,8 +1228,10 @@ class BookmarkBarViewTest13 : public BookmarkBarViewEventTestBase { ASSERT_TRUE(menu->GetSubmenu()->IsShowing()); // Select the first context menu item. - ui_controls::MoveMouseToCenterAndPress(menu->GetSubmenu()->GetMenuItemAt(0), - ui_controls::LEFT, ui_controls::DOWN | ui_controls::UP, + ui_test_utils::MoveMouseToCenterAndPress( + menu->GetSubmenu()->GetMenuItemAt(0), + ui_controls::LEFT, + ui_controls::DOWN | ui_controls::UP, CreateEventTask(this, &BookmarkBarViewTest13::Step5)); } @@ -1255,7 +1258,7 @@ class BookmarkBarViewTest14 : public BookmarkBarViewEventTestBase { // Move the mouse to the first folder on the bookmark bar and press the // right mouse button. views::TextButton* button = GetBookmarkButton(0); - ui_controls::MoveMouseToCenterAndPress(button, ui_controls::RIGHT, + ui_test_utils::MoveMouseToCenterAndPress(button, ui_controls::RIGHT, ui_controls::DOWN | ui_controls::UP, base::Closure()); // Step2 will be invoked by ContextMenuNotificationObserver. } @@ -1295,7 +1298,7 @@ class BookmarkBarViewTest15 : public BookmarkBarViewEventTestBase { virtual void DoTestOnMessageLoop() { // Show the other bookmarks. views::TextButton* button = bb_view_->other_bookmarked_button(); - ui_controls::MoveMouseToCenterAndPress(button, ui_controls::LEFT, + ui_test_utils::MoveMouseToCenterAndPress(button, ui_controls::LEFT, ui_controls::DOWN | ui_controls::UP, CreateEventTask(this, &BookmarkBarViewTest15::Step2)); } @@ -1314,7 +1317,7 @@ class BookmarkBarViewTest15 : public BookmarkBarViewEventTestBase { deleted_menu_id_ = child_menu->GetCommand(); // Right click on the second child to get its context menu. - ui_controls::MoveMouseToCenterAndPress(child_menu, ui_controls::RIGHT, + ui_test_utils::MoveMouseToCenterAndPress(child_menu, ui_controls::RIGHT, ui_controls::DOWN | ui_controls::UP, base::Closure()); // Step3 will be invoked by ContextMenuNotificationObserver. } @@ -1331,7 +1334,7 @@ class BookmarkBarViewTest15 : public BookmarkBarViewEventTestBase { ASSERT_TRUE(delete_menu); // Click on the delete button. - ui_controls::MoveMouseToCenterAndPress(delete_menu, + ui_test_utils::MoveMouseToCenterAndPress(delete_menu, ui_controls::LEFT, ui_controls::DOWN | ui_controls::UP, CreateEventTask(this, &BookmarkBarViewTest15::Step4)); } @@ -1369,7 +1372,7 @@ class BookmarkBarViewTest16 : public BookmarkBarViewEventTestBase { // Move the mouse to the first folder on the bookmark bar and press the // mouse. views::TextButton* button = GetBookmarkButton(0); - ui_controls::MoveMouseToCenterAndPress(button, ui_controls::LEFT, + ui_test_utils::MoveMouseToCenterAndPress(button, ui_controls::LEFT, ui_controls::DOWN | ui_controls::UP, CreateEventTask(this, &BookmarkBarViewTest16::Step2)); } @@ -1408,7 +1411,7 @@ class BookmarkBarViewTest17 : public BookmarkBarViewEventTestBase { // Move the mouse to the other folder on the bookmark bar and press the // left mouse button. views::TextButton* button = bb_view_->other_bookmarked_button(); - ui_controls::MoveMouseToCenterAndPress(button, ui_controls::LEFT, + ui_test_utils::MoveMouseToCenterAndPress(button, ui_controls::LEFT, ui_controls::DOWN | ui_controls::UP, CreateEventTask(this, &BookmarkBarViewTest17::Step2)); } @@ -1423,7 +1426,7 @@ class BookmarkBarViewTest17 : public BookmarkBarViewEventTestBase { // Right click on the second item to show its context menu. views::MenuItemView* child_menu = menu->GetSubmenu()->GetMenuItemAt(2); ASSERT_TRUE(child_menu != NULL); - ui_controls::MoveMouseToCenterAndPress(child_menu, ui_controls::RIGHT, + ui_test_utils::MoveMouseToCenterAndPress(child_menu, ui_controls::RIGHT, ui_controls::DOWN | ui_controls::UP, base::Closure()); // Step3 will be invoked by ContextMenuNotificationObserver. } @@ -1443,7 +1446,7 @@ class BookmarkBarViewTest17 : public BookmarkBarViewEventTestBase { ASSERT_TRUE(child_menu != NULL); observer_.set_task(CreateEventTask(this, &BookmarkBarViewTest17::Step4)); - ui_controls::MoveMouseToCenterAndPress(child_menu, ui_controls::RIGHT, + ui_test_utils::MoveMouseToCenterAndPress(child_menu, ui_controls::RIGHT, ui_controls::DOWN | ui_controls::UP, base::Closure()); // Step4 will be invoked by ContextMenuNotificationObserver. } @@ -1484,7 +1487,7 @@ class BookmarkBarViewTest18 : public BookmarkBarViewEventTestBase { // Move the mouse to the other folder on the bookmark bar and press the // left mouse button. views::TextButton* button = bb_view_->other_bookmarked_button(); - ui_controls::MoveMouseToCenterAndPress(button, ui_controls::LEFT, + ui_test_utils::MoveMouseToCenterAndPress(button, ui_controls::LEFT, ui_controls::DOWN | ui_controls::UP, CreateEventTask(this, &BookmarkBarViewTest18::Step2)); } @@ -1527,7 +1530,7 @@ class BookmarkBarViewTest19 : public BookmarkBarViewEventTestBase { // Move the mouse to the other folder on the bookmark bar and press the // left mouse button. views::TextButton* button = bb_view_->other_bookmarked_button(); - ui_controls::MoveMouseToCenterAndPress(button, ui_controls::LEFT, + ui_test_utils::MoveMouseToCenterAndPress(button, ui_controls::LEFT, ui_controls::DOWN | ui_controls::UP, CreateEventTask(this, &BookmarkBarViewTest19::Step2)); } @@ -1542,7 +1545,7 @@ class BookmarkBarViewTest19 : public BookmarkBarViewEventTestBase { // Click on the first folder. views::MenuItemView* child_menu = menu->GetSubmenu()->GetMenuItemAt(1); ASSERT_TRUE(child_menu != NULL); - ui_controls::MoveMouseToCenterAndPress( + ui_test_utils::MoveMouseToCenterAndPress( child_menu, ui_controls::LEFT, ui_controls::DOWN | ui_controls::UP, CreateEventTask(this, &BookmarkBarViewTest19::Step3)); @@ -1572,7 +1575,9 @@ class BookmarkBarViewTest19 : public BookmarkBarViewEventTestBase { // Click on the first folder. views::MenuItemView* child_menu = menu->GetSubmenu()->GetMenuItemAt(1); ASSERT_TRUE(child_menu != NULL); - ui_controls::MoveMouseToCenterAndPress(child_menu, ui_controls::LEFT, + ui_test_utils::MoveMouseToCenterAndPress( + child_menu, + ui_controls::LEFT, ui_controls::DOWN | ui_controls::UP, CreateEventTask(this, &BookmarkBarViewTest19::Step5)); } diff --git a/chrome/browser/ui/views/button_dropdown_test.cc b/chrome/browser/ui/views/button_dropdown_test.cc index 7d1642f..77cd2ae 100644 --- a/chrome/browser/ui/views/button_dropdown_test.cc +++ b/chrome/browser/ui/views/button_dropdown_test.cc @@ -1,12 +1,13 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "base/message_loop.h" #include "base/utf_string_conversions.h" -#include "chrome/browser/automation/ui_controls.h" #include "chrome/test/base/view_event_test_base.h" +#include "chrome/test/base/ui_test_utils.h" #include "ui/base/models/simple_menu_model.h" +#include "ui/ui_controls/ui_controls.h" #include "ui/views/controls/button/button_dropdown.h" class ButtonDropDownDragTest : public ViewEventTestBase, @@ -70,7 +71,7 @@ class ButtonDropDownDragTest : public ViewEventTestBase, // ViewEventTestBase implementation. virtual void DoTestOnMessageLoop() OVERRIDE { // Click on the ButtonDropDown. - ui_controls::MoveMouseToCenterAndPress( + ui_test_utils::MoveMouseToCenterAndPress( button_, ui_controls::LEFT, ui_controls::DOWN, @@ -101,7 +102,7 @@ class ButtonDropDownDragTest : public ViewEventTestBase, void Step3() { // Click mouse to dismiss menu. The views menu does not dismiss the // menu on click-drag-release unless an item is selected. - ui_controls::MoveMouseToCenterAndPress( + ui_test_utils::MoveMouseToCenterAndPress( button_, ui_controls::LEFT, ui_controls::DOWN | ui_controls::UP, diff --git a/chrome/browser/ui/views/frame/browser_view.cc b/chrome/browser/ui/views/frame/browser_view.cc index f81f4a7..5b6c5c7 100644 --- a/chrome/browser/ui/views/frame/browser_view.cc +++ b/chrome/browser/ui/views/frame/browser_view.cc @@ -20,7 +20,6 @@ #include "chrome/app/chrome_dll_resource.h" #include "chrome/browser/autocomplete/autocomplete_popup_model.h" #include "chrome/browser/autocomplete/autocomplete_popup_view.h" -#include "chrome/browser/automation/ui_controls.h" #include "chrome/browser/bookmarks/bookmark_utils.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/debugger/devtools_window.h" @@ -93,6 +92,7 @@ #include "ui/base/l10n/l10n_util.h" #include "ui/base/resource/resource_bundle.h" #include "ui/gfx/canvas.h" +#include "ui/ui_controls/ui_controls.h" #include "ui/views/controls/single_split_view.h" #include "ui/views/events/event.h" #include "ui/views/focus/external_focus_tracker.h" diff --git a/chrome/browser/ui/views/menu_item_view_test.cc b/chrome/browser/ui/views/menu_item_view_test.cc index 8f60856..cc75dd9 100644 --- a/chrome/browser/ui/views/menu_item_view_test.cc +++ b/chrome/browser/ui/views/menu_item_view_test.cc @@ -4,8 +4,9 @@ #include "base/callback.h" #include "base/utf_string_conversions.h" -#include "chrome/browser/automation/ui_controls.h" #include "chrome/test/base/view_event_test_base.h" +#include "chrome/test/base/ui_test_utils.h" +#include "ui/ui_controls/ui_controls.h" #include "ui/views/controls/button/menu_button.h" #include "ui/views/controls/button/menu_button_listener.h" #include "ui/views/controls/menu/menu_controller.h" @@ -85,7 +86,7 @@ class MenuItemViewTestBase : public ViewEventTestBase, protected: // Generate a mouse click on the specified view and post a new task. virtual void Click(views::View* view, const base::Closure& next) { - ui_controls::MoveMouseToCenterAndPress( + ui_test_utils::MoveMouseToCenterAndPress( view, ui_controls::LEFT, ui_controls::DOWN | ui_controls::UP, diff --git a/chrome/browser/ui/views/menu_model_adapter_test.cc b/chrome/browser/ui/views/menu_model_adapter_test.cc index 3d78504..d98966a 100644 --- a/chrome/browser/ui/views/menu_model_adapter_test.cc +++ b/chrome/browser/ui/views/menu_model_adapter_test.cc @@ -4,9 +4,10 @@ #include "base/callback.h" #include "base/utf_string_conversions.h" -#include "chrome/browser/automation/ui_controls.h" #include "chrome/test/base/view_event_test_base.h" +#include "chrome/test/base/ui_test_utils.h" #include "ui/base/models/menu_model.h" +#include "ui/ui_controls/ui_controls.h" #include "ui/views/controls/button/menu_button.h" #include "ui/views/controls/button/menu_button_listener.h" #include "ui/views/controls/menu/menu_controller.h" @@ -358,7 +359,7 @@ class MenuModelAdapterTest : public ViewEventTestBase, private: // Generate a mouse click on the specified view and post a new task. virtual void Click(views::View* view, const base::Closure& next) { - ui_controls::MoveMouseToCenterAndPress( + ui_test_utils::MoveMouseToCenterAndPress( view, ui_controls::LEFT, ui_controls::DOWN | ui_controls::UP, diff --git a/chrome/browser/ui/views/tabs/tab_drag_controller2_interactive_uitest.cc b/chrome/browser/ui/views/tabs/tab_drag_controller2_interactive_uitest.cc index 1f5a2ea..77df1f0 100644 --- a/chrome/browser/ui/views/tabs/tab_drag_controller2_interactive_uitest.cc +++ b/chrome/browser/ui/views/tabs/tab_drag_controller2_interactive_uitest.cc @@ -9,7 +9,6 @@ #include "base/command_line.h" #include "base/property_bag.h" #include "base/string_number_conversions.h" -#include "chrome/browser/automation/ui_controls.h" #include "chrome/browser/tabs/tab_strip_model.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_list.h" @@ -25,6 +24,7 @@ #include "content/public/browser/notification_service.h" #include "content/public/browser/notification_source.h" #include "content/public/browser/web_contents.h" +#include "ui/ui_controls/ui_controls.h" #include "ui/gfx/screen.h" #include "ui/views/view.h" #include "ui/views/widget/widget.h" |