Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1208)

Side by Side Diff: headless/lib/browser/headless_browser_impl_aura.cc

Issue 2669693002: Minimize headless code that refers to aura. (Closed)
Patch Set: Add aura dependencies in BUIL.gn only when use_aura == true" Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "content/public/browser/render_widget_host_view.h"
6 #include "content/public/browser/web_contents.h"
7 #include "headless/lib/browser/headless_browser_impl.h"
8 #include "headless/lib/browser/headless_screen.h"
9 #include "ui/aura/env.h"
10 #include "ui/aura/window.h"
11 #include "ui/display/screen.h"
12 #include "ui/events/devices/device_data_manager.h"
13 #include "ui/gfx/geometry/size.h"
14
15 namespace headless {
16
17 void HeadlessBrowserImpl::PlatformInitialize() {
18 HeadlessScreen* screen = HeadlessScreen::Create(options()->window_size);
19 display::Screen::SetScreenInstance(screen);
20 }
21
22 void HeadlessBrowserImpl::PlatformCreateWindow() {
23 DCHECK(aura::Env::GetInstance());
24 ui::DeviceDataManager::CreateInstance();
25
26 window_tree_host_.reset(
27 new HeadlessWindowTreeHost(gfx::Rect(options()->window_size)));
28 window_tree_host_->InitHost();
29 window_tree_host_->NativeWindow()->Show();
30 window_tree_host_->SetParentWindow(window_tree_host_->NativeWindow());
31 }
32
33 void HeadlessBrowserImpl::PlatformSetContents(
34 const gfx::Size& initial_size,
35 content::WebContents* web_contents) {
36 gfx::NativeView contents = web_contents->GetNativeView();
37 gfx::NativeWindow parent_window = window_tree_host_->window();
38 DCHECK(!parent_window->Contains(contents));
39 parent_window->AddChild(contents);
40 contents->Show();
41 contents->SetBounds(gfx::Rect(initial_size));
42
43 content::RenderWidgetHostView* host_view =
44 web_contents->GetRenderWidgetHostView();
45 if (host_view)
46 host_view->SetSize(initial_size);
47 }
48
49 } // namespace headless
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698