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>(); | |
64 } | 67 } |
65 | 68 |
66 CastContentWindow::~CastContentWindow() { | 69 CastContentWindowLinux::CastContentWindowLinux() : transparent_(false) { |
70 } | |
byungchul
2016/12/16 22:52:22
{}
derekjchow1
2016/12/17 00:13:07
Done.
| |
71 | |
72 CastContentWindowLinux::~CastContentWindowLinux() { | |
67 #if defined(USE_AURA) | 73 #if defined(USE_AURA) |
68 CastVSyncSettings::GetInstance()->RemoveObserver(this); | 74 CastVSyncSettings::GetInstance()->RemoveObserver(this); |
69 window_tree_host_.reset(); | 75 window_tree_host_.reset(); |
70 // We don't delete the screen here to avoid a CHECK failure when | 76 // 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 | 77 // the screen size is queried periodically for metric gathering. b/18101124 |
72 #endif | 78 #endif |
73 } | 79 } |
74 | 80 |
75 void CastContentWindow::CreateWindowTree(content::WebContents* web_contents) { | 81 void CastContentWindowLinux::SetTransparent() { |
82 DCHECK(!window_tree_host_); | |
83 transparent_ = true; | |
84 } | |
85 | |
86 void CastContentWindowLinux::ShowWebContents( | |
87 content::WebContents* web_contents) { | |
76 #if defined(USE_AURA) | 88 #if defined(USE_AURA) |
77 // Aura initialization | 89 // Aura initialization |
78 DCHECK(display::Screen::GetScreen()); | 90 DCHECK(display::Screen::GetScreen()); |
79 gfx::Size display_size = | 91 gfx::Size display_size = |
80 display::Screen::GetScreen()->GetPrimaryDisplay().GetSizeInPixel(); | 92 display::Screen::GetScreen()->GetPrimaryDisplay().GetSizeInPixel(); |
81 CHECK(aura::Env::GetInstance()); | 93 CHECK(aura::Env::GetInstance()); |
82 window_tree_host_.reset( | 94 window_tree_host_.reset( |
83 aura::WindowTreeHost::Create(gfx::Rect(display_size))); | 95 aura::WindowTreeHost::Create(gfx::Rect(display_size))); |
84 window_tree_host_->InitHost(); | 96 window_tree_host_->InitHost(); |
85 window_tree_host_->window()->SetLayoutManager( | 97 window_tree_host_->window()->SetLayoutManager( |
(...skipping 15 matching lines...) Expand all Loading... | |
101 // Add and show content's view/window | 113 // Add and show content's view/window |
102 aura::Window* content_window = web_contents->GetNativeView(); | 114 aura::Window* content_window = web_contents->GetNativeView(); |
103 aura::Window* parent = window_tree_host_->window(); | 115 aura::Window* parent = window_tree_host_->window(); |
104 if (!parent->Contains(content_window)) { | 116 if (!parent->Contains(content_window)) { |
105 parent->AddChild(content_window); | 117 parent->AddChild(content_window); |
106 } | 118 } |
107 content_window->Show(); | 119 content_window->Show(); |
108 #endif | 120 #endif |
109 } | 121 } |
110 | 122 |
111 std::unique_ptr<content::WebContents> CastContentWindow::CreateWebContents( | 123 std::unique_ptr<content::WebContents> CastContentWindowLinux::CreateWebContents( |
112 content::BrowserContext* browser_context) { | 124 content::BrowserContext* browser_context) { |
113 CHECK(display::Screen::GetScreen()); | 125 CHECK(display::Screen::GetScreen()); |
114 gfx::Size display_size = | 126 gfx::Size display_size = |
115 display::Screen::GetScreen()->GetPrimaryDisplay().size(); | 127 display::Screen::GetScreen()->GetPrimaryDisplay().size(); |
116 | 128 |
117 content::WebContents::CreateParams create_params(browser_context, NULL); | 129 content::WebContents::CreateParams create_params(browser_context, NULL); |
118 create_params.routing_id = MSG_ROUTING_NONE; | 130 create_params.routing_id = MSG_ROUTING_NONE; |
119 create_params.initial_size = display_size; | 131 create_params.initial_size = display_size; |
120 content::WebContents* web_contents = content::WebContents::Create( | 132 content::WebContents* web_contents = content::WebContents::Create( |
121 create_params); | 133 create_params); |
122 | 134 |
123 #if defined(USE_AURA) | 135 #if defined(USE_AURA) |
124 // Resize window | 136 // Resize window |
125 aura::Window* content_window = web_contents->GetNativeView(); | 137 aura::Window* content_window = web_contents->GetNativeView(); |
126 content_window->SetBounds(gfx::Rect(display_size.width(), | 138 content_window->SetBounds(gfx::Rect(display_size.width(), |
127 display_size.height())); | 139 display_size.height())); |
128 #endif | 140 #endif |
129 | 141 |
130 content::WebContentsObserver::Observe(web_contents); | 142 content::WebContentsObserver::Observe(web_contents); |
131 return base::WrapUnique(web_contents); | 143 return base::WrapUnique(web_contents); |
132 } | 144 } |
133 | 145 |
134 void CastContentWindow::DidFirstVisuallyNonEmptyPaint() { | 146 void CastContentWindowLinux::DidFirstVisuallyNonEmptyPaint() { |
135 metrics::CastMetricsHelper::GetInstance()->LogTimeToFirstPaint(); | 147 metrics::CastMetricsHelper::GetInstance()->LogTimeToFirstPaint(); |
136 } | 148 } |
137 | 149 |
138 void CastContentWindow::MediaStoppedPlaying(const MediaPlayerInfo& media_info, | 150 void CastContentWindowLinux::MediaStoppedPlaying( |
139 const MediaPlayerId& id) { | 151 const MediaPlayerInfo& media_info, |
152 const MediaPlayerId& id) { | |
140 metrics::CastMetricsHelper::GetInstance()->LogMediaPause(); | 153 metrics::CastMetricsHelper::GetInstance()->LogMediaPause(); |
141 } | 154 } |
142 | 155 |
143 void CastContentWindow::MediaStartedPlaying(const MediaPlayerInfo& media_info, | 156 void CastContentWindowLinux::MediaStartedPlaying( |
144 const MediaPlayerId& id) { | 157 const MediaPlayerInfo& media_info, |
158 const MediaPlayerId& id) { | |
145 metrics::CastMetricsHelper::GetInstance()->LogMediaPlay(); | 159 metrics::CastMetricsHelper::GetInstance()->LogMediaPlay(); |
146 } | 160 } |
147 | 161 |
148 void CastContentWindow::RenderViewCreated( | 162 void CastContentWindowLinux::RenderViewCreated( |
149 content::RenderViewHost* render_view_host) { | 163 content::RenderViewHost* render_view_host) { |
150 content::RenderWidgetHostView* view = | 164 content::RenderWidgetHostView* view = |
151 render_view_host->GetWidget()->GetView(); | 165 render_view_host->GetWidget()->GetView(); |
152 if (view) | 166 if (view) { |
153 view->SetBackgroundColor(transparent_ ? SK_ColorTRANSPARENT | 167 view->SetBackgroundColor(transparent_ ? SK_ColorTRANSPARENT |
154 : SK_ColorBLACK); | 168 : SK_ColorBLACK); |
169 } | |
155 } | 170 } |
156 | 171 |
157 void CastContentWindow::OnVSyncIntervalChanged(base::TimeDelta interval) { | 172 void CastContentWindowLinux::OnVSyncIntervalChanged(base::TimeDelta interval) { |
158 #if defined(USE_AURA) | 173 #if defined(USE_AURA) |
159 window_tree_host_->compositor()->SetAuthoritativeVSyncInterval( | 174 window_tree_host_->compositor()->SetAuthoritativeVSyncInterval( |
160 interval); | 175 interval); |
161 #endif | 176 #endif |
162 } | 177 } |
163 | 178 |
164 } // namespace shell | 179 } // namespace shell |
165 } // namespace chromecast | 180 } // namespace chromecast |
OLD | NEW |