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"
9 #include "base/logging.h"
10 #include "base/utf_string_conversions.h"
11 #include "chrome/browser/automation/automation_window_tracker.h"
12 #include "chrome/browser/ui/gtk/view_id_util.h"
13 #include "ui/base/gtk/gtk_screen_util.h"
15 void TestingAutomationProvider::TerminateSession(int handle
, bool* success
) {
20 void TestingAutomationProvider::WindowGetViewBounds(int handle
,
22 bool screen_coordinates
,
27 GtkWindow
* window
= window_tracker_
->GetResource(handle
);
29 GtkWidget
* widget
= ViewIDUtil::GetWidget(GTK_WIDGET(window
),
30 static_cast<ViewID
>(view_id
));
35 GtkAllocation allocation
;
36 gtk_widget_get_allocation(widget
, &allocation
);
37 *bounds
= gfx::Rect(allocation
.width
, allocation
.height
);
39 if (screen_coordinates
) {
40 origin
= gfx::PointAtOffsetFromOrigin(ui::GetWidgetScreenOffset(widget
));
43 gtk_widget_translate_coordinates(widget
, GTK_WIDGET(window
),
45 origin
= gfx::Point(x
, y
);
47 bounds
->set_origin(origin
);
51 void TestingAutomationProvider::SetWindowBounds(int handle
,
52 const gfx::Rect
& bounds
,
55 GtkWindow
* window
= window_tracker_
->GetResource(handle
);
57 gtk_window_move(window
, bounds
.x(), bounds
.height());
58 gtk_window_resize(window
, bounds
.width(), bounds
.height());