summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjorlow@chromium.org <jorlow@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-05 09:13:12 +0000
committerjorlow@chromium.org <jorlow@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-05 09:13:12 +0000
commitee2be5b38100f85155ab667d9979350f3a51e3fc (patch)
treee08834c987b20922238d1177f50fa28a6cc9d7fb
parentf94ead7d53296e14f1254ad1cdd4b73f3d6b9130 (diff)
downloadchromium_src-ee2be5b38100f85155ab667d9979350f3a51e3fc.zip
chromium_src-ee2be5b38100f85155ab667d9979350f3a51e3fc.tar.gz
chromium_src-ee2be5b38100f85155ab667d9979350f3a51e3fc.tar.bz2
Enable the URL portion of storage events. This is mostly just plumbing + a hack for making them work in test shell and single process mode.
This replaces http://codereview.chromium.org/335034/show TEST=none BUG=24581 Review URL: http://codereview.chromium.org/363014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31081 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/in_process_webkit/browser_webkitclient_impl.cc4
-rw-r--r--chrome/browser/in_process_webkit/browser_webkitclient_impl.h3
-rw-r--r--chrome/browser/in_process_webkit/dom_storage_dispatcher_host.cc33
-rw-r--r--chrome/browser/in_process_webkit/dom_storage_dispatcher_host.h15
-rw-r--r--chrome/browser/in_process_webkit/storage_area.cc8
-rw-r--r--chrome/common/render_messages.h7
-rw-r--r--chrome/common/render_messages_internal.h13
-rw-r--r--chrome/renderer/render_thread.cc2
-rw-r--r--chrome/renderer/renderer_webkitclient_impl.cc4
-rw-r--r--chrome/renderer/renderer_webkitclient_impl.h2
-rw-r--r--chrome/renderer/renderer_webstoragearea_impl.cc19
-rw-r--r--chrome/renderer/renderer_webstoragearea_impl.h11
-rw-r--r--chrome/worker/worker_webkitclient_impl.cc2
-rw-r--r--chrome/worker/worker_webkitclient_impl.h2
-rw-r--r--webkit/api/public/WebKitClient.h2
-rw-r--r--webkit/api/public/WebStorageArea.h15
-rw-r--r--webkit/api/public/WebStorageEventDispatcher.h4
-rw-r--r--webkit/api/src/StorageAreaProxy.cpp16
-rw-r--r--webkit/api/src/StorageEventDispatcherChromium.cpp3
-rw-r--r--webkit/api/src/StorageEventDispatcherImpl.cpp7
-rw-r--r--webkit/api/src/StorageEventDispatcherImpl.h5
-rw-r--r--webkit/api/src/WebStorageAreaImpl.cpp18
-rw-r--r--webkit/api/src/WebStorageAreaImpl.h27
-rw-r--r--webkit/api/src/WebStorageEventDispatcherImpl.cpp12
-rw-r--r--webkit/api/src/WebStorageEventDispatcherImpl.h2
-rw-r--r--webkit/data/layout_tests/platform/chromium-mac/LayoutTests/storage/domstorage/localstorage/iframe-events-expected.txt77
-rw-r--r--webkit/data/layout_tests/platform/chromium-mac/LayoutTests/storage/domstorage/localstorage/simple-events-expected.txt22
-rw-r--r--webkit/data/layout_tests/platform/chromium-win/LayoutTests/storage/domstorage/localstorage/iframe-events-expected.txt77
-rw-r--r--webkit/data/layout_tests/platform/chromium-win/LayoutTests/storage/domstorage/localstorage/simple-events-expected.txt22
-rw-r--r--webkit/tools/test_shell/test_shell_webkit_init.h7
30 files changed, 159 insertions, 282 deletions
diff --git a/chrome/browser/in_process_webkit/browser_webkitclient_impl.cc b/chrome/browser/in_process_webkit/browser_webkitclient_impl.cc
index e4105f6..6469cea 100644
--- a/chrome/browser/in_process_webkit/browser_webkitclient_impl.cc
+++ b/chrome/browser/in_process_webkit/browser_webkitclient_impl.cc
@@ -115,13 +115,13 @@ BrowserWebKitClientImpl::createSessionStorageNamespace() {
void BrowserWebKitClientImpl::dispatchStorageEvent(
const WebKit::WebString& key, const WebKit::WebString& old_value,
const WebKit::WebString& new_value, const WebKit::WebString& origin,
- bool is_local_storage) {
+ const WebKit::WebURL& url, bool is_local_storage) {
// TODO(jorlow): Implement
if (!is_local_storage)
return;
DOMStorageDispatcherHost::DispatchStorageEvent(key, old_value, new_value,
- origin, is_local_storage);
+ origin, url, is_local_storage);
}
WebKit::WebSharedWorkerRepository*
diff --git a/chrome/browser/in_process_webkit/browser_webkitclient_impl.h b/chrome/browser/in_process_webkit/browser_webkitclient_impl.h
index b562fd8..1065269 100644
--- a/chrome/browser/in_process_webkit/browser_webkitclient_impl.h
+++ b/chrome/browser/in_process_webkit/browser_webkitclient_impl.h
@@ -35,7 +35,8 @@ class BrowserWebKitClientImpl : public webkit_glue::WebKitClientImpl {
virtual WebKit::WebStorageNamespace* createSessionStorageNamespace();
virtual void dispatchStorageEvent(const WebKit::WebString& key,
const WebKit::WebString& oldValue, const WebKit::WebString& newValue,
- const WebKit::WebString& origin, bool isLocalStorage);
+ const WebKit::WebString& origin, const WebKit::WebURL& url,
+ bool isLocalStorage);
virtual WebKit::WebSharedWorkerRepository* sharedWorkerRepository();
};
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 63ff96e..75b9bfc 100644
--- a/chrome/browser/in_process_webkit/dom_storage_dispatcher_host.cc
+++ b/chrome/browser/in_process_webkit/dom_storage_dispatcher_host.cc
@@ -12,23 +12,30 @@
#include "chrome/browser/in_process_webkit/webkit_thread.h"
#include "chrome/browser/renderer_host/browser_render_process_host.h"
#include "chrome/common/render_messages.h"
+#include "googleurl/src/gurl.h"
DOMStorageDispatcherHost* DOMStorageDispatcherHost::storage_event_host_ = NULL;
+const GURL* DOMStorageDispatcherHost::storage_event_url_ = NULL;
DOMStorageDispatcherHost::
ScopedStorageEventContext::ScopedStorageEventContext(
- DOMStorageDispatcherHost* dispatcher_host) {
+ DOMStorageDispatcherHost* dispatcher_host, const GURL* url) {
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT));
DCHECK(!storage_event_host_);
+ DCHECK(!storage_event_url_);
storage_event_host_ = dispatcher_host;
+ storage_event_url_ = url;
DCHECK(storage_event_host_);
+ DCHECK(storage_event_url_);
}
DOMStorageDispatcherHost::
ScopedStorageEventContext::~ScopedStorageEventContext() {
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT));
DCHECK(storage_event_host_);
+ DCHECK(storage_event_url_);
storage_event_host_ = NULL;
+ storage_event_url_ = NULL;
}
DOMStorageDispatcherHost::DOMStorageDispatcherHost(
@@ -79,7 +86,7 @@ void DOMStorageDispatcherHost::Shutdown() {
/* static */
void DOMStorageDispatcherHost::DispatchStorageEvent(const NullableString16& key,
const NullableString16& old_value, const NullableString16& new_value,
- const string16& origin, bool is_local_storage) {
+ const string16& origin, const GURL& url, bool is_local_storage) {
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::WEBKIT));
DCHECK(is_local_storage); // Only LocalStorage is implemented right now.
DCHECK(storage_event_host_);
@@ -88,6 +95,7 @@ void DOMStorageDispatcherHost::DispatchStorageEvent(const NullableString16& key,
params.old_value_ = old_value;
params.new_value_ = new_value;
params.origin_ = origin;
+ params.url_ = *storage_event_url_; // The url passed in is junk.
params.storage_type_ = is_local_storage ? DOM_STORAGE_LOCAL
: DOM_STORAGE_SESSION;
// The storage_event_host_ is the DOMStorageDispatcherHost that is up in the
@@ -273,12 +281,13 @@ void DOMStorageDispatcherHost::OnGetItem(int64 storage_area_id,
Send(reply_msg);
}
-void DOMStorageDispatcherHost::OnSetItem(int64 storage_area_id,
- const string16& key, const string16& value, IPC::Message* reply_msg) {
+void DOMStorageDispatcherHost::OnSetItem(
+ int64 storage_area_id, const string16& key, const string16& value,
+ const GURL& url, IPC::Message* reply_msg) {
if (ChromeThread::CurrentlyOn(ChromeThread::IO)) {
PostTaskToWebKitThread(FROM_HERE, NewRunnableMethod(this,
&DOMStorageDispatcherHost::OnSetItem, storage_area_id, key, value,
- reply_msg));
+ url, reply_msg));
return;
}
@@ -291,17 +300,17 @@ void DOMStorageDispatcherHost::OnSetItem(int64 storage_area_id,
return;
}
- ScopedStorageEventContext scope(this);
+ ScopedStorageEventContext scope(this, &url);
storage_area->SetItem(key, value, &quota_exception);
ViewHostMsg_DOMStorageSetItem::WriteReplyParams(reply_msg, quota_exception);
Send(reply_msg);
}
void DOMStorageDispatcherHost::OnRemoveItem(
- int64 storage_area_id, const string16& key) {
+ int64 storage_area_id, const string16& key, const GURL& url) {
if (ChromeThread::CurrentlyOn(ChromeThread::IO)) {
PostTaskToWebKitThread(FROM_HERE, NewRunnableMethod(this,
- &DOMStorageDispatcherHost::OnRemoveItem, storage_area_id, key));
+ &DOMStorageDispatcherHost::OnRemoveItem, storage_area_id, key, url));
return;
}
@@ -313,14 +322,14 @@ void DOMStorageDispatcherHost::OnRemoveItem(
return;
}
- ScopedStorageEventContext scope(this);
+ ScopedStorageEventContext scope(this, &url);
storage_area->RemoveItem(key);
}
-void DOMStorageDispatcherHost::OnClear(int64 storage_area_id) {
+void DOMStorageDispatcherHost::OnClear(int64 storage_area_id, const GURL& url) {
if (ChromeThread::CurrentlyOn(ChromeThread::IO)) {
PostTaskToWebKitThread(FROM_HERE, NewRunnableMethod(this,
- &DOMStorageDispatcherHost::OnClear, storage_area_id));
+ &DOMStorageDispatcherHost::OnClear, storage_area_id, url));
return;
}
@@ -332,7 +341,7 @@ void DOMStorageDispatcherHost::OnClear(int64 storage_area_id) {
return;
}
- ScopedStorageEventContext scope(this);
+ ScopedStorageEventContext scope(this, &url);
storage_area->Clear();
}
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 28e3fc8..45b0eba 100644
--- a/chrome/browser/in_process_webkit/dom_storage_dispatcher_host.h
+++ b/chrome/browser/in_process_webkit/dom_storage_dispatcher_host.h
@@ -14,6 +14,7 @@
#include "ipc/ipc_message.h"
class DOMStorageContext;
+class GURL;
class Task;
class WebKitThread;
struct ViewMsg_DOMStorageEvent_Params;
@@ -45,7 +46,7 @@ class DOMStorageDispatcherHost :
// Only call on the WebKit thread.
static void DispatchStorageEvent(const NullableString16& key,
const NullableString16& old_value, const NullableString16& new_value,
- const string16& origin, bool is_local_storage);
+ const string16& origin, const GURL& url, bool is_local_storage);
private:
friend class base::RefCountedThreadSafe<DOMStorageDispatcherHost>;
@@ -61,9 +62,11 @@ class DOMStorageDispatcherHost :
void OnGetItem(int64 storage_area_id, const string16& key,
IPC::Message* reply_msg);
void OnSetItem(int64 storage_area_id, const string16& key,
- const string16& value, IPC::Message* reply_msg);
- void OnRemoveItem(int64 storage_area_id, const string16& key);
- void OnClear(int64 storage_area_id);
+ const string16& value, const GURL& url,
+ IPC::Message* reply_msg);
+ void OnRemoveItem(int64 storage_area_id, const string16& key,
+ const GURL& url);
+ void OnClear(int64 storage_area_id, const GURL& url);
// Only call on the IO thread.
void OnStorageEvent(const ViewMsg_DOMStorageEvent_Params& params);
@@ -80,12 +83,14 @@ class DOMStorageDispatcherHost :
// Use whenever there's a chance OnStorageEvent will be called.
class ScopedStorageEventContext {
public:
- ScopedStorageEventContext(DOMStorageDispatcherHost* dispatcher_host);
+ ScopedStorageEventContext(DOMStorageDispatcherHost* dispatcher_host,
+ const GURL* url);
~ScopedStorageEventContext();
};
// Only access on the WebKit thread! Used for storage events.
static DOMStorageDispatcherHost* storage_event_host_;
+ static const GURL* storage_event_url_;
// Data shared between renderer processes with the same profile.
scoped_refptr<WebKitContext> webkit_context_;
diff --git a/chrome/browser/in_process_webkit/storage_area.cc b/chrome/browser/in_process_webkit/storage_area.cc
index 603ead3..61b9f26 100644
--- a/chrome/browser/in_process_webkit/storage_area.cc
+++ b/chrome/browser/in_process_webkit/storage_area.cc
@@ -8,8 +8,10 @@
#include "chrome/browser/in_process_webkit/storage_namespace.h"
#include "webkit/api/public/WebStorageArea.h"
#include "webkit/api/public/WebString.h"
+#include "webkit/api/public/WebURL.h"
using WebKit::WebStorageArea;
+using WebKit::WebURL;
StorageArea::StorageArea(const string16& origin,
int64 id,
@@ -41,17 +43,17 @@ NullableString16 StorageArea::GetItem(const string16& key) {
void StorageArea::SetItem(const string16& key, const string16& value,
bool* quota_exception) {
CreateWebStorageAreaIfNecessary();
- storage_area_->setItem(key, value, *quota_exception);
+ storage_area_->setItem(key, value, WebURL(), *quota_exception);
}
void StorageArea::RemoveItem(const string16& key) {
CreateWebStorageAreaIfNecessary();
- storage_area_->removeItem(key);
+ storage_area_->removeItem(key, WebURL());
}
void StorageArea::Clear() {
CreateWebStorageAreaIfNecessary();
- storage_area_->clear();
+ storage_area_->clear(WebURL());
}
void StorageArea::PurgeMemory() {
diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h
index 37f7e23..e226cb3 100644
--- a/chrome/common/render_messages.h
+++ b/chrome/common/render_messages.h
@@ -509,6 +509,9 @@ struct ViewMsg_DOMStorageEvent_Params {
// The origin this is associated with.
string16 origin_;
+ // The URL of the page that caused the storage event.
+ GURL url_;
+
// The storage type of this event.
DOMStorageType storage_type_;
};
@@ -2235,6 +2238,7 @@ struct ParamTraits<ViewMsg_DOMStorageEvent_Params> {
WriteParam(m, p.old_value_);
WriteParam(m, p.new_value_);
WriteParam(m, p.origin_);
+ WriteParam(m, p.url_);
WriteParam(m, p.storage_type_);
}
static bool Read(const Message* m, void** iter, param_type* p) {
@@ -2243,6 +2247,7 @@ struct ParamTraits<ViewMsg_DOMStorageEvent_Params> {
ReadParam(m, iter, &p->old_value_) &&
ReadParam(m, iter, &p->new_value_) &&
ReadParam(m, iter, &p->origin_) &&
+ ReadParam(m, iter, &p->url_) &&
ReadParam(m, iter, &p->storage_type_);
}
static void Log(const param_type& p, std::wstring* l) {
@@ -2255,6 +2260,8 @@ struct ParamTraits<ViewMsg_DOMStorageEvent_Params> {
l->append(L", ");
LogParam(p.origin_, l);
l->append(L", ");
+ LogParam(p.url_, l);
+ l->append(L", ");
LogParam(p.storage_type_, l);
l->append(L")");
}
diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h
index 38694f3..fa8a9a6 100644
--- a/chrome/common/render_messages_internal.h
+++ b/chrome/common/render_messages_internal.h
@@ -1842,20 +1842,23 @@ IPC_BEGIN_MESSAGES(ViewHost)
NullableString16 /* value */)
// Set a value that's associated with a key in a storage area.
- IPC_SYNC_MESSAGE_CONTROL3_1(ViewHostMsg_DOMStorageSetItem,
+ IPC_SYNC_MESSAGE_CONTROL4_1(ViewHostMsg_DOMStorageSetItem,
int64 /* storage_area_id */,
string16 /* key */,
string16 /* value */,
+ GURL /* url */,
bool /* quota_exception */)
// Remove the value associated with a key in a storage area.
- IPC_MESSAGE_CONTROL2(ViewHostMsg_DOMStorageRemoveItem,
+ IPC_MESSAGE_CONTROL3(ViewHostMsg_DOMStorageRemoveItem,
int64 /* storage_area_id */,
- string16 /* key */)
+ string16 /* key */,
+ GURL /* url */)
// Clear the storage area.
- IPC_MESSAGE_CONTROL1(ViewHostMsg_DOMStorageClear,
- int64 /* storage_area_id */)
+ IPC_MESSAGE_CONTROL2(ViewHostMsg_DOMStorageClear,
+ int64 /* storage_area_id */,
+ GURL /* url */)
// Get file size in bytes. Set result to -1 if failed to get the file size.
IPC_SYNC_MESSAGE_CONTROL1_1(ViewHostMsg_GetFileSize,
diff --git a/chrome/renderer/render_thread.cc b/chrome/renderer/render_thread.cc
index 9e033e6..0805000 100644
--- a/chrome/renderer/render_thread.cc
+++ b/chrome/renderer/render_thread.cc
@@ -271,7 +271,7 @@ void RenderThread::OnDOMStorageEvent(
if (!dom_storage_event_dispatcher_.get())
dom_storage_event_dispatcher_.reset(WebStorageEventDispatcher::create());
dom_storage_event_dispatcher_->dispatchStorageEvent(params.key_,
- params.old_value_, params.new_value_, params.origin_,
+ params.old_value_, params.new_value_, params.origin_, params.url_,
params.storage_type_ == DOM_STORAGE_LOCAL);
}
diff --git a/chrome/renderer/renderer_webkitclient_impl.cc b/chrome/renderer/renderer_webkitclient_impl.cc
index cffa805..612277b 100644
--- a/chrome/renderer/renderer_webkitclient_impl.cc
+++ b/chrome/renderer/renderer_webkitclient_impl.cc
@@ -206,13 +206,13 @@ WebStorageNamespace* RendererWebKitClientImpl::createSessionStorageNamespace() {
void RendererWebKitClientImpl::dispatchStorageEvent(
const WebString& key, const WebString& old_value,
const WebString& new_value, const WebString& origin,
- bool is_local_storage) {
+ const WebKit::WebURL& url, bool is_local_storage) {
DCHECK(CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess));
// Inefficient, but only used in single process mode.
scoped_ptr<WebStorageEventDispatcher> event_dispatcher(
WebStorageEventDispatcher::create());
event_dispatcher->dispatchStorageEvent(key, old_value, new_value, origin,
- is_local_storage);
+ url, is_local_storage);
}
WebApplicationCacheHost* RendererWebKitClientImpl::createApplicationCacheHost(
diff --git a/chrome/renderer/renderer_webkitclient_impl.h b/chrome/renderer/renderer_webkitclient_impl.h
index 4a3852b..326d3a6 100644
--- a/chrome/renderer/renderer_webkitclient_impl.h
+++ b/chrome/renderer/renderer_webkitclient_impl.h
@@ -53,7 +53,7 @@ class RendererWebKitClientImpl : public webkit_glue::WebKitClientImpl {
virtual void dispatchStorageEvent(
const WebKit::WebString& key, const WebKit::WebString& old_value,
const WebKit::WebString& new_value, const WebKit::WebString& origin,
- bool is_local_storage);
+ const WebKit::WebURL& url, bool is_local_storage);
virtual WebKit::WebKitClient::FileHandle databaseOpenFile(
const WebKit::WebString& file_name, int desired_flags,
diff --git a/chrome/renderer/renderer_webstoragearea_impl.cc b/chrome/renderer/renderer_webstoragearea_impl.cc
index 417e949..3ddc29c 100644
--- a/chrome/renderer/renderer_webstoragearea_impl.cc
+++ b/chrome/renderer/renderer_webstoragearea_impl.cc
@@ -6,8 +6,10 @@
#include "chrome/common/render_messages.h"
#include "chrome/renderer/render_thread.h"
+#include "webkit/api/public/WebURL.h"
using WebKit::WebString;
+using WebKit::WebURL;
RendererWebStorageAreaImpl::RendererWebStorageAreaImpl(
int64 namespace_id, const WebString& origin) {
@@ -40,20 +42,21 @@ WebString RendererWebStorageAreaImpl::getItem(const WebString& key) {
return value;
}
-void RendererWebStorageAreaImpl::setItem(const WebString& key,
- const WebString& value,
- bool& quota_exception) {
+void RendererWebStorageAreaImpl::setItem(
+ const WebString& key, const WebString& value, const WebURL& url,
+ bool& quota_exception) {
RenderThread::current()->Send(
- new ViewHostMsg_DOMStorageSetItem(storage_area_id_, key, value,
+ new ViewHostMsg_DOMStorageSetItem(storage_area_id_, key, value, url,
&quota_exception));
}
-void RendererWebStorageAreaImpl::removeItem(const WebString& key) {
+void RendererWebStorageAreaImpl::removeItem(const WebString& key,
+ const WebURL& url) {
RenderThread::current()->Send(
- new ViewHostMsg_DOMStorageRemoveItem(storage_area_id_, key));
+ new ViewHostMsg_DOMStorageRemoveItem(storage_area_id_, key, url));
}
-void RendererWebStorageAreaImpl::clear() {
+void RendererWebStorageAreaImpl::clear(const WebURL& url) {
RenderThread::current()->Send(
- new ViewHostMsg_DOMStorageClear(storage_area_id_));
+ new ViewHostMsg_DOMStorageClear(storage_area_id_, url));
}
diff --git a/chrome/renderer/renderer_webstoragearea_impl.h b/chrome/renderer/renderer_webstoragearea_impl.h
index 57e13fc..c61a0f1 100644
--- a/chrome/renderer/renderer_webstoragearea_impl.h
+++ b/chrome/renderer/renderer_webstoragearea_impl.h
@@ -20,11 +20,12 @@ class RendererWebStorageAreaImpl : public WebKit::WebStorageArea {
virtual unsigned length();
virtual WebKit::WebString key(unsigned index);
virtual WebKit::WebString getItem(const WebKit::WebString& key);
- virtual void setItem(const WebKit::WebString& key,
- const WebKit::WebString& value,
- bool& quota_exception);
- virtual void removeItem(const WebKit::WebString& key);
- virtual void clear();
+ virtual void setItem(
+ const WebKit::WebString& key, const WebKit::WebString& value,
+ const WebKit::WebURL& url, bool& quota_exception);
+ virtual void removeItem(const WebKit::WebString& key,
+ const WebKit::WebURL& url);
+ virtual void clear(const WebKit::WebURL& url);
private:
// The ID we use for all IPC.
diff --git a/chrome/worker/worker_webkitclient_impl.cc b/chrome/worker/worker_webkitclient_impl.cc
index 2ba4419..c8df883 100644
--- a/chrome/worker/worker_webkitclient_impl.cc
+++ b/chrome/worker/worker_webkitclient_impl.cc
@@ -97,7 +97,7 @@ WebStorageNamespace* WorkerWebKitClientImpl::createSessionStorageNamespace() {
void WorkerWebKitClientImpl::dispatchStorageEvent(
const WebString& key, const WebString& old_value,
const WebString& new_value, const WebString& origin,
- bool is_local_storage) {
+ const WebKit::WebURL& url, bool is_local_storage) {
NOTREACHED();
}
diff --git a/chrome/worker/worker_webkitclient_impl.h b/chrome/worker/worker_webkitclient_impl.h
index 6fbe716..b0dcb68 100644
--- a/chrome/worker/worker_webkitclient_impl.h
+++ b/chrome/worker/worker_webkitclient_impl.h
@@ -34,7 +34,7 @@ class WorkerWebKitClientImpl : public webkit_glue::WebKitClientImpl,
virtual void dispatchStorageEvent(
const WebKit::WebString& key, const WebKit::WebString& old_value,
const WebKit::WebString& new_value, const WebKit::WebString& origin,
- bool is_local_storage);
+ const WebKit::WebURL& url, bool is_local_storage);
virtual WebKit::WebSharedWorkerRepository* sharedWorkerRepository();
// WebMimeRegistry methods:
diff --git a/webkit/api/public/WebKitClient.h b/webkit/api/public/WebKitClient.h
index 91c732f..97b958a 100644
--- a/webkit/api/public/WebKitClient.h
+++ b/webkit/api/public/WebKitClient.h
@@ -93,7 +93,7 @@ namespace WebKit {
// Called when storage events fire.
virtual void dispatchStorageEvent(const WebString& key, const WebString& oldValue,
const WebString& newValue, const WebString& origin,
- bool isLocalStorage) = 0;
+ const WebURL& url, bool isLocalStorage) = 0;
// File ----------------------------------------------------------------
diff --git a/webkit/api/public/WebStorageArea.h b/webkit/api/public/WebStorageArea.h
index b67aea6..6f2f91c 100644
--- a/webkit/api/public/WebStorageArea.h
+++ b/webkit/api/public/WebStorageArea.h
@@ -34,7 +34,9 @@
#include "WebCommon.h"
namespace WebKit {
+
class WebString;
+ class WebURL;
// In WebCore, there's one distinct StorageArea per origin per StorageNamespace. This
// class wraps a StorageArea. All the methods have obvious connections to the spec:
@@ -57,14 +59,15 @@ namespace WebKit {
// Set the value that corresponds to a specific key. QuotaException is set if we've
// the StorageArea would have exceeded its quota. The value is NOT set when there's
- // an exception.
- virtual void setItem(const WebString& key, const WebString& value, bool& quotaException) = 0;
+ // an exception. url is the url that should be used if a storage event fires.
+ virtual void setItem(const WebString& key, const WebString& value, const WebURL& url, bool& quotaException) = 0;
- // Remove the value associated with a particular key.
- virtual void removeItem(const WebString& key) = 0;
+ // Remove the value associated with a particular key. url is the url that should be used
+ // if a storage event fires.
+ virtual void removeItem(const WebString& key, const WebURL& url) = 0;
- // Clear all key/value pairs.
- virtual void clear() = 0;
+ // Clear all key/value pairs. url is the url that should be used if a storage event fires.
+ virtual void clear(const WebURL& url) = 0;
};
} // namespace WebKit
diff --git a/webkit/api/public/WebStorageEventDispatcher.h b/webkit/api/public/WebStorageEventDispatcher.h
index 88d0ea9..e9ed09d 100644
--- a/webkit/api/public/WebStorageEventDispatcher.h
+++ b/webkit/api/public/WebStorageEventDispatcher.h
@@ -35,6 +35,8 @@
namespace WebKit {
+ class WebURL;
+
// This is used to dispatch storage events to all pages.
// FIXME: Make this (or something) work for SessionStorage!
class WebStorageEventDispatcher {
@@ -46,7 +48,7 @@ namespace WebKit {
// Dispatch the actual event. Doesn't yet work for SessionStorage.
virtual void dispatchStorageEvent(const WebString& key, const WebString& oldValue,
const WebString& newValue, const WebString& origin,
- bool isLocalStorage) = 0;
+ const WebURL& url, bool isLocalStorage) = 0;
};
} // namespace WebKit
diff --git a/webkit/api/src/StorageAreaProxy.cpp b/webkit/api/src/StorageAreaProxy.cpp
index 736f97a..551507f 100644
--- a/webkit/api/src/StorageAreaProxy.cpp
+++ b/webkit/api/src/StorageAreaProxy.cpp
@@ -28,12 +28,15 @@
#if ENABLE(DOM_STORAGE)
+#include "Document.h"
#include "ExceptionCode.h"
#include "Frame.h"
#include "SecurityOrigin.h"
#include "StorageAreaImpl.h"
+
#include "WebStorageArea.h"
#include "WebString.h"
+#include "WebURL.h"
namespace WebCore {
@@ -61,24 +64,21 @@ String StorageAreaProxy::getItem(const String& key) const
return m_storageArea->getItem(key);
}
-void StorageAreaProxy::setItem(const String& key, const String& value, ExceptionCode& ec, Frame*)
+void StorageAreaProxy::setItem(const String& key, const String& value, ExceptionCode& ec, Frame* frame)
{
- // FIXME: Is frame any use to us? Probably not.
bool quotaException = false;
- m_storageArea->setItem(key, value, quotaException);
+ m_storageArea->setItem(key, value, frame->document()->url(), quotaException);
ec = quotaException ? QUOTA_EXCEEDED_ERR : 0;
}
-void StorageAreaProxy::removeItem(const String& key, Frame*)
+void StorageAreaProxy::removeItem(const String& key, Frame* frame)
{
- // FIXME: Is frame any use to us? Probably not.
- m_storageArea->removeItem(key);
+ m_storageArea->removeItem(key, frame->document()->url());
}
void StorageAreaProxy::clear(Frame* frame)
{
- // FIXME: Is frame any use to us? Probably not.
- m_storageArea->clear();
+ m_storageArea->clear(frame->document()->url());
}
bool StorageAreaProxy::contains(const String& key) const
diff --git a/webkit/api/src/StorageEventDispatcherChromium.cpp b/webkit/api/src/StorageEventDispatcherChromium.cpp
index 9c283cd..3286929 100644
--- a/webkit/api/src/StorageEventDispatcherChromium.cpp
+++ b/webkit/api/src/StorageEventDispatcherChromium.cpp
@@ -39,6 +39,7 @@
#include "WebKit.h"
#include "WebKitClient.h"
#include "WebString.h"
+#include "WebURL.h"
namespace WebCore {
@@ -47,7 +48,7 @@ void StorageEventDispatcher::dispatch(const String& key, const String& oldValue,
SecurityOrigin* origin, Frame* sourceFrame)
{
ASSERT(!sourceFrame); // Sad, but true.
- WebKit::webKitClient()->dispatchStorageEvent(key, oldValue, newValue, origin->toString(), storageType == LocalStorage);
+ WebKit::webKitClient()->dispatchStorageEvent(key, oldValue, newValue, origin->toString(), WebKit::WebURL(), storageType == LocalStorage);
}
} // namespace WebCore
diff --git a/webkit/api/src/StorageEventDispatcherImpl.cpp b/webkit/api/src/StorageEventDispatcherImpl.cpp
index 6dc6357..f07a5e0 100644
--- a/webkit/api/src/StorageEventDispatcherImpl.cpp
+++ b/webkit/api/src/StorageEventDispatcherImpl.cpp
@@ -36,6 +36,7 @@
#include "DOMWindow.h"
#include "EventNames.h"
#include "Frame.h"
+#include "KURL.h"
#include "Page.h"
#include "PageGroup.h"
#include "SecurityOrigin.h"
@@ -50,8 +51,8 @@ StorageEventDispatcherImpl::StorageEventDispatcherImpl(const String& groupName)
}
void StorageEventDispatcherImpl::dispatchStorageEvent(const String& key, const String& oldValue,
- const String& newValue, StorageType storageType,
- SecurityOrigin* securityOrigin)
+ const String& newValue, SecurityOrigin* securityOrigin,
+ const KURL& url, StorageType storageType)
{
// FIXME: Implement
if (storageType == SessionStorage)
@@ -73,7 +74,7 @@ void StorageEventDispatcherImpl::dispatchStorageEvent(const String& key, const S
// FIXME: Figure out how to pass in the document URI.
for (unsigned i = 0; i < frames.size(); ++i) {
frames[i]->document()->dispatchWindowEvent(StorageEvent::create(eventNames().storageEvent, key,oldValue, newValue,
- String(), frames[i]->domWindow()->localStorage()));
+ url, frames[i]->domWindow()->localStorage()));
}
}
diff --git a/webkit/api/src/StorageEventDispatcherImpl.h b/webkit/api/src/StorageEventDispatcherImpl.h
index e0f57e2..08700ed 100644
--- a/webkit/api/src/StorageEventDispatcherImpl.h
+++ b/webkit/api/src/StorageEventDispatcherImpl.h
@@ -38,6 +38,7 @@
namespace WebCore {
+ class KURL;
class PageGroup;
class SecurityOrigin;
@@ -46,8 +47,8 @@ namespace WebCore {
StorageEventDispatcherImpl(const String& groupName);
void dispatchStorageEvent(const String& key, const String& oldValue,
- const String& newValue, StorageType,
- SecurityOrigin*);
+ const String& newValue, SecurityOrigin*,
+ const KURL&, StorageType);
private:
PageGroup* m_pageGroup;
diff --git a/webkit/api/src/WebStorageAreaImpl.cpp b/webkit/api/src/WebStorageAreaImpl.cpp
index c835424..4e46f54 100644
--- a/webkit/api/src/WebStorageAreaImpl.cpp
+++ b/webkit/api/src/WebStorageAreaImpl.cpp
@@ -34,10 +34,14 @@
#if ENABLE(DOM_STORAGE)
#include "ExceptionCode.h"
+
#include "WebString.h"
+#include "WebURL.h"
namespace WebKit {
+const WebURL* WebStorageAreaImpl::storageEventURL = NULL;
+
WebStorageAreaImpl::WebStorageAreaImpl(PassRefPtr<WebCore::StorageArea> storageArea)
: m_storageArea(storageArea)
{
@@ -62,11 +66,13 @@ WebString WebStorageAreaImpl::getItem(const WebString& key)
return m_storageArea->getItem(key);
}
-void WebStorageAreaImpl::setItem(const WebString& key, const WebString& value, bool& quotaException)
+void WebStorageAreaImpl::setItem(const WebString& key, const WebString& value, const WebURL& url, bool& quotaException)
{
int exceptionCode = 0;
- // FIXME: Can we do any better than just passing 0 for the frame?
+
+ ScopedStorageEventURL scope(url);
m_storageArea->setItem(key, value, exceptionCode, 0);
+
if (exceptionCode != 0) {
ASSERT(exceptionCode == WebCore::QUOTA_EXCEEDED_ERR);
quotaException = true;
@@ -75,15 +81,15 @@ void WebStorageAreaImpl::setItem(const WebString& key, const WebString& value, b
}
}
-void WebStorageAreaImpl::removeItem(const WebString& key)
+void WebStorageAreaImpl::removeItem(const WebString& key, const WebURL& url)
{
- // FIXME: Can we do any better than just passing 0 for the frame?
+ ScopedStorageEventURL scope(url);
m_storageArea->removeItem(key, 0);
}
-void WebStorageAreaImpl::clear()
+void WebStorageAreaImpl::clear(const WebURL& url)
{
- // FIXME: Can we do any better than just passing 0 for the frame?
+ ScopedStorageEventURL scope(url);
m_storageArea->clear(0);
}
diff --git a/webkit/api/src/WebStorageAreaImpl.h b/webkit/api/src/WebStorageAreaImpl.h
index 5c57ae2..2a88af3 100644
--- a/webkit/api/src/WebStorageAreaImpl.h
+++ b/webkit/api/src/WebStorageAreaImpl.h
@@ -45,11 +45,32 @@ namespace WebKit {
virtual unsigned length();
virtual WebString key(unsigned index);
virtual WebString getItem(const WebString& key);
- virtual void setItem(const WebString& key, const WebString& value, bool& quotaException);
- virtual void removeItem(const WebString& key);
- virtual void clear();
+ virtual void setItem(const WebString& key, const WebString& value, const WebURL& url, bool& quotaException);
+ virtual void removeItem(const WebString& key, const WebURL& url);
+ virtual void clear(const WebURL& url);
+
+ // For storage events in single-process mode and test shell.
+ static const WebURL* currentStorageEventURL() { return storageEventURL; }
private:
+ class ScopedStorageEventURL {
+ public:
+ ScopedStorageEventURL(const WebURL& url) {
+ // FIXME: Once storage events are fired async in WebKit (as they should
+ // be) this can be ASSERTed to be NULL rather than saved.
+ m_existingStorageEventURL = storageEventURL;
+ storageEventURL = &url;
+ }
+ ~ScopedStorageEventURL() {
+ storageEventURL = m_existingStorageEventURL;
+ }
+
+ private:
+ const WebURL* m_existingStorageEventURL;
+ };
+
+ static const WebURL* storageEventURL;
+
RefPtr<WebCore::StorageArea> m_storageArea;
};
diff --git a/webkit/api/src/WebStorageEventDispatcherImpl.cpp b/webkit/api/src/WebStorageEventDispatcherImpl.cpp
index 2e6df47..515a423 100644
--- a/webkit/api/src/WebStorageEventDispatcherImpl.cpp
+++ b/webkit/api/src/WebStorageEventDispatcherImpl.cpp
@@ -33,8 +33,12 @@
#if ENABLE(DOM_STORAGE)
+#include "KURL.h"
#include "SecurityOrigin.h"
+#include "WebStorageAreaImpl.h"
+#include "WebURL.h"
+
namespace WebKit {
extern const char* pageGroupName;
@@ -52,11 +56,15 @@ WebStorageEventDispatcherImpl::WebStorageEventDispatcherImpl()
void WebStorageEventDispatcherImpl::dispatchStorageEvent(const WebString& key, const WebString& oldValue,
const WebString& newValue, const WebString& origin,
- bool isLocalStorage)
+ const WebURL& passedInURL, bool isLocalStorage)
{
+ // Hack for single-process mode and test shell.
+ const WebURL* storageAreaImplURL = WebStorageAreaImpl::currentStorageEventURL();
+ const WebURL& url = storageAreaImplURL ? *storageAreaImplURL : passedInURL;
+
WebCore::StorageType storageType = isLocalStorage ? WebCore::LocalStorage : WebCore::SessionStorage;
RefPtr<WebCore::SecurityOrigin> securityOrigin = WebCore::SecurityOrigin::createFromString(origin);
- m_eventDispatcher->dispatchStorageEvent(key, oldValue, newValue, storageType, securityOrigin.get());
+ m_eventDispatcher->dispatchStorageEvent(key, oldValue, newValue, securityOrigin.get(), url, storageType);
}
} // namespace WebKit
diff --git a/webkit/api/src/WebStorageEventDispatcherImpl.h b/webkit/api/src/WebStorageEventDispatcherImpl.h
index 464c4f3..aa3f066 100644
--- a/webkit/api/src/WebStorageEventDispatcherImpl.h
+++ b/webkit/api/src/WebStorageEventDispatcherImpl.h
@@ -46,7 +46,7 @@ namespace WebKit {
virtual void dispatchStorageEvent(const WebString& key, const WebString& oldValue,
const WebString& newValue, const WebString& origin,
- bool isLocalStorage);
+ const WebURL& url, bool isLocalStorage);
private:
OwnPtr<WebCore::StorageEventDispatcherImpl> m_eventDispatcher;
diff --git a/webkit/data/layout_tests/platform/chromium-mac/LayoutTests/storage/domstorage/localstorage/iframe-events-expected.txt b/webkit/data/layout_tests/platform/chromium-mac/LayoutTests/storage/domstorage/localstorage/iframe-events-expected.txt
deleted file mode 100644
index 33a4646..0000000
--- a/webkit/data/layout_tests/platform/chromium-mac/LayoutTests/storage/domstorage/localstorage/iframe-events-expected.txt
+++ /dev/null
@@ -1,77 +0,0 @@
-This is the main frame of a 2-frame document. Each frame is in the same security origin and therefore shares the same localStorage object. As a result, each frame should receive a StorageEvent when either frame changes the localStorage object.
-
-Main frame about to run setItem on localStorage...
-Main Frame received StorageEvent:
-Key - Main Frame
-New Value - SET
-Old Value - null
-URI -
-Storage Area - This window's window.localStorage
-
-Subframe received storage event:
-Key - Main Frame
-New Value - SET
-Old Value - null
-URI -
-Storage Area - This window's window.localStorage
-
-Subframe about to change localStorage...
-Main Frame received StorageEvent:
-Key - Subframe
-New Value - SET
-Old Value - null
-URI -
-Storage Area - This window's window.localStorage
-
-Subframe received storage event:
-Key - Subframe
-New Value - SET
-Old Value - null
-URI -
-Storage Area - This window's window.localStorage
-
-Main frame about to run removeItem on localStorage...
-Main Frame received StorageEvent:
-Key - Main Frame
-New Value - null
-Old Value - SET
-URI -
-Storage Area - This window's window.localStorage
-
-Subframe received storage event:
-Key - Main Frame
-New Value - null
-Old Value - SET
-URI -
-Storage Area - This window's window.localStorage
-
-Subframe about to change localStorage...
-Main frame about to clear localStorage...
-Main Frame received StorageEvent:
-Key -
-New Value - null
-Old Value - null
-URI -
-Storage Area - This window's window.localStorage
-
-Subframe received storage event:
-Key -
-New Value - null
-Old Value - null
-URI -
-Storage Area - This window's window.localStorage
-
-Subframe about to change localStorage...
-Main Frame received StorageEvent:
-Key - Subframe
-New Value - SET
-Old Value - null
-URI -
-Storage Area - This window's window.localStorage
-
-Subframe received storage event:
-Key - Subframe
-New Value - SET
-Old Value - null
-URI -
-Storage Area - This window's window.localStorage
diff --git a/webkit/data/layout_tests/platform/chromium-mac/LayoutTests/storage/domstorage/localstorage/simple-events-expected.txt b/webkit/data/layout_tests/platform/chromium-mac/LayoutTests/storage/domstorage/localstorage/simple-events-expected.txt
deleted file mode 100644
index b8f0608..0000000
--- a/webkit/data/layout_tests/platform/chromium-mac/LayoutTests/storage/domstorage/localstorage/simple-events-expected.txt
+++ /dev/null
@@ -1,22 +0,0 @@
-This is a test to make sure localStorage mutations fire StorageEvents
-Storage event fired:
-Key - FOO
-New Value - BAR
-Old Value - null
-
-Storage event fired:
-Key - FU
-New Value - BAR
-Old Value - null
-
-Storage event fired:
-Key - FOO
-New Value - null
-Old Value - BAR
-
-Storage event fired:
-Key - FU
-New Value - null
-Old Value - BAR
-
-
diff --git a/webkit/data/layout_tests/platform/chromium-win/LayoutTests/storage/domstorage/localstorage/iframe-events-expected.txt b/webkit/data/layout_tests/platform/chromium-win/LayoutTests/storage/domstorage/localstorage/iframe-events-expected.txt
deleted file mode 100644
index 33a4646..0000000
--- a/webkit/data/layout_tests/platform/chromium-win/LayoutTests/storage/domstorage/localstorage/iframe-events-expected.txt
+++ /dev/null
@@ -1,77 +0,0 @@
-This is the main frame of a 2-frame document. Each frame is in the same security origin and therefore shares the same localStorage object. As a result, each frame should receive a StorageEvent when either frame changes the localStorage object.
-
-Main frame about to run setItem on localStorage...
-Main Frame received StorageEvent:
-Key - Main Frame
-New Value - SET
-Old Value - null
-URI -
-Storage Area - This window's window.localStorage
-
-Subframe received storage event:
-Key - Main Frame
-New Value - SET
-Old Value - null
-URI -
-Storage Area - This window's window.localStorage
-
-Subframe about to change localStorage...
-Main Frame received StorageEvent:
-Key - Subframe
-New Value - SET
-Old Value - null
-URI -
-Storage Area - This window's window.localStorage
-
-Subframe received storage event:
-Key - Subframe
-New Value - SET
-Old Value - null
-URI -
-Storage Area - This window's window.localStorage
-
-Main frame about to run removeItem on localStorage...
-Main Frame received StorageEvent:
-Key - Main Frame
-New Value - null
-Old Value - SET
-URI -
-Storage Area - This window's window.localStorage
-
-Subframe received storage event:
-Key - Main Frame
-New Value - null
-Old Value - SET
-URI -
-Storage Area - This window's window.localStorage
-
-Subframe about to change localStorage...
-Main frame about to clear localStorage...
-Main Frame received StorageEvent:
-Key -
-New Value - null
-Old Value - null
-URI -
-Storage Area - This window's window.localStorage
-
-Subframe received storage event:
-Key -
-New Value - null
-Old Value - null
-URI -
-Storage Area - This window's window.localStorage
-
-Subframe about to change localStorage...
-Main Frame received StorageEvent:
-Key - Subframe
-New Value - SET
-Old Value - null
-URI -
-Storage Area - This window's window.localStorage
-
-Subframe received storage event:
-Key - Subframe
-New Value - SET
-Old Value - null
-URI -
-Storage Area - This window's window.localStorage
diff --git a/webkit/data/layout_tests/platform/chromium-win/LayoutTests/storage/domstorage/localstorage/simple-events-expected.txt b/webkit/data/layout_tests/platform/chromium-win/LayoutTests/storage/domstorage/localstorage/simple-events-expected.txt
deleted file mode 100644
index b8f0608..0000000
--- a/webkit/data/layout_tests/platform/chromium-win/LayoutTests/storage/domstorage/localstorage/simple-events-expected.txt
+++ /dev/null
@@ -1,22 +0,0 @@
-This is a test to make sure localStorage mutations fire StorageEvents
-Storage event fired:
-Key - FOO
-New Value - BAR
-Old Value - null
-
-Storage event fired:
-Key - FU
-New Value - BAR
-Old Value - null
-
-Storage event fired:
-Key - FOO
-New Value - null
-Old Value - BAR
-
-Storage event fired:
-Key - FU
-New Value - null
-Old Value - BAR
-
-
diff --git a/webkit/tools/test_shell/test_shell_webkit_init.h b/webkit/tools/test_shell/test_shell_webkit_init.h
index ee7845b..a360e77 100644
--- a/webkit/tools/test_shell/test_shell_webkit_init.h
+++ b/webkit/tools/test_shell/test_shell_webkit_init.h
@@ -198,7 +198,8 @@ class TestShellWebKitInit : public webkit_glue::WebKitClientImpl {
void dispatchStorageEvent(const WebKit::WebString& key,
const WebKit::WebString& old_value, const WebKit::WebString& new_value,
- const WebKit::WebString& origin, bool is_local_storage) {
+ const WebKit::WebString& origin, const WebKit::WebURL& url,
+ bool is_local_storage) {
// TODO(jorlow): Implement
if (!is_local_storage)
return;
@@ -207,8 +208,8 @@ class TestShellWebKitInit : public webkit_glue::WebKitClientImpl {
dom_storage_event_dispatcher_.reset(
WebKit::WebStorageEventDispatcher::create());
}
- dom_storage_event_dispatcher_->dispatchStorageEvent(key, old_value,
- new_value, origin, is_local_storage);
+ dom_storage_event_dispatcher_->dispatchStorageEvent(
+ key, old_value, new_value, origin, url, is_local_storage);
}
virtual WebKit::WebApplicationCacheHost* createApplicationCacheHost(