Chromium Code Reviews| Index: headless/lib/browser/headless_browser_impl_aura.cc |
| diff --git a/headless/lib/browser/headless_browser_impl_aura.cc b/headless/lib/browser/headless_browser_impl_aura.cc |
| index 33b028a41fe64a7c7ec3e3277444770cac5f2243..57a0f77c7918b6bcfd7df9277934a221dc564897 100644 |
| --- a/headless/lib/browser/headless_browser_impl_aura.cc |
| +++ b/headless/lib/browser/headless_browser_impl_aura.cc |
| @@ -7,9 +7,7 @@ |
| #include "content/public/browser/render_widget_host_view.h" |
| #include "content/public/browser/web_contents.h" |
| #include "headless/lib/browser/headless_clipboard.h" |
| -#include "headless/lib/browser/headless_focus_client.h" |
| #include "headless/lib/browser/headless_screen.h" |
| -#include "ui/aura/client/focus_client.h" |
| #include "ui/aura/env.h" |
| #include "ui/aura/window.h" |
| #include "ui/base/clipboard/clipboard.h" |
| @@ -23,6 +21,8 @@ void HeadlessBrowserImpl::PlatformInitialize() { |
| HeadlessScreen* screen = HeadlessScreen::Create(options()->window_size); |
| display::Screen::SetScreenInstance(screen); |
| + // TODO(eseckler): We shouldn't share clipboard contents across WebContents |
| + // (or at least BrowserContexts). |
|
Sami
2017/03/31 17:53:51
N.B. this might be tricky to pull off -- after all
|
| ui::Clipboard::SetClipboardForCurrentThread( |
| base::MakeUnique<HeadlessClipboard>()); |
| } |
| @@ -30,30 +30,29 @@ void HeadlessBrowserImpl::PlatformInitialize() { |
| void HeadlessBrowserImpl::PlatformCreateWindow() { |
| DCHECK(aura::Env::GetInstance()); |
| ui::DeviceDataManager::CreateInstance(); |
| - |
| - window_tree_host_.reset( |
| - new HeadlessWindowTreeHost(gfx::Rect(options()->window_size))); |
| - window_tree_host_->InitHost(); |
| - window_tree_host_->window()->Show(); |
| - window_tree_host_->SetParentWindow(window_tree_host_->window()); |
| - |
| - focus_client_.reset(new HeadlessFocusClient()); |
| - aura::client::SetFocusClient(window_tree_host_->window(), |
| - focus_client_.get()); |
| } |
| void HeadlessBrowserImpl::PlatformInitializeWebContents( |
| const gfx::Size& initial_size, |
| - content::WebContents* web_contents) { |
| - gfx::NativeView contents = web_contents->GetNativeView(); |
| - gfx::NativeWindow parent_window = window_tree_host_->window(); |
| + HeadlessWebContentsImpl* web_contents) { |
| + gfx::Rect initial_rect(initial_size); |
| + |
| + auto window_tree_host = |
| + base::MakeUnique<HeadlessWindowTreeHost>(initial_rect); |
| + window_tree_host->InitHost(); |
| + gfx::NativeWindow parent_window = window_tree_host->window(); |
| + parent_window->Show(); |
| + window_tree_host->SetParentWindow(parent_window); |
| + web_contents->set_window_tree_host(std::move(window_tree_host)); |
| + |
| + gfx::NativeView contents = web_contents->web_contents()->GetNativeView(); |
| DCHECK(!parent_window->Contains(contents)); |
| parent_window->AddChild(contents); |
| contents->Show(); |
| - contents->SetBounds(gfx::Rect(initial_size)); |
| + contents->SetBounds(initial_rect); |
| content::RenderWidgetHostView* host_view = |
| - web_contents->GetRenderWidgetHostView(); |
| + web_contents->web_contents()->GetRenderWidgetHostView(); |
| if (host_view) |
| host_view->SetSize(initial_size); |
| } |