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