Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chromecast/browser/cast_content_window.h" | 5 #include "chromecast/browser/cast_content_window_linux.h" |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "base/threading/thread_restrictions.h" | 9 #include "base/threading/thread_restrictions.h" |
| 10 #include "chromecast/base/metrics/cast_metrics_helper.h" | 10 #include "chromecast/base/metrics/cast_metrics_helper.h" |
| 11 #include "chromecast/browser/cast_browser_process.h" | 11 #include "chromecast/browser/cast_browser_process.h" |
| 12 #include "chromecast/graphics/cast_vsync_settings.h" | 12 #include "chromecast/graphics/cast_vsync_settings.h" |
| 13 #include "content/public/browser/render_view_host.h" | 13 #include "content/public/browser/render_view_host.h" |
| 14 #include "content/public/browser/render_widget_host.h" | 14 #include "content/public/browser/render_widget_host.h" |
| 15 #include "content/public/browser/render_widget_host_view.h" | 15 #include "content/public/browser/render_widget_host_view.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 53 const gfx::Rect& requested_bounds) override { | 53 const gfx::Rect& requested_bounds) override { |
| 54 SetChildBoundsDirect(child, requested_bounds); | 54 SetChildBoundsDirect(child, requested_bounds); |
| 55 } | 55 } |
| 56 | 56 |
| 57 aura::Window* root_; | 57 aura::Window* root_; |
| 58 | 58 |
| 59 DISALLOW_COPY_AND_ASSIGN(CastFillLayout); | 59 DISALLOW_COPY_AND_ASSIGN(CastFillLayout); |
| 60 }; | 60 }; |
| 61 #endif | 61 #endif |
| 62 | 62 |
| 63 CastContentWindow::CastContentWindow() : transparent_(false) { | 63 // static |
| 64 std::unique_ptr<CastContentWindow> CastContentWindow::Create( | |
| 65 CastContentWindow::Delegate* delegate) { | |
| 66 return base::MakeUnique<CastContentWindowLinux>(); | |
|
alokp
2017/01/05 22:04:51
Is dropping the delegate intentional?
derekjchow1
2017/01/05 22:27:24
Correct. The Linux version of CastContentWindow do
| |
| 64 } | 67 } |
| 65 | 68 |
| 66 CastContentWindow::~CastContentWindow() { | 69 CastContentWindowLinux::CastContentWindowLinux() : transparent_(false) {} |
| 70 | |
| 71 CastContentWindowLinux::~CastContentWindowLinux() { | |
| 67 #if defined(USE_AURA) | 72 #if defined(USE_AURA) |
| 68 CastVSyncSettings::GetInstance()->RemoveObserver(this); | 73 CastVSyncSettings::GetInstance()->RemoveObserver(this); |
| 69 window_tree_host_.reset(); | 74 window_tree_host_.reset(); |
| 70 // We don't delete the screen here to avoid a CHECK failure when | 75 // We don't delete the screen here to avoid a CHECK failure when |
| 71 // the screen size is queried periodically for metric gathering. b/18101124 | 76 // the screen size is queried periodically for metric gathering. b/18101124 |
| 72 #endif | 77 #endif |
| 73 } | 78 } |
| 74 | 79 |
| 75 void CastContentWindow::CreateWindowTree(content::WebContents* web_contents) { | 80 void CastContentWindowLinux::SetTransparent() { |
| 81 DCHECK(!window_tree_host_); | |
| 82 transparent_ = true; | |
| 83 } | |
| 84 | |
| 85 void CastContentWindowLinux::ShowWebContents( | |
| 86 content::WebContents* web_contents) { | |
| 76 #if defined(USE_AURA) | 87 #if defined(USE_AURA) |
| 77 // Aura initialization | 88 // Aura initialization |
| 78 DCHECK(display::Screen::GetScreen()); | 89 DCHECK(display::Screen::GetScreen()); |
| 79 gfx::Size display_size = | 90 gfx::Size display_size = |
| 80 display::Screen::GetScreen()->GetPrimaryDisplay().GetSizeInPixel(); | 91 display::Screen::GetScreen()->GetPrimaryDisplay().GetSizeInPixel(); |
| 81 CHECK(aura::Env::GetInstance()); | 92 CHECK(aura::Env::GetInstance()); |
| 82 window_tree_host_.reset( | 93 window_tree_host_.reset( |
| 83 aura::WindowTreeHost::Create(gfx::Rect(display_size))); | 94 aura::WindowTreeHost::Create(gfx::Rect(display_size))); |
| 84 window_tree_host_->InitHost(); | 95 window_tree_host_->InitHost(); |
| 85 window_tree_host_->window()->Show(); | 96 window_tree_host_->window()->Show(); |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 102 // Add and show content's view/window | 113 // Add and show content's view/window |
| 103 aura::Window* content_window = web_contents->GetNativeView(); | 114 aura::Window* content_window = web_contents->GetNativeView(); |
| 104 aura::Window* parent = window_tree_host_->window(); | 115 aura::Window* parent = window_tree_host_->window(); |
| 105 if (!parent->Contains(content_window)) { | 116 if (!parent->Contains(content_window)) { |
| 106 parent->AddChild(content_window); | 117 parent->AddChild(content_window); |
| 107 } | 118 } |
| 108 content_window->Show(); | 119 content_window->Show(); |
| 109 #endif | 120 #endif |
| 110 } | 121 } |
| 111 | 122 |
| 112 std::unique_ptr<content::WebContents> CastContentWindow::CreateWebContents( | 123 std::unique_ptr<content::WebContents> CastContentWindowLinux::CreateWebContents( |
| 113 content::BrowserContext* browser_context) { | 124 content::BrowserContext* browser_context) { |
| 114 CHECK(display::Screen::GetScreen()); | 125 CHECK(display::Screen::GetScreen()); |
| 115 gfx::Size display_size = | 126 gfx::Size display_size = |
| 116 display::Screen::GetScreen()->GetPrimaryDisplay().size(); | 127 display::Screen::GetScreen()->GetPrimaryDisplay().size(); |
| 117 | 128 |
| 118 content::WebContents::CreateParams create_params(browser_context, NULL); | 129 content::WebContents::CreateParams create_params(browser_context, NULL); |
| 119 create_params.routing_id = MSG_ROUTING_NONE; | 130 create_params.routing_id = MSG_ROUTING_NONE; |
| 120 create_params.initial_size = display_size; | 131 create_params.initial_size = display_size; |
| 121 content::WebContents* web_contents = content::WebContents::Create( | 132 content::WebContents* web_contents = |
| 122 create_params); | 133 content::WebContents::Create(create_params); |
| 123 | 134 |
| 124 #if defined(USE_AURA) | 135 #if defined(USE_AURA) |
| 125 // Resize window | 136 // Resize window |
| 126 aura::Window* content_window = web_contents->GetNativeView(); | 137 aura::Window* content_window = web_contents->GetNativeView(); |
| 127 content_window->SetBounds(gfx::Rect(display_size.width(), | 138 content_window->SetBounds( |
| 128 display_size.height())); | 139 gfx::Rect(display_size.width(), display_size.height())); |
| 129 #endif | 140 #endif |
| 130 | 141 |
| 131 content::WebContentsObserver::Observe(web_contents); | 142 content::WebContentsObserver::Observe(web_contents); |
| 132 return base::WrapUnique(web_contents); | 143 return base::WrapUnique(web_contents); |
| 133 } | 144 } |
| 134 | 145 |
| 135 void CastContentWindow::DidFirstVisuallyNonEmptyPaint() { | 146 void CastContentWindowLinux::DidFirstVisuallyNonEmptyPaint() { |
| 136 metrics::CastMetricsHelper::GetInstance()->LogTimeToFirstPaint(); | 147 metrics::CastMetricsHelper::GetInstance()->LogTimeToFirstPaint(); |
| 137 } | 148 } |
| 138 | 149 |
| 139 void CastContentWindow::MediaStoppedPlaying(const MediaPlayerInfo& media_info, | 150 void CastContentWindowLinux::MediaStoppedPlaying( |
| 140 const MediaPlayerId& id) { | 151 const MediaPlayerInfo& media_info, |
| 152 const MediaPlayerId& id) { | |
| 141 metrics::CastMetricsHelper::GetInstance()->LogMediaPause(); | 153 metrics::CastMetricsHelper::GetInstance()->LogMediaPause(); |
| 142 } | 154 } |
| 143 | 155 |
| 144 void CastContentWindow::MediaStartedPlaying(const MediaPlayerInfo& media_info, | 156 void CastContentWindowLinux::MediaStartedPlaying( |
| 145 const MediaPlayerId& id) { | 157 const MediaPlayerInfo& media_info, |
| 158 const MediaPlayerId& id) { | |
| 146 metrics::CastMetricsHelper::GetInstance()->LogMediaPlay(); | 159 metrics::CastMetricsHelper::GetInstance()->LogMediaPlay(); |
| 147 } | 160 } |
| 148 | 161 |
| 149 void CastContentWindow::RenderViewCreated( | 162 void CastContentWindowLinux::RenderViewCreated( |
| 150 content::RenderViewHost* render_view_host) { | 163 content::RenderViewHost* render_view_host) { |
| 151 content::RenderWidgetHostView* view = | 164 content::RenderWidgetHostView* view = |
| 152 render_view_host->GetWidget()->GetView(); | 165 render_view_host->GetWidget()->GetView(); |
| 153 if (view) | 166 if (view) { |
| 154 view->SetBackgroundColor(transparent_ ? SK_ColorTRANSPARENT | 167 view->SetBackgroundColor(transparent_ ? SK_ColorTRANSPARENT |
| 155 : SK_ColorBLACK); | 168 : SK_ColorBLACK); |
| 169 } | |
| 156 } | 170 } |
| 157 | 171 |
| 158 void CastContentWindow::OnVSyncIntervalChanged(base::TimeDelta interval) { | 172 void CastContentWindowLinux::OnVSyncIntervalChanged(base::TimeDelta interval) { |
| 159 #if defined(USE_AURA) | 173 #if defined(USE_AURA) |
| 160 window_tree_host_->compositor()->SetAuthoritativeVSyncInterval( | 174 window_tree_host_->compositor()->SetAuthoritativeVSyncInterval(interval); |
| 161 interval); | |
| 162 #endif | 175 #endif |
| 163 } | 176 } |
| 164 | 177 |
| 165 } // namespace shell | 178 } // namespace shell |
| 166 } // namespace chromecast | 179 } // namespace chromecast |
| OLD | NEW |