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

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

Issue 8060055: Adding support for MediaStream and PeerConnection functionality (Closed) Base URL: http://git.chromium.org/chromium/chromium.git@trunk
Patch Set: Merge Created 8 years, 11 months 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
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 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 #include "content/renderer/devtools_agent.h" 52 #include "content/renderer/devtools_agent.h"
53 #include "content/renderer/external_popup_menu.h" 53 #include "content/renderer/external_popup_menu.h"
54 #include "content/renderer/geolocation_dispatcher.h" 54 #include "content/renderer/geolocation_dispatcher.h"
55 #include "content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.h" 55 #include "content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.h"
56 #include "content/renderer/idle_user_detector.h" 56 #include "content/renderer/idle_user_detector.h"
57 #include "content/renderer/web_intents_host.h" 57 #include "content/renderer/web_intents_host.h"
58 #include "content/renderer/java/java_bridge_dispatcher.h" 58 #include "content/renderer/java/java_bridge_dispatcher.h"
59 #include "content/renderer/load_progress_tracker.h" 59 #include "content/renderer/load_progress_tracker.h"
60 #include "content/renderer/media/audio_message_filter.h" 60 #include "content/renderer/media/audio_message_filter.h"
61 #include "content/renderer/media/audio_renderer_impl.h" 61 #include "content/renderer/media/audio_renderer_impl.h"
62 #include "content/renderer/media/media_stream_dependency_factory.h"
63 #include "content/renderer/media/media_stream_dispatcher.h"
62 #include "content/renderer/media/media_stream_impl.h" 64 #include "content/renderer/media/media_stream_impl.h"
63 #include "content/renderer/media/render_media_log.h" 65 #include "content/renderer/media/render_media_log.h"
64 #include "content/renderer/mhtml_generator.h" 66 #include "content/renderer/mhtml_generator.h"
65 #include "content/renderer/notification_provider.h" 67 #include "content/renderer/notification_provider.h"
66 #include "content/renderer/p2p/socket_dispatcher.h" 68 #include "content/renderer/p2p/socket_dispatcher.h"
67 #include "content/renderer/plugin_channel_host.h" 69 #include "content/renderer/plugin_channel_host.h"
68 #include "content/renderer/render_audiosourceprovider.h" 70 #include "content/renderer/render_audiosourceprovider.h"
69 #include "content/renderer/render_process.h" 71 #include "content/renderer/render_process.h"
70 #include "content/renderer/render_thread_impl.h" 72 #include "content/renderer/render_thread_impl.h"
71 #include "content/renderer/render_widget_fullscreen_pepper.h" 73 #include "content/renderer/render_widget_fullscreen_pepper.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginDocument.h" 113 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginDocument.h"
112 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginParams.h" 114 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginParams.h"
113 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRange.h" 115 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRange.h"
114 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScriptSource.h" 116 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScriptSource.h"
115 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSearchableFormData .h" 117 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSearchableFormData .h"
116 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" 118 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h"
117 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityPolicy.h" 119 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityPolicy.h"
118 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSettings.h" 120 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSettings.h"
119 #include "third_party/WebKit/Source/WebKit/chromium/public/WebStorageNamespace.h " 121 #include "third_party/WebKit/Source/WebKit/chromium/public/WebStorageNamespace.h "
120 #include "third_party/WebKit/Source/WebKit/chromium/public/WebStorageQuotaCallba cks.h" 122 #include "third_party/WebKit/Source/WebKit/chromium/public/WebStorageQuotaCallba cks.h"
123 #include "third_party/WebKit/Source/WebKit/chromium/public/WebUserMediaClient.h"
121 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" 124 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
122 #include "third_party/WebKit/Source/WebKit/chromium/public/WebWindowFeatures.h" 125 #include "third_party/WebKit/Source/WebKit/chromium/public/WebWindowFeatures.h"
123 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebCString.h " 126 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebCString.h "
124 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebDragData. h" 127 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebDragData. h"
125 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebGraphicsC ontext3D.h" 128 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebGraphicsC ontext3D.h"
126 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebImage.h" 129 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebImage.h"
130 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebPeerConne ctionHandler.h"
131 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebPeerConne ctionHandlerClient.h"
127 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebPoint.h" 132 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebPoint.h"
128 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebRect.h" 133 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebRect.h"
129 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSize.h" 134 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSize.h"
130 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" 135 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h"
131 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h" 136 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h"
132 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLError. h" 137 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLError. h"
133 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLReques t.h" 138 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLReques t.h"
134 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLRespon se.h" 139 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLRespon se.h"
135 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h" 140 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h"
136 #include "third_party/skia/include/core/SkBitmap.h" 141 #include "third_party/skia/include/core/SkBitmap.h"
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 target_url_status_(TARGET_NONE), 358 target_url_status_(TARGET_NONE),
354 selection_text_offset_(0), 359 selection_text_offset_(0),
355 cached_is_main_frame_pinned_to_left_(false), 360 cached_is_main_frame_pinned_to_left_(false),
356 cached_is_main_frame_pinned_to_right_(false), 361 cached_is_main_frame_pinned_to_right_(false),
357 cached_has_main_frame_horizontal_scrollbar_(false), 362 cached_has_main_frame_horizontal_scrollbar_(false),
358 cached_has_main_frame_vertical_scrollbar_(false), 363 cached_has_main_frame_vertical_scrollbar_(false),
359 ALLOW_THIS_IN_INITIALIZER_LIST(cookie_jar_(this)), 364 ALLOW_THIS_IN_INITIALIZER_LIST(cookie_jar_(this)),
360 geolocation_dispatcher_(NULL), 365 geolocation_dispatcher_(NULL),
361 speech_input_dispatcher_(NULL), 366 speech_input_dispatcher_(NULL),
362 device_orientation_dispatcher_(NULL), 367 device_orientation_dispatcher_(NULL),
368 media_stream_dispatcher_(NULL),
363 p2p_socket_dispatcher_(NULL), 369 p2p_socket_dispatcher_(NULL),
364 devtools_agent_(NULL), 370 devtools_agent_(NULL),
365 renderer_accessibility_(NULL), 371 renderer_accessibility_(NULL),
366 session_storage_namespace_id_(session_storage_namespace_id), 372 session_storage_namespace_id_(session_storage_namespace_id),
367 handling_select_range_(false), 373 handling_select_range_(false),
368 #if defined(OS_WIN) 374 #if defined(OS_WIN)
369 focused_plugin_id_(-1), 375 focused_plugin_id_(-1),
370 #endif 376 #endif
371 ALLOW_THIS_IN_INITIALIZER_LIST(pepper_delegate_(this)) { 377 ALLOW_THIS_IN_INITIALIZER_LIST(pepper_delegate_(this)) {
372 routing_id_ = routing_id; 378 routing_id_ = routing_id;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 webview()->mainFrame()->setName(frame_name); 420 webview()->mainFrame()->setName(frame_name);
415 webview()->settings()->setMinimumTimerInterval( 421 webview()->settings()->setMinimumTimerInterval(
416 is_hidden() ? webkit_glue::kBackgroundTabTimerInterval : 422 is_hidden() ? webkit_glue::kBackgroundTabTimerInterval :
417 webkit_glue::kForegroundTabTimerInterval); 423 webkit_glue::kForegroundTabTimerInterval);
418 424
419 OnSetRendererPrefs(renderer_prefs); 425 OnSetRendererPrefs(renderer_prefs);
420 426
421 host_window_ = parent_hwnd; 427 host_window_ = parent_hwnd;
422 428
423 #if defined(ENABLE_P2P_APIS) 429 #if defined(ENABLE_P2P_APIS)
424 p2p_socket_dispatcher_ = new content::P2PSocketDispatcher(this); 430 if (!p2p_socket_dispatcher_)
431 p2p_socket_dispatcher_ = new content::P2PSocketDispatcher(this);
425 #endif 432 #endif
426 433
427 new MHTMLGenerator(this); 434 new MHTMLGenerator(this);
428 #if defined(OS_MACOSX) 435 #if defined(OS_MACOSX)
429 new TextInputClientObserver(this); 436 new TextInputClientObserver(this);
430 #endif // defined(OS_MACOSX) 437 #endif // defined(OS_MACOSX)
431 438
432 devtools_agent_ = new DevToolsAgent(this); 439 devtools_agent_ = new DevToolsAgent(this);
433 440
434 renderer_accessibility_ = new RendererAccessibility(this); 441 renderer_accessibility_ = new RendererAccessibility(this);
435 442
436 new IdleUserDetector(this); 443 new IdleUserDetector(this);
437 444
438 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
439 if (command_line.HasSwitch(switches::kEnableMediaStream)) {
440 media_stream_impl_ = new MediaStreamImpl(
441 RenderThreadImpl::current()->video_capture_impl_manager());
442 }
443
444 content::GetContentClient()->renderer()->RenderViewCreated(this); 445 content::GetContentClient()->renderer()->RenderViewCreated(this);
445 } 446 }
446 447
447 RenderViewImpl::~RenderViewImpl() { 448 RenderViewImpl::~RenderViewImpl() {
448 history_page_ids_.clear(); 449 history_page_ids_.clear();
449 450
450 if (decrement_shared_popup_at_destruction_) 451 if (decrement_shared_popup_at_destruction_)
451 shared_popup_counter_->data--; 452 shared_popup_counter_->data--;
452 453
453 // If file chooser is still waiting for answer, dispatch empty answer. 454 // If file chooser is still waiting for answer, dispatch empty answer.
(...skipping 15 matching lines...) Expand all
469 } 470 }
470 #endif 471 #endif
471 472
472 #ifndef NDEBUG 473 #ifndef NDEBUG
473 // Make sure we are no longer referenced by the ViewMap. 474 // Make sure we are no longer referenced by the ViewMap.
474 ViewMap* views = g_view_map.Pointer(); 475 ViewMap* views = g_view_map.Pointer();
475 for (ViewMap::iterator it = views->begin(); it != views->end(); ++it) 476 for (ViewMap::iterator it = views->begin(); it != views->end(); ++it)
476 DCHECK_NE(this, it->second) << "Failed to call Close?"; 477 DCHECK_NE(this, it->second) << "Failed to call Close?";
477 #endif 478 #endif
478 479
480 // MediaStreamImpl holds weak references to RenderViewObserver objects,
481 // ensure it's deleted before the observers.
482 media_stream_impl_ = NULL;
483
479 FOR_EACH_OBSERVER(RenderViewObserver, observers_, RenderViewGone()); 484 FOR_EACH_OBSERVER(RenderViewObserver, observers_, RenderViewGone());
480 FOR_EACH_OBSERVER(RenderViewObserver, observers_, OnDestruct()); 485 FOR_EACH_OBSERVER(RenderViewObserver, observers_, OnDestruct());
481 } 486 }
482 487
483 /*static*/ 488 /*static*/
484 RenderViewImpl* RenderViewImpl::FromWebView(WebView* webview) { 489 RenderViewImpl* RenderViewImpl::FromWebView(WebView* webview) {
485 ViewMap* views = g_view_map.Pointer(); 490 ViewMap* views = g_view_map.Pointer();
486 ViewMap::iterator it = views->find(webview); 491 ViewMap::iterator it = views->find(webview);
487 return it == views->end() ? NULL : it->second; 492 return it == views->end() ? NULL : it->second;
488 } 493 }
(...skipping 30 matching lines...) Expand all
519 opener_id, 524 opener_id,
520 renderer_prefs, 525 renderer_prefs,
521 webkit_prefs, 526 webkit_prefs,
522 counter, 527 counter,
523 routing_id, 528 routing_id,
524 session_storage_namespace_id, 529 session_storage_namespace_id,
525 frame_name, 530 frame_name,
526 next_page_id); // adds reference 531 next_page_id); // adds reference
527 } 532 }
528 533
534 WebKit::WebPeerConnectionHandler* RenderViewImpl::CreatePeerConnectionHandler(
535 WebKit::WebPeerConnectionHandlerClient* client) {
536 const CommandLine* cmd_line = CommandLine::ForCurrentProcess();
537 if (!cmd_line->HasSwitch(switches::kEnableMediaStream))
538 return NULL;
539 EnsureMediaStreamImpl();
540 return media_stream_impl_->CreatePeerConnectionHandler(client);
541 }
542
529 void RenderViewImpl::AddObserver(RenderViewObserver* observer) { 543 void RenderViewImpl::AddObserver(RenderViewObserver* observer) {
530 observers_.AddObserver(observer); 544 observers_.AddObserver(observer);
531 } 545 }
532 546
533 void RenderViewImpl::RemoveObserver(RenderViewObserver* observer) { 547 void RenderViewImpl::RemoveObserver(RenderViewObserver* observer) {
534 observer->RenderViewGone(); 548 observer->RenderViewGone();
535 observers_.RemoveObserver(observer); 549 observers_.RemoveObserver(observer);
536 } 550 }
537 551
538 WebKit::WebView* RenderViewImpl::webview() const { 552 WebKit::WebView* RenderViewImpl::webview() const {
(...skipping 2436 matching lines...) Expand 10 before | Expand all | Expand 10 after
2975 size.set_height(preferred_size_.height()); 2989 size.set_height(preferred_size_.height());
2976 2990
2977 if (size == preferred_size_) 2991 if (size == preferred_size_)
2978 return; 2992 return;
2979 2993
2980 preferred_size_ = size; 2994 preferred_size_ = size;
2981 Send(new ViewHostMsg_DidContentsPreferredSizeChange(routing_id_, 2995 Send(new ViewHostMsg_DidContentsPreferredSizeChange(routing_id_,
2982 preferred_size_)); 2996 preferred_size_));
2983 } 2997 }
2984 2998
2999 void RenderViewImpl::EnsureMediaStreamImpl() {
3000 #if defined(ENABLE_P2P_APIS)
3001 if (!p2p_socket_dispatcher_)
3002 p2p_socket_dispatcher_ = new content::P2PSocketDispatcher(this);
3003 #endif
3004
3005 if (!media_stream_dispatcher_)
3006 media_stream_dispatcher_ = new MediaStreamDispatcher(this);
3007
3008 if (!media_stream_impl_.get()) {
3009 MediaStreamDependencyFactory* factory = new MediaStreamDependencyFactory();
3010 media_stream_impl_ = new MediaStreamImpl(
3011 media_stream_dispatcher_,
3012 p2p_socket_dispatcher_,
3013 RenderThreadImpl::current()->video_capture_impl_manager(),
3014 factory);
3015 }
3016 }
3017
2985 void RenderViewImpl::didChangeContentsSize(WebFrame* frame, 3018 void RenderViewImpl::didChangeContentsSize(WebFrame* frame,
2986 const WebSize& size) { 3019 const WebSize& size) {
2987 if (webview()->mainFrame() != frame) 3020 if (webview()->mainFrame() != frame)
2988 return; 3021 return;
2989 WebView* frameView = frame->view(); 3022 WebView* frameView = frame->view();
2990 if (!frameView) 3023 if (!frameView)
2991 return; 3024 return;
2992 3025
2993 bool has_horizontal_scrollbar = frame->hasHorizontalScrollbar(); 3026 bool has_horizontal_scrollbar = frame->hasHorizontalScrollbar();
2994 bool has_vertical_scrollbar = frame->hasVerticalScrollbar(); 3027 bool has_vertical_scrollbar = frame->hasVerticalScrollbar();
(...skipping 1708 matching lines...) Expand 10 before | Expand all | Expand 10 after
4703 WebKit::WebPageVisibilityStateHidden : 4736 WebKit::WebPageVisibilityStateHidden :
4704 WebKit::WebPageVisibilityStateVisible; 4737 WebKit::WebPageVisibilityStateVisible;
4705 WebKit::WebPageVisibilityState override_state = current_state; 4738 WebKit::WebPageVisibilityState override_state = current_state;
4706 if (content::GetContentClient()->renderer()-> 4739 if (content::GetContentClient()->renderer()->
4707 ShouldOverridePageVisibilityState(this, 4740 ShouldOverridePageVisibilityState(this,
4708 &override_state)) 4741 &override_state))
4709 return override_state; 4742 return override_state;
4710 return current_state; 4743 return current_state;
4711 } 4744 }
4712 4745
4746 WebKit::WebUserMediaClient* RenderViewImpl::userMediaClient() {
4747 const CommandLine* cmd_line = CommandLine::ForCurrentProcess();
4748 if (!cmd_line->HasSwitch(switches::kEnableMediaStream))
4749 return NULL;
4750 EnsureMediaStreamImpl();
4751 return media_stream_impl_;
4752 }
4753
4713 bool RenderViewImpl::IsNonLocalTopLevelNavigation( 4754 bool RenderViewImpl::IsNonLocalTopLevelNavigation(
4714 const GURL& url, WebKit::WebFrame* frame, WebKit::WebNavigationType type) { 4755 const GURL& url, WebKit::WebFrame* frame, WebKit::WebNavigationType type) {
4715 // Must be a top level frame. 4756 // Must be a top level frame.
4716 if (frame->parent() != NULL) 4757 if (frame->parent() != NULL)
4717 return false; 4758 return false;
4718 4759
4719 // Navigations initiated within Webkit are not sent out to the external host 4760 // Navigations initiated within Webkit are not sent out to the external host
4720 // in the following cases. 4761 // in the following cases.
4721 // 1. The url scheme is not http/https 4762 // 1. The url scheme is not http/https
4722 // 2. The origin of the url and the opener is the same in which case the 4763 // 2. The origin of the url and the opener is the same in which case the
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
4830 bool RenderViewImpl::WebWidgetHandlesCompositorScheduling() const { 4871 bool RenderViewImpl::WebWidgetHandlesCompositorScheduling() const {
4831 return !!RenderThreadImpl::current()->compositor_thread(); 4872 return !!RenderThreadImpl::current()->compositor_thread();
4832 } 4873 }
4833 4874
4834 void RenderViewImpl::OnJavaBridgeInit() { 4875 void RenderViewImpl::OnJavaBridgeInit() {
4835 DCHECK(!java_bridge_dispatcher_.get()); 4876 DCHECK(!java_bridge_dispatcher_.get());
4836 #if defined(ENABLE_JAVA_BRIDGE) 4877 #if defined(ENABLE_JAVA_BRIDGE)
4837 java_bridge_dispatcher_.reset(new JavaBridgeDispatcher(this)); 4878 java_bridge_dispatcher_.reset(new JavaBridgeDispatcher(this));
4838 #endif 4879 #endif
4839 } 4880 }
OLDNEW
« no previous file with comments | « content/renderer/render_view_impl.h ('k') | content/renderer/renderer_webkitplatformsupport_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698