Index: content/browser/in_process_webkit/dom_storage_message_filter.cc |
diff --git a/content/browser/in_process_webkit/dom_storage_message_filter.cc b/content/browser/in_process_webkit/dom_storage_message_filter.cc |
index 6318c324ede361c47f43473013323f95197c9ede..c8b81a49b1ad87a88ab0a4d41e5b3b0f2e2c54fa 100644 |
--- a/content/browser/in_process_webkit/dom_storage_message_filter.cc |
+++ b/content/browser/in_process_webkit/dom_storage_message_filter.cc |
@@ -10,6 +10,8 @@ |
#include "content/browser/in_process_webkit/dom_storage_context.h" |
#include "content/browser/in_process_webkit/dom_storage_namespace.h" |
#include "content/common/dom_storage_messages.h" |
+#include "content/public/browser/notification_service.h" |
+#include "content/public/browser/notification_types.h" |
#include "content/public/browser/browser_thread.h" |
#include "googleurl/src/gurl.h" |
@@ -60,11 +62,20 @@ void DOMStorageMessageFilter::OnChannelConnected(int32 peer_pid) { |
} |
/* static */ |
+bool DOMStorageMessageFilter::ignore_storage_events_ = false; |
+ |
+/* static */ |
void DOMStorageMessageFilter::DispatchStorageEvent(const NullableString16& key, |
const NullableString16& old_value, const NullableString16& new_value, |
const string16& origin, const GURL& url, bool is_local_storage) { |
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
DCHECK(is_local_storage); // Only LocalStorage is implemented right now. |
+ |
+ // |ignore_storage_events_| is set when copying sessionStorages; don't post |
+ // events. |
+ if (!storage_event_message_filter && ignore_storage_events_) |
+ return; |
+ |
DCHECK(storage_event_message_filter); |
DOMStorageMsg_Event_Params params; |
params.key = key; |
@@ -82,6 +93,12 @@ void DOMStorageMessageFilter::DispatchStorageEvent(const NullableString16& key, |
storage_event_message_filter, params)); |
} |
+/* static */ |
+void DOMStorageMessageFilter::SetIgnoreStorageEvents( |
+ bool ignore_storage_events) { |
+ ignore_storage_events_ = ignore_storage_events; |
+} |
+ |
bool DOMStorageMessageFilter::OnMessageReceived(const IPC::Message& message, |
bool* message_was_ok) { |
bool handled = true; |
@@ -110,16 +127,43 @@ void DOMStorageMessageFilter::OverrideThreadForMessage( |
*thread = BrowserThread::WEBKIT_DEPRECATED; |
} |
+void DOMStorageMessageFilter::NotifyOnUIThread( |
+ int64 namespace_id, |
+ const FilePath& session_storage_directory) { |
+ SessionStorageCreatedDetails details; |
+ details.id = namespace_id; |
+ details.session_storage_directory = session_storage_directory; |
+ content::NotificationService::current()->Notify( |
+ content::NOTIFICATION_SESSION_STORAGE_NAMESPACE_CREATED, |
+ content::Source<DOMStorageMessageFilter>(this), |
+ content::Details<SessionStorageCreatedDetails>(&details)); |
+} |
+ |
void DOMStorageMessageFilter::OnStorageAreaId(int64 namespace_id, |
const string16& origin, |
int64* storage_area_id) { |
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::WEBKIT_DEPRECATED)); |
+ // Don't allow creation of the namespace. |
DOMStorageNamespace* storage_namespace = |
- Context()->GetStorageNamespace(namespace_id, true); |
+ Context()->GetStorageNamespace(namespace_id, false); |
if (!storage_namespace) { |
- *storage_area_id = DOMStorageContext::kInvalidStorageId; |
- return; |
+ // The namespace doesn't exist; create it and send a notification if it was |
+ // a session storage. |
+ storage_namespace = |
+ Context()->GetStorageNamespace(namespace_id, true); |
+ if (!storage_namespace) { |
+ *storage_area_id = DOMStorageContext::kInvalidStorageId; |
+ return; |
+ } |
+ |
+ if (storage_namespace->dom_storage_type() == DOM_STORAGE_SESSION) { |
+ BrowserThread::PostTask( |
+ BrowserThread::UI, FROM_HERE, |
+ base::Bind(&DOMStorageMessageFilter::NotifyOnUIThread, this, |
+ namespace_id, |
+ storage_namespace->session_storage_directory())); |
+ } |
} |
DOMStorageArea* storage_area = storage_namespace->GetStorageArea(origin); |
*storage_area_id = storage_area->id(); |