diff options
Diffstat (limited to 'WebKit/chromium/src/StorageNamespaceProxy.cpp')
-rw-r--r-- | WebKit/chromium/src/StorageNamespaceProxy.cpp | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/WebKit/chromium/src/StorageNamespaceProxy.cpp b/WebKit/chromium/src/StorageNamespaceProxy.cpp index e22bbef..1be1967 100644 --- a/WebKit/chromium/src/StorageNamespaceProxy.cpp +++ b/WebKit/chromium/src/StorageNamespaceProxy.cpp @@ -28,27 +28,35 @@ #if ENABLE(DOM_STORAGE) +#include "Chrome.h" +#include "ChromeClientImpl.h" +#include "Page.h" #include "SecurityOrigin.h" #include "StorageAreaProxy.h" #include "WebKit.h" #include "WebKitClient.h" #include "WebStorageNamespace.h" #include "WebString.h" +#include "WebViewClient.h" +#include "WebViewImpl.h" namespace WebCore { PassRefPtr<StorageNamespace> StorageNamespace::localStorageNamespace(const String& path, unsigned quota) { - return new StorageNamespaceProxy(WebKit::webKitClient()->createLocalStorageNamespace(path, quota)); + return adoptRef(new StorageNamespaceProxy(WebKit::webKitClient()->createLocalStorageNamespace(path, quota), LocalStorage)); } -PassRefPtr<StorageNamespace> StorageNamespace::sessionStorageNamespace() +PassRefPtr<StorageNamespace> StorageNamespace::sessionStorageNamespace(Page* page) { - return new StorageNamespaceProxy(WebKit::webKitClient()->createSessionStorageNamespace()); + WebKit::ChromeClientImpl* chromeClientImpl = static_cast<WebKit::ChromeClientImpl*>(page->chrome()->client()); + WebKit::WebViewClient* webViewClient = chromeClientImpl->webView()->client(); + return adoptRef(new StorageNamespaceProxy(webViewClient->createSessionStorageNamespace(), SessionStorage)); } -StorageNamespaceProxy::StorageNamespaceProxy(WebKit::WebStorageNamespace* storageNamespace) +StorageNamespaceProxy::StorageNamespaceProxy(WebKit::WebStorageNamespace* storageNamespace, StorageType storageType) : m_storageNamespace(storageNamespace) + , m_storageType(storageType) { } @@ -58,12 +66,19 @@ StorageNamespaceProxy::~StorageNamespaceProxy() PassRefPtr<StorageNamespace> StorageNamespaceProxy::copy() { - return adoptRef(new StorageNamespaceProxy(m_storageNamespace->copy())); + ASSERT(m_storageType == SessionStorage); + // The WebViewClient knows what its session storage namespace id is but we + // do not. Returning 0 here causes it to be fetched (via the WebViewClient) + // on its next use. Note that it is WebViewClient::createView's + // responsibility to clone the session storage namespace id and that the + // only time copy() is called is directly after the createView call...which + // is why all of this is safe. + return 0; } PassRefPtr<StorageArea> StorageNamespaceProxy::storageArea(PassRefPtr<SecurityOrigin> origin) { - return adoptRef(new StorageAreaProxy(m_storageNamespace->createStorageArea(origin->toString()))); + return adoptRef(new StorageAreaProxy(m_storageNamespace->createStorageArea(origin->toString()), m_storageType)); } void StorageNamespaceProxy::close() |