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

Side by Side Diff: content/browser/browser_plugin/browser_plugin_embedder.cc

Issue 10829225: Browser Plugin: Add HTML5-like postMessage support (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merged with ToT. Addressed creis@'s comments Created 8 years, 2 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_embedder.h" 5 #include "content/browser/browser_plugin/browser_plugin_embedder.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 // TabContents to the guest. 103 // TabContents to the guest.
104 // 104 //
105 // For GTK and Aura this is necessary to get proper renderer configuration 105 // For GTK and Aura this is necessary to get proper renderer configuration
106 // values for caret blinking interval, colors related to selection and 106 // values for caret blinking interval, colors related to selection and
107 // focus. 107 // focus.
108 *guest_renderer_prefs = *web_contents()->GetMutableRendererPrefs(); 108 *guest_renderer_prefs = *web_contents()->GetMutableRendererPrefs();
109 109
110 guest_renderer_prefs->throttle_input_events = false; 110 guest_renderer_prefs->throttle_input_events = false;
111 AddGuest(instance_id, guest_web_contents); 111 AddGuest(instance_id, guest_web_contents);
112 guest_web_contents->SetDelegate(guest); 112 guest_web_contents->SetDelegate(guest);
113
114 // Create a swapped out RenderView for the guest in the embedder render
115 // process, so that the embedder can access the guest's window object.
116 int guest_routing_id =
117 static_cast<WebContentsImpl*>(guest->GetWebContents())->
118 CreateSwappedOutRenderView(web_contents()->GetSiteInstance());
119 render_view_host->Send(new BrowserPluginMsg_GuestContentWindowReady(
120 instance_id, guest_routing_id));
113 } 121 }
114 122
115 void BrowserPluginEmbedder::NavigateGuest( 123 void BrowserPluginEmbedder::NavigateGuest(
116 RenderViewHost* render_view_host, 124 RenderViewHost* render_view_host,
117 int instance_id, 125 int instance_id,
118 const std::string& src, 126 const std::string& src,
119 const BrowserPluginHostMsg_ResizeGuest_Params& resize_params) { 127 const BrowserPluginHostMsg_ResizeGuest_Params& resize_params) {
120 BrowserPluginGuest* guest = GetGuestByInstanceID(instance_id); 128 BrowserPluginGuest* guest = GetGuestByInstanceID(instance_id);
121 CHECK(guest); 129 CHECK(guest);
122 GURL url(src); 130 GURL url(src);
123 WebContentsImpl* guest_web_contents = 131 WebContentsImpl* guest_web_contents =
124 static_cast<WebContentsImpl*>(guest->GetWebContents()); 132 static_cast<WebContentsImpl*>(guest->GetWebContents());
125 133
126 // We ignore loading empty urls in web_contents. 134 // We ignore loading empty urls in web_contents.
127 // If a guest sets empty src attribute after it has navigated to some 135 // If a guest sets empty src attribute after it has navigated to some
128 // non-empty page, the action is considered no-op. 136 // non-empty page, the action is considered no-op.
129 // TODO(lazyboy): The js shim for browser-plugin might need to reflect empty 137 // TODO(lazyboy): The js shim for browser-plugin might need to reflect empty
130 // src ignoring in the shadow DOM element: http://crbug.com/149001. 138 // src ignoring in the shadow DOM element: http://crbug.com/149001.
131 if (!src.empty()) { 139 if (!src.empty()) {
132 guest_web_contents->GetController().LoadURL(url, 140 guest_web_contents->GetController().LoadURL(url,
133 Referrer(), 141 Referrer(),
134 PAGE_TRANSITION_AUTO_SUBFRAME, 142 PAGE_TRANSITION_AUTO_TOPLEVEL,
135 std::string()); 143 std::string());
136 } 144 }
137 145
138 // Resize the guest if the resize parameter was set from the renderer. 146 // Resize the guest if the resize parameter was set from the renderer.
139 ResizeGuest(render_view_host, instance_id, resize_params); 147 ResizeGuest(render_view_host, instance_id, resize_params);
140 } 148 }
141 149
142 void BrowserPluginEmbedder::UpdateRectACK(int instance_id, 150 void BrowserPluginEmbedder::UpdateRectACK(int instance_id,
143 int message_id, 151 int message_id,
144 const gfx::Size& size) { 152 const gfx::Size& size) {
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 WebContents* guest_web_contents = guest->GetWebContents(); 244 WebContents* guest_web_contents = guest->GetWebContents();
237 245
238 // Destroy the guest's web_contents. 246 // Destroy the guest's web_contents.
239 delete guest_web_contents; 247 delete guest_web_contents;
240 guest_web_contents_by_instance_id_.erase(instance_id); 248 guest_web_contents_by_instance_id_.erase(instance_id);
241 } 249 }
242 } 250 }
243 251
244 void BrowserPluginEmbedder::RenderViewDeleted( 252 void BrowserPluginEmbedder::RenderViewDeleted(
245 RenderViewHost* render_view_host) { 253 RenderViewHost* render_view_host) {
246 DestroyGuests();
247 } 254 }
248 255
249 void BrowserPluginEmbedder::RenderViewGone(base::TerminationStatus status) { 256 void BrowserPluginEmbedder::RenderViewGone(base::TerminationStatus status) {
250 DestroyGuests(); 257 DestroyGuests();
251 } 258 }
252 259
253 void BrowserPluginEmbedder::WebContentsVisibilityChanged(bool visible) { 260 void BrowserPluginEmbedder::WebContentsVisibilityChanged(bool visible) {
254 visible_ = visible; 261 visible_ = visible;
255 // If the embedder is hidden we need to hide the guests as well. 262 // If the embedder is hidden we need to hide the guests as well.
256 for (ContainerInstanceMap::const_iterator it = 263 for (ContainerInstanceMap::const_iterator it =
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 bool visible = *Details<bool>(details).ptr(); 323 bool visible = *Details<bool>(details).ptr();
317 WebContentsVisibilityChanged(visible); 324 WebContentsVisibilityChanged(visible);
318 break; 325 break;
319 } 326 }
320 default: 327 default:
321 NOTREACHED() << "Unexpected notification type: " << type; 328 NOTREACHED() << "Unexpected notification type: " << type;
322 } 329 }
323 } 330 }
324 331
325 } // namespace content 332 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698