| 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 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 destruction_observers_.end()); | 432 destruction_observers_.end()); |
| 433 } | 433 } |
| 434 | 434 |
| 435 WebContentsImpl* WebContentsImpl::CreateWithOpener( | 435 WebContentsImpl* WebContentsImpl::CreateWithOpener( |
| 436 const WebContents::CreateParams& params, | 436 const WebContents::CreateParams& params, |
| 437 WebContentsImpl* opener) { | 437 WebContentsImpl* opener) { |
| 438 TRACE_EVENT0("browser", "WebContentsImpl::CreateWithOpener"); | 438 TRACE_EVENT0("browser", "WebContentsImpl::CreateWithOpener"); |
| 439 WebContentsImpl* new_contents = new WebContentsImpl( | 439 WebContentsImpl* new_contents = new WebContentsImpl( |
| 440 params.browser_context, params.opener_suppressed ? NULL : opener); | 440 params.browser_context, params.opener_suppressed ? NULL : opener); |
| 441 | 441 |
| 442 if (params.guest_instance_id) { | 442 if (params.guest_delegate) { |
| 443 scoped_ptr<base::DictionaryValue> extra_params; | |
| 444 if (params.guest_extra_params) | |
| 445 extra_params.reset(params.guest_extra_params->DeepCopy()); | |
| 446 // This makes |new_contents| act as a guest. | 443 // This makes |new_contents| act as a guest. |
| 447 // For more info, see comment above class BrowserPluginGuest. | 444 // For more info, see comment above class BrowserPluginGuest. |
| 448 BrowserPluginGuest::Create(params.guest_instance_id, | 445 BrowserPluginGuest::Create(params.guest_delegate->GetGuestInstanceID(), |
| 449 params.site_instance, | |
| 450 new_contents, | 446 new_contents, |
| 451 extra_params.Pass(), | 447 params.guest_delegate); |
| 452 opener ? opener->GetBrowserPluginGuest() : NULL); | |
| 453 // We are instantiating a WebContents for browser plugin. Set its subframe | 448 // We are instantiating a WebContents for browser plugin. Set its subframe |
| 454 // bit to true. | 449 // bit to true. |
| 455 new_contents->is_subframe_ = true; | 450 new_contents->is_subframe_ = true; |
| 456 } | 451 } |
| 457 new_contents->Init(params); | 452 new_contents->Init(params); |
| 458 return new_contents; | 453 return new_contents; |
| 459 } | 454 } |
| 460 | 455 |
| 461 RenderFrameHostManager* WebContentsImpl::GetRenderManagerForTesting() { | 456 RenderFrameHostManager* WebContentsImpl::GetRenderManagerForTesting() { |
| 462 return GetRenderManager(); | 457 return GetRenderManager(); |
| (...skipping 956 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1419 // Create the new web contents. This will automatically create the new | 1414 // Create the new web contents. This will automatically create the new |
| 1420 // WebContentsView. In the future, we may want to create the view separately. | 1415 // WebContentsView. In the future, we may want to create the view separately. |
| 1421 CreateParams create_params(GetBrowserContext(), site_instance.get()); | 1416 CreateParams create_params(GetBrowserContext(), site_instance.get()); |
| 1422 create_params.routing_id = route_id; | 1417 create_params.routing_id = route_id; |
| 1423 create_params.main_frame_routing_id = main_frame_route_id; | 1418 create_params.main_frame_routing_id = main_frame_route_id; |
| 1424 create_params.opener = this; | 1419 create_params.opener = this; |
| 1425 create_params.opener_suppressed = params.opener_suppressed; | 1420 create_params.opener_suppressed = params.opener_suppressed; |
| 1426 if (params.disposition == NEW_BACKGROUND_TAB) | 1421 if (params.disposition == NEW_BACKGROUND_TAB) |
| 1427 create_params.initially_hidden = true; | 1422 create_params.initially_hidden = true; |
| 1428 | 1423 |
| 1424 WebContentsImpl* new_contents = NULL; |
| 1429 if (!is_guest) { | 1425 if (!is_guest) { |
| 1430 create_params.context = view_->GetNativeView(); | 1426 create_params.context = view_->GetNativeView(); |
| 1431 create_params.initial_size = GetContainerBounds().size(); | 1427 create_params.initial_size = GetContainerBounds().size(); |
| 1432 } else { | 1428 new_contents = static_cast<WebContentsImpl*>( |
| 1433 create_params.guest_instance_id = | 1429 WebContents::Create(create_params)); |
| 1434 GetBrowserContext()->GetGuestManager()->GetNextInstanceID(); | 1430 } else { |
| 1431 new_contents = GetBrowserPluginGuest()->CreateNewGuestWindow(create_params); |
| 1435 } | 1432 } |
| 1436 WebContentsImpl* new_contents = static_cast<WebContentsImpl*>( | |
| 1437 WebContents::Create(create_params)); | |
| 1438 new_contents->GetController().SetSessionStorageNamespace( | 1433 new_contents->GetController().SetSessionStorageNamespace( |
| 1439 partition_id, | 1434 partition_id, |
| 1440 session_storage_namespace); | 1435 session_storage_namespace); |
| 1441 new_contents->RenderViewCreated(new_contents->GetRenderViewHost()); | 1436 new_contents->RenderViewCreated(new_contents->GetRenderViewHost()); |
| 1442 | 1437 |
| 1443 // Save the window for later if we're not suppressing the opener (since it | 1438 // Save the window for later if we're not suppressing the opener (since it |
| 1444 // will be shown immediately). | 1439 // will be shown immediately). |
| 1445 if (!params.opener_suppressed) { | 1440 if (!params.opener_suppressed) { |
| 1446 if (!is_guest) { | 1441 if (!is_guest) { |
| 1447 WebContentsView* new_view = new_contents->view_.get(); | 1442 WebContentsView* new_view = new_contents->view_.get(); |
| (...skipping 2624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4072 | 4067 |
| 4073 void WebContentsImpl::OnPreferredSizeChanged(const gfx::Size& old_size) { | 4068 void WebContentsImpl::OnPreferredSizeChanged(const gfx::Size& old_size) { |
| 4074 if (!delegate_) | 4069 if (!delegate_) |
| 4075 return; | 4070 return; |
| 4076 const gfx::Size new_size = GetPreferredSize(); | 4071 const gfx::Size new_size = GetPreferredSize(); |
| 4077 if (new_size != old_size) | 4072 if (new_size != old_size) |
| 4078 delegate_->UpdatePreferredSize(this, new_size); | 4073 delegate_->UpdatePreferredSize(this, new_size); |
| 4079 } | 4074 } |
| 4080 | 4075 |
| 4081 } // namespace content | 4076 } // namespace content |
| OLD | NEW |