Chromium Code Reviews
[email protected] (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(360)

Side by Side Diff: content/renderer/render_view_impl.cc

Issue 10412056: Browser Plugin: Remove MapInstance from BrowserPluginHost + More cross-process navigation work (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Simplified size logic Created 8 years, 7 months 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 | Annotate | Revision Log
OLDNEW
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
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::guest_to_embedder_channel() const {
jam 2012/05/23 22:11:10 nit: if the function definition is in the cc file,
Fady Samuel 2012/05/23 22:23:43 I left it in the CC file to avoid including guest_
jam 2012/05/23 22:30:20 I'm not following. Why do you need to include gues
782 return guest_to_embedder_channel_;
783 }
784
785 void RenderViewImpl::set_guest_to_embedder_channel(
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
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() && !guest_to_embedder_channel()) {
968 content::GuestToEmbedderChannel* embedder_channel =
969 RenderThreadImpl::current()->browser_plugin_channel_manager()->
970 GetChannelByName(params.embedder_channel_name);
971 DCHECK(embedder_channel);
972 set_guest_to_embedder_channel(embedder_channel);
973 host_window_set_ = false;
974 // TODO(fsamuel): This is test code. Need to find a better way to tell
975 // a WebView to drop its context. This needs to change in
976 // GuestToEmbedderChannel::OnContextLost.
977 GetWebView()->loseCompositorContext(1);
978 RenderThreadImpl::current()->browser_plugin_channel_manager()->
979 ReportChannelToEmbedder(this,
980 embedder_channel->embedder_channel_handle(),
981 params.embedder_channel_name,
982 params.embedder_container_id);
983 }
953 MaybeHandleDebugURL(params.url); 984 MaybeHandleDebugURL(params.url);
954 if (!webview()) 985 if (!webview())
955 return; 986 return;
956 987
957 FOR_EACH_OBSERVER(RenderViewObserver, observers_, Navigate(params.url)); 988 FOR_EACH_OBSERVER(RenderViewObserver, observers_, Navigate(params.url));
958 989
959 bool is_reload = IsReload(params); 990 bool is_reload = IsReload(params);
960 991
961 // If this is a stale back/forward (due to a recent navigation the browser 992 // If this is a stale back/forward (due to a recent navigation the browser
962 // didn't know about), ignore it. 993 // didn't know about), ignore it.
(...skipping 2748 matching lines...) Expand 10 before | Expand all | Expand 10 after
3711 3742
3712 void RenderViewImpl::GuestReady(PP_Instance instance) { 3743 void RenderViewImpl::GuestReady(PP_Instance instance) {
3713 guest_pp_instance_ = instance; 3744 guest_pp_instance_ = instance;
3714 if (guest_uninitialized_context_) { 3745 if (guest_uninitialized_context_) {
3715 bool success = guest_to_embedder_channel()->CreateGraphicsContext( 3746 bool success = guest_to_embedder_channel()->CreateGraphicsContext(
3716 guest_uninitialized_context_, 3747 guest_uninitialized_context_,
3717 guest_attributes_, 3748 guest_attributes_,
3718 false, 3749 false,
3719 this); 3750 this);
3720 DCHECK(success); 3751 DCHECK(success);
3752 CompleteInit(host_window_);
3753 guest_uninitialized_context_ = NULL;
3721 } 3754 }
3722 CompleteInit(host_window_);
3723 } 3755 }
3724 3756
3725 webkit::ppapi::WebPluginImpl* RenderViewImpl::CreateBrowserPlugin( 3757 webkit::ppapi::WebPluginImpl* RenderViewImpl::CreateBrowserPlugin(
3726 const IPC::ChannelHandle& channel_handle, 3758 const IPC::ChannelHandle& channel_handle,
3727 int guest_process_id, 3759 int guest_process_id,
3728 const WebKit::WebPluginParams& params) { 3760 const WebKit::WebPluginParams& params) {
3729 scoped_refptr<webkit::ppapi::PluginModule> pepper_module( 3761 scoped_refptr<webkit::ppapi::PluginModule> pepper_module(
3730 pepper_delegate_.CreateBrowserPluginModule(channel_handle, 3762 pepper_delegate_.CreateBrowserPluginModule(channel_handle,
3731 guest_process_id)); 3763 guest_process_id));
3732 return new webkit::ppapi::WebPluginImpl( 3764 return new webkit::ppapi::WebPluginImpl(
(...skipping 1739 matching lines...) Expand 10 before | Expand all | Expand 10 after
5472 bool RenderViewImpl::WebWidgetHandlesCompositorScheduling() const { 5504 bool RenderViewImpl::WebWidgetHandlesCompositorScheduling() const {
5473 return !!RenderThreadImpl::current()->compositor_thread(); 5505 return !!RenderThreadImpl::current()->compositor_thread();
5474 } 5506 }
5475 5507
5476 void RenderViewImpl::OnJavaBridgeInit() { 5508 void RenderViewImpl::OnJavaBridgeInit() {
5477 DCHECK(!java_bridge_dispatcher_); 5509 DCHECK(!java_bridge_dispatcher_);
5478 #if defined(ENABLE_JAVA_BRIDGE) 5510 #if defined(ENABLE_JAVA_BRIDGE)
5479 java_bridge_dispatcher_ = new JavaBridgeDispatcher(this); 5511 java_bridge_dispatcher_ = new JavaBridgeDispatcher(this);
5480 #endif 5512 #endif
5481 } 5513 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698