OLD | NEW |
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 | 9 |
10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 #include "content/renderer/dom_automation_controller.h" | 53 #include "content/renderer/dom_automation_controller.h" |
54 #include "content/renderer/history_controller.h" | 54 #include "content/renderer/history_controller.h" |
55 #include "content/renderer/history_serialization.h" | 55 #include "content/renderer/history_serialization.h" |
56 #include "content/renderer/image_loading_helper.h" | 56 #include "content/renderer/image_loading_helper.h" |
57 #include "content/renderer/ime_event_guard.h" | 57 #include "content/renderer/ime_event_guard.h" |
58 #include "content/renderer/internal_document_state_data.h" | 58 #include "content/renderer/internal_document_state_data.h" |
59 #include "content/renderer/java/java_bridge_dispatcher.h" | 59 #include "content/renderer/java/java_bridge_dispatcher.h" |
60 #include "content/renderer/media/audio_renderer_mixer_manager.h" | 60 #include "content/renderer/media/audio_renderer_mixer_manager.h" |
61 #include "content/renderer/media/media_stream_dispatcher.h" | 61 #include "content/renderer/media/media_stream_dispatcher.h" |
62 #include "content/renderer/media/media_stream_impl.h" | 62 #include "content/renderer/media/media_stream_impl.h" |
| 63 #include "content/renderer/media/media_stream_renderer_factory.h" |
63 #include "content/renderer/media/render_media_log.h" | 64 #include "content/renderer/media/render_media_log.h" |
64 #include "content/renderer/media/webcontentdecryptionmodule_impl.h" | 65 #include "content/renderer/media/webcontentdecryptionmodule_impl.h" |
65 #include "content/renderer/media/webmediaplayer_impl.h" | 66 #include "content/renderer/media/webmediaplayer_impl.h" |
66 #include "content/renderer/media/webmediaplayer_ms.h" | 67 #include "content/renderer/media/webmediaplayer_ms.h" |
67 #include "content/renderer/media/webmediaplayer_params.h" | 68 #include "content/renderer/media/webmediaplayer_params.h" |
68 #include "content/renderer/notification_provider.h" | 69 #include "content/renderer/notification_provider.h" |
69 #include "content/renderer/npapi/plugin_channel_host.h" | 70 #include "content/renderer/npapi/plugin_channel_host.h" |
70 #include "content/renderer/render_process.h" | 71 #include "content/renderer/render_process.h" |
71 #include "content/renderer/render_thread_impl.h" | 72 #include "content/renderer/render_thread_impl.h" |
72 #include "content/renderer/render_view_impl.h" | 73 #include "content/renderer/render_view_impl.h" |
(...skipping 11 matching lines...) Expand all Loading... |
84 #include "third_party/WebKit/public/platform/WebStorageQuotaCallbacks.h" | 85 #include "third_party/WebKit/public/platform/WebStorageQuotaCallbacks.h" |
85 #include "third_party/WebKit/public/platform/WebString.h" | 86 #include "third_party/WebKit/public/platform/WebString.h" |
86 #include "third_party/WebKit/public/platform/WebURL.h" | 87 #include "third_party/WebKit/public/platform/WebURL.h" |
87 #include "third_party/WebKit/public/platform/WebURLError.h" | 88 #include "third_party/WebKit/public/platform/WebURLError.h" |
88 #include "third_party/WebKit/public/platform/WebURLResponse.h" | 89 #include "third_party/WebKit/public/platform/WebURLResponse.h" |
89 #include "third_party/WebKit/public/platform/WebVector.h" | 90 #include "third_party/WebKit/public/platform/WebVector.h" |
90 #include "third_party/WebKit/public/web/WebColorSuggestion.h" | 91 #include "third_party/WebKit/public/web/WebColorSuggestion.h" |
91 #include "third_party/WebKit/public/web/WebDocument.h" | 92 #include "third_party/WebKit/public/web/WebDocument.h" |
92 #include "third_party/WebKit/public/web/WebGlyphCache.h" | 93 #include "third_party/WebKit/public/web/WebGlyphCache.h" |
93 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 94 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
| 95 #include "third_party/WebKit/public/web/WebMediaStreamRegistry.h" |
94 #include "third_party/WebKit/public/web/WebNavigationPolicy.h" | 96 #include "third_party/WebKit/public/web/WebNavigationPolicy.h" |
95 #include "third_party/WebKit/public/web/WebPlugin.h" | 97 #include "third_party/WebKit/public/web/WebPlugin.h" |
96 #include "third_party/WebKit/public/web/WebPluginParams.h" | 98 #include "third_party/WebKit/public/web/WebPluginParams.h" |
97 #include "third_party/WebKit/public/web/WebRange.h" | 99 #include "third_party/WebKit/public/web/WebRange.h" |
98 #include "third_party/WebKit/public/web/WebScriptSource.h" | 100 #include "third_party/WebKit/public/web/WebScriptSource.h" |
99 #include "third_party/WebKit/public/web/WebSearchableFormData.h" | 101 #include "third_party/WebKit/public/web/WebSearchableFormData.h" |
100 #include "third_party/WebKit/public/web/WebSecurityOrigin.h" | 102 #include "third_party/WebKit/public/web/WebSecurityOrigin.h" |
101 #include "third_party/WebKit/public/web/WebSecurityPolicy.h" | 103 #include "third_party/WebKit/public/web/WebSecurityPolicy.h" |
102 #include "third_party/WebKit/public/web/WebUserGestureIndicator.h" | 104 #include "third_party/WebKit/public/web/WebUserGestureIndicator.h" |
103 #include "third_party/WebKit/public/web/WebView.h" | 105 #include "third_party/WebKit/public/web/WebView.h" |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 render_view_(render_view->AsWeakPtr()), | 397 render_view_(render_view->AsWeakPtr()), |
396 routing_id_(routing_id), | 398 routing_id_(routing_id), |
397 is_swapped_out_(false), | 399 is_swapped_out_(false), |
398 render_frame_proxy_(NULL), | 400 render_frame_proxy_(NULL), |
399 is_detaching_(false), | 401 is_detaching_(false), |
400 cookie_jar_(this), | 402 cookie_jar_(this), |
401 selection_text_offset_(0), | 403 selection_text_offset_(0), |
402 selection_range_(gfx::Range::InvalidRange()), | 404 selection_range_(gfx::Range::InvalidRange()), |
403 handling_select_range_(false), | 405 handling_select_range_(false), |
404 notification_provider_(NULL), | 406 notification_provider_(NULL), |
405 media_stream_client_(NULL), | |
406 web_user_media_client_(NULL), | 407 web_user_media_client_(NULL), |
407 weak_factory_(this) { | 408 weak_factory_(this) { |
408 RenderThread::Get()->AddRoute(routing_id_, this); | 409 RenderThread::Get()->AddRoute(routing_id_, this); |
409 | 410 |
410 std::pair<RoutingIDFrameMap::iterator, bool> result = | 411 std::pair<RoutingIDFrameMap::iterator, bool> result = |
411 g_routing_id_frame_map.Get().insert(std::make_pair(routing_id_, this)); | 412 g_routing_id_frame_map.Get().insert(std::make_pair(routing_id_, this)); |
412 CHECK(result.second) << "Inserting a duplicate item."; | 413 CHECK(result.second) << "Inserting a duplicate item."; |
413 | 414 |
414 #if defined(OS_ANDROID) | 415 #if defined(OS_ANDROID) |
415 new JavaBridgeDispatcher(this); | 416 new JavaBridgeDispatcher(this); |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
628 // Mimics the order of events sent by WebKit. | 629 // Mimics the order of events sent by WebKit. |
629 // See WebCore::Editor::setComposition() for the corresponding code. | 630 // See WebCore::Editor::setComposition() for the corresponding code. |
630 render_view_->focused_pepper_plugin()->HandleCompositionEnd(last_text); | 631 render_view_->focused_pepper_plugin()->HandleCompositionEnd(last_text); |
631 render_view_->focused_pepper_plugin()->HandleTextInput(last_text); | 632 render_view_->focused_pepper_plugin()->HandleTextInput(last_text); |
632 } | 633 } |
633 pepper_composition_text_.clear(); | 634 pepper_composition_text_.clear(); |
634 } | 635 } |
635 | 636 |
636 #endif // ENABLE_PLUGINS | 637 #endif // ENABLE_PLUGINS |
637 | 638 |
638 void RenderFrameImpl::SetMediaStreamClientForTesting( | |
639 MediaStreamClient* media_stream_client) { | |
640 DCHECK(!media_stream_client_); | |
641 DCHECK(!web_user_media_client_); | |
642 media_stream_client_ = media_stream_client; | |
643 } | |
644 | |
645 bool RenderFrameImpl::Send(IPC::Message* message) { | 639 bool RenderFrameImpl::Send(IPC::Message* message) { |
646 if (is_detaching_) { | 640 if (is_detaching_) { |
647 delete message; | 641 delete message; |
648 return false; | 642 return false; |
649 } | 643 } |
650 if (is_swapped_out_ || render_view_->is_swapped_out()) { | 644 if (is_swapped_out_ || render_view_->is_swapped_out()) { |
651 if (!SwappedOutMessages::CanSendWhileSwappedOut(message)) { | 645 if (!SwappedOutMessages::CanSendWhileSwappedOut(message)) { |
652 delete message; | 646 delete message; |
653 return false; | 647 return false; |
654 } | 648 } |
(...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1368 return CreatePlugin(frame, info, params_to_use); | 1362 return CreatePlugin(frame, info, params_to_use); |
1369 #else | 1363 #else |
1370 return NULL; | 1364 return NULL; |
1371 #endif // defined(ENABLE_PLUGINS) | 1365 #endif // defined(ENABLE_PLUGINS) |
1372 } | 1366 } |
1373 | 1367 |
1374 blink::WebMediaPlayer* RenderFrameImpl::createMediaPlayer( | 1368 blink::WebMediaPlayer* RenderFrameImpl::createMediaPlayer( |
1375 blink::WebLocalFrame* frame, | 1369 blink::WebLocalFrame* frame, |
1376 const blink::WebURL& url, | 1370 const blink::WebURL& url, |
1377 blink::WebMediaPlayerClient* client) { | 1371 blink::WebMediaPlayerClient* client) { |
1378 WebMediaPlayer* player = CreateWebMediaPlayerForMediaStream(url, client); | 1372 blink::WebMediaStream web_stream( |
1379 if (player) | 1373 blink::WebMediaStreamRegistry::lookupMediaStreamDescriptor(url)); |
1380 return player; | 1374 if (!web_stream.isNull()) |
| 1375 return CreateWebMediaPlayerForMediaStream(url, client); |
1381 | 1376 |
1382 #if defined(OS_ANDROID) | 1377 #if defined(OS_ANDROID) |
1383 return CreateAndroidWebMediaPlayer(url, client); | 1378 return CreateAndroidWebMediaPlayer(url, client); |
1384 #else | 1379 #else |
1385 WebMediaPlayerParams params( | 1380 WebMediaPlayerParams params( |
1386 base::Bind(&ContentRendererClient::DeferMediaLoad, | 1381 base::Bind(&ContentRendererClient::DeferMediaLoad, |
1387 base::Unretained(GetContentClient()->renderer()), | 1382 base::Unretained(GetContentClient()->renderer()), |
1388 static_cast<RenderFrame*>(this)), | 1383 static_cast<RenderFrame*>(this)), |
1389 RenderThreadImpl::current()->GetAudioRendererMixerManager()->CreateInput( | 1384 RenderThreadImpl::current()->GetAudioRendererMixerManager()->CreateInput( |
1390 render_view_->routing_id_, routing_id_)); | 1385 render_view_->routing_id_, routing_id_)); |
(...skipping 1335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2726 blink::WebLocalFrame* frame, | 2721 blink::WebLocalFrame* frame, |
2727 blink::WebRTCPeerConnectionHandler* handler) { | 2722 blink::WebRTCPeerConnectionHandler* handler) { |
2728 DCHECK(!frame_ || frame_ == frame); | 2723 DCHECK(!frame_ || frame_ == frame); |
2729 #if defined(ENABLE_WEBRTC) | 2724 #if defined(ENABLE_WEBRTC) |
2730 static_cast<RTCPeerConnectionHandler*>(handler)->associateWithFrame(frame); | 2725 static_cast<RTCPeerConnectionHandler*>(handler)->associateWithFrame(frame); |
2731 #endif | 2726 #endif |
2732 } | 2727 } |
2733 | 2728 |
2734 blink::WebUserMediaClient* RenderFrameImpl::userMediaClient() { | 2729 blink::WebUserMediaClient* RenderFrameImpl::userMediaClient() { |
2735 // This can happen in tests, in which case it's OK to return NULL. | 2730 // This can happen in tests, in which case it's OK to return NULL. |
2736 if (!InitializeMediaStreamClient()) | 2731 if (!InitializeUserMediaClient()) |
2737 return NULL; | 2732 return NULL; |
2738 | 2733 |
2739 return web_user_media_client_; | 2734 return web_user_media_client_; |
2740 } | 2735 } |
2741 | 2736 |
2742 blink::WebMIDIClient* RenderFrameImpl::webMIDIClient() { | 2737 blink::WebMIDIClient* RenderFrameImpl::webMIDIClient() { |
2743 return render_view_->webMIDIClient(); | 2738 return render_view_->webMIDIClient(); |
2744 } | 2739 } |
2745 | 2740 |
2746 bool RenderFrameImpl::willCheckAndDispatchMessageEvent( | 2741 bool RenderFrameImpl::willCheckAndDispatchMessageEvent( |
(...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3390 selection_text_ = text; | 3385 selection_text_ = text; |
3391 selection_text_offset_ = offset; | 3386 selection_text_offset_ = offset; |
3392 selection_range_ = range; | 3387 selection_range_ = range; |
3393 // This IPC is dispatched by RenderWidetHost, so use its routing ID. | 3388 // This IPC is dispatched by RenderWidetHost, so use its routing ID. |
3394 Send(new ViewHostMsg_SelectionChanged( | 3389 Send(new ViewHostMsg_SelectionChanged( |
3395 GetRenderWidget()->routing_id(), text, offset, range)); | 3390 GetRenderWidget()->routing_id(), text, offset, range)); |
3396 } | 3391 } |
3397 GetRenderWidget()->UpdateSelectionBounds(); | 3392 GetRenderWidget()->UpdateSelectionBounds(); |
3398 } | 3393 } |
3399 | 3394 |
3400 bool RenderFrameImpl::InitializeMediaStreamClient() { | 3395 bool RenderFrameImpl::InitializeUserMediaClient() { |
3401 if (media_stream_client_) | 3396 if (web_user_media_client_) |
3402 return true; | 3397 return true; |
3403 | 3398 |
3404 if (!RenderThreadImpl::current()) // Will be NULL during unit tests. | 3399 if (!RenderThreadImpl::current()) // Will be NULL during unit tests. |
3405 return false; | 3400 return false; |
3406 | 3401 |
3407 #if defined(OS_ANDROID) | 3402 #if defined(OS_ANDROID) |
3408 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableWebRTC)) | 3403 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableWebRTC)) |
3409 return false; | 3404 return false; |
3410 #endif | 3405 #endif |
3411 | 3406 |
3412 #if defined(ENABLE_WEBRTC) | 3407 #if defined(ENABLE_WEBRTC) |
3413 if (!render_view_->media_stream_dispatcher_) { | 3408 if (!render_view_->media_stream_dispatcher_) { |
3414 render_view_->media_stream_dispatcher_ = | 3409 render_view_->media_stream_dispatcher_ = |
3415 new MediaStreamDispatcher(render_view_.get()); | 3410 new MediaStreamDispatcher(render_view_.get()); |
3416 } | 3411 } |
3417 | 3412 |
3418 MediaStreamImpl* media_stream_impl = new MediaStreamImpl( | 3413 MediaStreamImpl* media_stream_impl = new MediaStreamImpl( |
3419 render_view_.get(), | 3414 render_view_.get(), |
3420 render_view_->media_stream_dispatcher_, | 3415 render_view_->media_stream_dispatcher_, |
3421 RenderThreadImpl::current()->GetPeerConnectionDependencyFactory()); | 3416 RenderThreadImpl::current()->GetPeerConnectionDependencyFactory()); |
3422 media_stream_client_ = media_stream_impl; | |
3423 web_user_media_client_ = media_stream_impl; | 3417 web_user_media_client_ = media_stream_impl; |
3424 return true; | 3418 return true; |
3425 #else | 3419 #else |
3426 return false; | 3420 return false; |
3427 #endif | 3421 #endif |
3428 } | 3422 } |
3429 | 3423 |
3430 WebMediaPlayer* RenderFrameImpl::CreateWebMediaPlayerForMediaStream( | 3424 WebMediaPlayer* RenderFrameImpl::CreateWebMediaPlayerForMediaStream( |
3431 const blink::WebURL& url, | 3425 const blink::WebURL& url, |
3432 WebMediaPlayerClient* client) { | 3426 WebMediaPlayerClient* client) { |
3433 #if defined(ENABLE_WEBRTC) | 3427 #if defined(ENABLE_WEBRTC) |
3434 if (!InitializeMediaStreamClient()) { | |
3435 LOG(ERROR) << "Failed to initialize MediaStreamClient"; | |
3436 return NULL; | |
3437 } | |
3438 if (media_stream_client_->IsMediaStream(url)) { | |
3439 #if defined(OS_ANDROID) && defined(ARCH_CPU_ARMEL) | 3428 #if defined(OS_ANDROID) && defined(ARCH_CPU_ARMEL) |
3440 bool found_neon = | 3429 bool found_neon = |
3441 (android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) != 0; | 3430 (android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) != 0; |
3442 UMA_HISTOGRAM_BOOLEAN("Platform.WebRtcNEONFound", found_neon); | 3431 UMA_HISTOGRAM_BOOLEAN("Platform.WebRtcNEONFound", found_neon); |
3443 #endif // defined(OS_ANDROID) && defined(ARCH_CPU_ARMEL) | 3432 #endif // defined(OS_ANDROID) && defined(ARCH_CPU_ARMEL) |
3444 return new WebMediaPlayerMS(frame_, client, weak_factory_.GetWeakPtr(), | 3433 return new WebMediaPlayerMS(frame_, client, weak_factory_.GetWeakPtr(), |
3445 media_stream_client_, new RenderMediaLog()); | 3434 new RenderMediaLog(), |
3446 } | 3435 CreateRendererFactory()); |
| 3436 #else |
| 3437 return NULL; |
3447 #endif // defined(ENABLE_WEBRTC) | 3438 #endif // defined(ENABLE_WEBRTC) |
3448 return NULL; | 3439 } |
| 3440 |
| 3441 scoped_ptr<MediaStreamRendererFactory> |
| 3442 RenderFrameImpl::CreateRendererFactory() { |
| 3443 #if defined(ENABLE_WEBRTC) |
| 3444 return scoped_ptr<MediaStreamRendererFactory>( |
| 3445 new MediaStreamRendererFactory()); |
| 3446 #else |
| 3447 return scoped_ptr<MediaStreamRendererFactory>( |
| 3448 static_cast<MediaStreamRendererFactory*>(NULL)); |
| 3449 #endif |
3449 } | 3450 } |
3450 | 3451 |
3451 #if defined(OS_ANDROID) | 3452 #if defined(OS_ANDROID) |
3452 | 3453 |
3453 WebMediaPlayer* RenderFrameImpl::CreateAndroidWebMediaPlayer( | 3454 WebMediaPlayer* RenderFrameImpl::CreateAndroidWebMediaPlayer( |
3454 const blink::WebURL& url, | 3455 const blink::WebURL& url, |
3455 WebMediaPlayerClient* client) { | 3456 WebMediaPlayerClient* client) { |
3456 GpuChannelHost* gpu_channel_host = | 3457 GpuChannelHost* gpu_channel_host = |
3457 RenderThreadImpl::current()->EstablishGpuChannelSync( | 3458 RenderThreadImpl::current()->EstablishGpuChannelSync( |
3458 CAUSE_FOR_GPU_LAUNCH_VIDEODECODEACCELERATOR_INITIALIZE); | 3459 CAUSE_FOR_GPU_LAUNCH_VIDEODECODEACCELERATOR_INITIALIZE); |
(...skipping 27 matching lines...) Expand all Loading... |
3486 weak_factory_.GetWeakPtr(), | 3487 weak_factory_.GetWeakPtr(), |
3487 render_view_->media_player_manager_, | 3488 render_view_->media_player_manager_, |
3488 stream_texture_factory, | 3489 stream_texture_factory, |
3489 RenderThreadImpl::current()->GetMediaThreadMessageLoopProxy(), | 3490 RenderThreadImpl::current()->GetMediaThreadMessageLoopProxy(), |
3490 new RenderMediaLog()); | 3491 new RenderMediaLog()); |
3491 } | 3492 } |
3492 | 3493 |
3493 #endif | 3494 #endif |
3494 | 3495 |
3495 } // namespace content | 3496 } // namespace content |
OLD | NEW |