OLD | NEW |
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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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/intents_dispatcher.h" | 57 #include "content/renderer/intents_dispatcher.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_process.h" | 70 #include "content/renderer/render_process.h" |
69 #include "content/renderer/render_thread_impl.h" | 71 #include "content/renderer/render_thread_impl.h" |
70 #include "content/renderer/render_widget_fullscreen_pepper.h" | 72 #include "content/renderer/render_widget_fullscreen_pepper.h" |
71 #include "content/renderer/renderer_accessibility.h" | 73 #include "content/renderer/renderer_accessibility.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginDocument.h" | 111 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginDocument.h" |
110 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginParams.h" | 112 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginParams.h" |
111 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRange.h" | 113 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRange.h" |
112 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScriptSource.h" | 114 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScriptSource.h" |
113 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSearchableFormData
.h" | 115 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSearchableFormData
.h" |
114 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" | 116 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" |
115 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityPolicy.h" | 117 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityPolicy.h" |
116 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSettings.h" | 118 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSettings.h" |
117 #include "third_party/WebKit/Source/WebKit/chromium/public/WebStorageNamespace.h
" | 119 #include "third_party/WebKit/Source/WebKit/chromium/public/WebStorageNamespace.h
" |
118 #include "third_party/WebKit/Source/WebKit/chromium/public/WebStorageQuotaCallba
cks.h" | 120 #include "third_party/WebKit/Source/WebKit/chromium/public/WebStorageQuotaCallba
cks.h" |
| 121 #include "third_party/WebKit/Source/WebKit/chromium/public/WebUserMediaClient.h" |
119 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | 122 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
120 #include "third_party/WebKit/Source/WebKit/chromium/public/WebWindowFeatures.h" | 123 #include "third_party/WebKit/Source/WebKit/chromium/public/WebWindowFeatures.h" |
121 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebCString.h
" | 124 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebCString.h
" |
122 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebDragData.
h" | 125 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebDragData.
h" |
123 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebGraphicsC
ontext3D.h" | 126 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebGraphicsC
ontext3D.h" |
124 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebImage.h" | 127 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebImage.h" |
| 128 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebPeerConne
ctionHandler.h" |
| 129 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebPeerConne
ctionHandlerClient.h" |
125 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebPoint.h" | 130 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebPoint.h" |
126 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebRect.h" | 131 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebRect.h" |
127 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSize.h" | 132 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSize.h" |
128 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" | 133 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" |
129 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h" | 134 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h" |
130 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLError.
h" | 135 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLError.
h" |
131 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLReques
t.h" | 136 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLReques
t.h" |
132 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLRespon
se.h" | 137 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLRespon
se.h" |
133 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h" | 138 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h" |
134 #include "third_party/skia/include/core/SkBitmap.h" | 139 #include "third_party/skia/include/core/SkBitmap.h" |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 target_url_status_(TARGET_NONE), | 356 target_url_status_(TARGET_NONE), |
352 selection_text_offset_(0), | 357 selection_text_offset_(0), |
353 cached_is_main_frame_pinned_to_left_(false), | 358 cached_is_main_frame_pinned_to_left_(false), |
354 cached_is_main_frame_pinned_to_right_(false), | 359 cached_is_main_frame_pinned_to_right_(false), |
355 cached_has_main_frame_horizontal_scrollbar_(false), | 360 cached_has_main_frame_horizontal_scrollbar_(false), |
356 cached_has_main_frame_vertical_scrollbar_(false), | 361 cached_has_main_frame_vertical_scrollbar_(false), |
357 ALLOW_THIS_IN_INITIALIZER_LIST(cookie_jar_(this)), | 362 ALLOW_THIS_IN_INITIALIZER_LIST(cookie_jar_(this)), |
358 geolocation_dispatcher_(NULL), | 363 geolocation_dispatcher_(NULL), |
359 speech_input_dispatcher_(NULL), | 364 speech_input_dispatcher_(NULL), |
360 device_orientation_dispatcher_(NULL), | 365 device_orientation_dispatcher_(NULL), |
| 366 media_stream_dispatcher_(NULL), |
361 p2p_socket_dispatcher_(NULL), | 367 p2p_socket_dispatcher_(NULL), |
362 devtools_agent_(NULL), | 368 devtools_agent_(NULL), |
363 renderer_accessibility_(NULL), | 369 renderer_accessibility_(NULL), |
364 session_storage_namespace_id_(session_storage_namespace_id), | 370 session_storage_namespace_id_(session_storage_namespace_id), |
365 handling_select_range_(false), | 371 handling_select_range_(false), |
366 #if defined(OS_WIN) | 372 #if defined(OS_WIN) |
367 focused_plugin_id_(-1), | 373 focused_plugin_id_(-1), |
368 #endif | 374 #endif |
369 ALLOW_THIS_IN_INITIALIZER_LIST(pepper_delegate_(this)) { | 375 ALLOW_THIS_IN_INITIALIZER_LIST(pepper_delegate_(this)) { |
370 routing_id_ = routing_id; | 376 routing_id_ = routing_id; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
412 webview()->mainFrame()->setName(frame_name); | 418 webview()->mainFrame()->setName(frame_name); |
413 webview()->settings()->setMinimumTimerInterval( | 419 webview()->settings()->setMinimumTimerInterval( |
414 is_hidden() ? webkit_glue::kBackgroundTabTimerInterval : | 420 is_hidden() ? webkit_glue::kBackgroundTabTimerInterval : |
415 webkit_glue::kForegroundTabTimerInterval); | 421 webkit_glue::kForegroundTabTimerInterval); |
416 | 422 |
417 OnSetRendererPrefs(renderer_prefs); | 423 OnSetRendererPrefs(renderer_prefs); |
418 | 424 |
419 host_window_ = parent_hwnd; | 425 host_window_ = parent_hwnd; |
420 | 426 |
421 #if defined(ENABLE_P2P_APIS) | 427 #if defined(ENABLE_P2P_APIS) |
422 p2p_socket_dispatcher_ = new content::P2PSocketDispatcher(this); | 428 if (!p2p_socket_dispatcher_) |
| 429 p2p_socket_dispatcher_ = new content::P2PSocketDispatcher(this); |
423 #endif | 430 #endif |
424 | 431 |
425 new MHTMLGenerator(this); | 432 new MHTMLGenerator(this); |
426 #if defined(OS_MACOSX) | 433 #if defined(OS_MACOSX) |
427 new TextInputClientObserver(this); | 434 new TextInputClientObserver(this); |
428 #endif // defined(OS_MACOSX) | 435 #endif // defined(OS_MACOSX) |
429 | 436 |
430 devtools_agent_ = new DevToolsAgent(this); | 437 devtools_agent_ = new DevToolsAgent(this); |
431 | 438 |
432 renderer_accessibility_ = new RendererAccessibility(this); | 439 renderer_accessibility_ = new RendererAccessibility(this); |
433 | 440 |
434 new IdleUserDetector(this); | 441 new IdleUserDetector(this); |
435 | 442 |
436 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | |
437 if (command_line.HasSwitch(switches::kEnableMediaStream)) { | |
438 media_stream_impl_ = new MediaStreamImpl( | |
439 RenderThreadImpl::current()->video_capture_impl_manager()); | |
440 } | |
441 | |
442 content::GetContentClient()->renderer()->RenderViewCreated(this); | 443 content::GetContentClient()->renderer()->RenderViewCreated(this); |
443 } | 444 } |
444 | 445 |
445 RenderViewImpl::~RenderViewImpl() { | 446 RenderViewImpl::~RenderViewImpl() { |
446 history_page_ids_.clear(); | 447 history_page_ids_.clear(); |
447 | 448 |
448 if (decrement_shared_popup_at_destruction_) | 449 if (decrement_shared_popup_at_destruction_) |
449 shared_popup_counter_->data--; | 450 shared_popup_counter_->data--; |
450 | 451 |
451 // If file chooser is still waiting for answer, dispatch empty answer. | 452 // If file chooser is still waiting for answer, dispatch empty answer. |
(...skipping 15 matching lines...) Expand all Loading... |
467 } | 468 } |
468 #endif | 469 #endif |
469 | 470 |
470 #ifndef NDEBUG | 471 #ifndef NDEBUG |
471 // Make sure we are no longer referenced by the ViewMap. | 472 // Make sure we are no longer referenced by the ViewMap. |
472 ViewMap* views = g_view_map.Pointer(); | 473 ViewMap* views = g_view_map.Pointer(); |
473 for (ViewMap::iterator it = views->begin(); it != views->end(); ++it) | 474 for (ViewMap::iterator it = views->begin(); it != views->end(); ++it) |
474 DCHECK_NE(this, it->second) << "Failed to call Close?"; | 475 DCHECK_NE(this, it->second) << "Failed to call Close?"; |
475 #endif | 476 #endif |
476 | 477 |
| 478 // MediaStreamImpl holds weak references to RenderViewObserver objects, |
| 479 // ensure it's deleted before the observers. |
| 480 media_stream_impl_ = NULL; |
| 481 |
477 FOR_EACH_OBSERVER(RenderViewObserver, observers_, RenderViewGone()); | 482 FOR_EACH_OBSERVER(RenderViewObserver, observers_, RenderViewGone()); |
478 FOR_EACH_OBSERVER(RenderViewObserver, observers_, OnDestruct()); | 483 FOR_EACH_OBSERVER(RenderViewObserver, observers_, OnDestruct()); |
479 } | 484 } |
480 | 485 |
481 /*static*/ | 486 /*static*/ |
482 RenderViewImpl* RenderViewImpl::FromWebView(WebView* webview) { | 487 RenderViewImpl* RenderViewImpl::FromWebView(WebView* webview) { |
483 ViewMap* views = g_view_map.Pointer(); | 488 ViewMap* views = g_view_map.Pointer(); |
484 ViewMap::iterator it = views->find(webview); | 489 ViewMap::iterator it = views->find(webview); |
485 return it == views->end() ? NULL : it->second; | 490 return it == views->end() ? NULL : it->second; |
486 } | 491 } |
(...skipping 30 matching lines...) Expand all Loading... |
517 opener_id, | 522 opener_id, |
518 renderer_prefs, | 523 renderer_prefs, |
519 webkit_prefs, | 524 webkit_prefs, |
520 counter, | 525 counter, |
521 routing_id, | 526 routing_id, |
522 session_storage_namespace_id, | 527 session_storage_namespace_id, |
523 frame_name, | 528 frame_name, |
524 next_page_id); // adds reference | 529 next_page_id); // adds reference |
525 } | 530 } |
526 | 531 |
| 532 WebKit::WebPeerConnectionHandler* RenderViewImpl::CreatePeerConnectionHandler( |
| 533 WebKit::WebPeerConnectionHandlerClient* client) { |
| 534 const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); |
| 535 if (!cmd_line->HasSwitch(switches::kEnableMediaStream)) |
| 536 return NULL; |
| 537 EnsureMediaStreamImpl(); |
| 538 return media_stream_impl_->CreatePeerConnectionHandler(client); |
| 539 } |
| 540 |
527 void RenderViewImpl::AddObserver(RenderViewObserver* observer) { | 541 void RenderViewImpl::AddObserver(RenderViewObserver* observer) { |
528 observers_.AddObserver(observer); | 542 observers_.AddObserver(observer); |
529 } | 543 } |
530 | 544 |
531 void RenderViewImpl::RemoveObserver(RenderViewObserver* observer) { | 545 void RenderViewImpl::RemoveObserver(RenderViewObserver* observer) { |
532 observer->RenderViewGone(); | 546 observer->RenderViewGone(); |
533 observers_.RemoveObserver(observer); | 547 observers_.RemoveObserver(observer); |
534 } | 548 } |
535 | 549 |
536 WebKit::WebView* RenderViewImpl::webview() const { | 550 WebKit::WebView* RenderViewImpl::webview() const { |
(...skipping 2418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2955 size.set_height(preferred_size_.height()); | 2969 size.set_height(preferred_size_.height()); |
2956 | 2970 |
2957 if (size == preferred_size_) | 2971 if (size == preferred_size_) |
2958 return; | 2972 return; |
2959 | 2973 |
2960 preferred_size_ = size; | 2974 preferred_size_ = size; |
2961 Send(new ViewHostMsg_DidContentsPreferredSizeChange(routing_id_, | 2975 Send(new ViewHostMsg_DidContentsPreferredSizeChange(routing_id_, |
2962 preferred_size_)); | 2976 preferred_size_)); |
2963 } | 2977 } |
2964 | 2978 |
| 2979 void RenderViewImpl::EnsureMediaStreamImpl() { |
| 2980 #if defined(ENABLE_P2P_APIS) |
| 2981 if (!p2p_socket_dispatcher_) |
| 2982 p2p_socket_dispatcher_ = new content::P2PSocketDispatcher(this); |
| 2983 #endif |
| 2984 |
| 2985 if (!media_stream_dispatcher_) |
| 2986 media_stream_dispatcher_ = new MediaStreamDispatcher(this); |
| 2987 |
| 2988 if (!media_stream_impl_.get()) { |
| 2989 MediaStreamDependencyFactory* factory = new MediaStreamDependencyFactory(); |
| 2990 media_stream_impl_ = new MediaStreamImpl( |
| 2991 media_stream_dispatcher_, |
| 2992 p2p_socket_dispatcher_, |
| 2993 RenderThreadImpl::current()->video_capture_impl_manager(), |
| 2994 factory); |
| 2995 } |
| 2996 } |
| 2997 |
2965 void RenderViewImpl::didChangeContentsSize(WebFrame* frame, | 2998 void RenderViewImpl::didChangeContentsSize(WebFrame* frame, |
2966 const WebSize& size) { | 2999 const WebSize& size) { |
2967 if (webview()->mainFrame() != frame) | 3000 if (webview()->mainFrame() != frame) |
2968 return; | 3001 return; |
2969 WebView* frameView = frame->view(); | 3002 WebView* frameView = frame->view(); |
2970 if (!frameView) | 3003 if (!frameView) |
2971 return; | 3004 return; |
2972 | 3005 |
2973 bool has_horizontal_scrollbar = frame->hasHorizontalScrollbar(); | 3006 bool has_horizontal_scrollbar = frame->hasHorizontalScrollbar(); |
2974 bool has_vertical_scrollbar = frame->hasVerticalScrollbar(); | 3007 bool has_vertical_scrollbar = frame->hasVerticalScrollbar(); |
(...skipping 1692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4667 WebKit::WebPageVisibilityStateHidden : | 4700 WebKit::WebPageVisibilityStateHidden : |
4668 WebKit::WebPageVisibilityStateVisible; | 4701 WebKit::WebPageVisibilityStateVisible; |
4669 WebKit::WebPageVisibilityState override_state = current_state; | 4702 WebKit::WebPageVisibilityState override_state = current_state; |
4670 if (content::GetContentClient()->renderer()-> | 4703 if (content::GetContentClient()->renderer()-> |
4671 ShouldOverridePageVisibilityState(this, | 4704 ShouldOverridePageVisibilityState(this, |
4672 &override_state)) | 4705 &override_state)) |
4673 return override_state; | 4706 return override_state; |
4674 return current_state; | 4707 return current_state; |
4675 } | 4708 } |
4676 | 4709 |
| 4710 WebKit::WebUserMediaClient* RenderViewImpl::userMediaClient() { |
| 4711 const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); |
| 4712 if (!cmd_line->HasSwitch(switches::kEnableMediaStream)) |
| 4713 return NULL; |
| 4714 EnsureMediaStreamImpl(); |
| 4715 return media_stream_impl_; |
| 4716 } |
| 4717 |
4677 bool RenderViewImpl::IsNonLocalTopLevelNavigation( | 4718 bool RenderViewImpl::IsNonLocalTopLevelNavigation( |
4678 const GURL& url, WebKit::WebFrame* frame, WebKit::WebNavigationType type) { | 4719 const GURL& url, WebKit::WebFrame* frame, WebKit::WebNavigationType type) { |
4679 // Must be a top level frame. | 4720 // Must be a top level frame. |
4680 if (frame->parent() != NULL) | 4721 if (frame->parent() != NULL) |
4681 return false; | 4722 return false; |
4682 | 4723 |
4683 // Navigations initiated within Webkit are not sent out to the external host | 4724 // Navigations initiated within Webkit are not sent out to the external host |
4684 // in the following cases. | 4725 // in the following cases. |
4685 // 1. The url scheme is not http/https | 4726 // 1. The url scheme is not http/https |
4686 // 2. The origin of the url and the opener is the same in which case the | 4727 // 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 Loading... |
4794 bool RenderViewImpl::WebWidgetHandlesCompositorScheduling() const { | 4835 bool RenderViewImpl::WebWidgetHandlesCompositorScheduling() const { |
4795 return !!RenderThreadImpl::current()->compositor_thread(); | 4836 return !!RenderThreadImpl::current()->compositor_thread(); |
4796 } | 4837 } |
4797 | 4838 |
4798 void RenderViewImpl::OnJavaBridgeInit() { | 4839 void RenderViewImpl::OnJavaBridgeInit() { |
4799 DCHECK(!java_bridge_dispatcher_.get()); | 4840 DCHECK(!java_bridge_dispatcher_.get()); |
4800 #if defined(ENABLE_JAVA_BRIDGE) | 4841 #if defined(ENABLE_JAVA_BRIDGE) |
4801 java_bridge_dispatcher_.reset(new JavaBridgeDispatcher(this)); | 4842 java_bridge_dispatcher_.reset(new JavaBridgeDispatcher(this)); |
4802 #endif | 4843 #endif |
4803 } | 4844 } |
OLD | NEW |