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> |
11 | 11 |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/bind_helpers.h" | 13 #include "base/bind_helpers.h" |
14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
15 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
16 #include "base/json/json_writer.h" | 16 #include "base/json/json_writer.h" |
17 #include "base/lazy_instance.h" | 17 #include "base/lazy_instance.h" |
18 #include "base/metrics/histogram.h" | 18 #include "base/metrics/histogram.h" |
19 #include "base/path_service.h" | 19 #include "base/path_service.h" |
20 #include "base/process_util.h" | 20 #include "base/process_util.h" |
21 #include "base/string_number_conversions.h" | 21 #include "base/string_number_conversions.h" |
22 #include "base/string_piece.h" | 22 #include "base/string_piece.h" |
23 #include "base/string_split.h" | 23 #include "base/string_split.h" |
24 #include "base/string_util.h" | 24 #include "base/string_util.h" |
25 #include "base/sys_string_conversions.h" | 25 #include "base/sys_string_conversions.h" |
26 #include "base/time.h" | 26 #include "base/time.h" |
27 #include "base/utf_string_conversions.h" | 27 #include "base/utf_string_conversions.h" |
28 #include "content/common/appcache/appcache_dispatcher.h" | 28 #include "content/common/appcache/appcache_dispatcher.h" |
29 #include "content/common/browser_plugin_messages.h" | |
29 #include "content/common/child_thread.h" | 30 #include "content/common/child_thread.h" |
30 #include "content/common/clipboard_messages.h" | 31 #include "content/common/clipboard_messages.h" |
31 #include "content/common/database_messages.h" | 32 #include "content/common/database_messages.h" |
32 #include "content/common/drag_messages.h" | 33 #include "content/common/drag_messages.h" |
33 #include "content/common/fileapi/file_system_dispatcher.h" | 34 #include "content/common/fileapi/file_system_dispatcher.h" |
34 #include "content/common/fileapi/webfilesystem_callback_dispatcher.h" | 35 #include "content/common/fileapi/webfilesystem_callback_dispatcher.h" |
35 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" | 36 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" |
36 #include "content/common/intents_messages.h" | 37 #include "content/common/intents_messages.h" |
37 #include "content/common/java_bridge_messages.h" | 38 #include "content/common/java_bridge_messages.h" |
38 #include "content/common/pepper_messages.h" | 39 #include "content/common/pepper_messages.h" |
39 #include "content/common/pepper_plugin_registry.h" | 40 #include "content/common/pepper_plugin_registry.h" |
40 #include "content/common/quota_dispatcher.h" | 41 #include "content/common/quota_dispatcher.h" |
41 #include "content/common/request_extra_data.h" | 42 #include "content/common/request_extra_data.h" |
42 #include "content/common/socket_stream_handle_data.h" | 43 #include "content/common/socket_stream_handle_data.h" |
43 #include "content/common/view_messages.h" | 44 #include "content/common/view_messages.h" |
44 #include "content/common/webmessageportchannel_impl.h" | 45 #include "content/common/webmessageportchannel_impl.h" |
45 #include "content/public/common/bindings_policy.h" | 46 #include "content/public/common/bindings_policy.h" |
46 #include "content/public/common/content_client.h" | 47 #include "content/public/common/content_client.h" |
47 #include "content/public/common/content_constants.h" | 48 #include "content/public/common/content_constants.h" |
48 #include "content/public/common/content_switches.h" | 49 #include "content/public/common/content_switches.h" |
49 #include "content/public/common/context_menu_params.h" | 50 #include "content/public/common/context_menu_params.h" |
50 #include "content/public/common/file_chooser_params.h" | 51 #include "content/public/common/file_chooser_params.h" |
51 #include "content/public/common/selected_file_info.h" | 52 #include "content/public/common/selected_file_info.h" |
52 #include "content/public/common/url_constants.h" | 53 #include "content/public/common/url_constants.h" |
53 #include "content/public/renderer/content_renderer_client.h" | 54 #include "content/public/renderer/content_renderer_client.h" |
54 #include "content/public/renderer/document_state.h" | 55 #include "content/public/renderer/document_state.h" |
55 #include "content/public/renderer/navigation_state.h" | 56 #include "content/public/renderer/navigation_state.h" |
56 #include "content/public/renderer/render_view_observer.h" | 57 #include "content/public/renderer/render_view_observer.h" |
57 #include "content/public/renderer/render_view_visitor.h" | 58 #include "content/public/renderer/render_view_visitor.h" |
59 #include "content/renderer/browser_plugin/browser_plugin_channel_manager.h" | |
58 #include "content/renderer/browser_plugin/guest_to_embedder_channel.h" | 60 #include "content/renderer/browser_plugin/guest_to_embedder_channel.h" |
59 #include "content/renderer/device_orientation_dispatcher.h" | 61 #include "content/renderer/device_orientation_dispatcher.h" |
60 #include "content/renderer/devtools_agent.h" | 62 #include "content/renderer/devtools_agent.h" |
61 #include "content/renderer/dom_automation_controller.h" | 63 #include "content/renderer/dom_automation_controller.h" |
62 #include "content/renderer/dom_storage/webstoragenamespace_impl.h" | 64 #include "content/renderer/dom_storage/webstoragenamespace_impl.h" |
63 #include "content/renderer/external_popup_menu.h" | 65 #include "content/renderer/external_popup_menu.h" |
64 #include "content/renderer/geolocation_dispatcher.h" | 66 #include "content/renderer/geolocation_dispatcher.h" |
65 #include "content/renderer/gpu/compositor_thread.h" | 67 #include "content/renderer/gpu/compositor_thread.h" |
66 #include "content/renderer/idle_user_detector.h" | 68 #include "content/renderer/idle_user_detector.h" |
67 #include "content/renderer/input_tag_speech_dispatcher.h" | 69 #include "content/renderer/input_tag_speech_dispatcher.h" |
(...skipping 700 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
768 | 770 |
769 void RenderViewImpl::SetReportLoadProgressEnabled(bool enabled) { | 771 void RenderViewImpl::SetReportLoadProgressEnabled(bool enabled) { |
770 if (!enabled) { | 772 if (!enabled) { |
771 load_progress_tracker_.reset(NULL); | 773 load_progress_tracker_.reset(NULL); |
772 return; | 774 return; |
773 } | 775 } |
774 if (load_progress_tracker_ == NULL) | 776 if (load_progress_tracker_ == NULL) |
775 load_progress_tracker_.reset(new LoadProgressTracker(this)); | 777 load_progress_tracker_.reset(new LoadProgressTracker(this)); |
776 } | 778 } |
777 | 779 |
780 content::GuestToEmbedderChannel* | |
781 RenderViewImpl::GetGuestToEmbedderChannel() const { | |
Charlie Reis
2012/05/23 16:57:54
Why rename these to CamelCase if they're still one
Fady Samuel
2012/05/23 17:32:15
I believe I moved this because I needed SetGuestTo
Charlie Reis
2012/05/23 17:52:55
Still seems trivial to me.
| |
782 return guest_to_embedder_channel_; | |
783 } | |
784 | |
785 void RenderViewImpl::SetGuestToEmbedderChannel( | |
786 content::GuestToEmbedderChannel* channel) { | |
787 guest_to_embedder_channel_ = channel; | |
788 } | |
789 | |
778 void RenderViewImpl::PluginCrashed(const FilePath& plugin_path) { | 790 void RenderViewImpl::PluginCrashed(const FilePath& plugin_path) { |
779 Send(new ViewHostMsg_CrashedPlugin(routing_id_, plugin_path)); | 791 Send(new ViewHostMsg_CrashedPlugin(routing_id_, plugin_path)); |
780 } | 792 } |
781 | 793 |
782 void RenderViewImpl::RegisterPluginDelegate(WebPluginDelegateProxy* delegate) { | 794 void RenderViewImpl::RegisterPluginDelegate(WebPluginDelegateProxy* delegate) { |
783 plugin_delegates_.insert(delegate); | 795 plugin_delegates_.insert(delegate); |
784 // If the renderer is visible, set initial visibility and focus state. | 796 // If the renderer is visible, set initial visibility and focus state. |
785 if (!is_hidden()) { | 797 if (!is_hidden()) { |
786 #if defined(OS_MACOSX) | 798 #if defined(OS_MACOSX) |
787 delegate->SetContainerVisibility(true); | 799 delegate->SetContainerVisibility(true); |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
943 if (!msg_is_ok) { | 955 if (!msg_is_ok) { |
944 // The message had a handler, but its deserialization failed. | 956 // The message had a handler, but its deserialization failed. |
945 // Kill the renderer to avoid potential spoofing attacks. | 957 // Kill the renderer to avoid potential spoofing attacks. |
946 CHECK(false) << "Unable to deserialize message in RenderViewImpl."; | 958 CHECK(false) << "Unable to deserialize message in RenderViewImpl."; |
947 } | 959 } |
948 | 960 |
949 return handled; | 961 return handled; |
950 } | 962 } |
951 | 963 |
952 void RenderViewImpl::OnNavigate(const ViewMsg_Navigate_Params& params) { | 964 void RenderViewImpl::OnNavigate(const ViewMsg_Navigate_Params& params) { |
965 // If we don't have guest-to-embedder channel associated with this RenderView | |
966 // but we need one, grab one now. | |
967 if (!params.embedder_channel_name.empty() && !GetGuestToEmbedderChannel()) { | |
968 content::GuestToEmbedderChannel* embedder_channel = | |
969 RenderThreadImpl::current()->browser_plugin_channel_manager()-> | |
970 GetChannelByName(params.embedder_channel_name); | |
971 DCHECK(embedder_channel); | |
972 SetGuestToEmbedderChannel(embedder_channel); | |
973 host_window_set_ = false; | |
974 GetWebView()->loseCompositorContext(1); | |
975 RenderThreadImpl::current()->browser_plugin_channel_manager()-> | |
976 ReportChannelToEmbedder(this, | |
977 embedder_channel->embedder_channel_handle(), | |
978 params.embedder_channel_name, | |
979 params.embedder_container_id); | |
980 } | |
953 MaybeHandleDebugURL(params.url); | 981 MaybeHandleDebugURL(params.url); |
954 if (!webview()) | 982 if (!webview()) |
955 return; | 983 return; |
956 | 984 |
957 FOR_EACH_OBSERVER(RenderViewObserver, observers_, Navigate(params.url)); | 985 FOR_EACH_OBSERVER(RenderViewObserver, observers_, Navigate(params.url)); |
958 | 986 |
959 bool is_reload = IsReload(params); | 987 bool is_reload = IsReload(params); |
960 | 988 |
961 // If this is a stale back/forward (due to a recent navigation the browser | 989 // If this is a stale back/forward (due to a recent navigation the browser |
962 // didn't know about), ignore it. | 990 // didn't know about), ignore it. |
(...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1654 CHECK(session_storage_namespace_id_ != | 1682 CHECK(session_storage_namespace_id_ != |
1655 dom_storage::kInvalidSessionStorageNamespaceId); | 1683 dom_storage::kInvalidSessionStorageNamespaceId); |
1656 return new WebStorageNamespaceImpl(session_storage_namespace_id_); | 1684 return new WebStorageNamespaceImpl(session_storage_namespace_id_); |
1657 } | 1685 } |
1658 | 1686 |
1659 WebGraphicsContext3D* RenderViewImpl::createGraphicsContext3D( | 1687 WebGraphicsContext3D* RenderViewImpl::createGraphicsContext3D( |
1660 const WebGraphicsContext3D::Attributes& attributes) { | 1688 const WebGraphicsContext3D::Attributes& attributes) { |
1661 if (!webview()) | 1689 if (!webview()) |
1662 return NULL; | 1690 return NULL; |
1663 | 1691 |
1664 if (guest_to_embedder_channel()) { | 1692 if (GetGuestToEmbedderChannel()) { |
1665 WebGraphicsContext3DCommandBufferImpl* context = | 1693 WebGraphicsContext3DCommandBufferImpl* context = |
1666 guest_to_embedder_channel()->CreateWebGraphicsContext3D( | 1694 GetGuestToEmbedderChannel()->CreateWebGraphicsContext3D( |
1667 this, attributes, false); | 1695 this, attributes, false); |
1668 if (!guest_pp_instance()) { | 1696 if (!guest_pp_instance()) { |
1669 guest_uninitialized_context_ = context; | 1697 guest_uninitialized_context_ = context; |
1670 guest_attributes_ = attributes; | 1698 guest_attributes_ = attributes; |
1671 } | 1699 } |
1672 return context; | 1700 return context; |
1673 } | 1701 } |
1674 | 1702 |
1675 // The WebGraphicsContext3DInProcessImpl code path is used for | 1703 // The WebGraphicsContext3DInProcessImpl code path is used for |
1676 // layout tests (though not through this code) as well as for | 1704 // layout tests (though not through this code) as well as for |
(...skipping 2028 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3705 is_editable_node = | 3733 is_editable_node = |
3706 node.toConst<WebElement>().isTextFormControlElement(); | 3734 node.toConst<WebElement>().isTextFormControlElement(); |
3707 } | 3735 } |
3708 } | 3736 } |
3709 return is_editable_node; | 3737 return is_editable_node; |
3710 } | 3738 } |
3711 | 3739 |
3712 void RenderViewImpl::GuestReady(PP_Instance instance) { | 3740 void RenderViewImpl::GuestReady(PP_Instance instance) { |
3713 guest_pp_instance_ = instance; | 3741 guest_pp_instance_ = instance; |
3714 if (guest_uninitialized_context_) { | 3742 if (guest_uninitialized_context_) { |
3715 bool success = guest_to_embedder_channel()->CreateGraphicsContext( | 3743 bool success = GetGuestToEmbedderChannel()->CreateGraphicsContext( |
3716 guest_uninitialized_context_, | 3744 guest_uninitialized_context_, |
3717 guest_attributes_, | 3745 guest_attributes_, |
3718 false, | 3746 false, |
3719 this); | 3747 this); |
3720 DCHECK(success); | 3748 DCHECK(success); |
3749 CompleteInit(host_window_); | |
3750 guest_uninitialized_context_ = NULL; | |
3721 } | 3751 } |
3722 CompleteInit(host_window_); | |
3723 } | 3752 } |
3724 | 3753 |
3725 webkit::ppapi::WebPluginImpl* RenderViewImpl::CreateBrowserPlugin( | 3754 webkit::ppapi::WebPluginImpl* RenderViewImpl::CreateBrowserPlugin( |
3726 const IPC::ChannelHandle& channel_handle, | 3755 const IPC::ChannelHandle& channel_handle, |
3727 int guest_process_id, | 3756 int guest_process_id, |
3728 const WebKit::WebPluginParams& params) { | 3757 const WebKit::WebPluginParams& params) { |
3729 scoped_refptr<webkit::ppapi::PluginModule> pepper_module( | 3758 scoped_refptr<webkit::ppapi::PluginModule> pepper_module( |
3730 pepper_delegate_.CreateBrowserPluginModule(channel_handle, | 3759 pepper_delegate_.CreateBrowserPluginModule(channel_handle, |
3731 guest_process_id)); | 3760 guest_process_id)); |
3732 return new webkit::ppapi::WebPluginImpl( | 3761 return new webkit::ppapi::WebPluginImpl( |
(...skipping 1086 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4819 } | 4848 } |
4820 | 4849 |
4821 void RenderViewImpl::WillInitiatePaint() { | 4850 void RenderViewImpl::WillInitiatePaint() { |
4822 // Notify the pepper plugins that we're about to paint. | 4851 // Notify the pepper plugins that we're about to paint. |
4823 pepper_delegate_.ViewWillInitiatePaint(); | 4852 pepper_delegate_.ViewWillInitiatePaint(); |
4824 } | 4853 } |
4825 | 4854 |
4826 void RenderViewImpl::DidInitiatePaint() { | 4855 void RenderViewImpl::DidInitiatePaint() { |
4827 // Notify the pepper plugins that we've painted, and are waiting to flush. | 4856 // Notify the pepper plugins that we've painted, and are waiting to flush. |
4828 pepper_delegate_.ViewInitiatedPaint(); | 4857 pepper_delegate_.ViewInitiatedPaint(); |
4829 if (guest_to_embedder_channel()) | 4858 if (GetGuestToEmbedderChannel()) |
4830 guest_to_embedder_channel()->IssueSwapBuffers(guest_graphics_resource()); | 4859 GetGuestToEmbedderChannel()->IssueSwapBuffers(guest_graphics_resource()); |
4831 } | 4860 } |
4832 | 4861 |
4833 void RenderViewImpl::DidFlushPaint() { | 4862 void RenderViewImpl::DidFlushPaint() { |
4834 // Notify any pepper plugins that we painted. This will call into the plugin, | 4863 // Notify any pepper plugins that we painted. This will call into the plugin, |
4835 // and we it may ask to close itself as a result. This will, in turn, modify | 4864 // and we it may ask to close itself as a result. This will, in turn, modify |
4836 // our set, possibly invalidating the iterator. So we iterate on a copy that | 4865 // our set, possibly invalidating the iterator. So we iterate on a copy that |
4837 // won't change out from under us. | 4866 // won't change out from under us. |
4838 pepper_delegate_.ViewFlushedPaint(); | 4867 pepper_delegate_.ViewFlushedPaint(); |
4839 | 4868 |
4840 // If the RenderWidget is closing down then early-exit, otherwise we'll crash. | 4869 // If the RenderWidget is closing down then early-exit, otherwise we'll crash. |
(...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5472 bool RenderViewImpl::WebWidgetHandlesCompositorScheduling() const { | 5501 bool RenderViewImpl::WebWidgetHandlesCompositorScheduling() const { |
5473 return !!RenderThreadImpl::current()->compositor_thread(); | 5502 return !!RenderThreadImpl::current()->compositor_thread(); |
5474 } | 5503 } |
5475 | 5504 |
5476 void RenderViewImpl::OnJavaBridgeInit() { | 5505 void RenderViewImpl::OnJavaBridgeInit() { |
5477 DCHECK(!java_bridge_dispatcher_); | 5506 DCHECK(!java_bridge_dispatcher_); |
5478 #if defined(ENABLE_JAVA_BRIDGE) | 5507 #if defined(ENABLE_JAVA_BRIDGE) |
5479 java_bridge_dispatcher_ = new JavaBridgeDispatcher(this); | 5508 java_bridge_dispatcher_ = new JavaBridgeDispatcher(this); |
5480 #endif | 5509 #endif |
5481 } | 5510 } |
OLD | NEW |