OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/strings/string_util.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/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.h" | 13 #include "chrome/browser/ui/browser.h" |
14 #include "chrome/browser/ui/browser_window.h" | 14 #include "chrome/browser/ui/browser_window.h" |
15 | 15 |
16 void TestingAutomationProvider::TerminateSession(int handle, bool* success) { | 16 void TestingAutomationProvider::TerminateSession(int handle, bool* success) { |
17 *success = false; | 17 *success = false; |
18 | 18 |
19 if (browser_tracker_->ContainsHandle(handle)) { | 19 if (browser_tracker_->ContainsHandle(handle)) { |
20 Browser* browser = browser_tracker_->GetResource(handle); | 20 Browser* browser = browser_tracker_->GetResource(handle); |
21 HWND window = browser->window()->GetNativeWindow(); | 21 HWND window = browser->window()->GetNativeWindow(); |
22 *success = (::PostMessageW(window, WM_ENDSESSION, 0, 0) == TRUE); | 22 *success = (::PostMessageW(window, WM_ENDSESSION, 0, 0) == TRUE); |
23 } | 23 } |
24 } | 24 } |
25 | 25 |
26 void TestingAutomationProvider::SetWindowBounds(int handle, | 26 void TestingAutomationProvider::SetWindowBounds(int handle, |
27 const gfx::Rect& bounds, | 27 const gfx::Rect& bounds, |
28 bool* success) { | 28 bool* success) { |
29 *success = false; | 29 *success = false; |
30 if (window_tracker_->ContainsHandle(handle)) { | 30 if (window_tracker_->ContainsHandle(handle)) { |
31 HWND hwnd = window_tracker_->GetResource(handle); | 31 HWND hwnd = window_tracker_->GetResource(handle); |
32 if (::MoveWindow(hwnd, bounds.x(), bounds.y(), bounds.width(), | 32 if (::MoveWindow(hwnd, bounds.x(), bounds.y(), bounds.width(), |
33 bounds.height(), true)) { | 33 bounds.height(), true)) { |
34 *success = true; | 34 *success = true; |
35 } | 35 } |
36 } | 36 } |
37 } | 37 } |
OLD | NEW |