OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "headless/lib/browser/headless_browser_impl.h" | 5 #include "headless/lib/browser/headless_browser_impl.h" |
6 | 6 |
7 #include "content/public/browser/render_widget_host_view.h" | 7 #include "content/public/browser/render_widget_host_view.h" |
8 #include "content/public/browser/web_contents.h" | 8 #include "content/public/browser/web_contents.h" |
9 #include "headless/lib/browser/headless_screen.h" | 9 #include "headless/lib/browser/headless_screen.h" |
10 #include "ui/aura/env.h" | 10 #include "ui/aura/env.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 DCHECK(aura::Env::GetInstance()); | 24 DCHECK(aura::Env::GetInstance()); |
25 ui::DeviceDataManager::CreateInstance(); | 25 ui::DeviceDataManager::CreateInstance(); |
26 | 26 |
27 window_tree_host_.reset( | 27 window_tree_host_.reset( |
28 new HeadlessWindowTreeHost(gfx::Rect(options()->window_size))); | 28 new HeadlessWindowTreeHost(gfx::Rect(options()->window_size))); |
29 window_tree_host_->InitHost(); | 29 window_tree_host_->InitHost(); |
30 window_tree_host_->window()->Show(); | 30 window_tree_host_->window()->Show(); |
31 window_tree_host_->SetParentWindow(window_tree_host_->window()); | 31 window_tree_host_->SetParentWindow(window_tree_host_->window()); |
32 } | 32 } |
33 | 33 |
34 void HeadlessBrowserImpl::PlatformSetWebContents( | 34 void HeadlessBrowserImpl::PlatformInitializeWebContents( |
35 const gfx::Size& initial_size, | 35 const gfx::Size& initial_size, |
36 content::WebContents* web_contents) { | 36 content::WebContents* web_contents) { |
37 gfx::NativeView contents = web_contents->GetNativeView(); | 37 gfx::NativeView contents = web_contents->GetNativeView(); |
38 gfx::NativeWindow parent_window = window_tree_host_->window(); | 38 gfx::NativeWindow parent_window = window_tree_host_->window(); |
39 DCHECK(!parent_window->Contains(contents)); | 39 DCHECK(!parent_window->Contains(contents)); |
40 parent_window->AddChild(contents); | 40 parent_window->AddChild(contents); |
41 contents->Show(); | 41 contents->Show(); |
42 contents->SetBounds(gfx::Rect(initial_size)); | 42 contents->SetBounds(gfx::Rect(initial_size)); |
43 | 43 |
44 content::RenderWidgetHostView* host_view = | 44 content::RenderWidgetHostView* host_view = |
45 web_contents->GetRenderWidgetHostView(); | 45 web_contents->GetRenderWidgetHostView(); |
46 if (host_view) | 46 if (host_view) |
47 host_view->SetSize(initial_size); | 47 host_view->SetSize(initial_size); |
48 } | 48 } |
49 | 49 |
50 } // namespace headless | 50 } // namespace headless |
OLD | NEW |