| 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_linux.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" | |
| 10 #include "chromecast/base/metrics/cast_metrics_helper.h" | |
| 11 #include "chromecast/browser/cast_browser_process.h" | |
| 12 #include "chromecast/graphics/cast_vsync_settings.h" | 9 #include "chromecast/graphics/cast_vsync_settings.h" |
| 13 #include "content/public/browser/render_view_host.h" | |
| 14 #include "content/public/browser/render_widget_host.h" | |
| 15 #include "content/public/browser/render_widget_host_view.h" | |
| 16 #include "content/public/browser/web_contents.h" | 10 #include "content/public/browser/web_contents.h" |
| 17 #include "ipc/ipc_message.h" | 11 #include "ipc/ipc_message.h" |
| 18 #include "ui/display/display.h" | 12 #include "ui/display/display.h" |
| 19 #include "ui/display/screen.h" | 13 #include "ui/display/screen.h" |
| 20 | 14 |
| 21 #if defined(USE_AURA) | 15 #if defined(USE_AURA) |
| 22 #include "chromecast/graphics/cast_screen.h" | 16 #include "chromecast/graphics/cast_screen.h" |
| 23 #include "ui/aura/env.h" | 17 #include "ui/aura/env.h" |
| 24 #include "ui/aura/layout_manager.h" | 18 #include "ui/aura/layout_manager.h" |
| 25 #include "ui/aura/window.h" | 19 #include "ui/aura/window.h" |
| 26 #include "ui/aura/window_tree_host.h" | 20 #include "ui/aura/window_tree_host.h" |
| 27 #endif | 21 #endif // defined(USE_AURA) |
| 28 | 22 |
| 29 namespace chromecast { | 23 namespace chromecast { |
| 30 namespace shell { | 24 namespace shell { |
| 31 | 25 |
| 32 #if defined(USE_AURA) | 26 #if defined(USE_AURA) |
| 33 class CastFillLayout : public aura::LayoutManager { | 27 class CastFillLayout : public aura::LayoutManager { |
| 34 public: | 28 public: |
| 35 explicit CastFillLayout(aura::Window* root) : root_(root) {} | 29 explicit CastFillLayout(aura::Window* root) : root_(root) {} |
| 36 ~CastFillLayout() override {} | 30 ~CastFillLayout() override {} |
| 37 | 31 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 // Add and show content's view/window | 108 // Add and show content's view/window |
| 115 aura::Window* content_window = web_contents->GetNativeView(); | 109 aura::Window* content_window = web_contents->GetNativeView(); |
| 116 aura::Window* parent = window_tree_host_->window(); | 110 aura::Window* parent = window_tree_host_->window(); |
| 117 if (!parent->Contains(content_window)) { | 111 if (!parent->Contains(content_window)) { |
| 118 parent->AddChild(content_window); | 112 parent->AddChild(content_window); |
| 119 } | 113 } |
| 120 content_window->Show(); | 114 content_window->Show(); |
| 121 #endif | 115 #endif |
| 122 } | 116 } |
| 123 | 117 |
| 124 std::unique_ptr<content::WebContents> CastContentWindowLinux::CreateWebContents( | |
| 125 content::BrowserContext* browser_context) { | |
| 126 CHECK(display::Screen::GetScreen()); | |
| 127 gfx::Size display_size = | |
| 128 display::Screen::GetScreen()->GetPrimaryDisplay().size(); | |
| 129 | |
| 130 content::WebContents::CreateParams create_params(browser_context, NULL); | |
| 131 create_params.routing_id = MSG_ROUTING_NONE; | |
| 132 create_params.initial_size = display_size; | |
| 133 content::WebContents* web_contents = | |
| 134 content::WebContents::Create(create_params); | |
| 135 | |
| 136 #if defined(USE_AURA) | |
| 137 // Resize window | |
| 138 aura::Window* content_window = web_contents->GetNativeView(); | |
| 139 content_window->SetBounds( | |
| 140 gfx::Rect(display_size.width(), display_size.height())); | |
| 141 #endif | |
| 142 | |
| 143 content::WebContentsObserver::Observe(web_contents); | |
| 144 return base::WrapUnique(web_contents); | |
| 145 } | |
| 146 | |
| 147 void CastContentWindowLinux::DidFirstVisuallyNonEmptyPaint() { | |
| 148 metrics::CastMetricsHelper::GetInstance()->LogTimeToFirstPaint(); | |
| 149 } | |
| 150 | |
| 151 void CastContentWindowLinux::MediaStartedPlaying( | |
| 152 const MediaPlayerInfo& media_info, | |
| 153 const MediaPlayerId& id) { | |
| 154 metrics::CastMetricsHelper::GetInstance()->LogMediaPlay(); | |
| 155 } | |
| 156 | |
| 157 void CastContentWindowLinux::MediaStoppedPlaying( | |
| 158 const MediaPlayerInfo& media_info, | |
| 159 const MediaPlayerId& id) { | |
| 160 metrics::CastMetricsHelper::GetInstance()->LogMediaPause(); | |
| 161 } | |
| 162 | |
| 163 void CastContentWindowLinux::RenderViewCreated( | |
| 164 content::RenderViewHost* render_view_host) { | |
| 165 content::RenderWidgetHostView* view = | |
| 166 render_view_host->GetWidget()->GetView(); | |
| 167 if (view) { | |
| 168 view->SetBackgroundColor(transparent_ ? SK_ColorTRANSPARENT | |
| 169 : SK_ColorBLACK); | |
| 170 } | |
| 171 } | |
| 172 | |
| 173 void CastContentWindowLinux::OnVSyncIntervalChanged(base::TimeDelta interval) { | 118 void CastContentWindowLinux::OnVSyncIntervalChanged(base::TimeDelta interval) { |
| 174 #if defined(USE_AURA) | 119 #if defined(USE_AURA) |
| 175 window_tree_host_->compositor()->SetAuthoritativeVSyncInterval(interval); | 120 window_tree_host_->compositor()->SetAuthoritativeVSyncInterval(interval); |
| 176 #endif | 121 #endif |
| 177 } | 122 } |
| 178 | 123 |
| 179 } // namespace shell | 124 } // namespace shell |
| 180 } // namespace chromecast | 125 } // namespace chromecast |
| OLD | NEW |