| 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/web_contents/web_contents_impl.h" | 5 #include "content/browser/web_contents/web_contents_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <cmath> | 9 #include <cmath> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 1253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1264 !GetRenderViewHost()->SuddenTerminationAllowed(); | 1264 !GetRenderViewHost()->SuddenTerminationAllowed(); |
| 1265 } | 1265 } |
| 1266 | 1266 |
| 1267 void WebContentsImpl::DispatchBeforeUnload(bool for_cross_site_transition) { | 1267 void WebContentsImpl::DispatchBeforeUnload(bool for_cross_site_transition) { |
| 1268 GetMainFrame()->DispatchBeforeUnload(for_cross_site_transition); | 1268 GetMainFrame()->DispatchBeforeUnload(for_cross_site_transition); |
| 1269 } | 1269 } |
| 1270 | 1270 |
| 1271 void WebContentsImpl::AttachToOuterWebContentsFrame( | 1271 void WebContentsImpl::AttachToOuterWebContentsFrame( |
| 1272 WebContents* outer_web_contents, | 1272 WebContents* outer_web_contents, |
| 1273 RenderFrameHost* outer_contents_frame) { | 1273 RenderFrameHost* outer_contents_frame) { |
| 1274 DCHECK(outer_contents_frame); |
| 1275 RenderFrameHostImpl* outer_contents_frame_impl = |
| 1276 static_cast<RenderFrameHostImpl*>(outer_contents_frame); |
| 1274 CHECK(BrowserPluginGuestMode::UseCrossProcessFramesForGuests()); | 1277 CHECK(BrowserPluginGuestMode::UseCrossProcessFramesForGuests()); |
| 1275 RenderFrameHostManager* render_manager = GetRenderManager(); | 1278 RenderFrameHostManager* render_manager = GetRenderManager(); |
| 1276 | 1279 |
| 1277 // When the WebContents being initialized has an opener, the browser side | 1280 // When the WebContents being initialized has an opener, the browser side |
| 1278 // Render{View,Frame}Host must be initialized and the RenderWidgetHostView | 1281 // Render{View,Frame}Host must be initialized and the RenderWidgetHostView |
| 1279 // created. This is needed because the usual initialization happens during | 1282 // created. This is needed because the usual initialization happens during |
| 1280 // the first navigation, but when attaching a new window we don't navigate | 1283 // the first navigation, but when attaching a new window we don't navigate |
| 1281 // before attaching. If the browser side is already initialized, the calls | 1284 // before attaching. If the browser side is already initialized, the calls |
| 1282 // below will just early return. | 1285 // below will just early return. |
| 1283 render_manager->InitRenderView(GetRenderViewHost(), nullptr); | 1286 render_manager->InitRenderView(GetRenderViewHost(), nullptr); |
| 1284 GetMainFrame()->Init(); | 1287 GetMainFrame()->Init(); |
| 1285 if (!render_manager->GetRenderWidgetHostView()) | 1288 if (!render_manager->GetRenderWidgetHostView()) |
| 1286 CreateRenderWidgetHostViewForRenderManager(GetRenderViewHost()); | 1289 CreateRenderWidgetHostViewForRenderManager(GetRenderViewHost()); |
| 1287 | 1290 |
| 1288 // Create a link to our outer WebContents. | 1291 // Create a link to our outer WebContents. |
| 1289 node_.reset(new WebContentsTreeNode()); | 1292 node_.reset(new WebContentsTreeNode()); |
| 1290 node_->ConnectToOuterWebContents( | 1293 node_->ConnectToOuterWebContents( |
| 1291 static_cast<WebContentsImpl*>(outer_web_contents), | 1294 static_cast<WebContentsImpl*>(outer_web_contents), |
| 1292 static_cast<RenderFrameHostImpl*>(outer_contents_frame)); | 1295 outer_contents_frame_impl); |
| 1293 | |
| 1294 DCHECK(outer_contents_frame); | |
| 1295 | 1296 |
| 1296 // Create a proxy in top-level RenderFrameHostManager, pointing to the | 1297 // Create a proxy in top-level RenderFrameHostManager, pointing to the |
| 1297 // SiteInstance of the outer WebContents. The proxy will be used to send | 1298 // SiteInstance of the outer WebContents. The proxy will be used to send |
| 1298 // postMessage to the inner WebContents. | 1299 // postMessage to the inner WebContents. |
| 1299 render_manager->CreateOuterDelegateProxy( | 1300 render_manager->CreateOuterDelegateProxy( |
| 1300 outer_contents_frame->GetSiteInstance(), | 1301 outer_contents_frame_impl->GetSiteInstance(), outer_contents_frame_impl); |
| 1301 static_cast<RenderFrameHostImpl*>(outer_contents_frame)); | |
| 1302 | 1302 |
| 1303 render_manager->SetRWHViewForInnerContents( | 1303 render_manager->SetRWHViewForInnerContents( |
| 1304 render_manager->GetRenderWidgetHostView()); | 1304 render_manager->GetRenderWidgetHostView()); |
| 1305 | 1305 |
| 1306 static_cast<RenderWidgetHostViewChildFrame*>( | 1306 static_cast<RenderWidgetHostViewChildFrame*>( |
| 1307 render_manager->GetRenderWidgetHostView()) | 1307 render_manager->GetRenderWidgetHostView()) |
| 1308 ->RegisterSurfaceNamespaceId(); | 1308 ->RegisterSurfaceNamespaceId(); |
| 1309 } | 1309 } |
| 1310 | 1310 |
| 1311 void WebContentsImpl::Stop() { | 1311 void WebContentsImpl::Stop() { |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1370 should_normally_be_visible_ = !params.initially_hidden; | 1370 should_normally_be_visible_ = !params.initially_hidden; |
| 1371 | 1371 |
| 1372 // The routing ids must either all be set or all be unset. | 1372 // The routing ids must either all be set or all be unset. |
| 1373 DCHECK((params.routing_id == MSG_ROUTING_NONE && | 1373 DCHECK((params.routing_id == MSG_ROUTING_NONE && |
| 1374 params.main_frame_routing_id == MSG_ROUTING_NONE && | 1374 params.main_frame_routing_id == MSG_ROUTING_NONE && |
| 1375 params.main_frame_widget_routing_id == MSG_ROUTING_NONE) || | 1375 params.main_frame_widget_routing_id == MSG_ROUTING_NONE) || |
| 1376 (params.routing_id != MSG_ROUTING_NONE && | 1376 (params.routing_id != MSG_ROUTING_NONE && |
| 1377 params.main_frame_routing_id != MSG_ROUTING_NONE && | 1377 params.main_frame_routing_id != MSG_ROUTING_NONE && |
| 1378 params.main_frame_widget_routing_id != MSG_ROUTING_NONE)); | 1378 params.main_frame_widget_routing_id != MSG_ROUTING_NONE)); |
| 1379 | 1379 |
| 1380 scoped_refptr<SiteInstance> site_instance = params.site_instance; | 1380 scoped_refptr<SiteInstanceImpl> site_instance = |
| 1381 static_cast<SiteInstanceImpl*>(params.site_instance.get()); |
| 1381 if (!site_instance) | 1382 if (!site_instance) |
| 1382 site_instance = SiteInstance::Create(params.browser_context); | 1383 site_instance = SiteInstanceImpl::Create(params.browser_context); |
| 1383 | 1384 |
| 1384 // A main RenderFrameHost always has a RenderWidgetHost, since it is always a | 1385 // A main RenderFrameHost always has a RenderWidgetHost, since it is always a |
| 1385 // local root by definition. | 1386 // local root by definition. |
| 1386 // TODO(avi): Once RenderViewHostImpl has-a RenderWidgetHostImpl, it will no | 1387 // TODO(avi): Once RenderViewHostImpl has-a RenderWidgetHostImpl, it will no |
| 1387 // longer be necessary to eagerly grab a routing ID for the view. | 1388 // longer be necessary to eagerly grab a routing ID for the view. |
| 1388 // https://crbug.com/545684 | 1389 // https://crbug.com/545684 |
| 1389 int32_t view_routing_id = params.routing_id; | 1390 int32_t view_routing_id = params.routing_id; |
| 1390 int32_t main_frame_widget_routing_id = params.main_frame_widget_routing_id; | 1391 int32_t main_frame_widget_routing_id = params.main_frame_widget_routing_id; |
| 1391 if (main_frame_widget_routing_id == MSG_ROUTING_NONE) { | 1392 if (main_frame_widget_routing_id == MSG_ROUTING_NONE) { |
| 1392 view_routing_id = main_frame_widget_routing_id = | 1393 view_routing_id = main_frame_widget_routing_id = |
| (...skipping 3453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4846 else | 4847 else |
| 4847 WasHidden(); | 4848 WasHidden(); |
| 4848 } | 4849 } |
| 4849 | 4850 |
| 4850 void WebContentsImpl::SetJavaScriptDialogManagerForTesting( | 4851 void WebContentsImpl::SetJavaScriptDialogManagerForTesting( |
| 4851 JavaScriptDialogManager* dialog_manager) { | 4852 JavaScriptDialogManager* dialog_manager) { |
| 4852 dialog_manager_ = dialog_manager; | 4853 dialog_manager_ = dialog_manager; |
| 4853 } | 4854 } |
| 4854 | 4855 |
| 4855 } // namespace content | 4856 } // namespace content |
| OLD | NEW |