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 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 destruction_observers_.end()); | 424 destruction_observers_.end()); |
425 } | 425 } |
426 | 426 |
427 WebContentsImpl* WebContentsImpl::CreateWithOpener( | 427 WebContentsImpl* WebContentsImpl::CreateWithOpener( |
428 const WebContents::CreateParams& params, | 428 const WebContents::CreateParams& params, |
429 WebContentsImpl* opener) { | 429 WebContentsImpl* opener) { |
430 TRACE_EVENT0("browser", "WebContentsImpl::CreateWithOpener"); | 430 TRACE_EVENT0("browser", "WebContentsImpl::CreateWithOpener"); |
431 WebContentsImpl* new_contents = new WebContentsImpl( | 431 WebContentsImpl* new_contents = new WebContentsImpl( |
432 params.browser_context, opener); | 432 params.browser_context, opener); |
433 | 433 |
| 434 if (params.guest_instance_id) { |
| 435 scoped_ptr<base::DictionaryValue> extra_params( |
| 436 params.guest_extra_params->DeepCopy()); |
| 437 // This makes |new_contents| act as a guest. |
| 438 // For more info, see comment above class BrowserPluginGuest. |
| 439 BrowserPluginGuest::Create(params.guest_instance_id, |
| 440 params.site_instance, |
| 441 new_contents, |
| 442 extra_params.Pass()); |
| 443 // We are instantiating a WebContents for browser plugin. Set its subframe |
| 444 // bit to true. |
| 445 new_contents->is_subframe_ = true; |
| 446 } |
434 new_contents->Init(params); | 447 new_contents->Init(params); |
435 return new_contents; | 448 return new_contents; |
436 } | 449 } |
437 | 450 |
438 // static | |
439 BrowserPluginGuest* WebContentsImpl::CreateGuest( | |
440 BrowserContext* browser_context, | |
441 SiteInstance* site_instance, | |
442 int guest_instance_id, | |
443 scoped_ptr<base::DictionaryValue> extra_params) { | |
444 WebContentsImpl* new_contents = new WebContentsImpl(browser_context, NULL); | |
445 | |
446 // This makes |new_contents| act as a guest. | |
447 // For more info, see comment above class BrowserPluginGuest. | |
448 BrowserPluginGuest::Create( | |
449 guest_instance_id, site_instance, new_contents, extra_params.Pass()); | |
450 | |
451 WebContents::CreateParams create_params(browser_context, site_instance); | |
452 new_contents->Init(create_params); | |
453 | |
454 // We are instantiating a WebContents for browser plugin. Set its subframe bit | |
455 // to true. | |
456 new_contents->is_subframe_ = true; | |
457 | |
458 return new_contents->browser_plugin_guest_.get(); | |
459 } | |
460 | |
461 RenderFrameHostManager* WebContentsImpl::GetRenderManagerForTesting() { | 451 RenderFrameHostManager* WebContentsImpl::GetRenderManagerForTesting() { |
462 return GetRenderManager(); | 452 return GetRenderManager(); |
463 } | 453 } |
464 | 454 |
465 bool WebContentsImpl::OnMessageReceived(RenderViewHost* render_view_host, | 455 bool WebContentsImpl::OnMessageReceived(RenderViewHost* render_view_host, |
466 const IPC::Message& message) { | 456 const IPC::Message& message) { |
467 return OnMessageReceived(render_view_host, NULL, message); | 457 return OnMessageReceived(render_view_host, NULL, message); |
468 } | 458 } |
469 | 459 |
470 bool WebContentsImpl::OnMessageReceived(RenderViewHost* render_view_host, | 460 bool WebContentsImpl::OnMessageReceived(RenderViewHost* render_view_host, |
(...skipping 3499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3970 | 3960 |
3971 void WebContentsImpl::OnPreferredSizeChanged(const gfx::Size& old_size) { | 3961 void WebContentsImpl::OnPreferredSizeChanged(const gfx::Size& old_size) { |
3972 if (!delegate_) | 3962 if (!delegate_) |
3973 return; | 3963 return; |
3974 const gfx::Size new_size = GetPreferredSize(); | 3964 const gfx::Size new_size = GetPreferredSize(); |
3975 if (new_size != old_size) | 3965 if (new_size != old_size) |
3976 delegate_->UpdatePreferredSize(this, new_size); | 3966 delegate_->UpdatePreferredSize(this, new_size); |
3977 } | 3967 } |
3978 | 3968 |
3979 } // namespace content | 3969 } // namespace content |
OLD | NEW |