| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_view_impl.h" | 5 #include "content/renderer/render_view_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 | 9 |
| 10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
| (...skipping 787 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 798 cached_has_main_frame_horizontal_scrollbar_(false), | 798 cached_has_main_frame_horizontal_scrollbar_(false), |
| 799 cached_has_main_frame_vertical_scrollbar_(false), | 799 cached_has_main_frame_vertical_scrollbar_(false), |
| 800 cookie_jar_(this), | 800 cookie_jar_(this), |
| 801 notification_provider_(NULL), | 801 notification_provider_(NULL), |
| 802 geolocation_dispatcher_(NULL), | 802 geolocation_dispatcher_(NULL), |
| 803 input_tag_speech_dispatcher_(NULL), | 803 input_tag_speech_dispatcher_(NULL), |
| 804 speech_recognition_dispatcher_(NULL), | 804 speech_recognition_dispatcher_(NULL), |
| 805 device_orientation_dispatcher_(NULL), | 805 device_orientation_dispatcher_(NULL), |
| 806 media_stream_dispatcher_(NULL), | 806 media_stream_dispatcher_(NULL), |
| 807 browser_plugin_manager_(NULL), | 807 browser_plugin_manager_(NULL), |
| 808 media_stream_impl_(NULL), | 808 media_stream_client_(NULL), |
| 809 web_user_media_client_(NULL), |
| 809 devtools_agent_(NULL), | 810 devtools_agent_(NULL), |
| 810 accessibility_mode_(AccessibilityModeOff), | 811 accessibility_mode_(AccessibilityModeOff), |
| 811 renderer_accessibility_(NULL), | 812 renderer_accessibility_(NULL), |
| 812 java_bridge_dispatcher_(NULL), | 813 java_bridge_dispatcher_(NULL), |
| 813 mouse_lock_dispatcher_(NULL), | 814 mouse_lock_dispatcher_(NULL), |
| 814 #if defined(OS_ANDROID) | 815 #if defined(OS_ANDROID) |
| 815 body_background_color_(SK_ColorWHITE), | 816 body_background_color_(SK_ColorWHITE), |
| 816 expected_content_intent_id_(0), | 817 expected_content_intent_id_(0), |
| 817 media_player_proxy_(NULL), | 818 media_player_proxy_(NULL), |
| 818 #endif | 819 #endif |
| (...skipping 2050 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2869 } | 2870 } |
| 2870 } | 2871 } |
| 2871 | 2872 |
| 2872 WebMediaPlayer* RenderViewImpl::createMediaPlayer( | 2873 WebMediaPlayer* RenderViewImpl::createMediaPlayer( |
| 2873 WebFrame* frame, const WebKit::WebURL& url, WebMediaPlayerClient* client) { | 2874 WebFrame* frame, const WebKit::WebURL& url, WebMediaPlayerClient* client) { |
| 2874 FOR_EACH_OBSERVER( | 2875 FOR_EACH_OBSERVER( |
| 2875 RenderViewObserver, observers_, WillCreateMediaPlayer(frame, client)); | 2876 RenderViewObserver, observers_, WillCreateMediaPlayer(frame, client)); |
| 2876 | 2877 |
| 2877 const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); | 2878 const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); |
| 2878 #if defined(ENABLE_WEBRTC) | 2879 #if defined(ENABLE_WEBRTC) |
| 2879 webkit_media::MediaStreamClient* media_stream_client = | 2880 EnsureMediaStreamClient(); |
| 2880 GetContentClient()->renderer()->OverrideCreateMediaStreamClient(); | |
| 2881 if (!media_stream_client) { | |
| 2882 EnsureMediaStreamImpl(); | |
| 2883 media_stream_client = media_stream_impl_; | |
| 2884 } | |
| 2885 | |
| 2886 #if !defined(GOOGLE_TV) | 2881 #if !defined(GOOGLE_TV) |
| 2887 if (media_stream_client->IsMediaStream(url)) { | 2882 if (media_stream_client_->IsMediaStream(url)) { |
| 2888 #if defined(OS_ANDROID) && defined(ARCH_CPU_ARMEL) | 2883 #if defined(OS_ANDROID) && defined(ARCH_CPU_ARMEL) |
| 2889 bool found_neon = | 2884 bool found_neon = |
| 2890 (android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) != 0; | 2885 (android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) != 0; |
| 2891 UMA_HISTOGRAM_BOOLEAN("Platform.WebRtcNEONFound", found_neon); | 2886 UMA_HISTOGRAM_BOOLEAN("Platform.WebRtcNEONFound", found_neon); |
| 2892 #endif // defined(OS_ANDROID) && defined(ARCH_CPU_ARMEL) | 2887 #endif // defined(OS_ANDROID) && defined(ARCH_CPU_ARMEL) |
| 2893 return new webkit_media::WebMediaPlayerMS( | 2888 return new webkit_media::WebMediaPlayerMS( |
| 2894 frame, client, AsWeakPtr(), media_stream_client, new RenderMediaLog()); | 2889 frame, client, AsWeakPtr(), media_stream_client_, new RenderMediaLog()); |
| 2895 } | 2890 } |
| 2896 #endif // !defined(GOOGLE_TV) | 2891 #endif // !defined(GOOGLE_TV) |
| 2897 #endif // defined(ENABLE_WEBRTC) | 2892 #endif // defined(ENABLE_WEBRTC) |
| 2898 | 2893 |
| 2899 #if defined(OS_ANDROID) | 2894 #if defined(OS_ANDROID) |
| 2900 GpuChannelHost* gpu_channel_host = | 2895 GpuChannelHost* gpu_channel_host = |
| 2901 RenderThreadImpl::current()->EstablishGpuChannelSync( | 2896 RenderThreadImpl::current()->EstablishGpuChannelSync( |
| 2902 CAUSE_FOR_GPU_LAUNCH_VIDEODECODEACCELERATOR_INITIALIZE); | 2897 CAUSE_FOR_GPU_LAUNCH_VIDEODECODEACCELERATOR_INITIALIZE); |
| 2903 if (!gpu_channel_host) { | 2898 if (!gpu_channel_host) { |
| 2904 LOG(ERROR) << "Failed to establish GPU channel for media player"; | 2899 LOG(ERROR) << "Failed to establish GPU channel for media player"; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 2920 new WebMediaPlayerAndroid( | 2915 new WebMediaPlayerAndroid( |
| 2921 frame, | 2916 frame, |
| 2922 client, | 2917 client, |
| 2923 AsWeakPtr(), | 2918 AsWeakPtr(), |
| 2924 media_player_manager_.get(), | 2919 media_player_manager_.get(), |
| 2925 media_player_proxy_, | 2920 media_player_proxy_, |
| 2926 new StreamTextureFactory( | 2921 new StreamTextureFactory( |
| 2927 context_provider->Context3d(), gpu_channel_host, routing_id_), | 2922 context_provider->Context3d(), gpu_channel_host, routing_id_), |
| 2928 new RenderMediaLog())); | 2923 new RenderMediaLog())); |
| 2929 #if defined(ENABLE_WEBRTC) && defined(GOOGLE_TV) | 2924 #if defined(ENABLE_WEBRTC) && defined(GOOGLE_TV) |
| 2930 if (media_stream_client->IsMediaStream(url)) { | 2925 if (media_stream_client_->IsMediaStream(url)) { |
| 2931 RTCVideoDecoderFactoryTv* factory = RenderThreadImpl::current() | 2926 RTCVideoDecoderFactoryTv* factory = RenderThreadImpl::current() |
| 2932 ->GetMediaStreamDependencyFactory()->decoder_factory_tv(); | 2927 ->GetMediaStreamDependencyFactory()->decoder_factory_tv(); |
| 2933 // |media_stream_client| and |factory| outlives |web_media_player_android|. | 2928 // |media_stream_client| and |factory| outlives |web_media_player_android|. |
| 2934 if (!factory->AcquireDemuxer() || | 2929 if (!factory->AcquireDemuxer() || |
| 2935 !web_media_player_android->InjectMediaStream( | 2930 !web_media_player_android->InjectMediaStream( |
| 2936 media_stream_client, | 2931 media_stream_client_, |
| 2937 factory, | 2932 factory, |
| 2938 base::Bind( | 2933 base::Bind( |
| 2939 base::IgnoreResult(&RTCVideoDecoderFactoryTv::ReleaseDemuxer), | 2934 base::IgnoreResult(&RTCVideoDecoderFactoryTv::ReleaseDemuxer), |
| 2940 base::Unretained(factory)))) { | 2935 base::Unretained(factory)))) { |
| 2941 LOG(ERROR) << "Failed to inject media stream."; | 2936 LOG(ERROR) << "Failed to inject media stream."; |
| 2942 return NULL; | 2937 return NULL; |
| 2943 } | 2938 } |
| 2944 } | 2939 } |
| 2945 #endif // defined(ENABLE_WEBRTC) && defined(GOOGLE_TV) | 2940 #endif // defined(ENABLE_WEBRTC) && defined(GOOGLE_TV) |
| 2946 return web_media_player_android.release(); | 2941 return web_media_player_android.release(); |
| (...skipping 1324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4271 Send(new ViewHostMsg_DidContentsPreferredSizeChange(routing_id_, | 4266 Send(new ViewHostMsg_DidContentsPreferredSizeChange(routing_id_, |
| 4272 preferred_size_)); | 4267 preferred_size_)); |
| 4273 } | 4268 } |
| 4274 | 4269 |
| 4275 BrowserPluginManager* RenderViewImpl::GetBrowserPluginManager() { | 4270 BrowserPluginManager* RenderViewImpl::GetBrowserPluginManager() { |
| 4276 if (!browser_plugin_manager_.get()) | 4271 if (!browser_plugin_manager_.get()) |
| 4277 browser_plugin_manager_ = BrowserPluginManager::Create(this); | 4272 browser_plugin_manager_ = BrowserPluginManager::Create(this); |
| 4278 return browser_plugin_manager_.get(); | 4273 return browser_plugin_manager_.get(); |
| 4279 } | 4274 } |
| 4280 | 4275 |
| 4281 void RenderViewImpl::EnsureMediaStreamImpl() { | 4276 void RenderViewImpl::EnsureMediaStreamClient() { |
| 4282 if (!RenderThreadImpl::current()) // Will be NULL during unit tests. | 4277 if (!RenderThreadImpl::current()) // Will be NULL during unit tests. |
| 4283 return; | 4278 return; |
| 4284 | 4279 |
| 4285 #if defined(OS_ANDROID) | 4280 #if defined(OS_ANDROID) |
| 4286 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableWebRTC)) | 4281 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableWebRTC)) |
| 4287 return; | 4282 return; |
| 4288 #endif | 4283 #endif |
| 4289 | 4284 |
| 4290 #if defined(ENABLE_WEBRTC) | 4285 #if defined(ENABLE_WEBRTC) |
| 4291 if (!media_stream_dispatcher_) | 4286 if (!media_stream_dispatcher_) |
| 4292 media_stream_dispatcher_ = new MediaStreamDispatcher(this); | 4287 media_stream_dispatcher_ = new MediaStreamDispatcher(this); |
| 4293 | 4288 |
| 4294 if (!media_stream_impl_) { | 4289 if (!media_stream_client_) { |
| 4295 media_stream_impl_ = new MediaStreamImpl( | 4290 MediaStreamImpl* media_stream_impl = new MediaStreamImpl( |
| 4296 this, | 4291 this, |
| 4297 media_stream_dispatcher_, | 4292 media_stream_dispatcher_, |
| 4298 RenderThreadImpl::current()->GetMediaStreamDependencyFactory()); | 4293 RenderThreadImpl::current()->GetMediaStreamDependencyFactory()); |
| 4294 media_stream_client_ = media_stream_impl; |
| 4295 web_user_media_client_ = media_stream_impl; |
| 4299 } | 4296 } |
| 4300 #endif | 4297 #endif |
| 4301 } | 4298 } |
| 4302 | 4299 |
| 4303 void RenderViewImpl::didChangeContentsSize(WebFrame* frame, | 4300 void RenderViewImpl::didChangeContentsSize(WebFrame* frame, |
| 4304 const WebSize& size) { | 4301 const WebSize& size) { |
| 4305 if (webview()->mainFrame() != frame) | 4302 if (webview()->mainFrame() != frame) |
| 4306 return; | 4303 return; |
| 4307 WebView* frameView = frame->view(); | 4304 WebView* frameView = frame->view(); |
| 4308 if (!frameView) | 4305 if (!frameView) |
| (...skipping 2200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6509 WebKit::WebPageVisibilityStateVisible; | 6506 WebKit::WebPageVisibilityStateVisible; |
| 6510 WebKit::WebPageVisibilityState override_state = current_state; | 6507 WebKit::WebPageVisibilityState override_state = current_state; |
| 6511 if (GetContentClient()->renderer()-> | 6508 if (GetContentClient()->renderer()-> |
| 6512 ShouldOverridePageVisibilityState(this, | 6509 ShouldOverridePageVisibilityState(this, |
| 6513 &override_state)) | 6510 &override_state)) |
| 6514 return override_state; | 6511 return override_state; |
| 6515 return current_state; | 6512 return current_state; |
| 6516 } | 6513 } |
| 6517 | 6514 |
| 6518 WebKit::WebUserMediaClient* RenderViewImpl::userMediaClient() { | 6515 WebKit::WebUserMediaClient* RenderViewImpl::userMediaClient() { |
| 6519 EnsureMediaStreamImpl(); | 6516 EnsureMediaStreamClient(); |
| 6520 return media_stream_impl_; | 6517 return web_user_media_client_; |
| 6521 } | 6518 } |
| 6522 | 6519 |
| 6523 void RenderViewImpl::draggableRegionsChanged() { | 6520 void RenderViewImpl::draggableRegionsChanged() { |
| 6524 FOR_EACH_OBSERVER( | 6521 FOR_EACH_OBSERVER( |
| 6525 RenderViewObserver, | 6522 RenderViewObserver, |
| 6526 observers_, | 6523 observers_, |
| 6527 DraggableRegionsChanged(webview()->mainFrame())); | 6524 DraggableRegionsChanged(webview()->mainFrame())); |
| 6528 } | 6525 } |
| 6529 | 6526 |
| 6530 #if defined(OS_ANDROID) | 6527 #if defined(OS_ANDROID) |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6779 | 6776 |
| 6780 void RenderViewImpl::EnableAutoResizeForTesting(const gfx::Size& min_size, | 6777 void RenderViewImpl::EnableAutoResizeForTesting(const gfx::Size& min_size, |
| 6781 const gfx::Size& max_size) { | 6778 const gfx::Size& max_size) { |
| 6782 OnEnableAutoResize(min_size, max_size); | 6779 OnEnableAutoResize(min_size, max_size); |
| 6783 } | 6780 } |
| 6784 | 6781 |
| 6785 void RenderViewImpl::DisableAutoResizeForTesting(const gfx::Size& new_size) { | 6782 void RenderViewImpl::DisableAutoResizeForTesting(const gfx::Size& new_size) { |
| 6786 OnDisableAutoResize(new_size); | 6783 OnDisableAutoResize(new_size); |
| 6787 } | 6784 } |
| 6788 | 6785 |
| 6786 void RenderViewImpl::SetMediaStreamClientForTesting( |
| 6787 webkit_media::MediaStreamClient* media_stream_client) { |
| 6788 DCHECK(!media_stream_client_); |
| 6789 DCHECK(!web_user_media_client_); |
| 6790 media_stream_client_ = media_stream_client; |
| 6791 } |
| 6792 |
| 6789 void RenderViewImpl::OnReleaseDisambiguationPopupDIB( | 6793 void RenderViewImpl::OnReleaseDisambiguationPopupDIB( |
| 6790 TransportDIB::Handle dib_handle) { | 6794 TransportDIB::Handle dib_handle) { |
| 6791 TransportDIB* dib = TransportDIB::CreateWithHandle(dib_handle); | 6795 TransportDIB* dib = TransportDIB::CreateWithHandle(dib_handle); |
| 6792 RenderProcess::current()->ReleaseTransportDIB(dib); | 6796 RenderProcess::current()->ReleaseTransportDIB(dib); |
| 6793 } | 6797 } |
| 6794 | 6798 |
| 6795 void RenderViewImpl::DidCommitCompositorFrame() { | 6799 void RenderViewImpl::DidCommitCompositorFrame() { |
| 6796 RenderWidget::DidCommitCompositorFrame(); | 6800 RenderWidget::DidCommitCompositorFrame(); |
| 6797 FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidCommitCompositorFrame()); | 6801 FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidCommitCompositorFrame()); |
| 6798 } | 6802 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 6815 WebURL url = icon_urls[i].iconURL(); | 6819 WebURL url = icon_urls[i].iconURL(); |
| 6816 if (!url.isEmpty()) | 6820 if (!url.isEmpty()) |
| 6817 urls.push_back(FaviconURL(url, | 6821 urls.push_back(FaviconURL(url, |
| 6818 ToFaviconType(icon_urls[i].iconType()))); | 6822 ToFaviconType(icon_urls[i].iconType()))); |
| 6819 } | 6823 } |
| 6820 SendUpdateFaviconURL(urls); | 6824 SendUpdateFaviconURL(urls); |
| 6821 } | 6825 } |
| 6822 | 6826 |
| 6823 | 6827 |
| 6824 } // namespace content | 6828 } // namespace content |
| OLD | NEW |