Chromium Code Reviews| 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_focus_client.h" | |
| 9 #include "headless/lib/browser/headless_screen.h" | 10 #include "headless/lib/browser/headless_screen.h" |
| 11 #include "ui/aura/client/focus_client.h" | |
| 10 #include "ui/aura/env.h" | 12 #include "ui/aura/env.h" |
| 13 #include "ui/aura/test/test_focus_client.h" | |
|
Eric Seckler
2017/02/28 07:56:44
nit: unnecessary
irisu
2017/02/28 10:34:45
Done.
| |
| 11 #include "ui/aura/window.h" | 14 #include "ui/aura/window.h" |
| 12 #include "ui/display/screen.h" | 15 #include "ui/display/screen.h" |
| 13 #include "ui/events/devices/device_data_manager.h" | 16 #include "ui/events/devices/device_data_manager.h" |
| 14 #include "ui/gfx/geometry/size.h" | 17 #include "ui/gfx/geometry/size.h" |
| 15 | 18 |
| 16 namespace headless { | 19 namespace headless { |
| 17 | 20 |
| 18 void HeadlessBrowserImpl::PlatformInitialize() { | 21 void HeadlessBrowserImpl::PlatformInitialize() { |
| 19 HeadlessScreen* screen = HeadlessScreen::Create(options()->window_size); | 22 HeadlessScreen* screen = HeadlessScreen::Create(options()->window_size); |
| 20 display::Screen::SetScreenInstance(screen); | 23 display::Screen::SetScreenInstance(screen); |
| 21 } | 24 } |
| 22 | 25 |
| 23 void HeadlessBrowserImpl::PlatformCreateWindow() { | 26 void HeadlessBrowserImpl::PlatformCreateWindow() { |
| 24 DCHECK(aura::Env::GetInstance()); | 27 DCHECK(aura::Env::GetInstance()); |
| 25 ui::DeviceDataManager::CreateInstance(); | 28 ui::DeviceDataManager::CreateInstance(); |
| 26 | 29 |
| 27 window_tree_host_.reset( | 30 window_tree_host_.reset( |
| 28 new HeadlessWindowTreeHost(gfx::Rect(options()->window_size))); | 31 new HeadlessWindowTreeHost(gfx::Rect(options()->window_size))); |
| 29 window_tree_host_->InitHost(); | 32 window_tree_host_->InitHost(); |
| 30 window_tree_host_->window()->Show(); | 33 window_tree_host_->window()->Show(); |
| 31 window_tree_host_->SetParentWindow(window_tree_host_->window()); | 34 window_tree_host_->SetParentWindow(window_tree_host_->window()); |
| 35 | |
| 36 focus_client_.reset(new HeadlessFocusClient()); | |
| 37 aura::client::SetFocusClient(window_tree_host_->window(), | |
| 38 focus_client_.get()); | |
| 32 } | 39 } |
| 33 | 40 |
| 34 void HeadlessBrowserImpl::PlatformInitializeWebContents( | 41 void HeadlessBrowserImpl::PlatformInitializeWebContents( |
| 35 const gfx::Size& initial_size, | 42 const gfx::Size& initial_size, |
| 36 content::WebContents* web_contents) { | 43 content::WebContents* web_contents) { |
| 37 gfx::NativeView contents = web_contents->GetNativeView(); | 44 gfx::NativeView contents = web_contents->GetNativeView(); |
| 38 gfx::NativeWindow parent_window = window_tree_host_->window(); | 45 gfx::NativeWindow parent_window = window_tree_host_->window(); |
| 39 DCHECK(!parent_window->Contains(contents)); | 46 DCHECK(!parent_window->Contains(contents)); |
| 40 parent_window->AddChild(contents); | 47 parent_window->AddChild(contents); |
| 41 contents->Show(); | 48 contents->Show(); |
| 42 contents->SetBounds(gfx::Rect(initial_size)); | 49 contents->SetBounds(gfx::Rect(initial_size)); |
| 43 | 50 |
| 44 content::RenderWidgetHostView* host_view = | 51 content::RenderWidgetHostView* host_view = |
| 45 web_contents->GetRenderWidgetHostView(); | 52 web_contents->GetRenderWidgetHostView(); |
| 46 if (host_view) | 53 if (host_view) |
| 47 host_view->SetSize(initial_size); | 54 host_view->SetSize(initial_size); |
| 48 } | 55 } |
| 49 | 56 |
| 50 } // namespace headless | 57 } // namespace headless |
| OLD | NEW |