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

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

Issue 10388175: Remove all the unnused automation IPCs. These were used by UI tests that have been converted to bro… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 7 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 | Annotate | Revision Log
OLDNEW
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/testing_automation_provider.h" 5 #include "chrome/browser/automation/testing_automation_provider.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 8
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
11 #include "chrome/browser/automation/automation_browser_tracker.h" 11 #include "chrome/browser/automation/automation_browser_tracker.h"
12 #include "chrome/browser/automation/automation_window_tracker.h" 12 #include "chrome/browser/automation/automation_window_tracker.h"
13 #include "chrome/browser/ui/browser_window.h" 13 #include "chrome/browser/ui/browser_window.h"
14 14
15 void TestingAutomationProvider::ActivateWindow(int handle) {
16 if (window_tracker_->ContainsHandle(handle)) {
17 ::SetActiveWindow(window_tracker_->GetResource(handle));
18 }
19 }
20
21 void TestingAutomationProvider::IsWindowMaximized(int handle,
22 bool* is_maximized,
23 bool* success) {
24 *success = false;
25
26 HWND hwnd = window_tracker_->GetResource(handle);
27 if (hwnd) {
28 WINDOWPLACEMENT window_placement;
29 window_placement.length = sizeof(window_placement);
30 if (GetWindowPlacement(hwnd, &window_placement)) {
31 *success = true;
32 *is_maximized = (window_placement.showCmd == SW_MAXIMIZE);
33 }
34 }
35 }
36
37 void TestingAutomationProvider::TerminateSession(int handle, bool* success) { 15 void TestingAutomationProvider::TerminateSession(int handle, bool* success) {
38 *success = false; 16 *success = false;
39 17
40 if (browser_tracker_->ContainsHandle(handle)) { 18 if (browser_tracker_->ContainsHandle(handle)) {
41 Browser* browser = browser_tracker_->GetResource(handle); 19 Browser* browser = browser_tracker_->GetResource(handle);
42 HWND window = browser->window()->GetNativeHandle(); 20 HWND window = browser->window()->GetNativeHandle();
43 *success = (::PostMessageW(window, WM_ENDSESSION, 0, 0) == TRUE); 21 *success = (::PostMessageW(window, WM_ENDSESSION, 0, 0) == TRUE);
44 } 22 }
45 } 23 }
46 24
47 void TestingAutomationProvider::GetWindowBounds(int handle,
48 gfx::Rect* bounds,
49 bool* success) {
50 *success = false;
51 HWND hwnd = window_tracker_->GetResource(handle);
52 if (hwnd) {
53 WINDOWPLACEMENT window_placement;
54 window_placement.length = sizeof(window_placement);
55 if (GetWindowPlacement(hwnd, &window_placement)) {
56 *success = true;
57 *bounds = window_placement.rcNormalPosition;
58 }
59 }
60 }
61
62 void TestingAutomationProvider::SetWindowBounds(int handle, 25 void TestingAutomationProvider::SetWindowBounds(int handle,
63 const gfx::Rect& bounds, 26 const gfx::Rect& bounds,
64 bool* success) { 27 bool* success) {
65 *success = false; 28 *success = false;
66 if (window_tracker_->ContainsHandle(handle)) { 29 if (window_tracker_->ContainsHandle(handle)) {
67 HWND hwnd = window_tracker_->GetResource(handle); 30 HWND hwnd = window_tracker_->GetResource(handle);
68 if (::MoveWindow(hwnd, bounds.x(), bounds.y(), bounds.width(), 31 if (::MoveWindow(hwnd, bounds.x(), bounds.y(), bounds.width(),
69 bounds.height(), true)) { 32 bounds.height(), true)) {
70 *success = true; 33 *success = true;
71 } 34 }
72 } 35 }
73 } 36 }
74
75 void TestingAutomationProvider::SetWindowVisible(int handle,
76 bool visible,
77 bool* result) {
78 if (window_tracker_->ContainsHandle(handle)) {
79 HWND hwnd = window_tracker_->GetResource(handle);
80 ::ShowWindow(hwnd, visible ? SW_SHOW : SW_HIDE);
81 *result = true;
82 } else {
83 *result = false;
84 }
85 }
86
87 void TestingAutomationProvider::GetWindowTitle(int handle, string16* text) {
88 gfx::NativeWindow window = window_tracker_->GetResource(handle);
89 int length = ::GetWindowTextLength(window) + 1;
90 if (length > 1)
91 ::GetWindowText(window, WriteInto(text, length), length);
92 else
93 text->clear();
94 }
95
OLDNEW
« no previous file with comments | « chrome/browser/automation/testing_automation_provider_mac.mm ('k') | chrome/common/automation_messages_internal.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698