| OLD | NEW |
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "app/message_box_flags.h" | 8 #include "app/message_box_flags.h" |
| 9 #include "base/file_version_info.h" | 9 #include "base/file_version_info.h" |
| 10 #include "base/json_reader.h" | 10 #include "base/json_reader.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 | 67 |
| 68 #if defined(OS_WIN) | 68 #if defined(OS_WIN) |
| 69 #include "chrome/browser/views/bookmark_bar_view.h" | 69 #include "chrome/browser/views/bookmark_bar_view.h" |
| 70 #include "views/widget/root_view.h" | 70 #include "views/widget/root_view.h" |
| 71 #include "views/widget/widget_win.h" | 71 #include "views/widget/widget_win.h" |
| 72 #include "views/window/window.h" | 72 #include "views/window/window.h" |
| 73 #endif | 73 #endif |
| 74 | 74 |
| 75 using base::Time; | 75 using base::Time; |
| 76 | 76 |
| 77 #if defined(OS_WIN) |
| 78 static void MoveMouse(const POINT& point) { |
| 79 SetCursorPos(point.x, point.y); |
| 80 |
| 81 // Now, make sure that GetMessagePos returns the values we just set by |
| 82 // simulating a mouse move. The value returned by GetMessagePos is updated |
| 83 // when a mouse move event is removed from the event queue. |
| 84 PostMessage(NULL, WM_MOUSEMOVE, 0, MAKELPARAM(point.x, point.y)); |
| 85 MSG msg; |
| 86 while (PeekMessage(&msg, NULL, WM_MOUSEMOVE, WM_MOUSEMOVE, PM_REMOVE)) |
| 87 ; |
| 88 |
| 89 // Verify |
| 90 #ifndef NDEBUG |
| 91 DWORD pos = GetMessagePos(); |
| 92 DCHECK_EQ(point.x, GET_X_LPARAM(pos)); |
| 93 DCHECK_EQ(point.y, GET_Y_LPARAM(pos)); |
| 94 #endif |
| 95 } |
| 96 #endif |
| 97 |
| 77 class InitialLoadObserver : public NotificationObserver { | 98 class InitialLoadObserver : public NotificationObserver { |
| 78 public: | 99 public: |
| 79 InitialLoadObserver(size_t tab_count, AutomationProvider* automation) | 100 InitialLoadObserver(size_t tab_count, AutomationProvider* automation) |
| 80 : automation_(automation), | 101 : automation_(automation), |
| 81 outstanding_tab_count_(tab_count) { | 102 outstanding_tab_count_(tab_count) { |
| 82 if (outstanding_tab_count_ > 0) { | 103 if (outstanding_tab_count_ > 0) { |
| 83 registrar_.Add(this, NotificationType::LOAD_START, | 104 registrar_.Add(this, NotificationType::LOAD_START, |
| 84 NotificationService::AllSources()); | 105 NotificationService::AllSources()); |
| 85 registrar_.Add(this, NotificationType::LOAD_STOP, | 106 registrar_.Add(this, NotificationType::LOAD_STOP, |
| 86 NotificationService::AllSources()); | 107 NotificationService::AllSources()); |
| (...skipping 1410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1497 virtual void Run() { | 1518 virtual void Run() { |
| 1498 views::MouseEvent event(type_, point_.x, point_.y, flags_); | 1519 views::MouseEvent event(type_, point_.x, point_.y, flags_); |
| 1499 // We need to set the cursor position before we process the event because | 1520 // We need to set the cursor position before we process the event because |
| 1500 // some code (tab dragging, for instance) queries the actual cursor location | 1521 // some code (tab dragging, for instance) queries the actual cursor location |
| 1501 // rather than the location of the mouse event. Note that the reason why | 1522 // rather than the location of the mouse event. Note that the reason why |
| 1502 // the drag code moved away from using mouse event locations was because | 1523 // the drag code moved away from using mouse event locations was because |
| 1503 // our conversion to screen location doesn't work well with multiple | 1524 // our conversion to screen location doesn't work well with multiple |
| 1504 // monitors, so this only works reliably in a single monitor setup. | 1525 // monitors, so this only works reliably in a single monitor setup. |
| 1505 gfx::Point screen_location(point_.x, point_.y); | 1526 gfx::Point screen_location(point_.x, point_.y); |
| 1506 view_->ConvertPointToScreen(view_, &screen_location); | 1527 view_->ConvertPointToScreen(view_, &screen_location); |
| 1507 ::SetCursorPos(screen_location.x(), screen_location.y()); | 1528 MoveMouse(screen_location.ToPOINT()); |
| 1508 switch (type_) { | 1529 switch (type_) { |
| 1509 case views::Event::ET_MOUSE_PRESSED: | 1530 case views::Event::ET_MOUSE_PRESSED: |
| 1510 view_->OnMousePressed(event); | 1531 view_->OnMousePressed(event); |
| 1511 break; | 1532 break; |
| 1512 | 1533 |
| 1513 case views::Event::ET_MOUSE_DRAGGED: | 1534 case views::Event::ET_MOUSE_DRAGGED: |
| 1514 view_->OnMouseDragged(event); | 1535 view_->OnMouseDragged(event); |
| 1515 break; | 1536 break; |
| 1516 | 1537 |
| 1517 case views::Event::ET_MOUSE_RELEASED: | 1538 case views::Event::ET_MOUSE_RELEASED: |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1645 down_message = WM_LBUTTONDOWN; | 1666 down_message = WM_LBUTTONDOWN; |
| 1646 up_message = WM_LBUTTONUP; | 1667 up_message = WM_LBUTTONUP; |
| 1647 } | 1668 } |
| 1648 | 1669 |
| 1649 Browser* browser = browser_tracker_->GetResource(handle); | 1670 Browser* browser = browser_tracker_->GetResource(handle); |
| 1650 DCHECK(browser); | 1671 DCHECK(browser); |
| 1651 HWND top_level_hwnd = | 1672 HWND top_level_hwnd = |
| 1652 reinterpret_cast<HWND>(browser->window()->GetNativeHandle()); | 1673 reinterpret_cast<HWND>(browser->window()->GetNativeHandle()); |
| 1653 POINT temp = drag_path[0]; | 1674 POINT temp = drag_path[0]; |
| 1654 MapWindowPoints(top_level_hwnd, HWND_DESKTOP, &temp, 1); | 1675 MapWindowPoints(top_level_hwnd, HWND_DESKTOP, &temp, 1); |
| 1655 SetCursorPos(temp.x, temp.y); | 1676 MoveMouse(temp); |
| 1656 SendMessage(top_level_hwnd, down_message, wparam_flags, | 1677 SendMessage(top_level_hwnd, down_message, wparam_flags, |
| 1657 MAKELPARAM(drag_path[0].x, drag_path[0].y)); | 1678 MAKELPARAM(drag_path[0].x, drag_path[0].y)); |
| 1658 for (int i = 1; i < static_cast<int>(drag_path.size()); ++i) { | 1679 for (int i = 1; i < static_cast<int>(drag_path.size()); ++i) { |
| 1659 temp = drag_path[i]; | 1680 temp = drag_path[i]; |
| 1660 MapWindowPoints(top_level_hwnd, HWND_DESKTOP, &temp, 1); | 1681 MapWindowPoints(top_level_hwnd, HWND_DESKTOP, &temp, 1); |
| 1661 SetCursorPos(temp.x, temp.y); | 1682 MoveMouse(temp); |
| 1662 SendMessage(top_level_hwnd, WM_MOUSEMOVE, wparam_flags, | 1683 SendMessage(top_level_hwnd, WM_MOUSEMOVE, wparam_flags, |
| 1663 MAKELPARAM(drag_path[i].x, drag_path[i].y)); | 1684 MAKELPARAM(drag_path[i].x, drag_path[i].y)); |
| 1664 } | 1685 } |
| 1665 POINT end = drag_path[drag_path.size() - 1]; | 1686 POINT end = drag_path[drag_path.size() - 1]; |
| 1666 MapWindowPoints(top_level_hwnd, HWND_DESKTOP, &end, 1); | 1687 MapWindowPoints(top_level_hwnd, HWND_DESKTOP, &end, 1); |
| 1667 SetCursorPos(end.x, end.y); | 1688 MoveMouse(end); |
| 1668 | 1689 |
| 1669 if (press_escape_en_route) { | 1690 if (press_escape_en_route) { |
| 1670 // Press Escape. | 1691 // Press Escape. |
| 1671 ui_controls::SendKeyPress(VK_ESCAPE, | 1692 ui_controls::SendKeyPress(VK_ESCAPE, |
| 1672 ((flags & views::Event::EF_CONTROL_DOWN) | 1693 ((flags & views::Event::EF_CONTROL_DOWN) |
| 1673 == views::Event::EF_CONTROL_DOWN), | 1694 == views::Event::EF_CONTROL_DOWN), |
| 1674 ((flags & views::Event::EF_SHIFT_DOWN) == | 1695 ((flags & views::Event::EF_SHIFT_DOWN) == |
| 1675 views::Event::EF_SHIFT_DOWN), | 1696 views::Event::EF_SHIFT_DOWN), |
| 1676 ((flags & views::Event::EF_ALT_DOWN) == | 1697 ((flags & views::Event::EF_ALT_DOWN) == |
| 1677 views::Event::EF_ALT_DOWN)); | 1698 views::Event::EF_ALT_DOWN)); |
| (...skipping 1391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3069 NOTREACHED(); | 3090 NOTREACHED(); |
| 3070 return NULL; | 3091 return NULL; |
| 3071 } | 3092 } |
| 3072 | 3093 |
| 3073 RenderViewHost* view_host = tab_contents->render_view_host(); | 3094 RenderViewHost* view_host = tab_contents->render_view_host(); |
| 3074 return view_host; | 3095 return view_host; |
| 3075 } | 3096 } |
| 3076 | 3097 |
| 3077 return NULL; | 3098 return NULL; |
| 3078 } | 3099 } |
| OLD | NEW |