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 3056 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3067 webview()->devToolsAgent()->setLayerTreeId(rwc->GetLayerTreeId()); | 3067 webview()->devToolsAgent()->setLayerTreeId(rwc->GetLayerTreeId()); |
3068 } | 3068 } |
3069 | 3069 |
3070 // WebKit::WebFrameClient ----------------------------------------------------- | 3070 // WebKit::WebFrameClient ----------------------------------------------------- |
3071 | 3071 |
3072 WebMediaPlayer* RenderViewImpl::createMediaPlayer( | 3072 WebMediaPlayer* RenderViewImpl::createMediaPlayer( |
3073 WebFrame* frame, const WebKit::WebURL& url, WebMediaPlayerClient* client) { | 3073 WebFrame* frame, const WebKit::WebURL& url, WebMediaPlayerClient* client) { |
3074 FOR_EACH_OBSERVER( | 3074 FOR_EACH_OBSERVER( |
3075 RenderViewObserver, observers_, WillCreateMediaPlayer(frame, client)); | 3075 RenderViewObserver, observers_, WillCreateMediaPlayer(frame, client)); |
3076 | 3076 |
3077 const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); | 3077 WebMediaPlayer* player = CreateWebMediaPlayerForMediaStream(frame, url, |
3078 #if defined(ENABLE_WEBRTC) | 3078 client); |
3079 if (!InitializeMediaStreamClient()) | 3079 if (player != NULL) |
scherkus (not reviewing)
2013/11/04 20:38:50
nit: remove != NULL check
michaelbai
2013/11/04 21:43:34
Done.
| |
3080 return NULL; | 3080 return player; |
michaelbai
2013/11/01 18:41:50
Here is the difference, the original code will ret
| |
3081 | |
3082 #if !defined(GOOGLE_TV) | |
3083 if (media_stream_client_->IsMediaStream(url)) { | |
3084 #if defined(OS_ANDROID) && defined(ARCH_CPU_ARMEL) | |
3085 bool found_neon = | |
3086 (android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) != 0; | |
3087 UMA_HISTOGRAM_BOOLEAN("Platform.WebRtcNEONFound", found_neon); | |
3088 #endif // defined(OS_ANDROID) && defined(ARCH_CPU_ARMEL) | |
3089 return new WebMediaPlayerMS( | |
3090 frame, client, AsWeakPtr(), media_stream_client_, new RenderMediaLog()); | |
3091 } | |
3092 #endif // !defined(GOOGLE_TV) | |
3093 #endif // defined(ENABLE_WEBRTC) | |
3094 | 3081 |
3095 #if defined(OS_ANDROID) | 3082 #if defined(OS_ANDROID) |
3096 GpuChannelHost* gpu_channel_host = | 3083 return CreateAndroidWebMediaPlayer(frame, url, client); |
3097 RenderThreadImpl::current()->EstablishGpuChannelSync( | 3084 #else |
3098 CAUSE_FOR_GPU_LAUNCH_VIDEODECODEACCELERATOR_INITIALIZE); | |
3099 if (!gpu_channel_host) { | |
3100 LOG(ERROR) << "Failed to establish GPU channel for media player"; | |
3101 return NULL; | |
3102 } | |
3103 | |
3104 scoped_ptr<StreamTextureFactory> stream_texture_factory; | |
3105 if (UsingSynchronousRendererCompositor()) { | |
3106 SynchronousCompositorFactory* factory = | |
3107 SynchronousCompositorFactory::GetInstance(); | |
3108 stream_texture_factory = factory->CreateStreamTextureFactory(routing_id_); | |
3109 } else { | |
3110 scoped_refptr<cc::ContextProvider> context_provider = | |
3111 RenderThreadImpl::current()->SharedMainThreadContextProvider(); | |
3112 | |
3113 if (!context_provider.get()) { | |
3114 LOG(ERROR) << "Failed to get context3d for media player"; | |
3115 return NULL; | |
3116 } | |
3117 | |
3118 stream_texture_factory.reset(new StreamTextureFactoryImpl( | |
3119 context_provider->Context3d(), gpu_channel_host, routing_id_)); | |
3120 } | |
3121 | |
3122 scoped_ptr<WebMediaPlayerAndroid> web_media_player_android( | |
3123 new WebMediaPlayerAndroid( | |
3124 frame, | |
3125 client, | |
3126 AsWeakPtr(), | |
3127 media_player_manager_, | |
3128 stream_texture_factory.release(), | |
3129 RenderThreadImpl::current()->GetMediaThreadMessageLoopProxy(), | |
3130 new RenderMediaLog())); | |
3131 #if defined(ENABLE_WEBRTC) && defined(GOOGLE_TV) | |
3132 if (media_stream_client_->IsMediaStream(url)) { | |
3133 RTCVideoDecoderFactoryTv* factory = RenderThreadImpl::current() | |
3134 ->GetMediaStreamDependencyFactory()->decoder_factory_tv(); | |
3135 // |media_stream_client| and |factory| outlives |web_media_player_android|. | |
3136 if (!factory->AcquireDemuxer() || | |
3137 !web_media_player_android->InjectMediaStream( | |
3138 media_stream_client_, | |
3139 factory, | |
3140 base::Bind( | |
3141 base::IgnoreResult(&RTCVideoDecoderFactoryTv::ReleaseDemuxer), | |
3142 base::Unretained(factory)))) { | |
3143 LOG(ERROR) << "Failed to inject media stream."; | |
3144 return NULL; | |
3145 } | |
3146 } | |
3147 #endif // defined(ENABLE_WEBRTC) && defined(GOOGLE_TV) | |
3148 return web_media_player_android.release(); | |
3149 #endif // defined(OS_ANDROID) | |
3150 | |
3151 scoped_refptr<media::AudioRendererSink> sink; | 3085 scoped_refptr<media::AudioRendererSink> sink; |
3152 if (!cmd_line->HasSwitch(switches::kDisableAudio)) { | 3086 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableAudio)) { |
3153 sink = RenderThreadImpl::current()->GetAudioRendererMixerManager()-> | 3087 sink = RenderThreadImpl::current()->GetAudioRendererMixerManager()-> |
3154 CreateInput(routing_id_); | 3088 CreateInput(routing_id_); |
3155 DVLOG(1) << "Using AudioRendererMixerManager-provided sink: " << sink.get(); | 3089 DVLOG(1) << "Using AudioRendererMixerManager-provided sink: " << sink.get(); |
3156 } | 3090 } |
3157 | 3091 |
3158 WebMediaPlayerParams params( | 3092 WebMediaPlayerParams params( |
3159 RenderThreadImpl::current()->GetMediaThreadMessageLoopProxy(), | 3093 RenderThreadImpl::current()->GetMediaThreadMessageLoopProxy(), |
3160 base::Bind(&ContentRendererClient::DeferMediaLoad, | 3094 base::Bind(&ContentRendererClient::DeferMediaLoad, |
3161 base::Unretained(GetContentClient()->renderer()), | 3095 base::Unretained(GetContentClient()->renderer()), |
3162 static_cast<RenderView*>(this)), | 3096 static_cast<RenderView*>(this)), |
3163 sink, | 3097 sink, |
3164 RenderThreadImpl::current()->GetGpuFactories(), | 3098 RenderThreadImpl::current()->GetGpuFactories(), |
3165 new RenderMediaLog()); | 3099 new RenderMediaLog()); |
3166 return new WebMediaPlayerImpl(frame, client, AsWeakPtr(), params); | 3100 return new WebMediaPlayerImpl(frame, client, AsWeakPtr(), params); |
3101 #endif // defined(OS_ANDROID) | |
3167 } | 3102 } |
3168 | 3103 |
3169 WebCookieJar* RenderViewImpl::cookieJar(WebFrame* frame) { | 3104 WebCookieJar* RenderViewImpl::cookieJar(WebFrame* frame) { |
3170 return &cookie_jar_; | 3105 return &cookie_jar_; |
3171 } | 3106 } |
3172 | 3107 |
3173 void RenderViewImpl::didAccessInitialDocument(WebFrame* frame) { | 3108 void RenderViewImpl::didAccessInitialDocument(WebFrame* frame) { |
3174 // Notify the browser process that it is no longer safe to show the pending | 3109 // Notify the browser process that it is no longer safe to show the pending |
3175 // URL of the main frame, since a URL spoof is now possible. | 3110 // URL of the main frame, since a URL spoof is now possible. |
3176 if (!frame->parent() && page_id_ == -1) | 3111 if (!frame->parent() && page_id_ == -1) |
(...skipping 3123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6300 return midi_dispatcher_; | 6235 return midi_dispatcher_; |
6301 } | 6236 } |
6302 | 6237 |
6303 void RenderViewImpl::draggableRegionsChanged() { | 6238 void RenderViewImpl::draggableRegionsChanged() { |
6304 FOR_EACH_OBSERVER( | 6239 FOR_EACH_OBSERVER( |
6305 RenderViewObserver, | 6240 RenderViewObserver, |
6306 observers_, | 6241 observers_, |
6307 DraggableRegionsChanged(webview()->mainFrame())); | 6242 DraggableRegionsChanged(webview()->mainFrame())); |
6308 } | 6243 } |
6309 | 6244 |
6245 WebMediaPlayer* RenderViewImpl::CreateWebMediaPlayerForMediaStream( | |
6246 WebFrame* frame, | |
scherkus (not reviewing)
2013/11/04 20:38:50
fix indent (should be 4-space indent)
michaelbai
2013/11/04 21:43:34
Done.
| |
6247 const WebKit::WebURL& url, | |
6248 WebMediaPlayerClient* client) { | |
6249 #if defined(ENABLE_WEBRTC) | |
scherkus (not reviewing)
2013/11/01 00:21:36
OOC aren't we shipping WebRTC? do you know if we c
michaelbai
2013/11/01 00:31:50
WebRTC is disabled in WebView. But, I don't know w
| |
6250 if (!InitializeMediaStreamClient()) { | |
6251 LOG(ERROR) << "Failed to initialize MediaStreamClient"; | |
6252 return NULL; | |
6253 } | |
6254 #if !defined(GOOGLE_TV) | |
6255 if (media_stream_client_->IsMediaStream(url)) { | |
6256 #if defined(OS_ANDROID) && defined(ARCH_CPU_ARMEL) | |
6257 bool found_neon = | |
6258 (android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) != 0; | |
6259 UMA_HISTOGRAM_BOOLEAN("Platform.WebRtcNEONFound", found_neon); | |
6260 #endif // defined(OS_ANDROID) && defined(ARCH_CPU_ARMEL) | |
6261 return new WebMediaPlayerMS(frame, client, AsWeakPtr(), | |
6262 media_stream_client_, new RenderMediaLog()); | |
6263 } | |
6264 #endif // !defined(GOOGLE_TV) | |
6265 #endif // defined(ENABLE_WEBRTC) | |
6266 return NULL; | |
6267 } | |
6268 | |
6310 #if defined(OS_ANDROID) | 6269 #if defined(OS_ANDROID) |
6311 WebContentDetectionResult RenderViewImpl::detectContentAround( | 6270 WebContentDetectionResult RenderViewImpl::detectContentAround( |
6312 const WebHitTestResult& touch_hit) { | 6271 const WebHitTestResult& touch_hit) { |
6313 DCHECK(!touch_hit.isNull()); | 6272 DCHECK(!touch_hit.isNull()); |
6314 DCHECK(!touch_hit.node().isNull()); | 6273 DCHECK(!touch_hit.node().isNull()); |
6315 DCHECK(touch_hit.node().isTextNode()); | 6274 DCHECK(touch_hit.node().isTextNode()); |
6316 | 6275 |
6317 // Process the position with all the registered content detectors until | 6276 // Process the position with all the registered content detectors until |
6318 // a match is found. Priority is provided by their relative order. | 6277 // a match is found. Priority is provided by their relative order. |
6319 for (ContentDetectorList::const_iterator it = content_detectors_.begin(); | 6278 for (ContentDetectorList::const_iterator it = content_detectors_.begin(); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6355 } | 6314 } |
6356 | 6315 |
6357 bool RenderViewImpl::openDateTimeChooser( | 6316 bool RenderViewImpl::openDateTimeChooser( |
6358 const WebKit::WebDateTimeChooserParams& params, | 6317 const WebKit::WebDateTimeChooserParams& params, |
6359 WebKit::WebDateTimeChooserCompletion* completion) { | 6318 WebKit::WebDateTimeChooserCompletion* completion) { |
6360 date_time_picker_client_.reset( | 6319 date_time_picker_client_.reset( |
6361 new RendererDateTimePicker(this, params, completion)); | 6320 new RendererDateTimePicker(this, params, completion)); |
6362 return date_time_picker_client_->Open(); | 6321 return date_time_picker_client_->Open(); |
6363 } | 6322 } |
6364 | 6323 |
6324 WebMediaPlayer* RenderViewImpl::CreateAndroidWebMediaPlayer( | |
6325 WebFrame* frame, | |
6326 const WebKit::WebURL& url, | |
6327 WebMediaPlayerClient* client) { | |
6328 GpuChannelHost* gpu_channel_host = | |
6329 RenderThreadImpl::current()->EstablishGpuChannelSync( | |
6330 CAUSE_FOR_GPU_LAUNCH_VIDEODECODEACCELERATOR_INITIALIZE); | |
6331 if (!gpu_channel_host) { | |
6332 LOG(ERROR) << "Failed to establish GPU channel for media player"; | |
6333 return NULL; | |
6334 } | |
6335 | |
6336 scoped_ptr<StreamTextureFactory> stream_texture_factory; | |
6337 if (UsingSynchronousRendererCompositor()) { | |
6338 SynchronousCompositorFactory* factory = | |
6339 SynchronousCompositorFactory::GetInstance(); | |
6340 stream_texture_factory = factory->CreateStreamTextureFactory(routing_id_); | |
6341 } else { | |
6342 scoped_refptr<cc::ContextProvider> context_provider = | |
6343 RenderThreadImpl::current()->SharedMainThreadContextProvider(); | |
6344 | |
6345 if (!context_provider.get()) { | |
6346 LOG(ERROR) << "Failed to get context3d for media player"; | |
6347 return NULL; | |
6348 } | |
6349 | |
6350 stream_texture_factory.reset(new StreamTextureFactoryImpl( | |
6351 context_provider->Context3d(), gpu_channel_host, routing_id_)); | |
6352 } | |
6353 | |
6354 scoped_ptr<WebMediaPlayerAndroid> web_media_player_android( | |
6355 new WebMediaPlayerAndroid( | |
6356 frame, | |
6357 client, | |
6358 AsWeakPtr(), | |
6359 media_player_manager_, | |
6360 stream_texture_factory.release(), | |
6361 RenderThreadImpl::current()->GetMediaThreadMessageLoopProxy(), | |
6362 new RenderMediaLog())); | |
6363 #if defined(ENABLE_WEBRTC) && defined(GOOGLE_TV) | |
6364 if (media_stream_client && media_stream_client_->IsMediaStream(url)) { | |
scherkus (not reviewing)
2013/11/04 20:38:50
this code looks broken (media_stream_client doesn'
michaelbai
2013/11/04 21:43:34
media_stream_client is defined unconditionally,
michaelbai
2013/11/04 21:43:34
The media_stream_client is defined unconditionally
| |
6365 RTCVideoDecoderFactoryTv* factory = RenderThreadImpl::current() | |
6366 ->GetMediaStreamDependencyFactory()->decoder_factory_tv(); | |
6367 // |media_stream_client| and |factory| outlives |web_media_player_android|. | |
6368 if (!factory->AcquireDemuxer() || | |
6369 !web_media_player_android->InjectMediaStream( | |
6370 media_stream_client_, | |
6371 factory, | |
6372 base::Bind( | |
6373 base::IgnoreResult(&RTCVideoDecoderFactoryTv::ReleaseDemuxer), | |
6374 base::Unretained(factory)))) { | |
6375 LOG(ERROR) << "Failed to inject media stream."; | |
6376 return NULL; | |
6377 } | |
6378 } | |
6379 #endif // defined(ENABLE_WEBRTC) && defined(GOOGLE_TV) | |
6380 return web_media_player_android.release(); | |
6381 } | |
6382 | |
6365 #endif // defined(OS_ANDROID) | 6383 #endif // defined(OS_ANDROID) |
6366 | 6384 |
6367 #if defined(OS_MACOSX) | 6385 #if defined(OS_MACOSX) |
6368 void RenderViewImpl::OnSelectPopupMenuItem(int selected_index) { | 6386 void RenderViewImpl::OnSelectPopupMenuItem(int selected_index) { |
6369 if (external_popup_menu_ == NULL) { | 6387 if (external_popup_menu_ == NULL) { |
6370 // Crash reports from the field indicate that we can be notified with a | 6388 // Crash reports from the field indicate that we can be notified with a |
6371 // NULL external popup menu (we probably get notified twice). | 6389 // NULL external popup menu (we probably get notified twice). |
6372 // If you hit this please file a bug against jcivelli and include the page | 6390 // If you hit this please file a bug against jcivelli and include the page |
6373 // and steps to repro. | 6391 // and steps to repro. |
6374 NOTREACHED(); | 6392 NOTREACHED(); |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6599 for (size_t i = 0; i < icon_urls.size(); i++) { | 6617 for (size_t i = 0; i < icon_urls.size(); i++) { |
6600 WebURL url = icon_urls[i].iconURL(); | 6618 WebURL url = icon_urls[i].iconURL(); |
6601 if (!url.isEmpty()) | 6619 if (!url.isEmpty()) |
6602 urls.push_back(FaviconURL(url, | 6620 urls.push_back(FaviconURL(url, |
6603 ToFaviconType(icon_urls[i].iconType()))); | 6621 ToFaviconType(icon_urls[i].iconType()))); |
6604 } | 6622 } |
6605 SendUpdateFaviconURL(urls); | 6623 SendUpdateFaviconURL(urls); |
6606 } | 6624 } |
6607 | 6625 |
6608 } // namespace content | 6626 } // namespace content |
OLD | NEW |