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

Unified Diff: chromecast/browser/cast_content_window.cc

Issue 2570623003: [Chromecast] Turn CastContentWindow into an abstract interface. (Closed)
Patch Set: Fix browser test Created 3 years, 11 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
« no previous file with comments | « chromecast/browser/cast_content_window.h ('k') | chromecast/browser/cast_content_window_linux.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromecast/browser/cast_content_window.cc
diff --git a/chromecast/browser/cast_content_window.cc b/chromecast/browser/cast_content_window.cc
deleted file mode 100644
index 20c3b9d2248eaf47bc932fe9ca3229f492079e18..0000000000000000000000000000000000000000
--- a/chromecast/browser/cast_content_window.cc
+++ /dev/null
@@ -1,166 +0,0 @@
-// Copyright 2014 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_content_window.h"
-
-#include "base/macros.h"
-#include "base/memory/ptr_util.h"
-#include "base/threading/thread_restrictions.h"
-#include "chromecast/base/metrics/cast_metrics_helper.h"
-#include "chromecast/browser/cast_browser_process.h"
-#include "chromecast/graphics/cast_vsync_settings.h"
-#include "content/public/browser/render_view_host.h"
-#include "content/public/browser/render_widget_host.h"
-#include "content/public/browser/render_widget_host_view.h"
-#include "content/public/browser/web_contents.h"
-#include "ipc/ipc_message.h"
-#include "ui/display/display.h"
-#include "ui/display/screen.h"
-
-#if defined(USE_AURA)
-#include "chromecast/graphics/cast_screen.h"
-#include "ui/aura/env.h"
-#include "ui/aura/layout_manager.h"
-#include "ui/aura/window.h"
-#include "ui/aura/window_tree_host.h"
-#endif
-
-namespace chromecast {
-namespace shell {
-
-#if defined(USE_AURA)
-class CastFillLayout : public aura::LayoutManager {
- public:
- explicit CastFillLayout(aura::Window* root) : root_(root) {}
- ~CastFillLayout() override {}
-
- private:
- void OnWindowResized() override {}
-
- void OnWindowAddedToLayout(aura::Window* child) override {
- child->SetBounds(root_->bounds());
- }
-
- void OnWillRemoveWindowFromLayout(aura::Window* child) override {}
-
- void OnWindowRemovedFromLayout(aura::Window* child) override {}
-
- void OnChildWindowVisibilityChanged(aura::Window* child,
- bool visible) override {}
-
- void SetChildBounds(aura::Window* child,
- const gfx::Rect& requested_bounds) override {
- SetChildBoundsDirect(child, requested_bounds);
- }
-
- aura::Window* root_;
-
- DISALLOW_COPY_AND_ASSIGN(CastFillLayout);
-};
-#endif
-
-CastContentWindow::CastContentWindow() : transparent_(false) {
-}
-
-CastContentWindow::~CastContentWindow() {
-#if defined(USE_AURA)
- CastVSyncSettings::GetInstance()->RemoveObserver(this);
- window_tree_host_.reset();
- // We don't delete the screen here to avoid a CHECK failure when
- // the screen size is queried periodically for metric gathering. b/18101124
-#endif
-}
-
-void CastContentWindow::CreateWindowTree(content::WebContents* web_contents) {
-#if defined(USE_AURA)
- // Aura initialization
- 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()->Show();
- window_tree_host_->window()->SetLayoutManager(
- new CastFillLayout(window_tree_host_->window()));
-
- if (transparent_) {
- window_tree_host_->compositor()->SetBackgroundColor(SK_ColorTRANSPARENT);
- window_tree_host_->compositor()->SetHostHasTransparentBackground(true);
- } else {
- window_tree_host_->compositor()->SetBackgroundColor(SK_ColorBLACK);
- }
-
- CastVSyncSettings::GetInstance()->AddObserver(this);
- window_tree_host_->compositor()->SetAuthoritativeVSyncInterval(
- CastVSyncSettings::GetInstance()->GetVSyncInterval());
-
- window_tree_host_->Show();
-
- // Add and show content's view/window
- aura::Window* content_window = web_contents->GetNativeView();
- aura::Window* parent = window_tree_host_->window();
- if (!parent->Contains(content_window)) {
- parent->AddChild(content_window);
- }
- content_window->Show();
-#endif
-}
-
-std::unique_ptr<content::WebContents> CastContentWindow::CreateWebContents(
- content::BrowserContext* browser_context) {
- CHECK(display::Screen::GetScreen());
- gfx::Size display_size =
- display::Screen::GetScreen()->GetPrimaryDisplay().size();
-
- content::WebContents::CreateParams create_params(browser_context, NULL);
- create_params.routing_id = MSG_ROUTING_NONE;
- create_params.initial_size = display_size;
- content::WebContents* web_contents = content::WebContents::Create(
- create_params);
-
-#if defined(USE_AURA)
- // Resize window
- aura::Window* content_window = web_contents->GetNativeView();
- content_window->SetBounds(gfx::Rect(display_size.width(),
- display_size.height()));
-#endif
-
- content::WebContentsObserver::Observe(web_contents);
- return base::WrapUnique(web_contents);
-}
-
-void CastContentWindow::DidFirstVisuallyNonEmptyPaint() {
- metrics::CastMetricsHelper::GetInstance()->LogTimeToFirstPaint();
-}
-
-void CastContentWindow::MediaStoppedPlaying(const MediaPlayerInfo& media_info,
- const MediaPlayerId& id) {
- metrics::CastMetricsHelper::GetInstance()->LogMediaPause();
-}
-
-void CastContentWindow::MediaStartedPlaying(const MediaPlayerInfo& media_info,
- const MediaPlayerId& id) {
- metrics::CastMetricsHelper::GetInstance()->LogMediaPlay();
-}
-
-void CastContentWindow::RenderViewCreated(
- content::RenderViewHost* render_view_host) {
- content::RenderWidgetHostView* view =
- render_view_host->GetWidget()->GetView();
- if (view)
- view->SetBackgroundColor(transparent_ ? SK_ColorTRANSPARENT
- : SK_ColorBLACK);
-}
-
-void CastContentWindow::OnVSyncIntervalChanged(base::TimeDelta interval) {
-#if defined(USE_AURA)
- window_tree_host_->compositor()->SetAuthoritativeVSyncInterval(
- interval);
-#endif
-}
-
-} // namespace shell
-} // namespace chromecast
« no previous file with comments | « chromecast/browser/cast_content_window.h ('k') | chromecast/browser/cast_content_window_linux.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698