OLD | NEW |
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 "chrome/browser/automation/automation_window_tracker.h" | 7 #include "chrome/browser/automation/automation_window_tracker.h" |
8 #include "ui/views/view.h" | 8 #include "ui/views/view.h" |
9 #include "ui/views/widget/widget.h" | 9 #include "ui/views/widget/widget.h" |
10 | 10 |
11 void TestingAutomationProvider::WindowGetViewBounds(int handle, | 11 void TestingAutomationProvider::WindowGetViewBounds(int handle, |
12 int view_id, | 12 int view_id, |
13 bool screen_coordinates, | 13 bool screen_coordinates, |
14 bool* success, | 14 bool* success, |
15 gfx::Rect* bounds) { | 15 gfx::Rect* bounds) { |
16 *success = false; | 16 *success = false; |
17 | 17 |
18 if (window_tracker_->ContainsHandle(handle)) { | 18 if (window_tracker_->ContainsHandle(handle)) { |
19 gfx::NativeWindow window = window_tracker_->GetResource(handle); | 19 gfx::NativeWindow window = window_tracker_->GetResource(handle); |
20 views::Widget* widget = views::Widget::GetWidgetForNativeWindow(window); | 20 views::Widget* widget = views::Widget::GetWidgetForNativeWindow(window); |
21 if (widget) { | 21 if (widget) { |
22 views::View* root_view = widget->GetRootView(); | 22 views::View* root_view = widget->GetRootView(); |
23 views::View* view = root_view->GetViewByID(view_id); | 23 views::View* view = root_view->GetViewByID(view_id); |
24 if (view) { | 24 if (view) { |
25 *success = true; | 25 *success = true; |
26 gfx::Point point; | 26 gfx::Point point; |
27 if (screen_coordinates) | 27 if (screen_coordinates) |
28 views::View::ConvertPointToScreen(view, &point); | 28 views::View::ConvertPointToScreen(view, &point); |
29 else | 29 else |
30 views::View::ConvertPointToView(view, root_view, &point); | 30 views::View::ConvertPointToTarget(view, root_view, &point); |
31 *bounds = view->GetContentsBounds(); | 31 *bounds = view->GetContentsBounds(); |
32 bounds->set_origin(point); | 32 bounds->set_origin(point); |
33 } | 33 } |
34 } | 34 } |
35 } | 35 } |
36 } | 36 } |
OLD | NEW |