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

Unified 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 side-by-side diff with in-line comments
Download patch
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
new file mode 100644
index 0000000000000000000000000000000000000000..fa6aa12369536c96892ea8054dedcb1b1cb154b5
--- /dev/null
+++ b/headless/lib/browser/headless_browser_impl_aura.cc
@@ -0,0 +1,49 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/public/browser/render_widget_host_view.h"
+#include "content/public/browser/web_contents.h"
+#include "headless/lib/browser/headless_browser_impl.h"
+#include "headless/lib/browser/headless_screen.h"
+#include "ui/aura/env.h"
+#include "ui/aura/window.h"
+#include "ui/display/screen.h"
+#include "ui/events/devices/device_data_manager.h"
+#include "ui/gfx/geometry/size.h"
+
+namespace headless {
+
+void HeadlessBrowserImpl::PlatformInitialize() {
+ HeadlessScreen* screen = HeadlessScreen::Create(options()->window_size);
+ display::Screen::SetScreenInstance(screen);
+}
+
+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_->NativeWindow()->Show();
+ window_tree_host_->SetParentWindow(window_tree_host_->NativeWindow());
+}
+
+void HeadlessBrowserImpl::PlatformSetContents(
+ const gfx::Size& initial_size,
+ content::WebContents* web_contents) {
+ gfx::NativeView contents = web_contents->GetNativeView();
+ gfx::NativeWindow parent_window = window_tree_host_->window();
+ DCHECK(!parent_window->Contains(contents));
+ parent_window->AddChild(contents);
+ contents->Show();
+ contents->SetBounds(gfx::Rect(initial_size));
+
+ content::RenderWidgetHostView* host_view =
+ web_contents->GetRenderWidgetHostView();
+ if (host_view)
+ host_view->SetSize(initial_size);
+}
+
+} // namespace headless

Powered by Google App Engine
This is Rietveld 408576698