summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/chromeos/main_menu.cc7
-rw-r--r--chrome/browser/extensions/extension_host.cc7
-rw-r--r--chrome/browser/in_process_webkit/dom_storage_context.cc37
-rw-r--r--chrome/browser/in_process_webkit/dom_storage_context.h33
-rw-r--r--chrome/browser/in_process_webkit/dom_storage_dispatcher_host.cc4
-rw-r--r--chrome/browser/in_process_webkit/dom_storage_dispatcher_host.h6
-rw-r--r--chrome/browser/in_process_webkit/dom_storage_namespace.cc11
-rw-r--r--chrome/browser/in_process_webkit/dom_storage_namespace.h5
-rw-r--r--chrome/browser/renderer_host/render_view_host.cc18
-rw-r--r--chrome/browser/renderer_host/render_view_host.h6
-rw-r--r--chrome/browser/renderer_host/render_view_host_factory.cc9
-rw-r--r--chrome/browser/renderer_host/render_view_host_factory.h6
-rw-r--r--chrome/browser/renderer_host/resource_message_filter.cc5
-rw-r--r--chrome/browser/renderer_host/resource_message_filter.h4
-rw-r--r--chrome/browser/renderer_host/test/test_render_view_host.cc4
-rw-r--r--chrome/browser/renderer_host/test/test_render_view_host.h3
-rw-r--r--chrome/browser/tab_contents/interstitial_page.cc3
-rw-r--r--chrome/browser/tab_contents/navigation_controller.cc10
-rw-r--r--chrome/browser/tab_contents/navigation_controller.h8
-rw-r--r--chrome/browser/tab_contents/render_view_host_manager.cc6
-rw-r--r--chrome/browser/views/notifications/balloon_view_host.cc7
21 files changed, 158 insertions, 41 deletions
diff --git a/chrome/browser/chromeos/main_menu.cc b/chrome/browser/chromeos/main_menu.cc
index 051e554..eae51c9 100644
--- a/chrome/browser/chromeos/main_menu.cc
+++ b/chrome/browser/chromeos/main_menu.cc
@@ -14,6 +14,8 @@
#include "base/string_util.h"
#include "chrome/browser/browser_list.h"
#include "chrome/browser/browser.h"
+#include "chrome/browser/in_process_webkit/dom_storage_context.h"
+#include "chrome/browser/in_process_webkit/webkit_context.h"
#include "chrome/browser/profile.h"
#include "chrome/browser/renderer_host/render_view_host.h"
#include "chrome/browser/renderer_host/render_view_host_factory.h"
@@ -148,8 +150,11 @@ MainMenu::MainMenu()
DCHECK(BrowserList::begin() != BrowserList::end());
// TODO(sky): this shouldn't pick a random profile to use.
Profile* profile = (*BrowserList::begin())->profile();
+ int64 session_storage_namespace_id = profile->GetWebKitContext()->
+ dom_storage_context()->AllocateSessionStorageNamespaceId();
site_instance_ = SiteInstance::CreateSiteInstanceForURL(profile, menu_url);
- menu_rvh_ = new RenderViewHost(site_instance_, this, MSG_ROUTING_NONE);
+ menu_rvh_ = new RenderViewHost(site_instance_, this, MSG_ROUTING_NONE,
+ session_storage_namespace_id);
rwhv_ = new RenderWidgetHostViewGtk(menu_rvh_);
rwhv_->InitAsChild();
diff --git a/chrome/browser/extensions/extension_host.cc b/chrome/browser/extensions/extension_host.cc
index d7716be..e7ca8f0 100644
--- a/chrome/browser/extensions/extension_host.cc
+++ b/chrome/browser/extensions/extension_host.cc
@@ -21,6 +21,8 @@
#include "chrome/browser/dom_ui/dom_ui_factory.h"
#include "chrome/browser/extensions/extension_message_service.h"
#include "chrome/browser/extensions/extension_tabs_module.h"
+#include "chrome/browser/in_process_webkit/dom_storage_context.h"
+#include "chrome/browser/in_process_webkit/webkit_context.h"
#include "chrome/browser/jsmessage_box_handler.h"
#include "chrome/browser/profile.h"
#include "chrome/browser/renderer_host/render_view_host.h"
@@ -123,7 +125,10 @@ ExtensionHost::ExtensionHost(Extension* extension, SiteInstance* site_instance,
document_element_available_(false),
url_(url),
extension_host_type_(host_type) {
- render_view_host_ = new RenderViewHost(site_instance, this, MSG_ROUTING_NONE);
+ int64 session_storage_namespace_id = profile_->GetWebKitContext()->
+ dom_storage_context()->AllocateSessionStorageNamespaceId();
+ render_view_host_ = new RenderViewHost(site_instance, this, MSG_ROUTING_NONE,
+ session_storage_namespace_id);
render_view_host_->AllowBindings(BindingsPolicy::EXTENSION);
if (enable_dom_automation_)
render_view_host_->AllowBindings(BindingsPolicy::DOM_AUTOMATION);
diff --git a/chrome/browser/in_process_webkit/dom_storage_context.cc b/chrome/browser/in_process_webkit/dom_storage_context.cc
index b695f9f..15099c2 100644
--- a/chrome/browser/in_process_webkit/dom_storage_context.cc
+++ b/chrome/browser/in_process_webkit/dom_storage_context.cc
@@ -10,6 +10,7 @@
#include "chrome/browser/in_process_webkit/dom_storage_area.h"
#include "chrome/browser/in_process_webkit/dom_storage_namespace.h"
#include "chrome/browser/in_process_webkit/webkit_context.h"
+#include "chrome/common/dom_storage_common.h"
static const char* kLocalStorageDirectory = "Local Storage";
@@ -24,8 +25,9 @@ static void MigrateLocalStorageDirectory(const FilePath& data_path) {
}
DOMStorageContext::DOMStorageContext(WebKitContext* webkit_context)
- : last_storage_area_id_(kFirstStorageAreaId),
- last_storage_namespace_id_(kFirstStorageNamespaceId),
+ : last_storage_area_id_(0),
+ last_session_storage_namespace_id_on_ui_thread_(kLocalStorageNamespaceId),
+ last_session_storage_namespace_id_on_io_thread_(kLocalStorageNamespaceId),
webkit_context_(webkit_context) {
}
@@ -67,6 +69,27 @@ DOMStorageNamespace* DOMStorageContext::NewSessionStorage() {
return DOMStorageNamespace::CreateSessionStorageNamespace(this);
}
+int64 DOMStorageContext::AllocateStorageAreaId() {
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT));
+ return ++last_storage_area_id_;
+}
+
+int64 DOMStorageContext::AllocateSessionStorageNamespaceId() {
+ if (ChromeThread::CurrentlyOn(ChromeThread::UI))
+ return ++last_session_storage_namespace_id_on_ui_thread_;
+ return --last_session_storage_namespace_id_on_io_thread_;
+}
+
+int64 DOMStorageContext::CloneSessionStorage(int64 original_id) {
+ DCHECK(!ChromeThread::CurrentlyOn(ChromeThread::WEBKIT));
+ int64 clone_id = AllocateSessionStorageNamespaceId();
+ ChromeThread::PostTask(
+ ChromeThread::WEBKIT, FROM_HERE, NewRunnableFunction(
+ &DOMStorageContext::CompleteCloningSessionStorage,
+ this, original_id, clone_id));
+ return clone_id;
+}
+
void DOMStorageContext::RegisterStorageArea(DOMStorageArea* storage_area) {
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT));
int64 id = storage_area->id();
@@ -162,3 +185,13 @@ void DOMStorageContext::DeleteDataModifiedSince(const base::Time& cutoff) {
file_util::Delete(path, false);
}
}
+
+void DOMStorageContext::CompleteCloningSessionStorage(
+ DOMStorageContext* context, int64 existing_id, int64 clone_id) {
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT));
+ DOMStorageNamespace* existing_namespace =
+ context->GetStorageNamespace(existing_id);
+ // If nothing exists, then there's nothing to clone.
+ if (existing_namespace)
+ existing_namespace->Copy(clone_id);
+}
diff --git a/chrome/browser/in_process_webkit/dom_storage_context.h b/chrome/browser/in_process_webkit/dom_storage_context.h
index 9838930..df472f3 100644
--- a/chrome/browser/in_process_webkit/dom_storage_context.h
+++ b/chrome/browser/in_process_webkit/dom_storage_context.h
@@ -34,9 +34,15 @@ class DOMStorageContext {
// Get a new session storage namespace (but it's still owned by this class).
DOMStorageNamespace* NewSessionStorage();
- // Allocate a new storage ___ id.
- int64 AllocateStorageAreaId() { return ++last_storage_area_id_; }
- int64 AllocateStorageNamespaceId() { return ++last_storage_namespace_id_; }
+ // Allocate a new storage area id. Only call on the WebKit thread.
+ int64 AllocateStorageAreaId();
+
+ // Allocate a new session storage id. Only call on the UI or IO thread.
+ int64 AllocateSessionStorageNamespaceId();
+
+ // Clones a session storage namespace and returns the cloned namespaces' id.
+ // Only call on the IO thread.
+ int64 CloneSessionStorage(int64 original_id);
// Various storage area methods. The storage area is owned by one of the
// namespaces that's owned by this class.
@@ -65,15 +71,22 @@ class DOMStorageContext {
// date that's supplied.
void DeleteDataModifiedSince(const base::Time& cutoff);
- // The special ID used for local storage.
- static const int64 kLocalStorageNamespaceId = 0;
-
private:
- // The last used storage_area_id and storage_namespace_id's.
- static const int64 kFirstStorageAreaId = 1;
+ // The WebKit thread half of CloneSessionStorage above. Static because
+ // DOMStorageContext isn't ref counted thus we can't use a runnable method.
+ // That said, we know this is safe because this class is destroyed on the
+ // WebKit thread, so there's no way it could be destroyed before this is run.
+ static void CompleteCloningSessionStorage(DOMStorageContext* context,
+ int64 existing_id, int64 clone_id);
+
+ // The last used storage_area_id and storage_namespace_id's. For the storage
+ // namespaces, IDs allocated on the UI thread are positive and count up while
+ // IDs allocated on the IO thread are negative and count down. This allows us
+ // to allocate unique IDs on both without any locking. All storage area ids
+ // are allocated on the WebKit thread.
int64 last_storage_area_id_;
- static const int64 kFirstStorageNamespaceId = 1;
- int64 last_storage_namespace_id_;
+ int64 last_session_storage_namespace_id_on_ui_thread_;
+ int64 last_session_storage_namespace_id_on_io_thread_;
// We're owned by this WebKit context. Used while instantiating LocalStorage.
WebKitContext* webkit_context_;
diff --git a/chrome/browser/in_process_webkit/dom_storage_dispatcher_host.cc b/chrome/browser/in_process_webkit/dom_storage_dispatcher_host.cc
index 28005b4..dc8e3f3 100644
--- a/chrome/browser/in_process_webkit/dom_storage_dispatcher_host.cc
+++ b/chrome/browser/in_process_webkit/dom_storage_dispatcher_host.cc
@@ -129,6 +129,10 @@ bool DOMStorageDispatcherHost::OnMessageReceived(const IPC::Message& message,
return handled;
}
+int64 DOMStorageDispatcherHost::CloneSessionStorage(int64 original_id) {
+ return Context()->CloneSessionStorage(original_id);
+}
+
void DOMStorageDispatcherHost::Send(IPC::Message* message) {
if (!message_sender_) {
delete message;
diff --git a/chrome/browser/in_process_webkit/dom_storage_dispatcher_host.h b/chrome/browser/in_process_webkit/dom_storage_dispatcher_host.h
index 029a122..24aa739 100644
--- a/chrome/browser/in_process_webkit/dom_storage_dispatcher_host.h
+++ b/chrome/browser/in_process_webkit/dom_storage_dispatcher_host.h
@@ -10,7 +10,7 @@
#include "base/tracked.h"
#include "chrome/browser/in_process_webkit/dom_storage_area.h"
#include "chrome/browser/in_process_webkit/webkit_context.h"
-#include "chrome/common/dom_storage_type.h"
+#include "chrome/common/dom_storage_common.h"
#include "ipc/ipc_message.h"
class DOMStorageContext;
@@ -39,6 +39,10 @@ class DOMStorageDispatcherHost
// Only call from ResourceMessageFilter on the IO thread.
bool OnMessageReceived(const IPC::Message& message, bool *msg_is_ok);
+ // Clones a session storage namespace and returns the cloned namespaces' id.
+ // Only call on the IO thread.
+ int64 CloneSessionStorage(int64 original_id);
+
// Send a message to the renderer process associated with our
// message_sender_ via the IO thread. May be called from any thread.
void Send(IPC::Message* message);
diff --git a/chrome/browser/in_process_webkit/dom_storage_namespace.cc b/chrome/browser/in_process_webkit/dom_storage_namespace.cc
index f6e9ae5..924d954 100644
--- a/chrome/browser/in_process_webkit/dom_storage_namespace.cc
+++ b/chrome/browser/in_process_webkit/dom_storage_namespace.cc
@@ -19,7 +19,7 @@ using WebKit::WebString;
/* static */
DOMStorageNamespace* DOMStorageNamespace::CreateLocalStorageNamespace(
DOMStorageContext* dom_storage_context, const FilePath& data_dir_path) {
- int64 id = dom_storage_context->kLocalStorageNamespaceId;
+ int64 id = kLocalStorageNamespaceId;
DCHECK(!dom_storage_context->GetStorageNamespace(id));
return new DOMStorageNamespace(dom_storage_context, id,
webkit_glue::FilePathToWebString(data_dir_path), DOM_STORAGE_LOCAL);
@@ -28,7 +28,7 @@ DOMStorageNamespace* DOMStorageNamespace::CreateLocalStorageNamespace(
/* static */
DOMStorageNamespace* DOMStorageNamespace::CreateSessionStorageNamespace(
DOMStorageContext* dom_storage_context) {
- int64 id = dom_storage_context->AllocateStorageNamespaceId();
+ int64 id = dom_storage_context->AllocateSessionStorageNamespaceId();
DCHECK(!dom_storage_context->GetStorageNamespace(id));
return new DOMStorageNamespace(dom_storage_context, id, WebString(),
DOM_STORAGE_SESSION);
@@ -71,9 +71,14 @@ DOMStorageArea* DOMStorageNamespace::GetStorageArea(const string16& origin) {
return storage_area;
}
+// TODO(jorlow): Remove in the next patch.
DOMStorageNamespace* DOMStorageNamespace::Copy() {
+ int64 id = dom_storage_context_->AllocateSessionStorageNamespaceId();
+ return Copy(id);
+}
+
+DOMStorageNamespace* DOMStorageNamespace::Copy(int64 id) {
DCHECK(dom_storage_type_ == DOM_STORAGE_SESSION);
- int64 id = dom_storage_context_->AllocateStorageNamespaceId();
DCHECK(!dom_storage_context_->GetStorageNamespace(id));
DOMStorageNamespace* new_storage_namespace = new DOMStorageNamespace(
dom_storage_context_, id, data_dir_path_, dom_storage_type_);
diff --git a/chrome/browser/in_process_webkit/dom_storage_namespace.h b/chrome/browser/in_process_webkit/dom_storage_namespace.h
index a41dcd7..c317c67 100644
--- a/chrome/browser/in_process_webkit/dom_storage_namespace.h
+++ b/chrome/browser/in_process_webkit/dom_storage_namespace.h
@@ -8,7 +8,7 @@
#include "base/string16.h"
#include "base/hash_tables.h"
#include "base/scoped_ptr.h"
-#include "chrome/common/dom_storage_type.h"
+#include "chrome/common/dom_storage_common.h"
#include "third_party/WebKit/WebKit/chromium/public/WebString.h"
class DOMStorageArea;
@@ -31,7 +31,8 @@ class DOMStorageNamespace {
~DOMStorageNamespace();
DOMStorageArea* GetStorageArea(const string16& origin);
- DOMStorageNamespace* Copy();
+ DOMStorageNamespace* Copy(); // TODO(jorlow): Delete in next patch.
+ DOMStorageNamespace* Copy(int64 id);
void PurgeMemory();
const DOMStorageContext* dom_storage_context() const {
diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc
index 5d46ccc..842e7b4 100644
--- a/chrome/browser/renderer_host/render_view_host.cc
+++ b/chrome/browser/renderer_host/render_view_host.cc
@@ -104,7 +104,8 @@ RenderViewHost* RenderViewHost::FromID(int render_process_id,
RenderViewHost::RenderViewHost(SiteInstance* instance,
RenderViewHostDelegate* delegate,
- int routing_id)
+ int routing_id,
+ int64 session_storage_namespace_id)
: RenderWidgetHost(instance->GetProcess(), routing_id),
instance_(instance),
delegate_(delegate),
@@ -118,7 +119,8 @@ RenderViewHost::RenderViewHost(SiteInstance* instance,
is_waiting_for_unload_ack_(false),
unload_ack_is_for_cross_site_transition_(false),
are_javascript_messages_suppressed_(false),
- sudden_termination_allowed_(false) {
+ sudden_termination_allowed_(false),
+ session_storage_namespace_id_(session_storage_namespace_id) {
DCHECK(instance_);
DCHECK(delegate_);
@@ -205,10 +207,14 @@ bool RenderViewHost::CreateRenderView(
webkit_prefs.databases_enabled = true;
}
- Send(new ViewMsg_New(GetNativeViewId(),
- delegate_->GetRendererPrefs(process()->profile()),
- webkit_prefs,
- routing_id()));
+ ViewMsg_New_Params params;
+ params.parent_window = GetNativeViewId();
+ params.renderer_preferences =
+ delegate_->GetRendererPrefs(process()->profile());
+ params.web_preferences = webkit_prefs;
+ params.view_id = routing_id();
+ params.session_storage_namespace_id = session_storage_namespace_id_;
+ Send(new ViewMsg_New(params));
// Set the alternate error page, which is profile specific, in the renderer.
GURL url = delegate_->GetAlternateErrorPageURL();
diff --git a/chrome/browser/renderer_host/render_view_host.h b/chrome/browser/renderer_host/render_view_host.h
index cfd1a77..831bd80 100644
--- a/chrome/browser/renderer_host/render_view_host.h
+++ b/chrome/browser/renderer_host/render_view_host.h
@@ -92,7 +92,8 @@ class RenderViewHost : public RenderWidgetHost,
// which case RenderWidgetHost will create a new one.
RenderViewHost(SiteInstance* instance,
RenderViewHostDelegate* delegate,
- int routing_id);
+ int routing_id,
+ int64 session_storage_namespace_id);
virtual ~RenderViewHost();
SiteInstance* site_instance() const { return instance_; }
@@ -671,6 +672,9 @@ class RenderViewHost : public RenderWidgetHost,
NotificationRegistrar registrar_;
+ // The session storage namespace id to be used by the associated render view.
+ int64 session_storage_namespace_id_;
+
DISALLOW_COPY_AND_ASSIGN(RenderViewHost);
};
diff --git a/chrome/browser/renderer_host/render_view_host_factory.cc b/chrome/browser/renderer_host/render_view_host_factory.cc
index 01e8a18..4331f2d 100644
--- a/chrome/browser/renderer_host/render_view_host_factory.cc
+++ b/chrome/browser/renderer_host/render_view_host_factory.cc
@@ -14,11 +14,14 @@ RenderViewHostFactory* RenderViewHostFactory::factory_ = NULL;
RenderViewHost* RenderViewHostFactory::Create(
SiteInstance* instance,
RenderViewHostDelegate* delegate,
- int routing_id) {
+ int routing_id,
+ int64 session_storage_namespace_id) {
if (factory_) {
- return factory_->CreateRenderViewHost(instance, delegate, routing_id);
+ return factory_->CreateRenderViewHost(instance, delegate, routing_id,
+ session_storage_namespace_id);
}
- return new RenderViewHost(instance, delegate, routing_id);
+ return new RenderViewHost(instance, delegate, routing_id,
+ session_storage_namespace_id);
}
// static
diff --git a/chrome/browser/renderer_host/render_view_host_factory.h b/chrome/browser/renderer_host/render_view_host_factory.h
index 5e55054..4adf23d 100644
--- a/chrome/browser/renderer_host/render_view_host_factory.h
+++ b/chrome/browser/renderer_host/render_view_host_factory.h
@@ -25,7 +25,8 @@ class RenderViewHostFactory {
// pointer will be passed to the caller.
static RenderViewHost* Create(SiteInstance* instance,
RenderViewHostDelegate* delegate,
- int routing_id);
+ int routing_id,
+ int64 session_storage_namespace_id);
// Returns true if there is currently a globally-registered factory.
static bool has_factory() {
@@ -41,7 +42,8 @@ class RenderViewHostFactory {
virtual RenderViewHost* CreateRenderViewHost(
SiteInstance* instance,
RenderViewHostDelegate* delegate,
- int routing_id) = 0;
+ int routing_id,
+ int64 session_storage_namespace_id) = 0;
// Registers your factory to be called when new RenderViewHosts are created.
// We have only one global factory, so there must be no factory registered
diff --git a/chrome/browser/renderer_host/resource_message_filter.cc b/chrome/browser/renderer_host/resource_message_filter.cc
index 5c46a53..eafa767 100644
--- a/chrome/browser/renderer_host/resource_message_filter.cc
+++ b/chrome/browser/renderer_host/resource_message_filter.cc
@@ -461,7 +461,10 @@ URLRequestContext* ResourceMessageFilter::GetRequestContext(
}
void ResourceMessageFilter::OnMsgCreateWindow(
- int opener_id, bool user_gesture, int* route_id) {
+ int opener_id, bool user_gesture, int64 session_storage_namespace_id,
+ int* route_id, int64* cloned_session_storage_namespace_id) {
+ *cloned_session_storage_namespace_id = dom_storage_dispatcher_host_->
+ CloneSessionStorage(session_storage_namespace_id);
render_widget_helper_->CreateNewWindow(opener_id,
user_gesture,
handle(),
diff --git a/chrome/browser/renderer_host/resource_message_filter.h b/chrome/browser/renderer_host/resource_message_filter.h
index 4a97cb4..b24d095 100644
--- a/chrome/browser/renderer_host/resource_message_filter.h
+++ b/chrome/browser/renderer_host/resource_message_filter.h
@@ -118,7 +118,9 @@ class ResourceMessageFilter : public IPC::ChannelProxy::MessageFilter,
virtual ~ResourceMessageFilter();
- void OnMsgCreateWindow(int opener_id, bool user_gesture, int* route_id);
+ void OnMsgCreateWindow(int opener_id, bool user_gesture,
+ int64 session_storage_namespace_id, int* route_id,
+ int64* cloned_session_storage_namespace_id);
void OnMsgCreateWidget(int opener_id, bool activatable, int* route_id);
void OnSetCookie(const GURL& url,
const GURL& first_party_for_cookies,
diff --git a/chrome/browser/renderer_host/test/test_render_view_host.cc b/chrome/browser/renderer_host/test/test_render_view_host.cc
index 095c2e1..95c5b7b 100644
--- a/chrome/browser/renderer_host/test/test_render_view_host.cc
+++ b/chrome/browser/renderer_host/test/test_render_view_host.cc
@@ -7,6 +7,7 @@
#include "base/gfx/rect.h"
#include "chrome/browser/renderer_host/test/test_backing_store.h"
#include "chrome/browser/tab_contents/test_tab_contents.h"
+#include "chrome/common/dom_storage_common.h"
#include "chrome/common/render_messages.h"
using webkit_glue::PasswordForm;
@@ -14,7 +15,8 @@ using webkit_glue::PasswordForm;
TestRenderViewHost::TestRenderViewHost(SiteInstance* instance,
RenderViewHostDelegate* delegate,
int routing_id)
- : RenderViewHost(instance, delegate, routing_id),
+ : RenderViewHost(instance, delegate, routing_id,
+ kInvalidSessionStorageNamespaceId),
render_view_created_(false),
delete_counter_(NULL) {
set_view(new TestRenderWidgetHostView(this));
diff --git a/chrome/browser/renderer_host/test/test_render_view_host.h b/chrome/browser/renderer_host/test/test_render_view_host.h
index 9990fab..ca63c53 100644
--- a/chrome/browser/renderer_host/test/test_render_view_host.h
+++ b/chrome/browser/renderer_host/test/test_render_view_host.h
@@ -173,7 +173,8 @@ class TestRenderViewHostFactory : public RenderViewHostFactory {
virtual RenderViewHost* CreateRenderViewHost(
SiteInstance* instance,
RenderViewHostDelegate* delegate,
- int routing_id) {
+ int routing_id,
+ int64 session_storage_namespace_id) {
// See declaration of render_process_host_factory_ below.
instance->set_render_process_host_factory(render_process_host_factory_);
return new TestRenderViewHost(instance, delegate, routing_id);
diff --git a/chrome/browser/tab_contents/interstitial_page.cc b/chrome/browser/tab_contents/interstitial_page.cc
index 55972f3..f6db824 100644
--- a/chrome/browser/tab_contents/interstitial_page.cc
+++ b/chrome/browser/tab_contents/interstitial_page.cc
@@ -23,6 +23,7 @@
#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/browser/tab_contents/tab_contents_view.h"
#include "chrome/common/bindings_policy.h"
+#include "chrome/common/dom_storage_common.h"
#if defined(TOOLKIT_GTK)
#include "chrome/browser/gtk/gtk_theme_provider.h"
#endif
@@ -383,7 +384,7 @@ void InterstitialPage::DomOperationResponse(const std::string& json_string,
RenderViewHost* InterstitialPage::CreateRenderViewHost() {
RenderViewHost* render_view_host = new RenderViewHost(
SiteInstance::CreateSiteInstance(tab()->profile()),
- this, MSG_ROUTING_NONE);
+ this, MSG_ROUTING_NONE, kInvalidSessionStorageNamespaceId);
return render_view_host;
}
diff --git a/chrome/browser/tab_contents/navigation_controller.cc b/chrome/browser/tab_contents/navigation_controller.cc
index fa4c783..3cbe29c 100644
--- a/chrome/browser/tab_contents/navigation_controller.cc
+++ b/chrome/browser/tab_contents/navigation_controller.cc
@@ -12,6 +12,8 @@
#include "chrome/browser/browser_about_handler.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/browser_url_handler.h"
+#include "chrome/browser/in_process_webkit/dom_storage_context.h"
+#include "chrome/browser/in_process_webkit/webkit_context.h"
#include "chrome/browser/profile.h"
#include "chrome/browser/renderer_host/site_instance.h"
#include "chrome/browser/sessions/session_types.h"
@@ -133,7 +135,9 @@ NavigationController::NavigationController(TabContents* contents,
max_restored_page_id_(-1),
ALLOW_THIS_IN_INITIALIZER_LIST(ssl_manager_(this)),
needs_reload_(false),
- user_gesture_observed_(false) {
+ user_gesture_observed_(false),
+ session_storage_namespace_id_(profile->GetWebKitContext()->
+ dom_storage_context()->AllocateSessionStorageNamespaceId()) {
DCHECK(profile_);
}
@@ -856,6 +860,10 @@ void NavigationController::CopyStateFrom(const NavigationController& source) {
new NavigationEntry(*source.entries_[i])));
}
+ session_storage_namespace_id_ =
+ profile_->GetWebKitContext()->dom_storage_context()->CloneSessionStorage(
+ source.session_storage_namespace_id_);
+
FinishRestore(source.last_committed_entry_index_, false);
}
diff --git a/chrome/browser/tab_contents/navigation_controller.h b/chrome/browser/tab_contents/navigation_controller.h
index 59af542..5378546 100644
--- a/chrome/browser/tab_contents/navigation_controller.h
+++ b/chrome/browser/tab_contents/navigation_controller.h
@@ -374,6 +374,11 @@ class NavigationController {
// if it was restored from a previous session. (-1 otherwise)
int max_restored_page_id() const { return max_restored_page_id_; }
+ // The session storage namespace id that all child render views should use.
+ int64 session_storage_namespace_id() const {
+ return session_storage_namespace_id_;
+ }
+
// Disables checking for a repost and prompting the user. This is used during
// testing.
static void DisablePromptOnRepost();
@@ -528,6 +533,9 @@ class NavigationController {
// Whether a user gesture has been observed since the last navigation.
bool user_gesture_observed_;
+ // The session storage id that any (indirectly) owned RenderView should use.
+ int64 session_storage_namespace_id_;
+
// Should Reload check for post data? The default is true, but is set to false
// when testing.
static bool check_for_repost_;
diff --git a/chrome/browser/tab_contents/render_view_host_manager.cc b/chrome/browser/tab_contents/render_view_host_manager.cc
index 8622f39..6fec169 100644
--- a/chrome/browser/tab_contents/render_view_host_manager.cc
+++ b/chrome/browser/tab_contents/render_view_host_manager.cc
@@ -55,7 +55,8 @@ void RenderViewHostManager::Init(Profile* profile,
if (!site_instance)
site_instance = SiteInstance::CreateSiteInstance(profile);
render_view_host_ = RenderViewHostFactory::Create(
- site_instance, render_view_delegate_, routing_id);
+ site_instance, render_view_delegate_, routing_id, delegate_->
+ GetControllerForRenderManager().session_storage_namespace_id());
NotificationService::current()->Notify(
NotificationType::RENDER_VIEW_HOST_CREATED_FOR_TAB,
Source<RenderViewHostManager>(this),
@@ -412,7 +413,8 @@ bool RenderViewHostManager::CreatePendingRenderView(SiteInstance* instance) {
}
pending_render_view_host_ = RenderViewHostFactory::Create(
- instance, render_view_delegate_, MSG_ROUTING_NONE);
+ instance, render_view_delegate_, MSG_ROUTING_NONE, delegate_->
+ GetControllerForRenderManager().session_storage_namespace_id());
NotificationService::current()->Notify(
NotificationType::RENDER_VIEW_HOST_CREATED_FOR_TAB,
Source<RenderViewHostManager>(this),
diff --git a/chrome/browser/views/notifications/balloon_view_host.cc b/chrome/browser/views/notifications/balloon_view_host.cc
index e825399..0a02d63 100644
--- a/chrome/browser/views/notifications/balloon_view_host.cc
+++ b/chrome/browser/views/notifications/balloon_view_host.cc
@@ -6,6 +6,8 @@
#include "base/string_util.h"
#include "chrome/browser/browser_list.h"
+#include "chrome/browser/in_process_webkit/dom_storage_context.h"
+#include "chrome/browser/in_process_webkit/webkit_context.h"
#include "chrome/browser/notifications/balloon.h"
#include "chrome/browser/notifications/notification.h"
#include "chrome/browser/profile.h"
@@ -100,8 +102,11 @@ void BalloonViewHost::UpdatePreferredSize(const gfx::Size& new_size) {
void BalloonViewHost::Init(gfx::NativeView parent_hwnd) {
DCHECK(!render_view_host_) << "BalloonViewHost already initialized.";
+ int64 session_storage_namespace_id = balloon_->profile()->GetWebKitContext()->
+ dom_storage_context()->AllocateSessionStorageNamespaceId();
RenderViewHost* rvh = new RenderViewHost(site_instance_.get(),
- this, MSG_ROUTING_NONE);
+ this, MSG_ROUTING_NONE,
+ session_storage_namespace_id);
render_view_host_ = rvh;
// Pointer is owned by the RVH.