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

Side by Side Diff: content/browser/media/android/browser_media_player_manager.cc

Issue 107413006: Dismiss EME infobar when WebMediaPlayer is destroyed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/android/browser_media_player_manager.h" 5 #include "content/browser/media/android/browser_media_player_manager.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "content/browser/android/content_view_core_impl.h" 8 #include "content/browser/android/content_view_core_impl.h"
9 #include "content/browser/media/android/browser_demuxer_android.h" 9 #include "content/browser/media/android/browser_demuxer_android.h"
10 #include "content/browser/media/android/media_resource_getter_impl.h" 10 #include "content/browser/media/android/media_resource_getter_impl.h"
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 IPC_MESSAGE_HANDLER(MediaPlayerHostMsg_SetVolume, OnSetVolume) 127 IPC_MESSAGE_HANDLER(MediaPlayerHostMsg_SetVolume, OnSetVolume)
128 IPC_MESSAGE_HANDLER(MediaPlayerHostMsg_Release, OnReleaseResources) 128 IPC_MESSAGE_HANDLER(MediaPlayerHostMsg_Release, OnReleaseResources)
129 IPC_MESSAGE_HANDLER(MediaPlayerHostMsg_DestroyMediaPlayer, OnDestroyPlayer) 129 IPC_MESSAGE_HANDLER(MediaPlayerHostMsg_DestroyMediaPlayer, OnDestroyPlayer)
130 IPC_MESSAGE_HANDLER(MediaPlayerHostMsg_DestroyAllMediaPlayers, 130 IPC_MESSAGE_HANDLER(MediaPlayerHostMsg_DestroyAllMediaPlayers,
131 DestroyAllMediaPlayers) 131 DestroyAllMediaPlayers)
132 IPC_MESSAGE_HANDLER(MediaKeysHostMsg_InitializeCDM, 132 IPC_MESSAGE_HANDLER(MediaKeysHostMsg_InitializeCDM,
133 OnInitializeCDM) 133 OnInitializeCDM)
134 IPC_MESSAGE_HANDLER(MediaKeysHostMsg_CreateSession, OnCreateSession) 134 IPC_MESSAGE_HANDLER(MediaKeysHostMsg_CreateSession, OnCreateSession)
135 IPC_MESSAGE_HANDLER(MediaKeysHostMsg_UpdateSession, OnUpdateSession) 135 IPC_MESSAGE_HANDLER(MediaKeysHostMsg_UpdateSession, OnUpdateSession)
136 IPC_MESSAGE_HANDLER(MediaKeysHostMsg_ReleaseSession, OnReleaseSession) 136 IPC_MESSAGE_HANDLER(MediaKeysHostMsg_ReleaseSession, OnReleaseSession)
137 IPC_MESSAGE_HANDLER(MediaKeysHostMsg_CancelSession, OnCancelSession)
137 #if defined(VIDEO_HOLE) 138 #if defined(VIDEO_HOLE)
138 IPC_MESSAGE_HANDLER(MediaPlayerHostMsg_NotifyExternalSurface, 139 IPC_MESSAGE_HANDLER(MediaPlayerHostMsg_NotifyExternalSurface,
139 OnNotifyExternalSurface) 140 OnNotifyExternalSurface)
140 #endif // defined(VIDEO_HOLE) 141 #endif // defined(VIDEO_HOLE)
141 IPC_MESSAGE_UNHANDLED(handled = false) 142 IPC_MESSAGE_UNHANDLED(handled = false)
142 IPC_END_MESSAGE_MAP() 143 IPC_END_MESSAGE_MAP()
143 return handled; 144 return handled;
144 } 145 }
145 146
146 void BrowserMediaPlayerManager::FullscreenPlayerPlay() { 147 void BrowserMediaPlayerManager::FullscreenPlayerPlay() {
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 DLOG(WARNING) << "No MediaDrmBridge for ID: " << media_keys_id << " found"; 595 DLOG(WARNING) << "No MediaDrmBridge for ID: " << media_keys_id << " found";
595 OnSessionError( 596 OnSessionError(
596 media_keys_id, session_id, media::MediaKeys::kUnknownError, 0); 597 media_keys_id, session_id, media::MediaKeys::kUnknownError, 0);
597 return; 598 return;
598 } 599 }
599 600
600 if (media_keys_ids_approved_.find(media_keys_id) == 601 if (media_keys_ids_approved_.find(media_keys_id) ==
601 media_keys_ids_approved_.end()) { 602 media_keys_ids_approved_.end()) {
602 media_keys_ids_pending_approval_.insert(media_keys_id); 603 media_keys_ids_pending_approval_.insert(media_keys_id);
603 } 604 }
604 web_contents()->GetDelegate()->RequestProtectedMediaIdentifierPermission( 605
605 web_contents(), 606 BrowserContext* context =
607 web_contents()->GetRenderProcessHost()->GetBrowserContext();
608
609 context->RequestProtectedMediaIdentifierPermission(
610 web_contents()->GetRenderProcessHost()->GetID(),
611 web_contents()->GetRenderViewHost()->GetRoutingID(),
612 session_id,
606 drm_bridge->frame_url(), 613 drm_bridge->frame_url(),
607 base::Bind(&BrowserMediaPlayerManager::GenerateKeyIfAllowed, 614 base::Bind(&BrowserMediaPlayerManager::GenerateKeyIfAllowed,
608 weak_ptr_factory_.GetWeakPtr(), 615 weak_ptr_factory_.GetWeakPtr(),
609 media_keys_id, 616 media_keys_id,
610 session_id, 617 session_id,
611 type, 618 type,
612 init_data)); 619 init_data));
613 } 620 }
614 621
615 void BrowserMediaPlayerManager::OnUpdateSession( 622 void BrowserMediaPlayerManager::OnUpdateSession(
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
647 if (!drm_bridge) { 654 if (!drm_bridge) {
648 DLOG(WARNING) << "No MediaDrmBridge for ID: " << media_keys_id << " found"; 655 DLOG(WARNING) << "No MediaDrmBridge for ID: " << media_keys_id << " found";
649 OnSessionError( 656 OnSessionError(
650 media_keys_id, session_id, media::MediaKeys::kUnknownError, 0); 657 media_keys_id, session_id, media::MediaKeys::kUnknownError, 0);
651 return; 658 return;
652 } 659 }
653 660
654 drm_bridge->ReleaseSession(session_id); 661 drm_bridge->ReleaseSession(session_id);
655 } 662 }
656 663
664 void BrowserMediaPlayerManager::OnCancelSession(int media_keys_id,
665 uint32 session_id) {
666 MediaDrmBridge* drm_bridge = GetDrmBridge(media_keys_id);
667 if (!drm_bridge) {
668 DLOG(WARNING) << "No MediaDrmBridge for ID: " << media_keys_id << " found";
669 OnSessionError(
670 media_keys_id, session_id, media::MediaKeys::kUnknownError, 0);
671 return;
672 }
673
674 BrowserContext* context =
675 web_contents()->GetRenderProcessHost()->GetBrowserContext();
676
677 context->CancelProtectedMediaIdentifierPermissionRequest(
678 web_contents()->GetRenderProcessHost()->GetID(),
679 web_contents()->GetRenderViewHost()->GetRoutingID(),
680 static_cast<int>(session_id),
681 drm_bridge->frame_url());
682 }
683
657 void BrowserMediaPlayerManager::AddPlayer(MediaPlayerAndroid* player) { 684 void BrowserMediaPlayerManager::AddPlayer(MediaPlayerAndroid* player) {
658 DCHECK(!GetPlayer(player->player_id())); 685 DCHECK(!GetPlayer(player->player_id()));
659 players_.push_back(player); 686 players_.push_back(player);
660 if (player->IsRemote()) { 687 if (player->IsRemote()) {
661 Send(new MediaPlayerMsg_ConnectedToRemoteDevice(routing_id(), 688 Send(new MediaPlayerMsg_ConnectedToRemoteDevice(routing_id(),
662 player->player_id())); 689 player->player_id()));
663 } 690 }
664 } 691 }
665 692
666 void BrowserMediaPlayerManager::RemovePlayer(int player_id) { 693 void BrowserMediaPlayerManager::RemovePlayer(int player_id) {
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
739 MediaDrmBridge* drm_bridge = GetDrmBridge(media_keys_id); 766 MediaDrmBridge* drm_bridge = GetDrmBridge(media_keys_id);
740 if (!player || !drm_bridge) { 767 if (!player || !drm_bridge) {
741 DVLOG(1) << "OnSetMediaKeys(): Player and MediaKeys must be present."; 768 DVLOG(1) << "OnSetMediaKeys(): Player and MediaKeys must be present.";
742 return; 769 return;
743 } 770 }
744 // TODO(qinmin): add the logic to decide whether we should create the 771 // TODO(qinmin): add the logic to decide whether we should create the
745 // fullscreen surface for EME lv1. 772 // fullscreen surface for EME lv1.
746 player->SetDrmBridge(drm_bridge); 773 player->SetDrmBridge(drm_bridge);
747 } 774 }
748 775
749 void BrowserMediaPlayerManager::GenerateKeyIfAllowed( 776 void BrowserMediaPlayerManager::GenerateKeyIfAllowed(
xhwang 2013/12/21 00:40:48 This now should be renamed to CreateSessionIfAllow
Kibeom Kim (inactive) 2013/12/30 12:33:05 Done. (allowed-> permitted)
750 int media_keys_id, 777 int media_keys_id,
751 uint32 session_id, 778 uint32 session_id,
752 const std::string& type, 779 const std::string& type,
753 const std::vector<uint8>& init_data, 780 const std::vector<uint8>& init_data,
754 bool allowed) { 781 bool allowed) {
782 Send(new MediaKeysMsg_SessionApproved(
783 routing_id(), media_keys_id, session_id, allowed));
784
755 if (!allowed) 785 if (!allowed)
756 return; 786 return;
ddorwin 2013/12/20 23:59:52 I'm surprised we don't already fire some event her
xhwang 2013/12/21 00:40:48 Yeah, we should call OnSessionError() before we re
Kibeom Kim (inactive) 2013/12/30 12:33:05 Done.
757 787
758 MediaDrmBridge* drm_bridge = GetDrmBridge(media_keys_id); 788 MediaDrmBridge* drm_bridge = GetDrmBridge(media_keys_id);
759 if (!drm_bridge) { 789 if (!drm_bridge) {
760 DLOG(WARNING) << "No MediaDrmBridge for ID: " << media_keys_id << " found"; 790 DLOG(WARNING) << "No MediaDrmBridge for ID: " << media_keys_id << " found";
761 OnSessionError( 791 OnSessionError(
762 media_keys_id, session_id, media::MediaKeys::kUnknownError, 0); 792 media_keys_id, session_id, media::MediaKeys::kUnknownError, 0);
763 return; 793 return;
ddorwin 2013/12/20 23:59:52 Hmm, I see how this case makes using CreateSession
Kibeom Kim (inactive) 2013/12/30 12:33:05 Done.
764 } 794 }
765 media_keys_ids_pending_approval_.erase(media_keys_id); 795 media_keys_ids_pending_approval_.erase(media_keys_id);
766 media_keys_ids_approved_.insert(media_keys_id); 796 media_keys_ids_approved_.insert(media_keys_id);
767 drm_bridge->CreateSession(session_id, type, &init_data[0], init_data.size()); 797 drm_bridge->CreateSession(session_id, type, &init_data[0], init_data.size());
768 798
769 // TODO(qinmin): currently |media_keys_id| and player ID are identical. 799 // TODO(qinmin): currently |media_keys_id| and player ID are identical.
770 // This might not be true in the future. 800 // This might not be true in the future.
771 if (pending_fullscreen_player_id_ != media_keys_id) 801 if (pending_fullscreen_player_id_ != media_keys_id)
772 return; 802 return;
773 803
774 pending_fullscreen_player_id_ = -1; 804 pending_fullscreen_player_id_ = -1;
775 MediaPlayerAndroid* player = GetPlayer(media_keys_id); 805 MediaPlayerAndroid* player = GetPlayer(media_keys_id);
776 if (player->IsPlaying()) 806 if (player->IsPlaying())
777 OnProtectedSurfaceRequested(media_keys_id); 807 OnProtectedSurfaceRequested(media_keys_id);
778 } 808 }
779 809
780 } // namespace content 810 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698