Move SessionStorageNamespace entirely into NavigationController and support StoragePartitions.
Previously, WebContents, NavigationController, and RenderViewHost all exposed
APIs that allowed one to retrieve the SessionStorageNamespace associated with
them. This is confusing because there were too many ways to access the object.
After this change, the SessionStorageNamespace is only exposed by the
NavigationController.
Conceptually a SessionStorageNamespace belongs to a WebContents but we store
it in NavigationController because on tab duplication, the
NavigationController becomes the authoritative state of the tab.
Also, to support StoragePartitions, the NavigationController
now maintains a map of partition_id -> SessionStorageNamespace. Someone
requesting a SessionStorageNamespace must either know which StoragePartition
they are coming from, or which child process they are acting on behalf of.
This change also changes the way TabContents and WebContents are created.
1) We now have explicitly separate creation methods for prepopulating
with SessionStorage and creating with an opener.
2) Some of the WebContentImpl construct has been moved into an Init()
function to avoid accidental calls to virtual functions by subobjects.
TBR-ing all the directories where I just remove a NULL.
TBR=sky,stevenjb,dominich,brettw,satorux,kalman
BUG=85121
Review URL: https://chromiumcodereview.appspot.com/10831116
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@151379 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/content/public/browser/web_contents.h b/content/public/browser/web_contents.h
index 5f65201..c6f55f5 100644
--- a/content/public/browser/web_contents.h
+++ b/content/public/browser/web_contents.h
@@ -10,6 +10,7 @@
#include "base/process_util.h"
#include "base/string16.h"
#include "content/common/content_export.h"
+#include "content/public/browser/navigation_controller.h"
#include "content/public/browser/page_navigator.h"
#include "content/public/browser/save_page_type.h"
#include "content/public/browser/web_ui.h"
@@ -35,11 +36,9 @@
class BrowserContext;
class InterstitialPage;
-class NavigationController;
class RenderProcessHost;
class RenderViewHost;
class RenderWidgetHostView;
-class SessionStorageNamespace;
class SiteInstance;
class WebContentsDelegate;
class WebContentsView;
@@ -51,17 +50,28 @@
// |base_web_contents| is used if we want to size the new WebContents's view
// based on the view of an existing WebContents. This can be NULL if not
// needed.
- //
- // The session storage namespace parameter allows multiple render views and
- // web contentses to share the same session storage (part of the WebStorage
- // spec) space. This is useful when restoring tabs, but most callers should
- // pass in NULL which will cause a new SessionStorageNamespace to be created.
CONTENT_EXPORT static WebContents* Create(
BrowserContext* browser_context,
SiteInstance* site_instance,
int routing_id,
+ const WebContents* base_web_contents);
+
+ // Similar to Create() above but should be used when you need to prepopulate
+ // the SessionStorageNamespaceMap of the WebContents. This can happen if
+ // you duplicate a WebContents, try to reconstitute it from a saved state,
+ // or when you create a new WebContents based on another one (eg., when
+ // servicing a window.open() call).
+ //
+ // You do not want to call this. If you think you do, make sure you completely
+ // understand when SessionStorageNamespace objects should be cloned, why
+ // they should not be shared by multiple WebContents, and what bad things
+ // can happen if you share the object.
+ CONTENT_EXPORT static WebContents* CreateWithSessionStorage(
+ BrowserContext* browser_context,
+ SiteInstance* site_instance,
+ int routing_id,
const WebContents* base_web_contents,
- SessionStorageNamespace* session_storage_namespace);
+ const SessionStorageNamespaceMap& session_storage_namespace_map);
// Returns a WebContents that wraps the RenderViewHost, or NULL if the
// render view host's delegate isn't a WebContents.