Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / automation / testing_automation_provider_views.cc
blob194cbeda2a26f6782a97aee50f18d4fa5820bdf1
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
3 // found in the LICENSE file.
5 #include "chrome/browser/automation/testing_automation_provider.h"
7 #include "chrome/browser/automation/automation_window_tracker.h"
8 #include "ui/views/view.h"
9 #include "ui/views/widget/widget.h"
11 void TestingAutomationProvider::WindowGetViewBounds(int handle,
12 int view_id,
13 bool screen_coordinates,
14 bool* success,
15 gfx::Rect* bounds) {
16 *success = false;
18 if (window_tracker_->ContainsHandle(handle)) {
19 gfx::NativeWindow window = window_tracker_->GetResource(handle);
20 views::Widget* widget = views::Widget::GetWidgetForNativeWindow(window);
21 if (widget) {
22 views::View* root_view = widget->GetRootView();
23 views::View* view = root_view->GetViewByID(view_id);
24 if (view) {
25 *success = true;
26 gfx::Point point;
27 if (screen_coordinates)
28 views::View::ConvertPointToScreen(view, &point);
29 else
30 views::View::ConvertPointToTarget(view, root_view, &point);
31 *bounds = view->GetContentsBounds();
32 bounds->set_origin(point);