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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginDocument.h" | 110 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginDocument.h" |
113 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginParams.h" | 111 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginParams.h" |
114 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRange.h" | 112 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRange.h" |
115 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScriptSource.h" | 113 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScriptSource.h" |
116 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSearchableFormData
.h" | 114 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSearchableFormData
.h" |
117 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" | 115 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" |
118 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityPolicy.h" | 116 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityPolicy.h" |
119 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSettings.h" | 117 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSettings.h" |
120 #include "third_party/WebKit/Source/WebKit/chromium/public/WebStorageNamespace.h
" | 118 #include "third_party/WebKit/Source/WebKit/chromium/public/WebStorageNamespace.h
" |
121 #include "third_party/WebKit/Source/WebKit/chromium/public/WebStorageQuotaCallba
cks.h" | 119 #include "third_party/WebKit/Source/WebKit/chromium/public/WebStorageQuotaCallba
cks.h" |
122 #include "third_party/WebKit/Source/WebKit/chromium/public/WebUserMediaClient.h" | |
123 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" | 120 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
124 #include "third_party/WebKit/Source/WebKit/chromium/public/WebWindowFeatures.h" | 121 #include "third_party/WebKit/Source/WebKit/chromium/public/WebWindowFeatures.h" |
125 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebCString.h
" | 122 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebCString.h
" |
126 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebDragData.
h" | 123 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebDragData.
h" |
127 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebGraphicsC
ontext3D.h" | 124 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebGraphicsC
ontext3D.h" |
128 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebImage.h" | 125 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebImage.h" |
129 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebPeerConne
ctionHandler.h" | |
130 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebPeerConne
ctionHandlerClient.h" | |
131 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebPoint.h" | 126 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebPoint.h" |
132 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebRect.h" | 127 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebRect.h" |
133 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSize.h" | 128 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSize.h" |
134 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" | 129 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" |
135 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h" | 130 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h" |
136 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLError.
h" | 131 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLError.
h" |
137 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLReques
t.h" | 132 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLReques
t.h" |
138 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLRespon
se.h" | 133 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLRespon
se.h" |
139 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h" | 134 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h" |
140 #include "third_party/skia/include/core/SkBitmap.h" | 135 #include "third_party/skia/include/core/SkBitmap.h" |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 target_url_status_(TARGET_NONE), | 351 target_url_status_(TARGET_NONE), |
357 selection_text_offset_(0), | 352 selection_text_offset_(0), |
358 cached_is_main_frame_pinned_to_left_(false), | 353 cached_is_main_frame_pinned_to_left_(false), |
359 cached_is_main_frame_pinned_to_right_(false), | 354 cached_is_main_frame_pinned_to_right_(false), |
360 cached_has_main_frame_horizontal_scrollbar_(false), | 355 cached_has_main_frame_horizontal_scrollbar_(false), |
361 cached_has_main_frame_vertical_scrollbar_(false), | 356 cached_has_main_frame_vertical_scrollbar_(false), |
362 ALLOW_THIS_IN_INITIALIZER_LIST(cookie_jar_(this)), | 357 ALLOW_THIS_IN_INITIALIZER_LIST(cookie_jar_(this)), |
363 geolocation_dispatcher_(NULL), | 358 geolocation_dispatcher_(NULL), |
364 speech_input_dispatcher_(NULL), | 359 speech_input_dispatcher_(NULL), |
365 device_orientation_dispatcher_(NULL), | 360 device_orientation_dispatcher_(NULL), |
366 media_stream_dispatcher_(NULL), | |
367 p2p_socket_dispatcher_(NULL), | 361 p2p_socket_dispatcher_(NULL), |
368 devtools_agent_(NULL), | 362 devtools_agent_(NULL), |
369 renderer_accessibility_(NULL), | 363 renderer_accessibility_(NULL), |
370 session_storage_namespace_id_(session_storage_namespace_id), | 364 session_storage_namespace_id_(session_storage_namespace_id), |
371 handling_select_range_(false), | 365 handling_select_range_(false), |
372 #if defined(OS_WIN) | 366 #if defined(OS_WIN) |
373 focused_plugin_id_(-1), | 367 focused_plugin_id_(-1), |
374 #endif | 368 #endif |
375 ALLOW_THIS_IN_INITIALIZER_LIST(pepper_delegate_(this)) { | 369 ALLOW_THIS_IN_INITIALIZER_LIST(pepper_delegate_(this)) { |
376 routing_id_ = routing_id; | 370 routing_id_ = routing_id; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 webview()->mainFrame()->setName(frame_name); | 412 webview()->mainFrame()->setName(frame_name); |
419 webview()->settings()->setMinimumTimerInterval( | 413 webview()->settings()->setMinimumTimerInterval( |
420 is_hidden() ? webkit_glue::kBackgroundTabTimerInterval : | 414 is_hidden() ? webkit_glue::kBackgroundTabTimerInterval : |
421 webkit_glue::kForegroundTabTimerInterval); | 415 webkit_glue::kForegroundTabTimerInterval); |
422 | 416 |
423 OnSetRendererPrefs(renderer_prefs); | 417 OnSetRendererPrefs(renderer_prefs); |
424 | 418 |
425 host_window_ = parent_hwnd; | 419 host_window_ = parent_hwnd; |
426 | 420 |
427 #if defined(ENABLE_P2P_APIS) | 421 #if defined(ENABLE_P2P_APIS) |
428 if (!p2p_socket_dispatcher_) | 422 p2p_socket_dispatcher_ = new content::P2PSocketDispatcher(this); |
429 p2p_socket_dispatcher_ = new content::P2PSocketDispatcher(this); | |
430 #endif | 423 #endif |
431 | 424 |
432 new MHTMLGenerator(this); | 425 new MHTMLGenerator(this); |
433 #if defined(OS_MACOSX) | 426 #if defined(OS_MACOSX) |
434 new TextInputClientObserver(this); | 427 new TextInputClientObserver(this); |
435 #endif // defined(OS_MACOSX) | 428 #endif // defined(OS_MACOSX) |
436 | 429 |
437 devtools_agent_ = new DevToolsAgent(this); | 430 devtools_agent_ = new DevToolsAgent(this); |
438 | 431 |
439 renderer_accessibility_ = new RendererAccessibility(this); | 432 renderer_accessibility_ = new RendererAccessibility(this); |
440 | 433 |
441 new IdleUserDetector(this); | 434 new IdleUserDetector(this); |
442 | 435 |
| 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 |
443 content::GetContentClient()->renderer()->RenderViewCreated(this); | 442 content::GetContentClient()->renderer()->RenderViewCreated(this); |
444 } | 443 } |
445 | 444 |
446 RenderViewImpl::~RenderViewImpl() { | 445 RenderViewImpl::~RenderViewImpl() { |
447 history_page_ids_.clear(); | 446 history_page_ids_.clear(); |
448 | 447 |
449 if (decrement_shared_popup_at_destruction_) | 448 if (decrement_shared_popup_at_destruction_) |
450 shared_popup_counter_->data--; | 449 shared_popup_counter_->data--; |
451 | 450 |
452 // If file chooser is still waiting for answer, dispatch empty answer. | 451 // If file chooser is still waiting for answer, dispatch empty answer. |
(...skipping 15 matching lines...) Expand all Loading... |
468 } | 467 } |
469 #endif | 468 #endif |
470 | 469 |
471 #ifndef NDEBUG | 470 #ifndef NDEBUG |
472 // Make sure we are no longer referenced by the ViewMap. | 471 // Make sure we are no longer referenced by the ViewMap. |
473 ViewMap* views = g_view_map.Pointer(); | 472 ViewMap* views = g_view_map.Pointer(); |
474 for (ViewMap::iterator it = views->begin(); it != views->end(); ++it) | 473 for (ViewMap::iterator it = views->begin(); it != views->end(); ++it) |
475 DCHECK_NE(this, it->second) << "Failed to call Close?"; | 474 DCHECK_NE(this, it->second) << "Failed to call Close?"; |
476 #endif | 475 #endif |
477 | 476 |
478 // MediaStreamImpl holds weak references to RenderViewObserver objects, | |
479 // ensure it's deleted before the observers. | |
480 media_stream_impl_ = NULL; | |
481 | |
482 FOR_EACH_OBSERVER(RenderViewObserver, observers_, RenderViewGone()); | 477 FOR_EACH_OBSERVER(RenderViewObserver, observers_, RenderViewGone()); |
483 FOR_EACH_OBSERVER(RenderViewObserver, observers_, OnDestruct()); | 478 FOR_EACH_OBSERVER(RenderViewObserver, observers_, OnDestruct()); |
484 } | 479 } |
485 | 480 |
486 /*static*/ | 481 /*static*/ |
487 RenderViewImpl* RenderViewImpl::FromWebView(WebView* webview) { | 482 RenderViewImpl* RenderViewImpl::FromWebView(WebView* webview) { |
488 ViewMap* views = g_view_map.Pointer(); | 483 ViewMap* views = g_view_map.Pointer(); |
489 ViewMap::iterator it = views->find(webview); | 484 ViewMap::iterator it = views->find(webview); |
490 return it == views->end() ? NULL : it->second; | 485 return it == views->end() ? NULL : it->second; |
491 } | 486 } |
(...skipping 30 matching lines...) Expand all Loading... |
522 opener_id, | 517 opener_id, |
523 renderer_prefs, | 518 renderer_prefs, |
524 webkit_prefs, | 519 webkit_prefs, |
525 counter, | 520 counter, |
526 routing_id, | 521 routing_id, |
527 session_storage_namespace_id, | 522 session_storage_namespace_id, |
528 frame_name, | 523 frame_name, |
529 next_page_id); // adds reference | 524 next_page_id); // adds reference |
530 } | 525 } |
531 | 526 |
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 | |
541 void RenderViewImpl::AddObserver(RenderViewObserver* observer) { | 527 void RenderViewImpl::AddObserver(RenderViewObserver* observer) { |
542 observers_.AddObserver(observer); | 528 observers_.AddObserver(observer); |
543 } | 529 } |
544 | 530 |
545 void RenderViewImpl::RemoveObserver(RenderViewObserver* observer) { | 531 void RenderViewImpl::RemoveObserver(RenderViewObserver* observer) { |
546 observer->RenderViewGone(); | 532 observer->RenderViewGone(); |
547 observers_.RemoveObserver(observer); | 533 observers_.RemoveObserver(observer); |
548 } | 534 } |
549 | 535 |
550 WebKit::WebView* RenderViewImpl::webview() const { | 536 WebKit::WebView* RenderViewImpl::webview() const { |
(...skipping 2435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2986 size.set_height(preferred_size_.height()); | 2972 size.set_height(preferred_size_.height()); |
2987 | 2973 |
2988 if (size == preferred_size_) | 2974 if (size == preferred_size_) |
2989 return; | 2975 return; |
2990 | 2976 |
2991 preferred_size_ = size; | 2977 preferred_size_ = size; |
2992 Send(new ViewHostMsg_DidContentsPreferredSizeChange(routing_id_, | 2978 Send(new ViewHostMsg_DidContentsPreferredSizeChange(routing_id_, |
2993 preferred_size_)); | 2979 preferred_size_)); |
2994 } | 2980 } |
2995 | 2981 |
2996 void RenderViewImpl::EnsureMediaStreamImpl() { | |
2997 #if defined(ENABLE_P2P_APIS) | |
2998 if (!p2p_socket_dispatcher_) | |
2999 p2p_socket_dispatcher_ = new content::P2PSocketDispatcher(this); | |
3000 #endif | |
3001 | |
3002 if (!media_stream_dispatcher_) | |
3003 media_stream_dispatcher_ = new MediaStreamDispatcher(this); | |
3004 | |
3005 if (!media_stream_impl_.get()) { | |
3006 MediaStreamDependencyFactory* factory = new MediaStreamDependencyFactory(); | |
3007 media_stream_impl_ = new MediaStreamImpl( | |
3008 media_stream_dispatcher_, | |
3009 p2p_socket_dispatcher_, | |
3010 RenderThreadImpl::current()->video_capture_impl_manager(), | |
3011 factory); | |
3012 } | |
3013 } | |
3014 | |
3015 void RenderViewImpl::didChangeContentsSize(WebFrame* frame, | 2982 void RenderViewImpl::didChangeContentsSize(WebFrame* frame, |
3016 const WebSize& size) { | 2983 const WebSize& size) { |
3017 if (webview()->mainFrame() != frame) | 2984 if (webview()->mainFrame() != frame) |
3018 return; | 2985 return; |
3019 WebView* frameView = frame->view(); | 2986 WebView* frameView = frame->view(); |
3020 if (!frameView) | 2987 if (!frameView) |
3021 return; | 2988 return; |
3022 | 2989 |
3023 bool has_horizontal_scrollbar = frame->hasHorizontalScrollbar(); | 2990 bool has_horizontal_scrollbar = frame->hasHorizontalScrollbar(); |
3024 bool has_vertical_scrollbar = frame->hasVerticalScrollbar(); | 2991 bool has_vertical_scrollbar = frame->hasVerticalScrollbar(); |
(...skipping 1702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4727 WebKit::WebPageVisibilityStateHidden : | 4694 WebKit::WebPageVisibilityStateHidden : |
4728 WebKit::WebPageVisibilityStateVisible; | 4695 WebKit::WebPageVisibilityStateVisible; |
4729 WebKit::WebPageVisibilityState override_state = current_state; | 4696 WebKit::WebPageVisibilityState override_state = current_state; |
4730 if (content::GetContentClient()->renderer()-> | 4697 if (content::GetContentClient()->renderer()-> |
4731 ShouldOverridePageVisibilityState(this, | 4698 ShouldOverridePageVisibilityState(this, |
4732 &override_state)) | 4699 &override_state)) |
4733 return override_state; | 4700 return override_state; |
4734 return current_state; | 4701 return current_state; |
4735 } | 4702 } |
4736 | 4703 |
4737 WebKit::WebUserMediaClient* RenderViewImpl::userMediaClient() { | |
4738 const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); | |
4739 if (!cmd_line->HasSwitch(switches::kEnableMediaStream)) | |
4740 return NULL; | |
4741 EnsureMediaStreamImpl(); | |
4742 return media_stream_impl_; | |
4743 } | |
4744 | |
4745 bool RenderViewImpl::IsNonLocalTopLevelNavigation( | 4704 bool RenderViewImpl::IsNonLocalTopLevelNavigation( |
4746 const GURL& url, WebKit::WebFrame* frame, WebKit::WebNavigationType type) { | 4705 const GURL& url, WebKit::WebFrame* frame, WebKit::WebNavigationType type) { |
4747 // Must be a top level frame. | 4706 // Must be a top level frame. |
4748 if (frame->parent() != NULL) | 4707 if (frame->parent() != NULL) |
4749 return false; | 4708 return false; |
4750 | 4709 |
4751 // Navigations initiated within Webkit are not sent out to the external host | 4710 // Navigations initiated within Webkit are not sent out to the external host |
4752 // in the following cases. | 4711 // in the following cases. |
4753 // 1. The url scheme is not http/https | 4712 // 1. The url scheme is not http/https |
4754 // 2. The origin of the url and the opener is the same in which case the | 4713 // 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... |
4862 bool RenderViewImpl::WebWidgetHandlesCompositorScheduling() const { | 4821 bool RenderViewImpl::WebWidgetHandlesCompositorScheduling() const { |
4863 return !!RenderThreadImpl::current()->compositor_thread(); | 4822 return !!RenderThreadImpl::current()->compositor_thread(); |
4864 } | 4823 } |
4865 | 4824 |
4866 void RenderViewImpl::OnJavaBridgeInit() { | 4825 void RenderViewImpl::OnJavaBridgeInit() { |
4867 DCHECK(!java_bridge_dispatcher_.get()); | 4826 DCHECK(!java_bridge_dispatcher_.get()); |
4868 #if defined(ENABLE_JAVA_BRIDGE) | 4827 #if defined(ENABLE_JAVA_BRIDGE) |
4869 java_bridge_dispatcher_.reset(new JavaBridgeDispatcher(this)); | 4828 java_bridge_dispatcher_.reset(new JavaBridgeDispatcher(this)); |
4870 #endif | 4829 #endif |
4871 } | 4830 } |
OLD | NEW |