| OLD | NEW | 
|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/pepper_playback_observer.h" | 5 #include "content/browser/media/session/pepper_playback_observer.h" | 
| 6 | 6 | 
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" | 
| 8 #include "base/metrics/histogram_macros.h" | 8 #include "base/metrics/histogram_macros.h" | 
| 9 #include "content/browser/media/session/media_session_impl.h" | 9 #include "content/browser/media/session/media_session_impl.h" | 
| 10 #include "content/browser/media/session/pepper_player_delegate.h" | 10 #include "content/browser/media/session/pepper_player_delegate.h" | 
| 11 #include "content/common/frame_messages.h" | 11 #include "content/common/frame_messages.h" | 
| 12 #include "ipc/ipc_message_macros.h" | 12 #include "ipc/ipc_message_macros.h" | 
| 13 #include "media/base/media_content_type.h" | 13 #include "media/base/media_content_type.h" | 
| 14 #include "media/base/media_switches.h" | 14 #include "media/base/media_switches.h" | 
| 15 | 15 | 
| 16 namespace content { | 16 namespace content { | 
| 17 | 17 | 
| 18 namespace { | 18 namespace { | 
| 19 | 19 | 
| 20 bool ShouldDuckFlash() { | 20 bool ShouldDuckFlashFoo() { | 
| 21   return base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 21   return base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 
| 22              switches::kEnableAudioFocus) == | 22              switches::kEnableAudioFocus) == | 
| 23          switches::kEnableAudioFocusDuckFlash; | 23          switches::kEnableAudioFocusDuckFlash; | 
| 24 } | 24 } | 
| 25 | 25 | 
| 26 }  // anonymous namespace | 26 }  // anonymous namespace | 
| 27 | 27 | 
| 28 PepperPlaybackObserver::PepperPlaybackObserver(WebContents* contents) | 28 PepperPlaybackObserver::PepperPlaybackObserver(WebContents* contents) | 
| 29     : contents_(contents) {} | 29     : contents_(contents) {} | 
| 30 | 30 | 
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 78   players_played_sound_map_[id] = true; | 78   players_played_sound_map_[id] = true; | 
| 79 | 79 | 
| 80   if (players_map_.count(id)) | 80   if (players_map_.count(id)) | 
| 81     return; | 81     return; | 
| 82 | 82 | 
| 83   players_map_[id].reset(new PepperPlayerDelegate( | 83   players_map_[id].reset(new PepperPlayerDelegate( | 
| 84       render_frame_host, pp_instance)); | 84       render_frame_host, pp_instance)); | 
| 85 | 85 | 
| 86   MediaSessionImpl::Get(contents_)->AddPlayer( | 86   MediaSessionImpl::Get(contents_)->AddPlayer( | 
| 87       players_map_[id].get(), PepperPlayerDelegate::kPlayerId, | 87       players_map_[id].get(), PepperPlayerDelegate::kPlayerId, | 
| 88       ShouldDuckFlash() ? media::MediaContentType::Pepper | 88       ShouldDuckFlashFoo() ? media::MediaContentType::Pepper | 
| 89                         : media::MediaContentType::OneShot); | 89                         : media::MediaContentType::OneShot); | 
| 90 } | 90 } | 
| 91 | 91 | 
| 92 void PepperPlaybackObserver::PepperStopsPlayback( | 92 void PepperPlaybackObserver::PepperStopsPlayback( | 
| 93     RenderFrameHost* render_frame_host, int32_t pp_instance) { | 93     RenderFrameHost* render_frame_host, int32_t pp_instance) { | 
| 94   PlayerId id(render_frame_host, pp_instance); | 94   PlayerId id(render_frame_host, pp_instance); | 
| 95 | 95 | 
| 96   if (!players_map_.count(id)) | 96   if (!players_map_.count(id)) | 
| 97     return; | 97     return; | 
| 98 | 98 | 
| 99   MediaSessionImpl::Get(contents_)->RemovePlayer( | 99   MediaSessionImpl::Get(contents_)->RemovePlayer( | 
| 100       players_map_[id].get(), PepperPlayerDelegate::kPlayerId); | 100       players_map_[id].get(), PepperPlayerDelegate::kPlayerId); | 
| 101 | 101 | 
| 102   players_map_.erase(id); | 102   players_map_.erase(id); | 
| 103 } | 103 } | 
| 104 | 104 | 
| 105 }  // namespace content | 105 }  // namespace content | 
| OLD | NEW | 
|---|