OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "base/keyboard_codes.h" | 7 #include "base/keyboard_codes.h" |
8 #include "chrome/browser/automation/ui_controls.h" | 8 #include "chrome/browser/automation/ui_controls.h" |
9 #include "chrome/browser/browser_window.h" | 9 #include "chrome/browser/browser_window.h" |
10 #include "chrome/browser/external_tab_container.h" | 10 #include "chrome/browser/external_tab_container.h" |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 reinterpret_cast<LPARAM>(window))) { | 68 reinterpret_cast<LPARAM>(window))) { |
69 // We enumerated all the windows and did not find the foreground window, | 69 // We enumerated all the windows and did not find the foreground window, |
70 // it is not our window, ignore it. | 70 // it is not our window, ignore it. |
71 *handle = 0; | 71 *handle = 0; |
72 return; | 72 return; |
73 } | 73 } |
74 | 74 |
75 *handle = window_tracker_->Add(window); | 75 *handle = window_tracker_->Add(window); |
76 } | 76 } |
77 | 77 |
78 void AutomationProvider::WindowGetViewBounds(int handle, int view_id, | |
79 bool screen_coordinates, | |
80 bool* success, | |
81 gfx::Rect* bounds) { | |
82 *success = false; | |
83 if (window_tracker_->ContainsHandle(handle)) { | |
84 gfx::NativeWindow window = window_tracker_->GetResource(handle); | |
85 views::RootView* root_view = views::WidgetWin::FindRootView(window); | |
86 if (root_view) { | |
87 views::View* view = root_view->GetViewByID(view_id); | |
88 if (view) { | |
89 *success = true; | |
90 gfx::Point point; | |
91 if (screen_coordinates) | |
92 views::View::ConvertPointToScreen(view, &point); | |
93 else | |
94 views::View::ConvertPointToView(view, root_view, &point); | |
95 *bounds = view->GetLocalBounds(false); | |
96 bounds->set_origin(point); | |
97 } | |
98 } | |
99 } | |
100 } | |
101 | |
102 // This task enqueues a mouse event on the event loop, so that the view | 78 // This task enqueues a mouse event on the event loop, so that the view |
103 // that it's being sent to can do the requisite post-processing. | 79 // that it's being sent to can do the requisite post-processing. |
104 class MouseEventTask : public Task { | 80 class MouseEventTask : public Task { |
105 public: | 81 public: |
106 MouseEventTask(views::View* view, | 82 MouseEventTask(views::View* view, |
107 views::Event::EventType type, | 83 views::Event::EventType type, |
108 const gfx::Point& point, | 84 const gfx::Point& point, |
109 int flags) | 85 int flags) |
110 : view_(view), type_(type), point_(point), flags_(flags) {} | 86 : view_(view), type_(type), point_(point), flags_(flags) {} |
111 virtual ~MouseEventTask() {} | 87 virtual ~MouseEventTask() {} |
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
507 | 483 |
508 void AutomationProvider::TerminateSession(int handle, bool* success) { | 484 void AutomationProvider::TerminateSession(int handle, bool* success) { |
509 *success = false; | 485 *success = false; |
510 | 486 |
511 if (browser_tracker_->ContainsHandle(handle)) { | 487 if (browser_tracker_->ContainsHandle(handle)) { |
512 Browser* browser = browser_tracker_->GetResource(handle); | 488 Browser* browser = browser_tracker_->GetResource(handle); |
513 HWND window = browser->window()->GetNativeHandle(); | 489 HWND window = browser->window()->GetNativeHandle(); |
514 *success = (::PostMessageW(window, WM_ENDSESSION, 0, 0) == TRUE); | 490 *success = (::PostMessageW(window, WM_ENDSESSION, 0, 0) == TRUE); |
515 } | 491 } |
516 } | 492 } |
OLD | NEW |