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

Unified Diff: chromecast/browser/cast_window_manager_aura.cc

Issue 2428383007: [Chromecast] Add input support. (Closed)
Patch Set: Created 4 years, 2 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: chromecast/browser/cast_window_manager_aura.cc
diff --git a/chromecast/browser/cast_window_manager_aura.cc b/chromecast/browser/cast_window_manager_aura.cc
new file mode 100644
index 0000000000000000000000000000000000000000..46549a6528eca99c82ef673e2b1d4a949b1d0d0d
--- /dev/null
+++ b/chromecast/browser/cast_window_manager_aura.cc
@@ -0,0 +1,102 @@
+// Copyright 2016 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 "chromecast/browser/cast_window_manager_aura.h"
+
+#include "content/public/browser/web_contents.h"
+#include "ui/aura/env.h"
+#include "ui/aura/window.h"
+#include "ui/aura/window_tree_host.h"
+#include "ui/display/display.h"
+#include "ui/display/screen.h"
+
+namespace chromecast {
+namespace shell {
+
+CastWindowManagerAura::CastWindowManagerAura() { }
+
+CastWindowManagerAura::~CastWindowManagerAura() {
+ CastVSyncSettings::GetInstance()->RemoveObserver(this);
+ window_tree_host_.reset();
+}
+
+void CastWindowManagerAura::StartWindowManager() {
+ DCHECK(!window_tree_host_.get());
+ DCHECK(display::Screen::GetScreen());
+
+ gfx::Size display_size =
+ display::Screen::GetScreen()->GetPrimaryDisplay().GetSizeInPixel();
+ CHECK(aura::Env::GetInstance());
+ window_tree_host_.reset(
+ aura::WindowTreeHost::Create(gfx::Rect(display_size)));
+ window_tree_host_->InitHost();
+ window_tree_host_->window()->SetLayoutManager(this);
+ window_tree_host_->compositor()->SetBackgroundColor(SK_ColorBLACK);
+
+ CastVSyncSettings::GetInstance()->AddObserver(this);
+ window_tree_host_->compositor()->SetAuthoritativeVSyncInterval(
+ CastVSyncSettings::GetInstance()->GetVSyncInterval());
+
+ window_tree_host_->Show();
+}
+
+void CastWindowManagerAura::AddWebContents(content::WebContents* web_contents,
+ bool is_overlay,
+ bool is_transparent) {
+ if (window_tree_host_.get() == nullptr) {
+ StartWindowManager();
+ }
+
+ aura::Window* child = web_contents->GetNativeView();
+ aura::Window* parent = window_tree_host_->window();
+ if (!parent->Contains(child)) {
+ parent->AddChild(child);
+ }
+ if (is_overlay) {
+ parent->StackChildAtTop(child);
+ } else {
+ parent->StackChildAtBottom(child);
+
+ // The transparency of the root window depends on the bottom window's
+ // transparency setting.
+ if (is_transparent) {
+ window_tree_host_->compositor()->SetBackgroundColor(SK_ColorTRANSPARENT);
+ window_tree_host_->compositor()->SetHostHasTransparentBackground(true);
+ } else {
+ window_tree_host_->compositor()->SetBackgroundColor(SK_ColorBLACK);
+ }
+ }
+ child->SetTransparent(is_transparent);
+ child->SetBounds(window_tree_host_->window()->bounds());
+ child->Show();
+}
+
+void CastWindowManagerAura::OnVSyncIntervalChanged(base::TimeDelta interval) {
+ DCHECK(window_tree_host_.get());
+ window_tree_host_->compositor()->SetAuthoritativeVSyncInterval(interval);
+}
+
+void CastWindowManagerAura::OnWindowResized() {
+}
+
+void CastWindowManagerAura::OnWindowAddedToLayout(aura::Window* child) {
+}
+
+void CastWindowManagerAura::OnWillRemoveWindowFromLayout(aura::Window* child) {
+}
+
+void CastWindowManagerAura::OnWindowRemovedFromLayout(aura::Window* child) {
+}
+
+void CastWindowManagerAura::OnChildWindowVisibilityChanged(aura::Window* child,
+ bool visible) {
+}
+
+void CastWindowManagerAura::SetChildBounds(aura::Window* child,
+ const gfx::Rect& requested_bounds) {
+ SetChildBoundsDirect(child, requested_bounds);
+}
+
+} // namespace shell
+} // namespace chromecast

Powered by Google App Engine
This is Rietveld 408576698