| Index: content/browser/web_contents/web_contents_impl.cc
|
| diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
|
| index ecd1f40ce0c36f9d6fc8155f7afeee9f5d4f1988..d5a09dcbb874a55aa40e394cedb5f2975d3edf94 100644
|
| --- a/content/browser/web_contents/web_contents_impl.cc
|
| +++ b/content/browser/web_contents/web_contents_impl.cc
|
| @@ -18,6 +18,7 @@
|
| #include "content/browser/browser_plugin/old/old_browser_plugin_host.h"
|
| #include "content/browser/child_process_security_policy_impl.h"
|
| #include "content/browser/debugger/devtools_manager_impl.h"
|
| +#include "content/browser/dom_storage/dom_storage_context_impl.h"
|
| #include "content/browser/dom_storage/session_storage_namespace_impl.h"
|
| #include "content/browser/download/download_stats.h"
|
| #include "content/browser/download/mhtml_generation_manager.h"
|
| @@ -281,15 +282,31 @@ WebContents* WebContents::Create(
|
| BrowserContext* browser_context,
|
| SiteInstance* site_instance,
|
| int routing_id,
|
| + const WebContents* base_web_contents) {
|
| + return WebContentsImpl::Create(
|
| + browser_context, site_instance, routing_id,
|
| + static_cast<const WebContentsImpl*>(base_web_contents));
|
| +}
|
| +
|
| +WebContents* WebContents::CreateWithSessionStorage(
|
| + BrowserContext* browser_context,
|
| + SiteInstance* site_instance,
|
| + int routing_id,
|
| const WebContents* base_web_contents,
|
| - SessionStorageNamespace* session_storage_namespace) {
|
| - return new WebContentsImpl(
|
| - browser_context,
|
| - site_instance,
|
| - routing_id,
|
| - static_cast<const WebContentsImpl*>(base_web_contents),
|
| - NULL,
|
| - static_cast<SessionStorageNamespaceImpl*>(session_storage_namespace));
|
| + const SessionStorageNamespaceMap& session_storage_namespace_map) {
|
| + WebContentsImpl* new_contents = new WebContentsImpl(browser_context, NULL);
|
| +
|
| + for (SessionStorageNamespaceMap::const_iterator it =
|
| + session_storage_namespace_map.begin();
|
| + it != session_storage_namespace_map.end();
|
| + ++it) {
|
| + new_contents->GetController().SetSessionStorageNamespace(it->first,
|
| + it->second);
|
| + }
|
| +
|
| + new_contents->Init(browser_context, site_instance, routing_id,
|
| + static_cast<const WebContentsImpl*>(base_web_contents));
|
| + return new_contents;
|
| }
|
|
|
| WebContents* WebContents::FromRenderViewHost(const RenderViewHost* rvh) {
|
| @@ -302,14 +319,9 @@ WebContents* WebContents::FromRenderViewHost(const RenderViewHost* rvh) {
|
|
|
| WebContentsImpl::WebContentsImpl(
|
| content::BrowserContext* browser_context,
|
| - SiteInstance* site_instance,
|
| - int routing_id,
|
| - const WebContentsImpl* base_web_contents,
|
| - WebContentsImpl* opener,
|
| - SessionStorageNamespaceImpl* session_storage_namespace)
|
| + WebContentsImpl* opener)
|
| : delegate_(NULL),
|
| - ALLOW_THIS_IN_INITIALIZER_LIST(controller_(
|
| - this, browser_context, session_storage_namespace)),
|
| + ALLOW_THIS_IN_INITIALIZER_LIST(controller_(this, browser_context)),
|
| render_view_host_delegate_view_(NULL),
|
| opener_(opener),
|
| ALLOW_THIS_IN_INITIALIZER_LIST(render_manager_(this, this, this)),
|
| @@ -338,43 +350,6 @@ WebContentsImpl::WebContentsImpl(
|
| temporary_zoom_settings_(false),
|
| content_restrictions_(0),
|
| color_chooser_(NULL) {
|
| - render_manager_.Init(browser_context, site_instance, routing_id);
|
| -
|
| - view_.reset(content::GetContentClient()->browser()->
|
| - OverrideCreateWebContentsView(this, &render_view_host_delegate_view_));
|
| - if (view_.get()) {
|
| - CHECK(render_view_host_delegate_view_);
|
| - } else {
|
| - content::WebContentsViewDelegate* delegate =
|
| - content::GetContentClient()->browser()->GetWebContentsViewDelegate(
|
| - this);
|
| - view_.reset(CreateWebContentsView(
|
| - this, delegate, &render_view_host_delegate_view_));
|
| - CHECK(render_view_host_delegate_view_);
|
| - }
|
| - CHECK(view_.get());
|
| -
|
| - // We have the initial size of the view be based on the size of the view of
|
| - // the passed in WebContents.
|
| - view_->CreateView(base_web_contents ?
|
| - base_web_contents->GetView()->GetContainerSize() : gfx::Size());
|
| -
|
| - // Listen for whether our opener gets destroyed.
|
| - if (opener_) {
|
| - registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED,
|
| - content::Source<WebContents>(opener_));
|
| - }
|
| -
|
| - registrar_.Add(this,
|
| - content::NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED,
|
| - content::NotificationService::AllBrowserContextsAndSources());
|
| -
|
| -#if defined(ENABLE_JAVA_BRIDGE)
|
| - java_bridge_dispatcher_host_manager_.reset(
|
| - new JavaBridgeDispatcherHostManager(this));
|
| -#endif
|
| -
|
| - old_browser_plugin_host_.reset(new content::old::BrowserPluginHost(this));
|
| }
|
|
|
| WebContentsImpl::~WebContentsImpl() {
|
| @@ -419,6 +394,28 @@ WebContentsImpl::~WebContentsImpl() {
|
| SetDelegate(NULL);
|
| }
|
|
|
| +WebContentsImpl* WebContentsImpl::Create(
|
| + BrowserContext* browser_context,
|
| + SiteInstance* site_instance,
|
| + int routing_id,
|
| + const WebContentsImpl* base_web_contents) {
|
| + return CreateWithOpener(browser_context, site_instance, routing_id,
|
| + base_web_contents, NULL);
|
| +}
|
| +
|
| +WebContentsImpl* WebContentsImpl::CreateWithOpener(
|
| + BrowserContext* browser_context,
|
| + SiteInstance* site_instance,
|
| + int routing_id,
|
| + const WebContentsImpl* base_web_contents,
|
| + WebContentsImpl* opener) {
|
| + WebContentsImpl* new_contents = new WebContentsImpl(browser_context, opener);
|
| +
|
| + new_contents->Init(browser_context, site_instance, routing_id,
|
| + static_cast<const WebContentsImpl*>(base_web_contents));
|
| + return new_contents;
|
| +}
|
| +
|
| WebPreferences WebContentsImpl::GetWebkitPrefs(RenderViewHost* rvh,
|
| const GURL& url) {
|
| WebPreferences prefs;
|
| @@ -620,10 +617,6 @@ WebPreferences WebContentsImpl::GetWebkitPrefs(RenderViewHost* rvh,
|
| return prefs;
|
| }
|
|
|
| -NavigationControllerImpl& WebContentsImpl::GetControllerImpl() {
|
| - return controller_;
|
| -}
|
| -
|
| RenderViewHostManager* WebContentsImpl::GetRenderManagerForTesting() {
|
| return &render_manager_;
|
| }
|
| @@ -699,11 +692,11 @@ void WebContentsImpl::RunFileChooser(
|
| delegate_->RunFileChooser(this, params);
|
| }
|
|
|
| -NavigationController& WebContentsImpl::GetController() {
|
| +NavigationControllerImpl& WebContentsImpl::GetController() {
|
| return controller_;
|
| }
|
|
|
| -const NavigationController& WebContentsImpl::GetController() const {
|
| +const NavigationControllerImpl& WebContentsImpl::GetController() const {
|
| return controller_;
|
| }
|
|
|
| @@ -1017,10 +1010,10 @@ WebContents* WebContentsImpl::Clone() {
|
| // We use our current SiteInstance since the cloned entry will use it anyway.
|
| // We pass |this| for the |base_web_contents| to size the view correctly, and
|
| // our own opener so that the cloned page can access it if it was before.
|
| - WebContentsImpl* tc = new WebContentsImpl(
|
| - GetBrowserContext(), GetSiteInstance(),
|
| - MSG_ROUTING_NONE, this, opener_, NULL);
|
| - tc->GetControllerImpl().CopyStateFrom(controller_);
|
| + WebContentsImpl* tc = CreateWithOpener(GetBrowserContext(),
|
| + GetSiteInstance(), MSG_ROUTING_NONE,
|
| + this, opener_);
|
| + tc->GetController().CopyStateFrom(controller_);
|
| return tc;
|
| }
|
|
|
| @@ -1075,6 +1068,48 @@ void WebContentsImpl::Observe(int type,
|
| }
|
| }
|
|
|
| +void WebContentsImpl::Init(BrowserContext* browser_context,
|
| + SiteInstance* site_instance,
|
| + int routing_id,
|
| + const WebContents* base_web_contents) {
|
| + render_manager_.Init(browser_context, site_instance, routing_id);
|
| +
|
| + view_.reset(content::GetContentClient()->browser()->
|
| + OverrideCreateWebContentsView(this, &render_view_host_delegate_view_));
|
| + if (view_.get()) {
|
| + CHECK(render_view_host_delegate_view_);
|
| + } else {
|
| + content::WebContentsViewDelegate* delegate =
|
| + content::GetContentClient()->browser()->GetWebContentsViewDelegate(
|
| + this);
|
| + view_.reset(CreateWebContentsView(
|
| + this, delegate, &render_view_host_delegate_view_));
|
| + CHECK(render_view_host_delegate_view_);
|
| + }
|
| + CHECK(view_.get());
|
| +
|
| + // We have the initial size of the view be based on the size of the view of
|
| + // the passed in WebContents.
|
| + view_->CreateView(base_web_contents ?
|
| + base_web_contents->GetView()->GetContainerSize() : gfx::Size());
|
| +
|
| + // Listen for whether our opener gets destroyed.
|
| + if (opener_) {
|
| + registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED,
|
| + content::Source<WebContents>(opener_));
|
| + }
|
| +
|
| + registrar_.Add(this,
|
| + content::NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED,
|
| + content::NotificationService::AllBrowserContextsAndSources());
|
| +#if defined(ENABLE_JAVA_BRIDGE)
|
| + java_bridge_dispatcher_host_manager_.reset(
|
| + new JavaBridgeDispatcherHostManager(this));
|
| +#endif
|
| +
|
| + old_browser_plugin_host_.reset(new content::old::BrowserPluginHost(this));
|
| +}
|
| +
|
| void WebContentsImpl::OnWebContentsDestroyed(WebContents* web_contents) {
|
| // Clear the opener if it has been closed.
|
| if (web_contents == opener_) {
|
| @@ -1189,13 +1224,27 @@ void WebContentsImpl::CreateNewWindow(
|
|
|
| // Create the new web contents. This will automatically create the new
|
| // WebContentsView. In the future, we may want to create the view separately.
|
| - WebContentsImpl* new_contents = new WebContentsImpl(
|
| - GetBrowserContext(),
|
| - site_instance,
|
| - route_id,
|
| - this,
|
| - params.opener_suppressed ? NULL : this,
|
| - static_cast<SessionStorageNamespaceImpl*>(session_storage_namespace));
|
| + WebContentsImpl* new_contents =
|
| + new WebContentsImpl(GetBrowserContext(),
|
| + params.opener_suppressed ? NULL : this);
|
| +
|
| + // We must assign the SessionStorageNamespace before calling Init().
|
| + const std::string& partition_id =
|
| + content::GetContentClient()->browser()->
|
| + GetStoragePartitionIdForSiteInstance(GetBrowserContext(),
|
| + site_instance);
|
| + DOMStorageContextImpl* dom_storage_context =
|
| + static_cast<DOMStorageContextImpl*>(
|
| + BrowserContext::GetDOMStorageContextByPartitionId(
|
| + GetBrowserContext(), partition_id));
|
| + SessionStorageNamespaceImpl* session_storage_namespace_impl =
|
| + static_cast<SessionStorageNamespaceImpl*>(session_storage_namespace);
|
| + CHECK(session_storage_namespace_impl->IsFromContext(dom_storage_context));
|
| + new_contents->GetController().SetSessionStorageNamespace(
|
| + partition_id,
|
| + session_storage_namespace);
|
| + new_contents->Init(GetBrowserContext(), site_instance, route_id, this);
|
| +
|
| new_contents->set_opener_web_ui_type(GetWebUITypeForCurrentState());
|
|
|
| if (!params.opener_suppressed) {
|
| @@ -1989,7 +2038,7 @@ void WebContentsImpl::OnDidLoadResourceFromMemoryCache(
|
| void WebContentsImpl::OnDidDisplayInsecureContent() {
|
| content::RecordAction(UserMetricsAction("SSL.DisplayedInsecureContent"));
|
| displayed_insecure_content_ = true;
|
| - SSLManager::NotifySSLInternalStateChanged(&GetControllerImpl());
|
| + SSLManager::NotifySSLInternalStateChanged(&GetController());
|
| }
|
|
|
| void WebContentsImpl::OnDidRunInsecureContent(
|
| @@ -2001,7 +2050,7 @@ void WebContentsImpl::OnDidRunInsecureContent(
|
| content::RecordAction(UserMetricsAction("SSL.RanInsecureContentGoogle"));
|
| controller_.ssl_manager()->DidRunInsecureContent(security_origin);
|
| displayed_insecure_content_ = true;
|
| - SSLManager::NotifySSLInternalStateChanged(&GetControllerImpl());
|
| + SSLManager::NotifySSLInternalStateChanged(&GetController());
|
| }
|
|
|
| void WebContentsImpl::OnDocumentLoadedInFrame(int64 frame_id) {
|
| @@ -3017,7 +3066,7 @@ int WebContentsImpl::CreateOpenerRenderViews(SiteInstance* instance) {
|
| }
|
|
|
| NavigationControllerImpl& WebContentsImpl::GetControllerForRenderManager() {
|
| - return GetControllerImpl();
|
| + return GetController();
|
| }
|
|
|
| WebUIImpl* WebContentsImpl::CreateWebUIForRenderManager(const GURL& url) {
|
|
|