Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(800)

Side by Side Diff: chrome/browser/automation/automation_provider_win.cc

Issue 3191015: GTTF: next batch of automation separation. (Closed)
Patch Set: tryservers Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/json/json_reader.h" 7 #include "base/json/json_reader.h"
8 #include "base/keyboard_codes.h" 8 #include "base/keyboard_codes.h"
9 #include "base/trace_event.h" 9 #include "base/trace_event.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 #endif 66 #endif
67 } 67 }
68 68
69 BOOL CALLBACK EnumThreadWndProc(HWND hwnd, LPARAM l_param) { 69 BOOL CALLBACK EnumThreadWndProc(HWND hwnd, LPARAM l_param) {
70 if (hwnd == reinterpret_cast<HWND>(l_param)) { 70 if (hwnd == reinterpret_cast<HWND>(l_param)) {
71 return FALSE; 71 return FALSE;
72 } 72 }
73 return TRUE; 73 return TRUE;
74 } 74 }
75 75
76 void AutomationProvider::GetActiveWindow(int* handle) {
77 HWND window = GetForegroundWindow();
78
79 // Let's make sure this window belongs to our process.
80 if (EnumThreadWindows(::GetCurrentThreadId(),
81 EnumThreadWndProc,
82 reinterpret_cast<LPARAM>(window))) {
83 // We enumerated all the windows and did not find the foreground window,
84 // it is not our window, ignore it.
85 *handle = 0;
86 return;
87 }
88
89 *handle = window_tracker_->Add(window);
90 }
91
92 // This task enqueues a mouse event on the event loop, so that the view 76 // This task enqueues a mouse event on the event loop, so that the view
93 // that it's being sent to can do the requisite post-processing. 77 // that it's being sent to can do the requisite post-processing.
94 class MouseEventTask : public Task { 78 class MouseEventTask : public Task {
95 public: 79 public:
96 MouseEventTask(views::View* view, 80 MouseEventTask(views::View* view,
97 views::Event::EventType type, 81 views::Event::EventType type,
98 const gfx::Point& point, 82 const gfx::Point& point,
99 int flags) 83 int flags)
100 : view_(view), type_(type), point_(point), flags_(flags) {} 84 : view_(view), type_(type), point_(point), flags_(flags) {}
101 virtual ~MouseEventTask() {} 85 virtual ~MouseEventTask() {}
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 bool* result) { 248 bool* result) {
265 if (window_tracker_->ContainsHandle(handle)) { 249 if (window_tracker_->ContainsHandle(handle)) {
266 HWND hwnd = window_tracker_->GetResource(handle); 250 HWND hwnd = window_tracker_->GetResource(handle);
267 ::ShowWindow(hwnd, visible ? SW_SHOW : SW_HIDE); 251 ::ShowWindow(hwnd, visible ? SW_SHOW : SW_HIDE);
268 *result = true; 252 *result = true;
269 } else { 253 } else {
270 *result = false; 254 *result = false;
271 } 255 }
272 } 256 }
273 257
274 void AutomationProvider::ActivateWindow(int handle) {
275 if (window_tracker_->ContainsHandle(handle)) {
276 ::SetActiveWindow(window_tracker_->GetResource(handle));
277 }
278 }
279
280 void AutomationProvider::IsWindowMaximized(int handle, bool* is_maximized,
281 bool* success) {
282 *success = false;
283
284 HWND hwnd = window_tracker_->GetResource(handle);
285 if (hwnd) {
286 *success = true;
287 WINDOWPLACEMENT window_placement;
288 GetWindowPlacement(hwnd, &window_placement);
289 *is_maximized = (window_placement.showCmd == SW_MAXIMIZE);
290 }
291 }
292
293 void AutomationProvider::GetTabHWND(int handle, HWND* tab_hwnd) { 258 void AutomationProvider::GetTabHWND(int handle, HWND* tab_hwnd) {
294 *tab_hwnd = NULL; 259 *tab_hwnd = NULL;
295 260
296 if (tab_tracker_->ContainsHandle(handle)) { 261 if (tab_tracker_->ContainsHandle(handle)) {
297 NavigationController* tab = tab_tracker_->GetResource(handle); 262 NavigationController* tab = tab_tracker_->GetResource(handle);
298 *tab_hwnd = tab->tab_contents()->GetNativeView(); 263 *tab_hwnd = tab->tab_contents()->GetNativeView();
299 } 264 }
300 } 265 }
301 266
302 void AutomationProvider::CreateExternalTab( 267 void AutomationProvider::CreateExternalTab(
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 581
617 void AutomationProvider::OnSetZoomLevel(int handle, int zoom_level) { 582 void AutomationProvider::OnSetZoomLevel(int handle, int zoom_level) {
618 if (tab_tracker_->ContainsHandle(handle)) { 583 if (tab_tracker_->ContainsHandle(handle)) {
619 NavigationController* tab = tab_tracker_->GetResource(handle); 584 NavigationController* tab = tab_tracker_->GetResource(handle);
620 if (tab->tab_contents() && tab->tab_contents()->render_view_host()) { 585 if (tab->tab_contents() && tab->tab_contents()->render_view_host()) {
621 tab->tab_contents()->render_view_host()->Zoom( 586 tab->tab_contents()->render_view_host()->Zoom(
622 static_cast<PageZoom::Function>(zoom_level)); 587 static_cast<PageZoom::Function>(zoom_level));
623 } 588 }
624 } 589 }
625 } 590 }
OLDNEW
« no previous file with comments | « chrome/browser/automation/automation_provider_mac.mm ('k') | chrome/browser/automation/testing_automation_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698