Chromium Code Reviews| Index: content/renderer/render_frame_impl.cc |
| diff --git a/content/renderer/render_frame_impl.cc b/content/renderer/render_frame_impl.cc |
| index f327bc6756e8596333fd0b7248a37e5c5dbcd6c5..2585b04045abf77b138efd2ef6a8258a509927b1 100644 |
| --- a/content/renderer/render_frame_impl.cc |
| +++ b/content/renderer/render_frame_impl.cc |
| @@ -116,6 +116,7 @@ |
| #include "content/renderer/navigation_state_impl.h" |
| #include "content/renderer/notification_permission_dispatcher.h" |
| #include "content/renderer/pepper/plugin_instance_throttler_impl.h" |
| +#include "content/renderer/pepper/ppb_audio_impl.h" |
| #include "content/renderer/presentation/presentation_dispatcher.h" |
| #include "content/renderer/push_messaging/push_messaging_dispatcher.h" |
| #include "content/renderer/render_frame_proxy.h" |
| @@ -1478,6 +1479,9 @@ bool RenderFrameImpl::OnMessageReceived(const IPC::Message& msg) { |
| IPC_MESSAGE_HANDLER(FrameMsg_ContextMenuClosed, OnContextMenuClosed) |
| IPC_MESSAGE_HANDLER(FrameMsg_CustomContextMenuAction, |
| OnCustomContextMenuAction) |
| +#if defined(ENABLE_PLUGINS) |
| + IPC_MESSAGE_HANDLER(FrameMsg_SetPepperVolume, OnSetPepperVolume) |
| +#endif //defined(ENABLE_PLUGINS) |
| IPC_MESSAGE_HANDLER(InputMsg_Undo, OnUndo) |
| IPC_MESSAGE_HANDLER(InputMsg_Redo, OnRedo) |
| IPC_MESSAGE_HANDLER(InputMsg_Cut, OnCut) |
| @@ -6188,7 +6192,8 @@ void RenderFrameImpl::PepperInstanceCreated( |
| PepperPluginInstanceImpl* instance) { |
| active_pepper_instances_.insert(instance); |
| - Send(new FrameHostMsg_PepperInstanceCreated(routing_id_)); |
| + Send(new FrameHostMsg_PepperInstanceCreated(routing_id_, |
| + instance->pp_instance())); |
| } |
| void RenderFrameImpl::PepperInstanceDeleted( |
| @@ -6203,7 +6208,8 @@ void RenderFrameImpl::PepperInstanceDeleted( |
| RenderFrameImpl* const render_frame = instance->render_frame(); |
| if (render_frame) |
| render_frame->Send( |
| - new FrameHostMsg_PepperInstanceDeleted(render_frame->GetRoutingID())); |
| + new FrameHostMsg_PepperInstanceDeleted(render_frame->GetRoutingID(), |
| + instance->pp_instance())); |
| } |
| void RenderFrameImpl::PepperFocusChanged(PepperPluginInstanceImpl* instance, |
| @@ -6218,6 +6224,40 @@ void RenderFrameImpl::PepperFocusChanged(PepperPluginInstanceImpl* instance, |
| GetRenderWidget()->UpdateSelectionBounds(); |
| } |
| +void RenderFrameImpl::PepperStartsPlayback( |
| + PepperPluginInstanceImpl* instance, PPB_Audio_Impl* ppb_audio) { |
| + // Only send start signal for the first PPB_Audio_Impl starts playback. |
| + if (pepper_audios_map_[instance->pp_instance()].empty()) { |
| + RenderFrameImpl* const render_frame = instance->render_frame(); |
| + if (render_frame) |
| + render_frame->Send( |
| + new FrameHostMsg_PepperStartsPlayback(render_frame->GetRoutingID(), |
| + instance->pp_instance())); |
| + } |
| + // TODO(zqzhang): it is unsure that whether a pepper instance can |
| + // have multiple audio instances. Currently let the pepper instance |
| + // delegates the SetVolume() method of all it's audio instances. |
| + pepper_audios_map_[instance->pp_instance()].insert(ppb_audio); |
| +} |
| + |
| +void RenderFrameImpl::PepperStopsPlayback( |
| + PepperPluginInstanceImpl* instance, PPB_Audio_Impl* ppb_audio) { |
| + pepper_audios_map_[instance->pp_instance()].erase(ppb_audio); |
| + |
| + RenderFrameImpl* const render_frame = instance->render_frame(); |
| + // Only send stop signal for the last PPB_Audio_Impl stops playback. |
| + if (render_frame && pepper_audios_map_[instance->pp_instance()].empty()) |
| + render_frame->Send( |
| + new FrameHostMsg_PepperStopsPlayback(render_frame->GetRoutingID(), |
| + instance->pp_instance())); |
| +} |
| + |
| +void RenderFrameImpl::OnSetPepperVolume(int32_t pp_instance, double volume) { |
| + if (pepper_audios_map_.count(pp_instance) == 0) return; |
| + for (auto ppb_audio : pepper_audios_map_[pp_instance]) { |
|
dcheng
2016/06/14 20:00:32
Nit: auto*, since this is a pointer.
Zhiqiang Zhang (Slow)
2016/06/20 19:11:54
Done.
|
| + ppb_audio->SetVolume(volume); |
| + } |
| +} |
| #endif // ENABLE_PLUGINS |
| void RenderFrameImpl::RenderWidgetSetFocus(bool enable) { |