Fix SessionStorage confusion between RenderViewHostImpl and NavigationController.

Both RenderViewHostImpl and NavigationController had SessionStorageNamespace*,
and under some circumstances, they pointed to different
SessionStorageNamespaces* which is wrong.

This also cleans up some storage partition code, since we're not going to have
multiple SessionStorageNamespaces.

For more information, see bug.

BUG=138152

Review URL: https://chromiumcodereview.appspot.com/18500005

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@212218 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index 0d943c8..4cd9375d 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -271,18 +271,11 @@
 
 WebContents* WebContents::CreateWithSessionStorage(
     const WebContents::CreateParams& params,
-    const SessionStorageNamespaceMap& session_storage_namespace_map) {
+    SessionStorageNamespace* session_storage_namespace) {
   WebContentsImpl* new_contents = new WebContentsImpl(
       params.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.get());
-  }
-
+  new_contents->GetController()
+      .SetSessionStorageNamespace(session_storage_namespace);
   new_contents->Init(params);
   return new_contents;
 }
@@ -1463,10 +1456,6 @@
   // We must assign the SessionStorageNamespace before calling Init().
   //
   // http://crbug.com/142685
-  const std::string& partition_id =
-      GetContentClient()->browser()->
-          GetStoragePartitionIdForSite(GetBrowserContext(),
-                                       site_instance->GetSiteURL());
   StoragePartition* partition = BrowserContext::GetStoragePartition(
       GetBrowserContext(), site_instance.get());
   DOMStorageContextImpl* dom_storage_context =
@@ -1475,7 +1464,6 @@
       static_cast<SessionStorageNamespaceImpl*>(session_storage_namespace);
   CHECK(session_storage_namespace_impl->IsFromContext(dom_storage_context));
   new_contents->GetController().SetSessionStorageNamespace(
-      partition_id,
       session_storage_namespace);
   CreateParams create_params(GetBrowserContext(), site_instance.get());
   create_params.routing_id = route_id;
@@ -1695,6 +1683,10 @@
     callback.Run(MediaStreamDevices(), scoped_ptr<MediaStreamUI>());
 }
 
+SessionStorageNamespace* WebContentsImpl::GetSessionStorageNamespace() {
+  return controller_.GetSessionStorageNamespace();
+}
+
 void WebContentsImpl::DidSendScreenRects(RenderWidgetHostImpl* rwh) {
   if (browser_plugin_embedder_)
     browser_plugin_embedder_->DidSendScreenRects();