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

Side by Side Diff: content/renderer/render_frame_impl.cc

Issue 2065513004: Expose flash playback status and volume control to content renderer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@audio_focus_manager
Patch Set: fixed nits for bbudge Created 4 years, 6 months 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/renderer/render_frame_impl.h" 5 #include "content/renderer/render_frame_impl.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 #include "content/renderer/media/render_media_log.h" 109 #include "content/renderer/media/render_media_log.h"
110 #include "content/renderer/media/renderer_webmediaplayer_delegate.h" 110 #include "content/renderer/media/renderer_webmediaplayer_delegate.h"
111 #include "content/renderer/media/user_media_client_impl.h" 111 #include "content/renderer/media/user_media_client_impl.h"
112 #include "content/renderer/media/web_media_element_source_utils.h" 112 #include "content/renderer/media/web_media_element_source_utils.h"
113 #include "content/renderer/media/webmediaplayer_ms.h" 113 #include "content/renderer/media/webmediaplayer_ms.h"
114 #include "content/renderer/mojo/service_registry_js_wrapper.h" 114 #include "content/renderer/mojo/service_registry_js_wrapper.h"
115 #include "content/renderer/mojo_bindings_controller.h" 115 #include "content/renderer/mojo_bindings_controller.h"
116 #include "content/renderer/navigation_state_impl.h" 116 #include "content/renderer/navigation_state_impl.h"
117 #include "content/renderer/notification_permission_dispatcher.h" 117 #include "content/renderer/notification_permission_dispatcher.h"
118 #include "content/renderer/pepper/plugin_instance_throttler_impl.h" 118 #include "content/renderer/pepper/plugin_instance_throttler_impl.h"
119 #include "content/renderer/pepper/ppb_audio_impl.h"
119 #include "content/renderer/presentation/presentation_dispatcher.h" 120 #include "content/renderer/presentation/presentation_dispatcher.h"
120 #include "content/renderer/push_messaging/push_messaging_dispatcher.h" 121 #include "content/renderer/push_messaging/push_messaging_dispatcher.h"
121 #include "content/renderer/render_frame_proxy.h" 122 #include "content/renderer/render_frame_proxy.h"
122 #include "content/renderer/render_process.h" 123 #include "content/renderer/render_process.h"
123 #include "content/renderer/render_thread_impl.h" 124 #include "content/renderer/render_thread_impl.h"
124 #include "content/renderer/render_view_impl.h" 125 #include "content/renderer/render_view_impl.h"
125 #include "content/renderer/render_widget_fullscreen_pepper.h" 126 #include "content/renderer/render_widget_fullscreen_pepper.h"
126 #include "content/renderer/renderer_webapplicationcachehost_impl.h" 127 #include "content/renderer/renderer_webapplicationcachehost_impl.h"
127 #include "content/renderer/renderer_webcolorchooser_impl.h" 128 #include "content/renderer/renderer_webcolorchooser_impl.h"
128 #include "content/renderer/savable_resources.h" 129 #include "content/renderer/savable_resources.h"
(...skipping 1342 matching lines...) Expand 10 before | Expand all | Expand 10 after
1471 bool handled = true; 1472 bool handled = true;
1472 IPC_BEGIN_MESSAGE_MAP(RenderFrameImpl, msg) 1473 IPC_BEGIN_MESSAGE_MAP(RenderFrameImpl, msg)
1473 IPC_MESSAGE_HANDLER(FrameMsg_Navigate, OnNavigate) 1474 IPC_MESSAGE_HANDLER(FrameMsg_Navigate, OnNavigate)
1474 IPC_MESSAGE_HANDLER(FrameMsg_BeforeUnload, OnBeforeUnload) 1475 IPC_MESSAGE_HANDLER(FrameMsg_BeforeUnload, OnBeforeUnload)
1475 IPC_MESSAGE_HANDLER(FrameMsg_SwapOut, OnSwapOut) 1476 IPC_MESSAGE_HANDLER(FrameMsg_SwapOut, OnSwapOut)
1476 IPC_MESSAGE_HANDLER(FrameMsg_Delete, OnDeleteFrame) 1477 IPC_MESSAGE_HANDLER(FrameMsg_Delete, OnDeleteFrame)
1477 IPC_MESSAGE_HANDLER(FrameMsg_Stop, OnStop) 1478 IPC_MESSAGE_HANDLER(FrameMsg_Stop, OnStop)
1478 IPC_MESSAGE_HANDLER(FrameMsg_ContextMenuClosed, OnContextMenuClosed) 1479 IPC_MESSAGE_HANDLER(FrameMsg_ContextMenuClosed, OnContextMenuClosed)
1479 IPC_MESSAGE_HANDLER(FrameMsg_CustomContextMenuAction, 1480 IPC_MESSAGE_HANDLER(FrameMsg_CustomContextMenuAction,
1480 OnCustomContextMenuAction) 1481 OnCustomContextMenuAction)
1482 #if defined(ENABLE_PLUGINS)
1483 IPC_MESSAGE_HANDLER(FrameMsg_SetPepperVolume, OnSetPepperVolume)
1484 #endif //defined(ENABLE_PLUGINS)
1481 IPC_MESSAGE_HANDLER(InputMsg_Undo, OnUndo) 1485 IPC_MESSAGE_HANDLER(InputMsg_Undo, OnUndo)
1482 IPC_MESSAGE_HANDLER(InputMsg_Redo, OnRedo) 1486 IPC_MESSAGE_HANDLER(InputMsg_Redo, OnRedo)
1483 IPC_MESSAGE_HANDLER(InputMsg_Cut, OnCut) 1487 IPC_MESSAGE_HANDLER(InputMsg_Cut, OnCut)
1484 IPC_MESSAGE_HANDLER(InputMsg_Copy, OnCopy) 1488 IPC_MESSAGE_HANDLER(InputMsg_Copy, OnCopy)
1485 IPC_MESSAGE_HANDLER(InputMsg_Paste, OnPaste) 1489 IPC_MESSAGE_HANDLER(InputMsg_Paste, OnPaste)
1486 IPC_MESSAGE_HANDLER(InputMsg_PasteAndMatchStyle, OnPasteAndMatchStyle) 1490 IPC_MESSAGE_HANDLER(InputMsg_PasteAndMatchStyle, OnPasteAndMatchStyle)
1487 IPC_MESSAGE_HANDLER(InputMsg_Delete, OnDelete) 1491 IPC_MESSAGE_HANDLER(InputMsg_Delete, OnDelete)
1488 IPC_MESSAGE_HANDLER(InputMsg_SelectAll, OnSelectAll) 1492 IPC_MESSAGE_HANDLER(InputMsg_SelectAll, OnSelectAll)
1489 IPC_MESSAGE_HANDLER(InputMsg_SelectRange, OnSelectRange) 1493 IPC_MESSAGE_HANDLER(InputMsg_SelectRange, OnSelectRange)
1490 IPC_MESSAGE_HANDLER(InputMsg_AdjustSelectionByCharacterOffset, 1494 IPC_MESSAGE_HANDLER(InputMsg_AdjustSelectionByCharacterOffset,
(...skipping 4690 matching lines...) Expand 10 before | Expand all | Expand 10 after
6181 selection_rect, 6185 selection_rect,
6182 ordinal, 6186 ordinal,
6183 final_status_update)); 6187 final_status_update));
6184 } 6188 }
6185 6189
6186 #if defined(ENABLE_PLUGINS) 6190 #if defined(ENABLE_PLUGINS)
6187 void RenderFrameImpl::PepperInstanceCreated( 6191 void RenderFrameImpl::PepperInstanceCreated(
6188 PepperPluginInstanceImpl* instance) { 6192 PepperPluginInstanceImpl* instance) {
6189 active_pepper_instances_.insert(instance); 6193 active_pepper_instances_.insert(instance);
6190 6194
6191 Send(new FrameHostMsg_PepperInstanceCreated(routing_id_)); 6195 Send(new FrameHostMsg_PepperInstanceCreated(routing_id_,
6196 instance->pp_instance()));
6192 } 6197 }
6193 6198
6194 void RenderFrameImpl::PepperInstanceDeleted( 6199 void RenderFrameImpl::PepperInstanceDeleted(
6195 PepperPluginInstanceImpl* instance) { 6200 PepperPluginInstanceImpl* instance) {
6196 active_pepper_instances_.erase(instance); 6201 active_pepper_instances_.erase(instance);
6197 6202
6198 if (pepper_last_mouse_event_target_ == instance) 6203 if (pepper_last_mouse_event_target_ == instance)
6199 pepper_last_mouse_event_target_ = nullptr; 6204 pepper_last_mouse_event_target_ = nullptr;
6200 if (focused_pepper_plugin_ == instance) 6205 if (focused_pepper_plugin_ == instance)
6201 PepperFocusChanged(instance, false); 6206 PepperFocusChanged(instance, false);
6202 6207
6203 RenderFrameImpl* const render_frame = instance->render_frame(); 6208 RenderFrameImpl* const render_frame = instance->render_frame();
6204 if (render_frame) 6209 if (render_frame)
6205 render_frame->Send( 6210 render_frame->Send(
6206 new FrameHostMsg_PepperInstanceDeleted(render_frame->GetRoutingID())); 6211 new FrameHostMsg_PepperInstanceDeleted(render_frame->GetRoutingID(),
6212 instance->pp_instance()));
6207 } 6213 }
6208 6214
6209 void RenderFrameImpl::PepperFocusChanged(PepperPluginInstanceImpl* instance, 6215 void RenderFrameImpl::PepperFocusChanged(PepperPluginInstanceImpl* instance,
6210 bool focused) { 6216 bool focused) {
6211 if (focused) 6217 if (focused)
6212 focused_pepper_plugin_ = instance; 6218 focused_pepper_plugin_ = instance;
6213 else if (focused_pepper_plugin_ == instance) 6219 else if (focused_pepper_plugin_ == instance)
6214 focused_pepper_plugin_ = nullptr; 6220 focused_pepper_plugin_ = nullptr;
6215 6221
6216 GetRenderWidget()->UpdateTextInputState(ShowIme::HIDE_IME, 6222 GetRenderWidget()->UpdateTextInputState(ShowIme::HIDE_IME,
6217 ChangeSource::FROM_NON_IME); 6223 ChangeSource::FROM_NON_IME);
6218 GetRenderWidget()->UpdateSelectionBounds(); 6224 GetRenderWidget()->UpdateSelectionBounds();
6219 } 6225 }
6220 6226
6227 void RenderFrameImpl::PepperStartsPlayback(
6228 PepperPluginInstanceImpl* instance, PPB_Audio_Impl* ppb_audio) {
6229 // Only send start signal for the first PPB_Audio_Impl starts playback.
6230 if (pepper_audios_map_[instance->pp_instance()].empty()) {
6231 RenderFrameImpl* const render_frame = instance->render_frame();
6232 if (render_frame)
6233 render_frame->Send(
6234 new FrameHostMsg_PepperStartsPlayback(render_frame->GetRoutingID(),
6235 instance->pp_instance()));
6236 }
6237 // TODO(zqzhang): it is unsure that whether a pepper instance can
6238 // have multiple audio instances. Currently let the pepper instance
6239 // delegates the SetVolume() method of all it's audio instances.
6240 pepper_audios_map_[instance->pp_instance()].insert(ppb_audio);
6241 }
6242
6243 void RenderFrameImpl::PepperStopsPlayback(
6244 PepperPluginInstanceImpl* instance, PPB_Audio_Impl* ppb_audio) {
6245 pepper_audios_map_[instance->pp_instance()].erase(ppb_audio);
6246
6247 RenderFrameImpl* const render_frame = instance->render_frame();
6248 // Only send stop signal for the last PPB_Audio_Impl stops playback.
6249 if (render_frame && pepper_audios_map_[instance->pp_instance()].empty())
6250 render_frame->Send(
6251 new FrameHostMsg_PepperStopsPlayback(render_frame->GetRoutingID(),
6252 instance->pp_instance()));
6253 }
6254
6255 void RenderFrameImpl::OnSetPepperVolume(int32_t pp_instance, double volume) {
6256 if (pepper_audios_map_.count(pp_instance) == 0) return;
6257 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.
6258 ppb_audio->SetVolume(volume);
6259 }
6260 }
6221 #endif // ENABLE_PLUGINS 6261 #endif // ENABLE_PLUGINS
6222 6262
6223 void RenderFrameImpl::RenderWidgetSetFocus(bool enable) { 6263 void RenderFrameImpl::RenderWidgetSetFocus(bool enable) {
6224 #if defined(ENABLE_PLUGINS) 6264 #if defined(ENABLE_PLUGINS)
6225 // Notify all Pepper plugins. 6265 // Notify all Pepper plugins.
6226 for (auto* plugin : active_pepper_instances_) 6266 for (auto* plugin : active_pepper_instances_)
6227 plugin->SetContentAreaFocus(enable); 6267 plugin->SetContentAreaFocus(enable);
6228 #endif 6268 #endif
6229 } 6269 }
6230 6270
6231 void RenderFrameImpl::RenderWidgetWillHandleMouseEvent() { 6271 void RenderFrameImpl::RenderWidgetWillHandleMouseEvent() {
6232 #if defined(ENABLE_PLUGINS) 6272 #if defined(ENABLE_PLUGINS)
6233 // This method is called for every mouse event that the RenderWidget receives. 6273 // This method is called for every mouse event that the RenderWidget receives.
6234 // And then the mouse event is forwarded to blink, which dispatches it to the 6274 // And then the mouse event is forwarded to blink, which dispatches it to the
6235 // event target. Potentially a Pepper plugin will receive the event. 6275 // event target. Potentially a Pepper plugin will receive the event.
6236 // In order to tell whether a plugin gets the last mouse event and which it 6276 // In order to tell whether a plugin gets the last mouse event and which it
6237 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets 6277 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets
6238 // the event, it will notify us via DidReceiveMouseEvent() and set itself as 6278 // the event, it will notify us via DidReceiveMouseEvent() and set itself as
6239 // |pepper_last_mouse_event_target_|. 6279 // |pepper_last_mouse_event_target_|.
6240 pepper_last_mouse_event_target_ = nullptr; 6280 pepper_last_mouse_event_target_ = nullptr;
6241 #endif 6281 #endif
6242 } 6282 }
6243 6283
6244 } // namespace content 6284 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698