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

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

Issue 53313005: Respect disable_webrtc command line. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments Created 7 years, 1 month 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
« no previous file with comments | « content/renderer/render_view_impl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 3061 matching lines...) Expand 10 before | Expand all | Expand 10 after
3072 webview()->devToolsAgent()->setLayerTreeId(rwc->GetLayerTreeId()); 3072 webview()->devToolsAgent()->setLayerTreeId(rwc->GetLayerTreeId());
3073 } 3073 }
3074 3074
3075 // WebKit::WebFrameClient ----------------------------------------------------- 3075 // WebKit::WebFrameClient -----------------------------------------------------
3076 3076
3077 WebMediaPlayer* RenderViewImpl::createMediaPlayer( 3077 WebMediaPlayer* RenderViewImpl::createMediaPlayer(
3078 WebFrame* frame, const WebKit::WebURL& url, WebMediaPlayerClient* client) { 3078 WebFrame* frame, const WebKit::WebURL& url, WebMediaPlayerClient* client) {
3079 FOR_EACH_OBSERVER( 3079 FOR_EACH_OBSERVER(
3080 RenderViewObserver, observers_, WillCreateMediaPlayer(frame, client)); 3080 RenderViewObserver, observers_, WillCreateMediaPlayer(frame, client));
3081 3081
3082 const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); 3082 WebMediaPlayer* player = CreateWebMediaPlayerForMediaStream(frame, url,
3083 #if defined(ENABLE_WEBRTC) 3083 client);
3084 if (!InitializeMediaStreamClient()) 3084 if (player)
3085 return NULL; 3085 return player;
3086
3087 #if !defined(GOOGLE_TV)
3088 if (media_stream_client_->IsMediaStream(url)) {
3089 #if defined(OS_ANDROID) && defined(ARCH_CPU_ARMEL)
3090 bool found_neon =
3091 (android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) != 0;
3092 UMA_HISTOGRAM_BOOLEAN("Platform.WebRtcNEONFound", found_neon);
3093 #endif // defined(OS_ANDROID) && defined(ARCH_CPU_ARMEL)
3094 return new WebMediaPlayerMS(
3095 frame, client, AsWeakPtr(), media_stream_client_, new RenderMediaLog());
3096 }
3097 #endif // !defined(GOOGLE_TV)
3098 #endif // defined(ENABLE_WEBRTC)
3099 3086
3100 #if defined(OS_ANDROID) 3087 #if defined(OS_ANDROID)
3101 GpuChannelHost* gpu_channel_host = 3088 return CreateAndroidWebMediaPlayer(frame, url, client);
3102 RenderThreadImpl::current()->EstablishGpuChannelSync( 3089 #else
3103 CAUSE_FOR_GPU_LAUNCH_VIDEODECODEACCELERATOR_INITIALIZE);
3104 if (!gpu_channel_host) {
3105 LOG(ERROR) << "Failed to establish GPU channel for media player";
3106 return NULL;
3107 }
3108
3109 scoped_ptr<StreamTextureFactory> stream_texture_factory;
3110 if (UsingSynchronousRendererCompositor()) {
3111 SynchronousCompositorFactory* factory =
3112 SynchronousCompositorFactory::GetInstance();
3113 stream_texture_factory = factory->CreateStreamTextureFactory(routing_id_);
3114 } else {
3115 scoped_refptr<cc::ContextProvider> context_provider =
3116 RenderThreadImpl::current()->SharedMainThreadContextProvider();
3117
3118 if (!context_provider.get()) {
3119 LOG(ERROR) << "Failed to get context3d for media player";
3120 return NULL;
3121 }
3122
3123 stream_texture_factory.reset(new StreamTextureFactoryImpl(
3124 context_provider->Context3d(), gpu_channel_host, routing_id_));
3125 }
3126
3127 scoped_ptr<WebMediaPlayerAndroid> web_media_player_android(
3128 new WebMediaPlayerAndroid(
3129 frame,
3130 client,
3131 AsWeakPtr(),
3132 media_player_manager_,
3133 stream_texture_factory.release(),
3134 RenderThreadImpl::current()->GetMediaThreadMessageLoopProxy(),
3135 new RenderMediaLog()));
3136 #if defined(ENABLE_WEBRTC) && defined(GOOGLE_TV)
3137 if (media_stream_client_->IsMediaStream(url)) {
3138 RTCVideoDecoderFactoryTv* factory = RenderThreadImpl::current()
3139 ->GetMediaStreamDependencyFactory()->decoder_factory_tv();
3140 // |media_stream_client| and |factory| outlives |web_media_player_android|.
3141 if (!factory->AcquireDemuxer() ||
3142 !web_media_player_android->InjectMediaStream(
3143 media_stream_client_,
3144 factory,
3145 base::Bind(
3146 base::IgnoreResult(&RTCVideoDecoderFactoryTv::ReleaseDemuxer),
3147 base::Unretained(factory)))) {
3148 LOG(ERROR) << "Failed to inject media stream.";
3149 return NULL;
3150 }
3151 }
3152 #endif // defined(ENABLE_WEBRTC) && defined(GOOGLE_TV)
3153 return web_media_player_android.release();
3154 #endif // defined(OS_ANDROID)
3155
3156 scoped_refptr<media::AudioRendererSink> sink; 3090 scoped_refptr<media::AudioRendererSink> sink;
3157 if (!cmd_line->HasSwitch(switches::kDisableAudio)) { 3091 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableAudio)) {
3158 sink = RenderThreadImpl::current()->GetAudioRendererMixerManager()-> 3092 sink = RenderThreadImpl::current()->GetAudioRendererMixerManager()->
3159 CreateInput(routing_id_); 3093 CreateInput(routing_id_);
3160 DVLOG(1) << "Using AudioRendererMixerManager-provided sink: " << sink.get(); 3094 DVLOG(1) << "Using AudioRendererMixerManager-provided sink: " << sink.get();
3161 } 3095 }
3162 3096
3163 WebMediaPlayerParams params( 3097 WebMediaPlayerParams params(
3164 RenderThreadImpl::current()->GetMediaThreadMessageLoopProxy(), 3098 RenderThreadImpl::current()->GetMediaThreadMessageLoopProxy(),
3165 base::Bind(&ContentRendererClient::DeferMediaLoad, 3099 base::Bind(&ContentRendererClient::DeferMediaLoad,
3166 base::Unretained(GetContentClient()->renderer()), 3100 base::Unretained(GetContentClient()->renderer()),
3167 static_cast<RenderView*>(this)), 3101 static_cast<RenderView*>(this)),
3168 sink, 3102 sink,
3169 RenderThreadImpl::current()->GetGpuFactories(), 3103 RenderThreadImpl::current()->GetGpuFactories(),
3170 new RenderMediaLog()); 3104 new RenderMediaLog());
3171 return new WebMediaPlayerImpl(frame, client, AsWeakPtr(), params); 3105 return new WebMediaPlayerImpl(frame, client, AsWeakPtr(), params);
3106 #endif // defined(OS_ANDROID)
3172 } 3107 }
3173 3108
3174 WebCookieJar* RenderViewImpl::cookieJar(WebFrame* frame) { 3109 WebCookieJar* RenderViewImpl::cookieJar(WebFrame* frame) {
3175 return &cookie_jar_; 3110 return &cookie_jar_;
3176 } 3111 }
3177 3112
3178 void RenderViewImpl::didAccessInitialDocument(WebFrame* frame) { 3113 void RenderViewImpl::didAccessInitialDocument(WebFrame* frame) {
3179 // Notify the browser process that it is no longer safe to show the pending 3114 // Notify the browser process that it is no longer safe to show the pending
3180 // URL of the main frame, since a URL spoof is now possible. 3115 // URL of the main frame, since a URL spoof is now possible.
3181 if (!frame->parent() && page_id_ == -1) 3116 if (!frame->parent() && page_id_ == -1)
(...skipping 3125 matching lines...) Expand 10 before | Expand all | Expand 10 after
6307 return midi_dispatcher_; 6242 return midi_dispatcher_;
6308 } 6243 }
6309 6244
6310 void RenderViewImpl::draggableRegionsChanged() { 6245 void RenderViewImpl::draggableRegionsChanged() {
6311 FOR_EACH_OBSERVER( 6246 FOR_EACH_OBSERVER(
6312 RenderViewObserver, 6247 RenderViewObserver,
6313 observers_, 6248 observers_,
6314 DraggableRegionsChanged(webview()->mainFrame())); 6249 DraggableRegionsChanged(webview()->mainFrame()));
6315 } 6250 }
6316 6251
6252 WebMediaPlayer* RenderViewImpl::CreateWebMediaPlayerForMediaStream(
6253 WebFrame* frame,
6254 const WebKit::WebURL& url,
6255 WebMediaPlayerClient* client) {
6256 #if defined(ENABLE_WEBRTC)
6257 if (!InitializeMediaStreamClient()) {
6258 LOG(ERROR) << "Failed to initialize MediaStreamClient";
6259 return NULL;
6260 }
6261 #if !defined(GOOGLE_TV)
6262 if (media_stream_client_->IsMediaStream(url)) {
6263 #if defined(OS_ANDROID) && defined(ARCH_CPU_ARMEL)
6264 bool found_neon =
6265 (android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) != 0;
6266 UMA_HISTOGRAM_BOOLEAN("Platform.WebRtcNEONFound", found_neon);
6267 #endif // defined(OS_ANDROID) && defined(ARCH_CPU_ARMEL)
6268 return new WebMediaPlayerMS(frame, client, AsWeakPtr(),
6269 media_stream_client_, new RenderMediaLog());
6270 }
6271 #endif // !defined(GOOGLE_TV)
6272 #endif // defined(ENABLE_WEBRTC)
6273 return NULL;
6274 }
6275
6317 #if defined(OS_ANDROID) 6276 #if defined(OS_ANDROID)
6318 WebContentDetectionResult RenderViewImpl::detectContentAround( 6277 WebContentDetectionResult RenderViewImpl::detectContentAround(
6319 const WebHitTestResult& touch_hit) { 6278 const WebHitTestResult& touch_hit) {
6320 DCHECK(!touch_hit.isNull()); 6279 DCHECK(!touch_hit.isNull());
6321 DCHECK(!touch_hit.node().isNull()); 6280 DCHECK(!touch_hit.node().isNull());
6322 DCHECK(touch_hit.node().isTextNode()); 6281 DCHECK(touch_hit.node().isTextNode());
6323 6282
6324 // Process the position with all the registered content detectors until 6283 // Process the position with all the registered content detectors until
6325 // a match is found. Priority is provided by their relative order. 6284 // a match is found. Priority is provided by their relative order.
6326 for (ContentDetectorList::const_iterator it = content_detectors_.begin(); 6285 for (ContentDetectorList::const_iterator it = content_detectors_.begin();
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
6362 } 6321 }
6363 6322
6364 bool RenderViewImpl::openDateTimeChooser( 6323 bool RenderViewImpl::openDateTimeChooser(
6365 const WebKit::WebDateTimeChooserParams& params, 6324 const WebKit::WebDateTimeChooserParams& params,
6366 WebKit::WebDateTimeChooserCompletion* completion) { 6325 WebKit::WebDateTimeChooserCompletion* completion) {
6367 date_time_picker_client_.reset( 6326 date_time_picker_client_.reset(
6368 new RendererDateTimePicker(this, params, completion)); 6327 new RendererDateTimePicker(this, params, completion));
6369 return date_time_picker_client_->Open(); 6328 return date_time_picker_client_->Open();
6370 } 6329 }
6371 6330
6331 WebMediaPlayer* RenderViewImpl::CreateAndroidWebMediaPlayer(
6332 WebFrame* frame,
6333 const WebKit::WebURL& url,
6334 WebMediaPlayerClient* client) {
6335 GpuChannelHost* gpu_channel_host =
6336 RenderThreadImpl::current()->EstablishGpuChannelSync(
6337 CAUSE_FOR_GPU_LAUNCH_VIDEODECODEACCELERATOR_INITIALIZE);
6338 if (!gpu_channel_host) {
6339 LOG(ERROR) << "Failed to establish GPU channel for media player";
6340 return NULL;
6341 }
6342
6343 scoped_ptr<StreamTextureFactory> stream_texture_factory;
6344 if (UsingSynchronousRendererCompositor()) {
6345 SynchronousCompositorFactory* factory =
6346 SynchronousCompositorFactory::GetInstance();
6347 stream_texture_factory = factory->CreateStreamTextureFactory(routing_id_);
6348 } else {
6349 scoped_refptr<cc::ContextProvider> context_provider =
6350 RenderThreadImpl::current()->SharedMainThreadContextProvider();
6351
6352 if (!context_provider.get()) {
6353 LOG(ERROR) << "Failed to get context3d for media player";
6354 return NULL;
6355 }
6356
6357 stream_texture_factory.reset(new StreamTextureFactoryImpl(
6358 context_provider->Context3d(), gpu_channel_host, routing_id_));
6359 }
6360
6361 scoped_ptr<WebMediaPlayerAndroid> web_media_player_android(
6362 new WebMediaPlayerAndroid(
6363 frame,
6364 client,
6365 AsWeakPtr(),
6366 media_player_manager_,
6367 stream_texture_factory.release(),
6368 RenderThreadImpl::current()->GetMediaThreadMessageLoopProxy(),
6369 new RenderMediaLog()));
6370 #if defined(ENABLE_WEBRTC) && defined(GOOGLE_TV)
6371 if (media_stream_client && media_stream_client_->IsMediaStream(url)) {
scherkus (not reviewing) 2013/11/04 21:53:10 perhaps I'm missing it ... but where is media_stre
michaelbai 2013/11/04 22:00:26 It's my bad, there was underscore there. Do we hav
6372 RTCVideoDecoderFactoryTv* factory = RenderThreadImpl::current()
6373 ->GetMediaStreamDependencyFactory()->decoder_factory_tv();
6374 // |media_stream_client| and |factory| outlives |web_media_player_android|.
6375 if (!factory->AcquireDemuxer() ||
6376 !web_media_player_android->InjectMediaStream(
6377 media_stream_client_,
6378 factory,
6379 base::Bind(
6380 base::IgnoreResult(&RTCVideoDecoderFactoryTv::ReleaseDemuxer),
6381 base::Unretained(factory)))) {
6382 LOG(ERROR) << "Failed to inject media stream.";
6383 return NULL;
6384 }
6385 }
6386 #endif // defined(ENABLE_WEBRTC) && defined(GOOGLE_TV)
6387 return web_media_player_android.release();
6388 }
6389
6372 #endif // defined(OS_ANDROID) 6390 #endif // defined(OS_ANDROID)
6373 6391
6374 #if defined(OS_MACOSX) 6392 #if defined(OS_MACOSX)
6375 void RenderViewImpl::OnSelectPopupMenuItem(int selected_index) { 6393 void RenderViewImpl::OnSelectPopupMenuItem(int selected_index) {
6376 if (external_popup_menu_ == NULL) { 6394 if (external_popup_menu_ == NULL) {
6377 // Crash reports from the field indicate that we can be notified with a 6395 // Crash reports from the field indicate that we can be notified with a
6378 // NULL external popup menu (we probably get notified twice). 6396 // NULL external popup menu (we probably get notified twice).
6379 // If you hit this please file a bug against jcivelli and include the page 6397 // If you hit this please file a bug against jcivelli and include the page
6380 // and steps to repro. 6398 // and steps to repro.
6381 NOTREACHED(); 6399 NOTREACHED();
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
6606 for (size_t i = 0; i < icon_urls.size(); i++) { 6624 for (size_t i = 0; i < icon_urls.size(); i++) {
6607 WebURL url = icon_urls[i].iconURL(); 6625 WebURL url = icon_urls[i].iconURL();
6608 if (!url.isEmpty()) 6626 if (!url.isEmpty())
6609 urls.push_back(FaviconURL(url, 6627 urls.push_back(FaviconURL(url,
6610 ToFaviconType(icon_urls[i].iconType()))); 6628 ToFaviconType(icon_urls[i].iconType())));
6611 } 6629 }
6612 SendUpdateFaviconURL(urls); 6630 SendUpdateFaviconURL(urls);
6613 } 6631 }
6614 6632
6615 } // namespace content 6633 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_view_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698