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

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: Fixed nits 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
« no previous file with comments | « no previous file | content/browser/browser_plugin/browser_plugin_host_browsertest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 do not load empty urls in web_contents. 134 // We do not load 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. This empty src navigation 136 // non-empty page, the action is considered no-op. This empty src navigation
129 // should never be sent to BrowserPluginEmbedder (browser process). 137 // should never be sent to BrowserPluginEmbedder (browser process).
130 DCHECK(!src.empty()); 138 DCHECK(!src.empty());
131 if (!src.empty()) { 139 if (!src.empty()) {
132 // TODO(creis): Check the validity of the URL: http://crbug.com/139397. 140 // TODO(creis): Check the validity of the URL: http://crbug.com/139397.
133 guest_web_contents->GetController().LoadURL(url, 141 guest_web_contents->GetController().LoadURL(url,
134 Referrer(), 142 Referrer(),
135 PAGE_TRANSITION_AUTO_SUBFRAME, 143 PAGE_TRANSITION_AUTO_TOPLEVEL,
136 std::string()); 144 std::string());
137 } 145 }
138 146
139 // Resize the guest if the resize parameter was set from the renderer. 147 // Resize the guest if the resize parameter was set from the renderer.
140 ResizeGuest(render_view_host, instance_id, resize_params); 148 ResizeGuest(render_view_host, instance_id, resize_params);
141 } 149 }
142 150
143 void BrowserPluginEmbedder::UpdateRectACK(int instance_id, 151 void BrowserPluginEmbedder::UpdateRectACK(int instance_id,
144 int message_id, 152 int message_id,
145 const gfx::Size& size) { 153 const gfx::Size& size) {
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 WebContents* guest_web_contents = guest->GetWebContents(); 245 WebContents* guest_web_contents = guest->GetWebContents();
238 246
239 // Destroy the guest's web_contents. 247 // Destroy the guest's web_contents.
240 delete guest_web_contents; 248 delete guest_web_contents;
241 guest_web_contents_by_instance_id_.erase(instance_id); 249 guest_web_contents_by_instance_id_.erase(instance_id);
242 } 250 }
243 } 251 }
244 252
245 void BrowserPluginEmbedder::RenderViewDeleted( 253 void BrowserPluginEmbedder::RenderViewDeleted(
246 RenderViewHost* render_view_host) { 254 RenderViewHost* render_view_host) {
247 DestroyGuests();
248 } 255 }
249 256
250 void BrowserPluginEmbedder::RenderViewGone(base::TerminationStatus status) { 257 void BrowserPluginEmbedder::RenderViewGone(base::TerminationStatus status) {
251 DestroyGuests(); 258 DestroyGuests();
252 } 259 }
253 260
254 void BrowserPluginEmbedder::WebContentsVisibilityChanged(bool visible) { 261 void BrowserPluginEmbedder::WebContentsVisibilityChanged(bool visible) {
255 visible_ = visible; 262 visible_ = visible;
256 // If the embedder is hidden we need to hide the guests as well. 263 // If the embedder is hidden we need to hide the guests as well.
257 for (ContainerInstanceMap::const_iterator it = 264 for (ContainerInstanceMap::const_iterator it =
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 bool visible = *Details<bool>(details).ptr(); 324 bool visible = *Details<bool>(details).ptr();
318 WebContentsVisibilityChanged(visible); 325 WebContentsVisibilityChanged(visible);
319 break; 326 break;
320 } 327 }
321 default: 328 default:
322 NOTREACHED() << "Unexpected notification type: " << type; 329 NOTREACHED() << "Unexpected notification type: " << type;
323 } 330 }
324 } 331 }
325 332
326 } // namespace content 333 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/browser_plugin/browser_plugin_host_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698