Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / automation / testing_automation_provider_win.cc
blobc47cc9ef05b3ba03d4642e1439e4f594e35ae511
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
3 // found in the LICENSE file.
5 #include "chrome/browser/automation/testing_automation_provider.h"
7 #include <windows.h>
9 #include "base/strings/string_util.h"
10 #include "base/strings/utf_string_conversions.h"
11 #include "chrome/browser/automation/automation_browser_tracker.h"
12 #include "chrome/browser/automation/automation_window_tracker.h"
13 #include "chrome/browser/ui/browser.h"
14 #include "chrome/browser/ui/browser_window.h"
16 void TestingAutomationProvider::TerminateSession(int handle, bool* success) {
17 *success = false;
19 if (browser_tracker_->ContainsHandle(handle)) {
20 Browser* browser = browser_tracker_->GetResource(handle);
21 HWND window = browser->window()->GetNativeWindow();
22 *success = (::PostMessageW(window, WM_ENDSESSION, 0, 0) == TRUE);
26 void TestingAutomationProvider::SetWindowBounds(int handle,
27 const gfx::Rect& bounds,
28 bool* success) {
29 *success = false;
30 if (window_tracker_->ContainsHandle(handle)) {
31 HWND hwnd = window_tracker_->GetResource(handle);
32 if (::MoveWindow(hwnd, bounds.x(), bounds.y(), bounds.width(),
33 bounds.height(), true)) {
34 *success = true;