OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/session/media_session_impl.h" | 5 #include "content/browser/media/session/media_session_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include "content/browser/media/session/audio_focus_delegate.h" | 8 #include "content/browser/media/session/audio_focus_delegate.h" |
9 #include "content/browser/media/session/media_session_controller.h" | 9 #include "content/browser/media/session/media_session_controller.h" |
10 #include "content/browser/media/session/media_session_player_observer.h" | 10 #include "content/browser/media/session/media_session_player_observer.h" |
(...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
623 | 623 |
624 void MediaSessionImpl::UpdateRoutedService() { | 624 void MediaSessionImpl::UpdateRoutedService() { |
625 MediaSessionServiceImpl* new_service = ComputeServiceForRouting(); | 625 MediaSessionServiceImpl* new_service = ComputeServiceForRouting(); |
626 if (new_service == routed_service_) | 626 if (new_service == routed_service_) |
627 return; | 627 return; |
628 | 628 |
629 routed_service_ = new_service; | 629 routed_service_ = new_service; |
630 if (routed_service_) { | 630 if (routed_service_) { |
631 NotifyMediaSessionMetadataChange(routed_service_->metadata()); | 631 NotifyMediaSessionMetadataChange(routed_service_->metadata()); |
632 NotifyMediaSessionActionsChange(routed_service_->actions()); | 632 NotifyMediaSessionActionsChange(routed_service_->actions()); |
633 } else { | |
634 NotifyMediaSessionMetadataChange(base::nullopt); | |
635 NotifyMediaSessionActionsChange( | |
636 std::set<blink::mojom::MediaSessionAction>()); | |
637 } | 633 } |
638 } | 634 } |
639 | 635 |
640 MediaSessionServiceImpl* MediaSessionImpl::ComputeServiceForRouting() { | 636 MediaSessionServiceImpl* MediaSessionImpl::ComputeServiceForRouting() { |
641 // The service selection strategy is: select a frame that has a playing/paused | 637 // The service selection strategy is: select a frame that has a playing/paused |
642 // player and has a corresponding MediaSessionService and return the | 638 // player and has a corresponding MediaSessionService and return the |
643 // corresponding MediaSessionService. If multiple frames satisfy the criteria, | 639 // corresponding MediaSessionService. If multiple frames satisfy the criteria, |
644 // prefer the top-most frame. | 640 // prefer the top-most frame. |
645 std::set<RenderFrameHost*> frames; | 641 std::set<RenderFrameHost*> frames; |
646 for (const auto& player : normal_players_) { | 642 for (const auto& player : normal_players_) { |
(...skipping 25 matching lines...) Expand all Loading... |
672 if (!IsServiceActiveForRenderFrameHost(frame)) | 668 if (!IsServiceActiveForRenderFrameHost(frame)) |
673 continue; | 669 continue; |
674 best_frame = frame; | 670 best_frame = frame; |
675 min_depth = depth; | 671 min_depth = depth; |
676 } | 672 } |
677 | 673 |
678 return best_frame ? services_[best_frame] : nullptr; | 674 return best_frame ? services_[best_frame] : nullptr; |
679 } | 675 } |
680 | 676 |
681 } // namespace content | 677 } // namespace content |
OLD | NEW |