Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(362)

Side by Side Diff: content/browser/browser_plugin/browser_plugin_host.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: Removed commented out code 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/browser/browser_plugin/browser_plugin_host.h" 5 #include "content/browser/browser_plugin/browser_plugin_host.h"
6 6
7 #include "content/browser/browser_plugin/browser_plugin_host_helper.h" 7 #include "content/browser/browser_plugin/browser_plugin_host_helper.h"
8 #include "content/browser/renderer_host/render_view_host_impl.h" 8 #include "content/browser/renderer_host/render_view_host_impl.h"
9 #include "content/browser/web_contents/web_contents_impl.h" 9 #include "content/browser/web_contents/web_contents_impl.h"
10 #include "content/common/browser_plugin_messages.h" 10 #include "content/common/browser_plugin_messages.h"
11 #include "content/public/browser/notification_details.h" 11 #include "content/public/browser/notification_details.h"
12 #include "content/public/browser/notification_source.h" 12 #include "content/public/browser/notification_source.h"
13 #include "content/public/browser/notification_types.h" 13 #include "content/public/browser/notification_types.h"
14 #include "content/public/browser/render_process_host.h" 14 #include "content/public/browser/render_process_host.h"
15 #include "content/public/browser/render_widget_host_view.h" 15 #include "content/public/browser/render_widget_host_view.h"
16 #include "content/public/browser/site_instance.h" 16 #include "content/public/browser/site_instance.h"
17 #include "content/public/browser/web_contents_view.h" 17 #include "content/public/browser/web_contents_view.h"
18 #include "ppapi/proxy/ppapi_messages.h" 18 #include "ppapi/proxy/ppapi_messages.h"
19 19
20 namespace content { 20 namespace content {
21 21
22 BrowserPluginHost::BrowserPluginHost( 22 BrowserPluginHost::BrowserPluginHost(
23 WebContentsImpl* web_contents) 23 WebContentsImpl* web_contents)
24 : WebContentsObserver(web_contents), 24 : WebContentsObserver(web_contents),
25 embedder_render_process_host_(NULL), 25 embedder_render_process_host_(NULL),
26 instance_id_(0), 26 instance_id_(0) {
27 pending_render_view_host_(NULL) {
28 // Listen to visibility changes so that an embedder hides its guests 27 // Listen to visibility changes so that an embedder hides its guests
29 // as well. 28 // as well.
30 registrar_.Add(this, 29 registrar_.Add(this,
31 NOTIFICATION_WEB_CONTENTS_VISIBILITY_CHANGED, 30 NOTIFICATION_WEB_CONTENTS_VISIBILITY_CHANGED,
32 Source<WebContents>(web_contents)); 31 Source<WebContents>(web_contents));
33 // Construct plumbing helpers when a new RenderViewHost is created for 32 // Construct plumbing helpers when a new RenderViewHost is created for
34 // this BrowserPluginHost's WebContentsImpl. 33 // this BrowserPluginHost's WebContentsImpl.
35 registrar_.Add(this, 34 registrar_.Add(this,
36 NOTIFICATION_RENDER_VIEW_HOST_CREATED_FOR_TAB, 35 NOTIFICATION_RENDER_VIEW_HOST_CREATED_FOR_TAB,
37 Source<WebContents>(web_contents)); 36 Source<WebContents>(web_contents));
(...skipping 11 matching lines...) Expand all
49 } 48 }
50 49
51 void BrowserPluginHost::RegisterContainerInstance( 50 void BrowserPluginHost::RegisterContainerInstance(
52 int container_id, 51 int container_id,
53 BrowserPluginHost* observer) { 52 BrowserPluginHost* observer) {
54 DCHECK(guests_by_container_id_.find(container_id) == 53 DCHECK(guests_by_container_id_.find(container_id) ==
55 guests_by_container_id_.end()); 54 guests_by_container_id_.end());
56 guests_by_container_id_[container_id] = observer; 55 guests_by_container_id_[container_id] = observer;
57 } 56 }
58 57
59 void BrowserPluginHost::OnPendingNavigation(RenderViewHost* dest_rvh) {
60 if (web_contents()->GetRenderViewHost() != dest_rvh) {
61 pending_render_view_host_ = dest_rvh;
62 }
63 }
64
65 bool BrowserPluginHost::OnMessageReceived(const IPC::Message& message) { 58 bool BrowserPluginHost::OnMessageReceived(const IPC::Message& message) {
66 bool handled = true; 59 bool handled = true;
67 IPC_BEGIN_MESSAGE_MAP(BrowserPluginHost, message) 60 IPC_BEGIN_MESSAGE_MAP(BrowserPluginHost, message)
68 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_NavigateFromGuest, 61 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_NavigateFromGuest,
69 OnNavigateFromGuest) 62 OnNavigateFromGuest)
70 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_MapInstance,
71 OnMapInstance)
72 IPC_MESSAGE_UNHANDLED(handled = false) 63 IPC_MESSAGE_UNHANDLED(handled = false)
73 IPC_END_MESSAGE_MAP() 64 IPC_END_MESSAGE_MAP()
74 return handled; 65 return handled;
75 } 66 }
76 67
77 void BrowserPluginHost::NavigateGuestFromEmbedder( 68 void BrowserPluginHost::NavigateGuestFromEmbedder(
78 RenderViewHost* render_view_host, 69 RenderViewHost* render_view_host,
79 int container_instance_id, 70 int container_instance_id,
80 long long frame_id, 71 long long frame_id,
81 const std::string& src, 72 const std::string& src,
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 const std::string& src) { 110 const std::string& src) {
120 DCHECK(embedder_render_process_host()); 111 DCHECK(embedder_render_process_host());
121 GURL url(src); 112 GURL url(src);
122 web_contents()->GetController().LoadURL( 113 web_contents()->GetController().LoadURL(
123 url, 114 url,
124 Referrer(), 115 Referrer(),
125 PAGE_TRANSITION_AUTO_SUBFRAME, 116 PAGE_TRANSITION_AUTO_SUBFRAME,
126 std::string()); 117 std::string());
127 } 118 }
128 119
129 // TODO(fsamuel): This handler is all kinds of bad and could be racy.
130 // Between the time we set the pending_render_view_host and use it here,
131 // the pending_render_view_host may no longer be valid and this message
132 // may not go to the right place.
133 // See https://code.google.com/p/chromium/issues/detail?id=128976.
134 // The correct solution is probably to send
135 // "BrowserPluginMsg_CompleteNavigation" over the pepper channel to the guest
136 // and then have the guest send the browser "BrowserPluginHostMsg_ResizeGuest"
137 // to resize appropriately.
138 void BrowserPluginHost::OnMapInstance(int container_instance_id,
139 PP_Instance instance) {
140 BrowserPluginHost* guest_observer =
141 GetGuestByContainerID(container_instance_id);
142 WebContentsImpl* guest_web_contents =
143 static_cast<WebContentsImpl*>(guest_observer->web_contents());
144 RenderViewHost* rvh = guest_observer->pending_render_view_host() ?
145 guest_observer->pending_render_view_host() :
146 guest_web_contents->GetRenderViewHost();
147
148 guest_web_contents->GetView()->SizeContents(guest_observer->initial_size());
149
150 rvh->Send(new BrowserPluginMsg_CompleteNavigation(
151 rvh->GetRoutingID(),
152 instance));
153 }
154
155 void BrowserPluginHost::ConnectEmbedderToChannel( 120 void BrowserPluginHost::ConnectEmbedderToChannel(
156 RenderViewHost* render_view_host, 121 RenderViewHost* render_view_host,
157 const IPC::ChannelHandle& channel_handle) { 122 const IPC::ChannelHandle& channel_handle) {
158 DCHECK(embedder_render_process_host()); 123 DCHECK(embedder_render_process_host());
159 // Tell the BrowserPlugin in the embedder that we're done and that it can 124 // Tell the BrowserPlugin in the embedder that we're done and that it can
160 // begin using the guest renderer. 125 // begin using the guest renderer.
161 embedder_render_process_host()->Send( 126 embedder_render_process_host()->Send(
162 new BrowserPluginMsg_LoadGuest( 127 new BrowserPluginMsg_LoadGuest(
163 instance_id(), 128 instance_id(),
164 render_view_host->GetProcess()-> 129 render_view_host->GetProcess()->
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 web_contents->HideContents(); 215 web_contents->HideContents();
251 } 216 }
252 break; 217 break;
253 } 218 }
254 default: 219 default:
255 NOTREACHED() << "Unexpected notification type: " << type; 220 NOTREACHED() << "Unexpected notification type: " << type;
256 } 221 }
257 } 222 }
258 223
259 } // namespace content 224 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698