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 <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
(...skipping 1336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1347 main_frame_route_id); | 1347 main_frame_route_id); |
1348 return; | 1348 return; |
1349 } | 1349 } |
1350 | 1350 |
1351 // Create the new web contents. This will automatically create the new | 1351 // Create the new web contents. This will automatically create the new |
1352 // WebContentsView. In the future, we may want to create the view separately. | 1352 // WebContentsView. In the future, we may want to create the view separately. |
1353 WebContentsImpl* new_contents = | 1353 WebContentsImpl* new_contents = |
1354 new WebContentsImpl(GetBrowserContext(), | 1354 new WebContentsImpl(GetBrowserContext(), |
1355 params.opener_suppressed ? NULL : this); | 1355 params.opener_suppressed ? NULL : this); |
1356 | 1356 |
| 1357 NotificationService::current()->Notify( |
| 1358 NOTIFICATION_WEB_CONTENTS_CREATE_NEW_WINDOW, |
| 1359 Source<WebContents>(this), |
| 1360 Details<WebContents>(new_contents)); |
| 1361 |
1357 new_contents->GetController().SetSessionStorageNamespace( | 1362 new_contents->GetController().SetSessionStorageNamespace( |
1358 partition_id, | 1363 partition_id, |
1359 session_storage_namespace); | 1364 session_storage_namespace); |
1360 CreateParams create_params(GetBrowserContext(), site_instance.get()); | 1365 CreateParams create_params(GetBrowserContext(), site_instance.get()); |
1361 create_params.routing_id = route_id; | 1366 create_params.routing_id = route_id; |
1362 create_params.main_frame_routing_id = main_frame_route_id; | 1367 create_params.main_frame_routing_id = main_frame_route_id; |
1363 if (!is_guest) { | 1368 if (!is_guest) { |
1364 create_params.context = view_->GetNativeView(); | 1369 create_params.context = view_->GetNativeView(); |
1365 create_params.initial_size = view_->GetContainerSize(); | 1370 create_params.initial_size = view_->GetContainerSize(); |
1366 } else { | 1371 } else { |
1367 // This makes |new_contents| act as a guest. | 1372 // This makes |new_contents| act as a guest. |
1368 // For more info, see comment above class BrowserPluginGuest. | 1373 // For more info, see comment above class BrowserPluginGuest. |
1369 int instance_id = GetBrowserPluginGuestManager()->get_next_instance_id(); | 1374 int instance_id = GetBrowserPluginGuestManager()->get_next_instance_id(); |
1370 WebContentsImpl* new_contents_impl = | 1375 WebContentsImpl* new_contents_impl = |
1371 static_cast<WebContentsImpl*>(new_contents); | 1376 static_cast<WebContentsImpl*>(new_contents); |
1372 BrowserPluginGuest::CreateWithOpener(instance_id, | 1377 BrowserPluginGuest::CreateWithOpener(instance_id, |
1373 new_contents_impl->opener() != NULL, | 1378 new_contents_impl->opener() != NULL, |
1374 new_contents_impl, | 1379 new_contents_impl, |
1375 GetBrowserPluginGuest()); | 1380 GetBrowserPluginGuest()); |
1376 } | 1381 } |
1377 if (params.disposition == NEW_BACKGROUND_TAB) | 1382 if (params.disposition == NEW_BACKGROUND_TAB) |
1378 create_params.initially_hidden = true; | 1383 create_params.initially_hidden = true; |
1379 new_contents->Init(create_params); | 1384 new_contents->Init(create_params); |
| 1385 new_contents->RenderViewCreated(new_contents->GetRenderViewHost()); |
1380 | 1386 |
1381 // Save the window for later if we're not suppressing the opener (since it | 1387 // Save the window for later if we're not suppressing the opener (since it |
1382 // will be shown immediately). | 1388 // will be shown immediately). |
1383 if (!params.opener_suppressed) { | 1389 if (!params.opener_suppressed) { |
1384 if (!is_guest) { | 1390 if (!is_guest) { |
1385 WebContentsViewPort* new_view = new_contents->view_.get(); | 1391 WebContentsViewPort* new_view = new_contents->view_.get(); |
1386 | 1392 |
1387 // TODO(brettw): It seems bogus that we have to call this function on the | 1393 // TODO(brettw): It seems bogus that we have to call this function on the |
1388 // newly created object and give it one of its own member variables. | 1394 // newly created object and give it one of its own member variables. |
1389 new_view->CreateViewForWidget(new_contents->GetRenderViewHost()); | 1395 new_view->CreateViewForWidget(new_contents->GetRenderViewHost()); |
(...skipping 2237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3627 | 3633 |
3628 void WebContentsImpl::OnPreferredSizeChanged(const gfx::Size& old_size) { | 3634 void WebContentsImpl::OnPreferredSizeChanged(const gfx::Size& old_size) { |
3629 if (!delegate_) | 3635 if (!delegate_) |
3630 return; | 3636 return; |
3631 const gfx::Size new_size = GetPreferredSize(); | 3637 const gfx::Size new_size = GetPreferredSize(); |
3632 if (new_size != old_size) | 3638 if (new_size != old_size) |
3633 delegate_->UpdatePreferredSize(this, new_size); | 3639 delegate_->UpdatePreferredSize(this, new_size); |
3634 } | 3640 } |
3635 | 3641 |
3636 } // namespace content | 3642 } // namespace content |
OLD | NEW |