| 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 | 71 |
| 72 #if defined(OS_WIN) | 72 #if defined(OS_WIN) |
| 73 #include "chrome/browser/views/bookmark_bar_view.h" | 73 #include "chrome/browser/views/bookmark_bar_view.h" |
| 74 #include "views/widget/root_view.h" | 74 #include "views/widget/root_view.h" |
| 75 #include "views/widget/widget_win.h" | 75 #include "views/widget/widget_win.h" |
| 76 #include "views/window/window.h" | 76 #include "views/window/window.h" |
| 77 #endif | 77 #endif |
| 78 | 78 |
| 79 using base::Time; | 79 using base::Time; |
| 80 | 80 |
| 81 #if defined(OS_WIN) |
| 82 static void MoveMouse(const POINT& point) { |
| 83 SetCursorPos(point.x, point.y); |
| 84 |
| 85 // Now, make sure that GetMessagePos returns the values we just set by |
| 86 // simulating a mouse move. The value returned by GetMessagePos is updated |
| 87 // when a mouse move event is removed from the event queue. |
| 88 PostMessage(NULL, WM_MOUSEMOVE, 0, MAKELPARAM(point.x, point.y)); |
| 89 MSG msg; |
| 90 while (PeekMessage(&msg, NULL, WM_MOUSEMOVE, WM_MOUSEMOVE, PM_REMOVE)) |
| 91 ; |
| 92 |
| 93 // Verify |
| 94 #ifndef NDEBUG |
| 95 DWORD pos = GetMessagePos(); |
| 96 DCHECK_EQ(point.x, GET_X_LPARAM(pos)); |
| 97 DCHECK_EQ(point.y, GET_Y_LPARAM(pos)); |
| 98 #endif |
| 99 } |
| 100 #endif |
| 101 |
| 81 class InitialLoadObserver : public NotificationObserver { | 102 class InitialLoadObserver : public NotificationObserver { |
| 82 public: | 103 public: |
| 83 InitialLoadObserver(size_t tab_count, AutomationProvider* automation) | 104 InitialLoadObserver(size_t tab_count, AutomationProvider* automation) |
| 84 : automation_(automation), | 105 : automation_(automation), |
| 85 outstanding_tab_count_(tab_count) { | 106 outstanding_tab_count_(tab_count) { |
| 86 if (outstanding_tab_count_ > 0) { | 107 if (outstanding_tab_count_ > 0) { |
| 87 registrar_.Add(this, NotificationType::LOAD_START, | 108 registrar_.Add(this, NotificationType::LOAD_START, |
| 88 NotificationService::AllSources()); | 109 NotificationService::AllSources()); |
| 89 registrar_.Add(this, NotificationType::LOAD_STOP, | 110 registrar_.Add(this, NotificationType::LOAD_STOP, |
| 90 NotificationService::AllSources()); | 111 NotificationService::AllSources()); |
| (...skipping 1405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1496 virtual void Run() { | 1517 virtual void Run() { |
| 1497 views::MouseEvent event(type_, point_.x, point_.y, flags_); | 1518 views::MouseEvent event(type_, point_.x, point_.y, flags_); |
| 1498 // We need to set the cursor position before we process the event because | 1519 // We need to set the cursor position before we process the event because |
| 1499 // some code (tab dragging, for instance) queries the actual cursor location | 1520 // some code (tab dragging, for instance) queries the actual cursor location |
| 1500 // rather than the location of the mouse event. Note that the reason why | 1521 // rather than the location of the mouse event. Note that the reason why |
| 1501 // the drag code moved away from using mouse event locations was because | 1522 // the drag code moved away from using mouse event locations was because |
| 1502 // our conversion to screen location doesn't work well with multiple | 1523 // our conversion to screen location doesn't work well with multiple |
| 1503 // monitors, so this only works reliably in a single monitor setup. | 1524 // monitors, so this only works reliably in a single monitor setup. |
| 1504 gfx::Point screen_location(point_.x, point_.y); | 1525 gfx::Point screen_location(point_.x, point_.y); |
| 1505 view_->ConvertPointToScreen(view_, &screen_location); | 1526 view_->ConvertPointToScreen(view_, &screen_location); |
| 1506 ::SetCursorPos(screen_location.x(), screen_location.y()); | 1527 MoveMouse(screen_location.ToPOINT()); |
| 1507 switch (type_) { | 1528 switch (type_) { |
| 1508 case views::Event::ET_MOUSE_PRESSED: | 1529 case views::Event::ET_MOUSE_PRESSED: |
| 1509 view_->OnMousePressed(event); | 1530 view_->OnMousePressed(event); |
| 1510 break; | 1531 break; |
| 1511 | 1532 |
| 1512 case views::Event::ET_MOUSE_DRAGGED: | 1533 case views::Event::ET_MOUSE_DRAGGED: |
| 1513 view_->OnMouseDragged(event); | 1534 view_->OnMouseDragged(event); |
| 1514 break; | 1535 break; |
| 1515 | 1536 |
| 1516 case views::Event::ET_MOUSE_RELEASED: | 1537 case views::Event::ET_MOUSE_RELEASED: |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1644 down_message = WM_LBUTTONDOWN; | 1665 down_message = WM_LBUTTONDOWN; |
| 1645 up_message = WM_LBUTTONUP; | 1666 up_message = WM_LBUTTONUP; |
| 1646 } | 1667 } |
| 1647 | 1668 |
| 1648 Browser* browser = browser_tracker_->GetResource(handle); | 1669 Browser* browser = browser_tracker_->GetResource(handle); |
| 1649 DCHECK(browser); | 1670 DCHECK(browser); |
| 1650 HWND top_level_hwnd = | 1671 HWND top_level_hwnd = |
| 1651 reinterpret_cast<HWND>(browser->window()->GetNativeHandle()); | 1672 reinterpret_cast<HWND>(browser->window()->GetNativeHandle()); |
| 1652 POINT temp = drag_path[0]; | 1673 POINT temp = drag_path[0]; |
| 1653 MapWindowPoints(top_level_hwnd, HWND_DESKTOP, &temp, 1); | 1674 MapWindowPoints(top_level_hwnd, HWND_DESKTOP, &temp, 1); |
| 1654 SetCursorPos(temp.x, temp.y); | 1675 MoveMouse(temp); |
| 1655 SendMessage(top_level_hwnd, down_message, wparam_flags, | 1676 SendMessage(top_level_hwnd, down_message, wparam_flags, |
| 1656 MAKELPARAM(drag_path[0].x, drag_path[0].y)); | 1677 MAKELPARAM(drag_path[0].x, drag_path[0].y)); |
| 1657 for (int i = 1; i < static_cast<int>(drag_path.size()); ++i) { | 1678 for (int i = 1; i < static_cast<int>(drag_path.size()); ++i) { |
| 1658 temp = drag_path[i]; | 1679 temp = drag_path[i]; |
| 1659 MapWindowPoints(top_level_hwnd, HWND_DESKTOP, &temp, 1); | 1680 MapWindowPoints(top_level_hwnd, HWND_DESKTOP, &temp, 1); |
| 1660 SetCursorPos(temp.x, temp.y); | 1681 MoveMouse(temp); |
| 1661 SendMessage(top_level_hwnd, WM_MOUSEMOVE, wparam_flags, | 1682 SendMessage(top_level_hwnd, WM_MOUSEMOVE, wparam_flags, |
| 1662 MAKELPARAM(drag_path[i].x, drag_path[i].y)); | 1683 MAKELPARAM(drag_path[i].x, drag_path[i].y)); |
| 1663 } | 1684 } |
| 1664 POINT end = drag_path[drag_path.size() - 1]; | 1685 POINT end = drag_path[drag_path.size() - 1]; |
| 1665 MapWindowPoints(top_level_hwnd, HWND_DESKTOP, &end, 1); | 1686 MapWindowPoints(top_level_hwnd, HWND_DESKTOP, &end, 1); |
| 1666 SetCursorPos(end.x, end.y); | 1687 MoveMouse(end); |
| 1667 | 1688 |
| 1668 if (press_escape_en_route) { | 1689 if (press_escape_en_route) { |
| 1669 // Press Escape. | 1690 // Press Escape. |
| 1670 ui_controls::SendKeyPress(VK_ESCAPE, | 1691 ui_controls::SendKeyPress(VK_ESCAPE, |
| 1671 ((flags & views::Event::EF_CONTROL_DOWN) | 1692 ((flags & views::Event::EF_CONTROL_DOWN) |
| 1672 == views::Event::EF_CONTROL_DOWN), | 1693 == views::Event::EF_CONTROL_DOWN), |
| 1673 ((flags & views::Event::EF_SHIFT_DOWN) == | 1694 ((flags & views::Event::EF_SHIFT_DOWN) == |
| 1674 views::Event::EF_SHIFT_DOWN), | 1695 views::Event::EF_SHIFT_DOWN), |
| 1675 ((flags & views::Event::EF_ALT_DOWN) == | 1696 ((flags & views::Event::EF_ALT_DOWN) == |
| 1676 views::Event::EF_ALT_DOWN)); | 1697 views::Event::EF_ALT_DOWN)); |
| (...skipping 1353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3030 if (container) { | 3051 if (container) { |
| 3031 *count = static_cast<int>(container->GetBlockedPopupCount()); | 3052 *count = static_cast<int>(container->GetBlockedPopupCount()); |
| 3032 } else { | 3053 } else { |
| 3033 // If we don't have a container, we don't have any blocked popups to | 3054 // If we don't have a container, we don't have any blocked popups to |
| 3034 // contain! | 3055 // contain! |
| 3035 *count = 0; | 3056 *count = 0; |
| 3036 } | 3057 } |
| 3037 } | 3058 } |
| 3038 } | 3059 } |
| 3039 } | 3060 } |
| OLD | NEW |