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