Commit 1c14e5b9 authored by haraken's avatar haraken Committed by Commit bot

Remove ContextClient from DOMWindowStorage

Now that DOMWindowStorage can access DOMWindow with host(),
DOMWindowStorage doesn't need to observe ContextClient.

BUG=610176

Review-Url: https://codereview.chromium.org/2617703003
Cr-Commit-Position: refs/heads/master@{#441901}
parent 4f38a5bc
......@@ -18,14 +18,12 @@
namespace blink {
DOMWindowStorage::DOMWindowStorage(LocalDOMWindow& window)
: ContextClient(window.frame()), m_window(&window) {}
: Supplement<LocalDOMWindow>(window) {}
DEFINE_TRACE(DOMWindowStorage) {
visitor->trace(m_window);
visitor->trace(m_sessionStorage);
visitor->trace(m_localStorage);
Supplement<LocalDOMWindow>::trace(visitor);
ContextClient::trace(visitor);
}
// static
......@@ -58,13 +56,11 @@ Storage* DOMWindowStorage::localStorage(DOMWindow& window,
Storage* DOMWindowStorage::sessionStorage(
ExceptionState& exceptionState) const {
if (!m_window->isCurrentlyDisplayedInFrame())
return nullptr;
Document* document = m_window->document();
if (!document)
if (!host()->frame())
return nullptr;
Document* document = host()->frame()->document();
DCHECK(document);
String accessDeniedMessage = "Access is denied for this document.";
if (!document->getSecurityOrigin()->canAccessLocalStorage()) {
if (document->isSandboxed(SandboxOrigin))
......@@ -79,7 +75,7 @@ Storage* DOMWindowStorage::sessionStorage(
}
if (m_sessionStorage) {
if (!m_sessionStorage->area()->canAccessStorage(m_window->frame())) {
if (!m_sessionStorage->area()->canAccessStorage(document->frame())) {
exceptionState.throwSecurityError(accessDeniedMessage);
return nullptr;
}
......@@ -93,21 +89,21 @@ Storage* DOMWindowStorage::sessionStorage(
StorageArea* storageArea =
StorageNamespaceController::from(page)->sessionStorage()->storageArea(
document->getSecurityOrigin());
if (!storageArea->canAccessStorage(m_window->frame())) {
if (!storageArea->canAccessStorage(document->frame())) {
exceptionState.throwSecurityError(accessDeniedMessage);
return nullptr;
}
m_sessionStorage = Storage::create(m_window->frame(), storageArea);
m_sessionStorage = Storage::create(document->frame(), storageArea);
return m_sessionStorage;
}
Storage* DOMWindowStorage::localStorage(ExceptionState& exceptionState) const {
if (!m_window->isCurrentlyDisplayedInFrame())
return nullptr;
Document* document = m_window->document();
if (!document)
if (!host()->frame())
return nullptr;
Document* document = host()->frame()->document();
DCHECK(document);
String accessDeniedMessage = "Access is denied for this document.";
if (!document->getSecurityOrigin()->canAccessLocalStorage()) {
if (document->isSandboxed(SandboxOrigin))
......@@ -121,7 +117,7 @@ Storage* DOMWindowStorage::localStorage(ExceptionState& exceptionState) const {
return nullptr;
}
if (m_localStorage) {
if (!m_localStorage->area()->canAccessStorage(m_window->frame())) {
if (!m_localStorage->area()->canAccessStorage(document->frame())) {
exceptionState.throwSecurityError(accessDeniedMessage);
return nullptr;
}
......@@ -133,11 +129,11 @@ Storage* DOMWindowStorage::localStorage(ExceptionState& exceptionState) const {
return nullptr;
StorageArea* storageArea =
StorageNamespace::localStorageArea(document->getSecurityOrigin());
if (!storageArea->canAccessStorage(m_window->frame())) {
if (!storageArea->canAccessStorage(document->frame())) {
exceptionState.throwSecurityError(accessDeniedMessage);
return nullptr;
}
m_localStorage = Storage::create(m_window->frame(), storageArea);
m_localStorage = Storage::create(document->frame(), storageArea);
return m_localStorage;
}
......
......@@ -5,7 +5,6 @@
#ifndef DOMWindowStorage_h
#define DOMWindowStorage_h
#include "core/dom/ContextLifecycleObserver.h"
#include "core/frame/LocalDOMWindow.h"
#include "platform/Supplementable.h"
#include "platform/heap/Handle.h"
......@@ -18,8 +17,7 @@ class LocalDOMWindow;
class Storage;
class DOMWindowStorage final : public GarbageCollected<DOMWindowStorage>,
public Supplement<LocalDOMWindow>,
public ContextClient {
public Supplement<LocalDOMWindow> {
USING_GARBAGE_COLLECTED_MIXIN(DOMWindowStorage);
public:
......@@ -38,7 +36,6 @@ class DOMWindowStorage final : public GarbageCollected<DOMWindowStorage>,
explicit DOMWindowStorage(LocalDOMWindow&);
static const char* supplementName();
Member<LocalDOMWindow> m_window;
mutable Member<Storage> m_sessionStorage;
mutable Member<Storage> m_localStorage;
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment