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

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: Code review fixes plus implementation of WebKit::WebUserMediaClient. Created 9 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 #include "content/renderer/device_orientation_dispatcher.h" 48 #include "content/renderer/device_orientation_dispatcher.h"
49 #include "content/renderer/devtools_agent.h" 49 #include "content/renderer/devtools_agent.h"
50 #include "content/renderer/external_popup_menu.h" 50 #include "content/renderer/external_popup_menu.h"
51 #include "content/renderer/geolocation_dispatcher.h" 51 #include "content/renderer/geolocation_dispatcher.h"
52 #include "content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.h" 52 #include "content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.h"
53 #include "content/renderer/intents_dispatcher.h" 53 #include "content/renderer/intents_dispatcher.h"
54 #include "content/renderer/java_bridge_dispatcher.h" 54 #include "content/renderer/java_bridge_dispatcher.h"
55 #include "content/renderer/load_progress_tracker.h" 55 #include "content/renderer/load_progress_tracker.h"
56 #include "content/renderer/media/audio_message_filter.h" 56 #include "content/renderer/media/audio_message_filter.h"
57 #include "content/renderer/media/audio_renderer_impl.h" 57 #include "content/renderer/media/audio_renderer_impl.h"
58 #include "content/renderer/media/media_stream_dependency_factory.h"
59 #include "content/renderer/media/media_stream_dispatcher.h"
58 #include "content/renderer/media/media_stream_impl.h" 60 #include "content/renderer/media/media_stream_impl.h"
59 #include "content/renderer/media/render_media_log.h" 61 #include "content/renderer/media/render_media_log.h"
60 #include "content/renderer/mhtml_generator.h" 62 #include "content/renderer/mhtml_generator.h"
61 #include "content/renderer/notification_provider.h" 63 #include "content/renderer/notification_provider.h"
62 #include "content/renderer/p2p/socket_dispatcher.h" 64 #include "content/renderer/p2p/socket_dispatcher.h"
63 #include "content/renderer/plugin_channel_host.h" 65 #include "content/renderer/plugin_channel_host.h"
64 #include "content/renderer/render_process.h" 66 #include "content/renderer/render_process.h"
65 #include "content/renderer/render_thread_impl.h" 67 #include "content/renderer/render_thread_impl.h"
66 #include "content/renderer/render_widget_fullscreen_pepper.h" 68 #include "content/renderer/render_widget_fullscreen_pepper.h"
67 #include "content/renderer/renderer_accessibility.h" 69 #include "content/renderer/renderer_accessibility.h"
(...skipping 25 matching lines...) Expand all
93 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFormElement.h" 95 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFormElement.h"
94 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" 96 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
95 #include "third_party/WebKit/Source/WebKit/chromium/public/WebGraphicsContext3D. h" 97 #include "third_party/WebKit/Source/WebKit/chromium/public/WebGraphicsContext3D. h"
96 #include "third_party/WebKit/Source/WebKit/chromium/public/WebHistoryItem.h" 98 #include "third_party/WebKit/Source/WebKit/chromium/public/WebHistoryItem.h"
97 #include "third_party/WebKit/Source/WebKit/chromium/public/WebImage.h" 99 #include "third_party/WebKit/Source/WebKit/chromium/public/WebImage.h"
98 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputElement.h" 100 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputElement.h"
99 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" 101 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
100 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaPlayerAction. h" 102 #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaPlayerAction. h"
101 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNodeList.h" 103 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNodeList.h"
102 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPageSerializer.h" 104 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPageSerializer.h"
105 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPeerConnectionHand ler.h"
106 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPeerConnectionHand lerClient.h"
103 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPlugin.h" 107 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPlugin.h"
104 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h" 108 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h"
105 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginDocument.h" 109 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginDocument.h"
106 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginParams.h" 110 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginParams.h"
107 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPoint.h" 111 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPoint.h"
108 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRange.h" 112 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRange.h"
109 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRect.h" 113 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRect.h"
110 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScriptSource.h" 114 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScriptSource.h"
111 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSearchableFormData .h" 115 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSearchableFormData .h"
112 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" 116 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h"
113 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityPolicy.h" 117 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityPolicy.h"
114 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSettings.h" 118 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSettings.h"
115 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSize.h" 119 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSize.h"
116 #include "third_party/WebKit/Source/WebKit/chromium/public/WebStorageNamespace.h " 120 #include "third_party/WebKit/Source/WebKit/chromium/public/WebStorageNamespace.h "
117 #include "third_party/WebKit/Source/WebKit/chromium/public/WebStorageQuotaCallba cks.h" 121 #include "third_party/WebKit/Source/WebKit/chromium/public/WebStorageQuotaCallba cks.h"
118 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" 122 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h"
119 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURL.h" 123 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURL.h"
120 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLError.h" 124 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLError.h"
121 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLRequest.h" 125 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLRequest.h"
122 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLResponse.h" 126 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLResponse.h"
127 #include "third_party/WebKit/Source/WebKit/chromium/public/WebUserMediaClient.h"
123 #include "third_party/WebKit/Source/WebKit/chromium/public/WebVector.h" 128 #include "third_party/WebKit/Source/WebKit/chromium/public/WebVector.h"
124 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" 129 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
125 #include "third_party/WebKit/Source/WebKit/chromium/public/WebWindowFeatures.h" 130 #include "third_party/WebKit/Source/WebKit/chromium/public/WebWindowFeatures.h"
126 #include "third_party/skia/include/core/SkBitmap.h" 131 #include "third_party/skia/include/core/SkBitmap.h"
127 #include "ui/base/message_box_flags.h" 132 #include "ui/base/message_box_flags.h"
128 #include "ui/gfx/native_widget_types.h" 133 #include "ui/gfx/native_widget_types.h"
129 #include "ui/gfx/point.h" 134 #include "ui/gfx/point.h"
130 #include "ui/gfx/rect.h" 135 #include "ui/gfx/rect.h"
131 #include "v8/include/v8.h" 136 #include "v8/include/v8.h"
132 #include "webkit/appcache/web_application_cache_host_impl.h" 137 #include "webkit/appcache/web_application_cache_host_impl.h"
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 cached_has_main_frame_horizontal_scrollbar_(false), 339 cached_has_main_frame_horizontal_scrollbar_(false),
335 cached_has_main_frame_vertical_scrollbar_(false), 340 cached_has_main_frame_vertical_scrollbar_(false),
336 ALLOW_THIS_IN_INITIALIZER_LIST(pepper_delegate_(this)), 341 ALLOW_THIS_IN_INITIALIZER_LIST(pepper_delegate_(this)),
337 #if defined(OS_WIN) 342 #if defined(OS_WIN)
338 focused_plugin_id_(-1), 343 focused_plugin_id_(-1),
339 #endif 344 #endif
340 ALLOW_THIS_IN_INITIALIZER_LIST(cookie_jar_(this)), 345 ALLOW_THIS_IN_INITIALIZER_LIST(cookie_jar_(this)),
341 geolocation_dispatcher_(NULL), 346 geolocation_dispatcher_(NULL),
342 speech_input_dispatcher_(NULL), 347 speech_input_dispatcher_(NULL),
343 device_orientation_dispatcher_(NULL), 348 device_orientation_dispatcher_(NULL),
349 media_stream_dispatcher_(NULL),
344 p2p_socket_dispatcher_(NULL), 350 p2p_socket_dispatcher_(NULL),
345 devtools_agent_(NULL), 351 devtools_agent_(NULL),
346 renderer_accessibility_(NULL), 352 renderer_accessibility_(NULL),
347 session_storage_namespace_id_(session_storage_namespace_id), 353 session_storage_namespace_id_(session_storage_namespace_id),
348 handling_select_range_(false) { 354 handling_select_range_(false) {
349 routing_id_ = routing_id; 355 routing_id_ = routing_id;
350 if (opener_id != MSG_ROUTING_NONE) 356 if (opener_id != MSG_ROUTING_NONE)
351 opener_id_ = opener_id; 357 opener_id_ = opener_id;
352 358
353 webwidget_ = WebView::create(this); 359 webwidget_ = WebView::create(this);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 webview()->mainFrame()->setName(frame_name); 394 webview()->mainFrame()->setName(frame_name);
389 webview()->settings()->setMinimumTimerInterval( 395 webview()->settings()->setMinimumTimerInterval(
390 is_hidden() ? webkit_glue::kBackgroundTabTimerInterval : 396 is_hidden() ? webkit_glue::kBackgroundTabTimerInterval :
391 webkit_glue::kForegroundTabTimerInterval); 397 webkit_glue::kForegroundTabTimerInterval);
392 398
393 OnSetRendererPrefs(renderer_prefs); 399 OnSetRendererPrefs(renderer_prefs);
394 400
395 host_window_ = parent_hwnd; 401 host_window_ = parent_hwnd;
396 402
397 #if defined(ENABLE_P2P_APIS) 403 #if defined(ENABLE_P2P_APIS)
398 p2p_socket_dispatcher_ = new content::P2PSocketDispatcher(this); 404 if (!p2p_socket_dispatcher_)
405 p2p_socket_dispatcher_ = new content::P2PSocketDispatcher(this);
399 #endif 406 #endif
400 407
401 new MHTMLGenerator(this); 408 new MHTMLGenerator(this);
402 #if defined(OS_MACOSX) 409 #if defined(OS_MACOSX)
403 new TextInputClientObserver(this); 410 new TextInputClientObserver(this);
404 #endif // defined(OS_MACOSX) 411 #endif // defined(OS_MACOSX)
405 412
406 devtools_agent_ = new DevToolsAgent(this); 413 devtools_agent_ = new DevToolsAgent(this);
407 414
408 renderer_accessibility_ = new RendererAccessibility(this); 415 renderer_accessibility_ = new RendererAccessibility(this);
409 416
410 const CommandLine& command_line = *CommandLine::ForCurrentProcess();
411 if (command_line.HasSwitch(switches::kEnableMediaStream)) {
412 media_stream_impl_ = new MediaStreamImpl(
413 RenderThreadImpl::current()->video_capture_impl_manager());
414 }
415
416 content::GetContentClient()->renderer()->RenderViewCreated(this); 417 content::GetContentClient()->renderer()->RenderViewCreated(this);
417 } 418 }
418 419
419 RenderViewImpl::~RenderViewImpl() { 420 RenderViewImpl::~RenderViewImpl() {
420 history_page_ids_.clear(); 421 history_page_ids_.clear();
421 422
422 if (decrement_shared_popup_at_destruction_) 423 if (decrement_shared_popup_at_destruction_)
423 shared_popup_counter_->data--; 424 shared_popup_counter_->data--;
424 425
425 // If file chooser is still waiting for answer, dispatch empty answer. 426 // If file chooser is still waiting for answer, dispatch empty answer.
(...skipping 15 matching lines...) Expand all
441 } 442 }
442 #endif 443 #endif
443 444
444 #ifndef NDEBUG 445 #ifndef NDEBUG
445 // Make sure we are no longer referenced by the ViewMap. 446 // Make sure we are no longer referenced by the ViewMap.
446 ViewMap* views = g_view_map.Pointer(); 447 ViewMap* views = g_view_map.Pointer();
447 for (ViewMap::iterator it = views->begin(); it != views->end(); ++it) 448 for (ViewMap::iterator it = views->begin(); it != views->end(); ++it)
448 DCHECK_NE(this, it->second) << "Failed to call Close?"; 449 DCHECK_NE(this, it->second) << "Failed to call Close?";
449 #endif 450 #endif
450 451
452 // MediaStreamImpl holds weak references to RenderViewObserver objects,
453 // ensure it's deleted before the observers.
454 media_stream_impl_ = NULL;
455
451 FOR_EACH_OBSERVER(RenderViewObserver, observers_, RenderViewGone()); 456 FOR_EACH_OBSERVER(RenderViewObserver, observers_, RenderViewGone());
452 FOR_EACH_OBSERVER(RenderViewObserver, observers_, OnDestruct()); 457 FOR_EACH_OBSERVER(RenderViewObserver, observers_, OnDestruct());
453 } 458 }
454 459
455 /*static*/ 460 /*static*/
456 RenderViewImpl* RenderViewImpl::FromWebView(WebView* webview) { 461 RenderViewImpl* RenderViewImpl::FromWebView(WebView* webview) {
457 ViewMap* views = g_view_map.Pointer(); 462 ViewMap* views = g_view_map.Pointer();
458 ViewMap::iterator it = views->find(webview); 463 ViewMap::iterator it = views->find(webview);
459 return it == views->end() ? NULL : it->second; 464 return it == views->end() ? NULL : it->second;
460 } 465 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 503
499 // static 504 // static
500 void RenderViewImpl::SetNextPageID(int32 next_page_id) { 505 void RenderViewImpl::SetNextPageID(int32 next_page_id) {
501 // This method should only be called during process startup, and the given 506 // This method should only be called during process startup, and the given
502 // page id had better not exceed our current next page id! 507 // page id had better not exceed our current next page id!
503 DCHECK_EQ(next_page_id_, 1); 508 DCHECK_EQ(next_page_id_, 1);
504 DCHECK(next_page_id >= next_page_id_); 509 DCHECK(next_page_id >= next_page_id_);
505 next_page_id_ = next_page_id; 510 next_page_id_ = next_page_id;
506 } 511 }
507 512
513 WebKit::WebPeerConnectionHandler* RenderViewImpl::CreatePeerConnectionHandler(
514 WebKit::WebPeerConnectionHandlerClient* client) {
515 const CommandLine* cmd_line = CommandLine::ForCurrentProcess();
516 if (!cmd_line->HasSwitch(switches::kEnableMediaStream))
517 return NULL;
518
519 #if defined(ENABLE_P2P_APIS)
520 if (!p2p_socket_dispatcher_)
521 p2p_socket_dispatcher_ = new content::P2PSocketDispatcher(this);
522 #endif
523
524 if (!media_stream_dispatcher_)
525 media_stream_dispatcher_ = new MediaStreamDispatcher(this);
526
527 if (!media_stream_impl_.get()) {
528 MediaStreamDependencyFactory* factory = new MediaStreamDependencyFactory();
529 media_stream_impl_ = new MediaStreamImpl(
530 media_stream_dispatcher_,
531 p2p_socket_dispatcher_,
532 RenderThreadImpl::current()->video_capture_impl_manager(),
533 factory);
534 }
535 return media_stream_impl_->CreatePeerConnectionHandler(client);
536 }
537
508 void RenderViewImpl::AddObserver(RenderViewObserver* observer) { 538 void RenderViewImpl::AddObserver(RenderViewObserver* observer) {
509 observers_.AddObserver(observer); 539 observers_.AddObserver(observer);
510 } 540 }
511 541
512 void RenderViewImpl::RemoveObserver(RenderViewObserver* observer) { 542 void RenderViewImpl::RemoveObserver(RenderViewObserver* observer) {
513 observer->RenderViewGone(); 543 observer->RenderViewGone();
514 observers_.RemoveObserver(observer); 544 observers_.RemoveObserver(observer);
515 } 545 }
516 546
517 WebKit::WebView* RenderViewImpl::webview() const { 547 WebKit::WebView* RenderViewImpl::webview() const {
(...skipping 4058 matching lines...) Expand 10 before | Expand all | Expand 10 after
4576 const WebKit::WebString& data, 4606 const WebKit::WebString& data,
4577 int intent_id) { 4607 int intent_id) {
4578 webkit_glue::WebIntentData intent_data; 4608 webkit_glue::WebIntentData intent_data;
4579 intent_data.action = action; 4609 intent_data.action = action;
4580 intent_data.type = type; 4610 intent_data.type = type;
4581 intent_data.data = data; 4611 intent_data.data = data;
4582 Send(new IntentsHostMsg_WebIntentDispatch( 4612 Send(new IntentsHostMsg_WebIntentDispatch(
4583 routing_id_, intent_data, intent_id)); 4613 routing_id_, intent_data, intent_id));
4584 } 4614 }
4585 4615
4616 WebKit::WebUserMediaClient* RenderViewImpl::userMediaClient() {
4617 const CommandLine* cmd_line = CommandLine::ForCurrentProcess();
4618 if (!cmd_line->HasSwitch(switches::kEnableMediaStream))
4619 return NULL;
4620
4621 #if defined(ENABLE_P2P_APIS)
4622 if (!p2p_socket_dispatcher_)
4623 p2p_socket_dispatcher_ = new content::P2PSocketDispatcher(this);
4624 #endif
4625
4626 if (!media_stream_dispatcher_)
4627 media_stream_dispatcher_ = new MediaStreamDispatcher(this);
4628
4629 if (!media_stream_impl_.get()) {
4630 MediaStreamDependencyFactory* factory = new MediaStreamDependencyFactory();
4631 media_stream_impl_ = new MediaStreamImpl(
4632 media_stream_dispatcher_,
4633 p2p_socket_dispatcher_,
4634 RenderThreadImpl::current()->video_capture_impl_manager(),
4635 factory);
4636 }
4637 return media_stream_impl_;
4638 }
4639
4586 bool RenderViewImpl::IsNonLocalTopLevelNavigation( 4640 bool RenderViewImpl::IsNonLocalTopLevelNavigation(
4587 const GURL& url, WebKit::WebFrame* frame, WebKit::WebNavigationType type) { 4641 const GURL& url, WebKit::WebFrame* frame, WebKit::WebNavigationType type) {
4588 // Must be a top level frame. 4642 // Must be a top level frame.
4589 if (frame->parent() != NULL) 4643 if (frame->parent() != NULL)
4590 return false; 4644 return false;
4591 4645
4592 // Navigations initiated within Webkit are not sent out to the external host 4646 // Navigations initiated within Webkit are not sent out to the external host
4593 // in the following cases. 4647 // in the following cases.
4594 // 1. The url scheme is not http/https 4648 // 1. The url scheme is not http/https
4595 // 2. The origin of the url and the opener is the same in which case the 4649 // 2. The origin of the url and the opener is the same in which case the
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
4704 return webview()->settings()->useThreadedCompositor(); 4758 return webview()->settings()->useThreadedCompositor();
4705 } 4759 }
4706 4760
4707 void RenderViewImpl::OnJavaBridgeInit( 4761 void RenderViewImpl::OnJavaBridgeInit(
4708 const IPC::ChannelHandle& channel_handle) { 4762 const IPC::ChannelHandle& channel_handle) {
4709 DCHECK(!java_bridge_dispatcher_.get()); 4763 DCHECK(!java_bridge_dispatcher_.get());
4710 #if defined(ENABLE_JAVA_BRIDGE) 4764 #if defined(ENABLE_JAVA_BRIDGE)
4711 java_bridge_dispatcher_.reset(new JavaBridgeDispatcher(this, channel_handle)); 4765 java_bridge_dispatcher_.reset(new JavaBridgeDispatcher(this, channel_handle));
4712 #endif 4766 #endif
4713 } 4767 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698