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/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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 // TabContents to the guest. | 102 // TabContents to the guest. |
103 // | 103 // |
104 // For GTK and Aura this is necessary to get proper renderer configuration | 104 // For GTK and Aura this is necessary to get proper renderer configuration |
105 // values for caret blinking interval, colors related to selection and | 105 // values for caret blinking interval, colors related to selection and |
106 // focus. | 106 // focus. |
107 *guest_renderer_prefs = *web_contents()->GetMutableRendererPrefs(); | 107 *guest_renderer_prefs = *web_contents()->GetMutableRendererPrefs(); |
108 | 108 |
109 guest_renderer_prefs->throttle_input_events = false; | 109 guest_renderer_prefs->throttle_input_events = false; |
110 AddGuest(instance_id, guest_web_contents); | 110 AddGuest(instance_id, guest_web_contents); |
111 guest_web_contents->SetDelegate(guest); | 111 guest_web_contents->SetDelegate(guest); |
| 112 |
| 113 // Create a swapped out RenderView for the guest in the embedder render |
| 114 // process, so that the embedder can access the guest's window object. |
| 115 int guest_routing_id = |
| 116 static_cast<WebContentsImpl*>(guest->GetWebContents())-> |
| 117 CreateSwappedOutRenderView(web_contents()->GetSiteInstance()); |
| 118 render_view_host->Send(new BrowserPluginMsg_GuestContentWindowReady( |
| 119 instance_id, guest_routing_id)); |
112 } | 120 } |
113 | 121 |
114 void BrowserPluginEmbedder::NavigateGuest( | 122 void BrowserPluginEmbedder::NavigateGuest( |
115 RenderViewHost* render_view_host, | 123 RenderViewHost* render_view_host, |
116 int instance_id, | 124 int instance_id, |
117 const std::string& src, | 125 const std::string& src, |
118 const BrowserPluginHostMsg_ResizeGuest_Params& resize_params) { | 126 const BrowserPluginHostMsg_ResizeGuest_Params& resize_params) { |
119 BrowserPluginGuest* guest = GetGuestByInstanceID(instance_id); | 127 BrowserPluginGuest* guest = GetGuestByInstanceID(instance_id); |
120 CHECK(guest); | 128 CHECK(guest); |
121 GURL url(src); | 129 GURL url(src); |
122 WebContentsImpl* guest_web_contents = | 130 WebContentsImpl* guest_web_contents = |
123 static_cast<WebContentsImpl*>(guest->GetWebContents()); | 131 static_cast<WebContentsImpl*>(guest->GetWebContents()); |
124 | 132 |
125 // We ignore loading empty urls in web_contents. | 133 // We ignore loading empty urls in web_contents. |
126 // If a guest sets empty src attribute after it has navigated to some | 134 // If a guest sets empty src attribute after it has navigated to some |
127 // non-empty page, the action is considered no-op. | 135 // non-empty page, the action is considered no-op. |
128 // TODO(lazyboy): The js shim for browser-plugin might need to reflect empty | 136 // TODO(lazyboy): The js shim for browser-plugin might need to reflect empty |
129 // src ignoring in the shadow DOM element: http://crbug.com/149001. | 137 // src ignoring in the shadow DOM element: http://crbug.com/149001. |
130 if (!src.empty()) { | 138 if (!src.empty()) { |
131 guest_web_contents->GetController().LoadURL(url, | 139 guest_web_contents->GetController().LoadURL(url, |
132 Referrer(), | 140 Referrer(), |
133 PAGE_TRANSITION_AUTO_SUBFRAME, | 141 PAGE_TRANSITION_AUTO_TOPLEVEL, |
134 std::string()); | 142 std::string()); |
135 } | 143 } |
136 | 144 |
137 // Resize the guest if the resize parameter was set from the renderer. | 145 // Resize the guest if the resize parameter was set from the renderer. |
138 ResizeGuest(render_view_host, instance_id, resize_params); | 146 ResizeGuest(render_view_host, instance_id, resize_params); |
139 } | 147 } |
140 | 148 |
141 void BrowserPluginEmbedder::UpdateRectACK(int instance_id, | 149 void BrowserPluginEmbedder::UpdateRectACK(int instance_id, |
142 int message_id, | 150 int message_id, |
143 const gfx::Size& size) { | 151 const gfx::Size& size) { |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 WebContents* guest_web_contents = guest->GetWebContents(); | 243 WebContents* guest_web_contents = guest->GetWebContents(); |
236 | 244 |
237 // Destroy the guest's web_contents. | 245 // Destroy the guest's web_contents. |
238 delete guest_web_contents; | 246 delete guest_web_contents; |
239 guest_web_contents_by_instance_id_.erase(instance_id); | 247 guest_web_contents_by_instance_id_.erase(instance_id); |
240 } | 248 } |
241 } | 249 } |
242 | 250 |
243 void BrowserPluginEmbedder::RenderViewDeleted( | 251 void BrowserPluginEmbedder::RenderViewDeleted( |
244 RenderViewHost* render_view_host) { | 252 RenderViewHost* render_view_host) { |
245 DestroyGuests(); | |
246 } | 253 } |
247 | 254 |
248 void BrowserPluginEmbedder::RenderViewGone(base::TerminationStatus status) { | 255 void BrowserPluginEmbedder::RenderViewGone(base::TerminationStatus status) { |
249 DestroyGuests(); | 256 DestroyGuests(); |
250 } | 257 } |
251 | 258 |
252 void BrowserPluginEmbedder::WebContentsVisibilityChanged(bool visible) { | 259 void BrowserPluginEmbedder::WebContentsVisibilityChanged(bool visible) { |
253 visible_ = visible; | 260 visible_ = visible; |
254 // If the embedder is hidden we need to hide the guests as well. | 261 // If the embedder is hidden we need to hide the guests as well. |
255 for (ContainerInstanceMap::const_iterator it = | 262 for (ContainerInstanceMap::const_iterator it = |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 bool visible = *Details<bool>(details).ptr(); | 311 bool visible = *Details<bool>(details).ptr(); |
305 WebContentsVisibilityChanged(visible); | 312 WebContentsVisibilityChanged(visible); |
306 break; | 313 break; |
307 } | 314 } |
308 default: | 315 default: |
309 NOTREACHED() << "Unexpected notification type: " << type; | 316 NOTREACHED() << "Unexpected notification type: " << type; |
310 } | 317 } |
311 } | 318 } |
312 | 319 |
313 } // namespace content | 320 } // namespace content |
OLD | NEW |