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

Side by Side Diff: content/browser/media/media_web_contents_observer.cc

Issue 1441883003: Hook up RendererMediaSessionManager with browser side (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years 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 unified diff | Download patch
OLDNEW
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 "content/browser/media/media_web_contents_observer.h" 5 #include "content/browser/media/media_web_contents_observer.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "content/browser/media/cdm/browser_cdm_manager.h" 9 #include "content/browser/media/cdm/browser_cdm_manager.h"
10 #include "content/browser/renderer_host/render_process_host_impl.h" 10 #include "content/browser/renderer_host/render_process_host_impl.h"
11 #include "content/browser/web_contents/web_contents_impl.h" 11 #include "content/browser/web_contents/web_contents_impl.h"
12 #include "content/common/frame_messages.h" 12 #include "content/common/frame_messages.h"
13 #include "content/public/browser/render_frame_host.h" 13 #include "content/public/browser/render_frame_host.h"
14 #include "content/public/browser/web_contents.h" 14 #include "content/public/browser/web_contents.h"
15 #include "ipc/ipc_message_macros.h" 15 #include "ipc/ipc_message_macros.h"
16 16
17 #if defined(OS_ANDROID) 17 #if defined(OS_ANDROID)
18 #include "content/browser/media/android/browser_media_player_manager.h" 18 #include "content/browser/media/android/browser_media_player_manager.h"
19 #include "content/browser/media/android/browser_media_session_manager.h"
19 #include "content/common/media/media_player_messages_android.h" 20 #include "content/common/media/media_player_messages_android.h"
21 #include "content/common/media/media_session_messages_android.h"
20 #include "media/base/android/media_player_android.h" 22 #include "media/base/android/media_player_android.h"
21 #endif // defined(OS_ANDROID) 23 #endif // defined(OS_ANDROID)
22 24
23 namespace content { 25 namespace content {
24 26
25 MediaWebContentsObserver::MediaWebContentsObserver(WebContents* web_contents) 27 MediaWebContentsObserver::MediaWebContentsObserver(WebContents* web_contents)
26 : WebContentsObserver(web_contents) {} 28 : WebContentsObserver(web_contents) {}
27 29
28 MediaWebContentsObserver::~MediaWebContentsObserver() {} 30 MediaWebContentsObserver::~MediaWebContentsObserver() {}
29 31
30 void MediaWebContentsObserver::RenderFrameDeleted( 32 void MediaWebContentsObserver::RenderFrameDeleted(
31 RenderFrameHost* render_frame_host) { 33 RenderFrameHost* render_frame_host) {
32 ClearPowerSaveBlockers(render_frame_host); 34 ClearPowerSaveBlockers(render_frame_host);
33 35
34 #if defined(OS_ANDROID) 36 #if defined(OS_ANDROID)
35 // Always destroy the media players before CDMs because we do not support 37 // Always destroy the media players before CDMs because we do not support
36 // detaching CDMs from media players yet. See http://crbug.com/330324 38 // detaching CDMs from media players yet. See http://crbug.com/330324
37 media_player_managers_.erase(render_frame_host); 39 media_player_managers_.erase(render_frame_host);
40 media_session_managers_.erase(render_frame_host);
38 41
39 // TODO(xhwang): Currently MediaWebContentsObserver, BrowserMediaPlayerManager 42 // TODO(xhwang): Currently MediaWebContentsObserver, BrowserMediaPlayerManager
40 // and BrowserCdmManager all run on browser UI thread. So this call is okay. 43 // and BrowserCdmManager all run on browser UI thread. So this call is okay.
41 // In the future we need to support the case where MediaWebContentsObserver 44 // In the future we need to support the case where MediaWebContentsObserver
42 // get notified on browser UI thread, but BrowserMediaPlayerManager and 45 // get notified on browser UI thread, but BrowserMediaPlayerManager and
43 // BrowserCdmManager run on a different thread. 46 // BrowserCdmManager run on a different thread.
44 BrowserCdmManager* browser_cdm_manager = 47 BrowserCdmManager* browser_cdm_manager =
45 BrowserCdmManager::FromProcess(render_frame_host->GetProcess()->GetID()); 48 BrowserCdmManager::FromProcess(render_frame_host->GetProcess()->GetID());
46 if (browser_cdm_manager) 49 if (browser_cdm_manager)
47 browser_cdm_manager->RenderFrameDeleted(render_frame_host->GetRoutingID()); 50 browser_cdm_manager->RenderFrameDeleted(render_frame_host->GetRoutingID());
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 BrowserMediaPlayerManager::OnRequestRemotePlayback) 291 BrowserMediaPlayerManager::OnRequestRemotePlayback)
289 IPC_MESSAGE_FORWARD( 292 IPC_MESSAGE_FORWARD(
290 MediaPlayerHostMsg_RequestRemotePlaybackControl, 293 MediaPlayerHostMsg_RequestRemotePlaybackControl,
291 GetMediaPlayerManager(render_frame_host), 294 GetMediaPlayerManager(render_frame_host),
292 BrowserMediaPlayerManager::OnRequestRemotePlaybackControl) 295 BrowserMediaPlayerManager::OnRequestRemotePlaybackControl)
293 #if defined(VIDEO_HOLE) 296 #if defined(VIDEO_HOLE)
294 IPC_MESSAGE_FORWARD(MediaPlayerHostMsg_NotifyExternalSurface, 297 IPC_MESSAGE_FORWARD(MediaPlayerHostMsg_NotifyExternalSurface,
295 GetMediaPlayerManager(render_frame_host), 298 GetMediaPlayerManager(render_frame_host),
296 BrowserMediaPlayerManager::OnNotifyExternalSurface) 299 BrowserMediaPlayerManager::OnNotifyExternalSurface)
297 #endif // defined(VIDEO_HOLE) 300 #endif // defined(VIDEO_HOLE)
301 IPC_MESSAGE_FORWARD(MediaSessionHostMsg_Activate,
302 GetMediaSessionManager(render_frame_host),
303 BrowserMediaSessionManager::OnActivate)
304 IPC_MESSAGE_FORWARD(MediaSessionHostMsg_Deactivate,
305 GetMediaSessionManager(render_frame_host),
306 BrowserMediaSessionManager::OnDeactivate)
298 IPC_MESSAGE_UNHANDLED(handled = false) 307 IPC_MESSAGE_UNHANDLED(handled = false)
299 IPC_END_MESSAGE_MAP() 308 IPC_END_MESSAGE_MAP()
300 return handled; 309 return handled;
301 } 310 }
302 311
303 bool MediaWebContentsObserver::OnMediaPlayerSetCdmMessageReceived( 312 bool MediaWebContentsObserver::OnMediaPlayerSetCdmMessageReceived(
304 const IPC::Message& msg, 313 const IPC::Message& msg,
305 RenderFrameHost* render_frame_host) { 314 RenderFrameHost* render_frame_host) {
306 bool handled = true; 315 bool handled = true;
307 IPC_BEGIN_MESSAGE_MAP_WITH_PARAM( 316 IPC_BEGIN_MESSAGE_MAP_WITH_PARAM(
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 auto it = media_player_managers_.find(render_frame_host); 356 auto it = media_player_managers_.find(render_frame_host);
348 if (it != media_player_managers_.end()) 357 if (it != media_player_managers_.end())
349 return it->second; 358 return it->second;
350 359
351 BrowserMediaPlayerManager* manager = 360 BrowserMediaPlayerManager* manager =
352 BrowserMediaPlayerManager::Create(render_frame_host); 361 BrowserMediaPlayerManager::Create(render_frame_host);
353 media_player_managers_.set(render_frame_host, make_scoped_ptr(manager)); 362 media_player_managers_.set(render_frame_host, make_scoped_ptr(manager));
354 return manager; 363 return manager;
355 } 364 }
356 365
366 BrowserMediaSessionManager* MediaWebContentsObserver::GetMediaSessionManager(
367 RenderFrameHost* render_frame_host) {
368 auto it = media_session_managers_.find(render_frame_host);
369 if (it != media_session_managers_.end())
370 return it->second;
371
372 BrowserMediaSessionManager* manager =
373 new BrowserMediaSessionManager(render_frame_host);
374 media_session_managers_.set(render_frame_host, make_scoped_ptr(manager));
375 return manager;
376 }
377
357 #if defined(VIDEO_HOLE) 378 #if defined(VIDEO_HOLE)
358 void MediaWebContentsObserver::OnFrameInfoUpdated() { 379 void MediaWebContentsObserver::OnFrameInfoUpdated() {
359 for (auto it = media_player_managers_.begin(); 380 for (auto it = media_player_managers_.begin();
360 it != media_player_managers_.end(); ++it) { 381 it != media_player_managers_.end(); ++it) {
361 it->second->OnFrameInfoUpdated(); 382 it->second->OnFrameInfoUpdated();
362 } 383 }
363 } 384 }
364 #endif // defined(VIDEO_HOLE) 385 #endif // defined(VIDEO_HOLE)
365 386
366 #endif // defined(OS_ANDROID) 387 #endif // defined(OS_ANDROID)
367 388
368 } // namespace content 389 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/media/media_web_contents_observer.h ('k') | content/common/content_message_generator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698