Home | History | Annotate | Download | only in automation
      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.
      4 
      5 #include "chrome/browser/automation/testing_automation_provider.h"
      6 
      7 #include <windows.h>
      8 
      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"
     15 
     16 void TestingAutomationProvider::TerminateSession(int handle, bool* success) {
     17   *success = false;
     18 
     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);
     23   }
     24 }
     25 
     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;
     35     }
     36   }
     37 }
     38