OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/automation/automation_provider.h" | 5 #include "chrome/browser/automation/automation_provider.h" |
6 | 6 |
7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 // TODO(estade): don't ignore |flags| or |escape_en_route|. | 46 // TODO(estade): don't ignore |flags| or |escape_en_route|. |
47 gfx::NativeWindow window = | 47 gfx::NativeWindow window = |
48 browser_tracker_->GetResource(handle)->window()->GetNativeHandle(); | 48 browser_tracker_->GetResource(handle)->window()->GetNativeHandle(); |
49 if (window && (drag_path.size() > 1)) { | 49 if (window && (drag_path.size() > 1)) { |
50 int x, y; | 50 int x, y; |
51 gdk_window_get_position(gtk_widget_get_window(GTK_WIDGET(window)), &x, &y); | 51 gdk_window_get_position(gtk_widget_get_window(GTK_WIDGET(window)), &x, &y); |
52 | 52 |
53 // Create a nested stack of tasks to run. | 53 // Create a nested stack of tasks to run. |
54 base::Closure drag_response_cb = base::Bind( | 54 base::Closure drag_response_cb = base::Bind( |
55 &SendWindowDragResponse, make_scoped_refptr(this), reply_message); | 55 &SendWindowDragResponse, make_scoped_refptr(this), reply_message); |
56 base::Closure move_chain_cb = base::IgnoreReturn<bool>( | 56 base::Closure move_chain_cb = base::Bind( |
57 base::Bind(&ui_controls::SendMouseEventsNotifyWhenDone, | 57 base::IgnoreResult(&ui_controls::SendMouseEventsNotifyWhenDone), |
58 ui_controls::LEFT, ui_controls::UP, drag_response_cb)); | 58 ui_controls::LEFT, ui_controls::UP, drag_response_cb); |
59 move_chain_cb = base::IgnoreReturn<bool>( | 59 move_chain_cb = base::Bind( |
60 base::Bind(&ui_controls::SendMouseEventsNotifyWhenDone, | 60 base::IgnoreResult(&ui_controls::SendMouseEventsNotifyWhenDone), |
61 ui_controls::LEFT, ui_controls::UP, move_chain_cb)); | 61 ui_controls::LEFT, ui_controls::UP, move_chain_cb); |
62 for (size_t i = drag_path.size() - 1; i > 0; --i) { | 62 for (size_t i = drag_path.size() - 1; i > 0; --i) { |
63 // Smooth out the mouse movements by adding intermediate points. This | 63 // Smooth out the mouse movements by adding intermediate points. This |
64 // better simulates a real user drag. | 64 // better simulates a real user drag. |
65 int dest_x = drag_path[i].x() + x; | 65 int dest_x = drag_path[i].x() + x; |
66 int dest_y = drag_path[i].y() + y; | 66 int dest_y = drag_path[i].y() + y; |
67 int half_step_x = (dest_x + drag_path[i - 1].x() + x) / 2; | 67 int half_step_x = (dest_x + drag_path[i - 1].x() + x) / 2; |
68 int half_step_y = (dest_y + drag_path[i - 1].y() + y) / 2; | 68 int half_step_y = (dest_y + drag_path[i - 1].y() + y) / 2; |
69 | 69 |
70 move_chain_cb = base::IgnoreReturn<bool>( | 70 move_chain_cb = base::Bind( |
71 base::Bind(&ui_controls::SendMouseMoveNotifyWhenDone, dest_x, dest_y, | 71 base::IgnoreResult(&ui_controls::SendMouseMoveNotifyWhenDone), |
72 move_chain_cb)); | 72 dest_x, dest_y, move_chain_cb); |
73 move_chain_cb = base::IgnoreReturn<bool>( | 73 move_chain_cb = base::Bind( |
74 base::Bind(&ui_controls::SendMouseMoveNotifyWhenDone, half_step_x, | 74 base::IgnoreResult(&ui_controls::SendMouseMoveNotifyWhenDone), |
75 half_step_y, move_chain_cb)); | 75 half_step_x, half_step_y, move_chain_cb); |
76 } | 76 } |
77 move_chain_cb = base::IgnoreReturn<bool>( | 77 move_chain_cb = base::Bind( |
78 base::Bind(&ui_controls::SendMouseEventsNotifyWhenDone, | 78 base::IgnoreResult(&ui_controls::SendMouseEventsNotifyWhenDone), |
79 ui_controls::LEFT, ui_controls::DOWN, move_chain_cb)); | 79 ui_controls::LEFT, ui_controls::DOWN, move_chain_cb); |
80 | 80 |
81 ui_controls::SendMouseMoveNotifyWhenDone(x + drag_path[0].x(), | 81 ui_controls::SendMouseMoveNotifyWhenDone(x + drag_path[0].x(), |
82 y + drag_path[0].y(), | 82 y + drag_path[0].y(), |
83 move_chain_cb); | 83 move_chain_cb); |
84 } else { | 84 } else { |
85 AutomationMsg_WindowDrag::WriteReplyParams(reply_message, false); | 85 AutomationMsg_WindowDrag::WriteReplyParams(reply_message, false); |
86 Send(reply_message); | 86 Send(reply_message); |
87 } | 87 } |
88 } | 88 } |
OLD | NEW |