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

Side by Side Diff: content/browser/media/session/pepper_player_delegate.cc

Issue 2551093002: Route Pepper MediaSession messages to frames (Closed)
Patch Set: fixed Android build Created 4 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 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_player_delegate.h" 5 #include "content/browser/media/session/pepper_player_delegate.h"
6 6
7 #include "content/browser/frame_host/render_frame_host_impl.h" 7 #include "content/browser/frame_host/render_frame_host_impl.h"
8 #include "content/browser/media/session/pepper_playback_observer.h" 8 #include "content/browser/media/session/pepper_playback_observer.h"
9 #include "content/browser/web_contents/web_contents_impl.h"
10 #include "content/common/frame_messages.h" 9 #include "content/common/frame_messages.h"
11 #include "media/base/media_switches.h" 10 #include "media/base/media_switches.h"
12 11
13 namespace content { 12 namespace content {
14 13
15 namespace { 14 namespace {
16 15
17 const double kDuckVolume = 0.2f; 16 const double kDuckVolume = 0.2f;
18 17
19 bool ShouldDuckFlash() { 18 bool ShouldDuckFlash() {
20 return base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 19 return base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
21 switches::kEnableDefaultMediaSession) == 20 switches::kEnableDefaultMediaSession) ==
22 switches::kEnableDefaultMediaSessionDuckFlash; 21 switches::kEnableDefaultMediaSessionDuckFlash;
23 } 22 }
24 23
25 } // anonymous namespace 24 } // anonymous namespace
26 25
27 const int PepperPlayerDelegate::kPlayerId = 0; 26 const int PepperPlayerDelegate::kPlayerId = 0;
28 27
29 PepperPlayerDelegate::PepperPlayerDelegate( 28 PepperPlayerDelegate::PepperPlayerDelegate(
30 WebContentsImpl* contents, int32_t pp_instance) 29 RenderFrameHost* render_frame_host, int32_t pp_instance)
31 : contents_(contents), 30 : render_frame_host_(render_frame_host),
32 pp_instance_(pp_instance) {} 31 pp_instance_(pp_instance) {}
33 32
34 PepperPlayerDelegate::~PepperPlayerDelegate() = default; 33 PepperPlayerDelegate::~PepperPlayerDelegate() = default;
35 34
36 void PepperPlayerDelegate::OnSuspend(int player_id) { 35 void PepperPlayerDelegate::OnSuspend(int player_id) {
37 if (!ShouldDuckFlash()) 36 if (!ShouldDuckFlash())
38 return; 37 return;
39 38
40 // Pepper player cannot be really suspended. Duck the volume instead. 39 // Pepper player cannot be really suspended. Duck the volume instead.
41 DCHECK_EQ(player_id, kPlayerId); 40 DCHECK_EQ(player_id, kPlayerId);
(...skipping 11 matching lines...) Expand all
53 void PepperPlayerDelegate::OnSetVolumeMultiplier(int player_id, 52 void PepperPlayerDelegate::OnSetVolumeMultiplier(int player_id,
54 double volume_multiplier) { 53 double volume_multiplier) {
55 if (!ShouldDuckFlash()) 54 if (!ShouldDuckFlash())
56 return; 55 return;
57 56
58 DCHECK_EQ(player_id, kPlayerId); 57 DCHECK_EQ(player_id, kPlayerId);
59 SetVolume(player_id, volume_multiplier); 58 SetVolume(player_id, volume_multiplier);
60 } 59 }
61 60
62 RenderFrameHost* PepperPlayerDelegate::GetRenderFrameHost() const { 61 RenderFrameHost* PepperPlayerDelegate::GetRenderFrameHost() const {
63 // TODO(zqzhang): Pepper player should be associated to a RenderFrameHost. 62 return render_frame_host_;
64 return nullptr;
65 } 63 }
66 64
67 void PepperPlayerDelegate::SetVolume(int player_id, double volume) { 65 void PepperPlayerDelegate::SetVolume(int player_id, double volume) {
68 contents_->Send(new FrameMsg_SetPepperVolume( 66 render_frame_host_->Send(new FrameMsg_SetPepperVolume(
69 contents_->GetMainFrame()->routing_id(), pp_instance_, volume)); 67 render_frame_host_->GetRoutingID(), pp_instance_, volume));
70 } 68 }
71 69
72 } // namespace content 70 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/media/session/pepper_player_delegate.h ('k') | content/browser/web_contents/web_contents_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698