Chromium Code Reviews| Index: third_party/WebKit/Source/modules/storage/DOMWindowStorage.cpp |
| diff --git a/third_party/WebKit/Source/modules/storage/DOMWindowStorage.cpp b/third_party/WebKit/Source/modules/storage/DOMWindowStorage.cpp |
| index 24eca7cfa0cf9648294b05b9a8d57d8635c89226..979e61b987a5d984ce348dd2f33a28483fb8efab 100644 |
| --- a/third_party/WebKit/Source/modules/storage/DOMWindowStorage.cpp |
| +++ b/third_party/WebKit/Source/modules/storage/DOMWindowStorage.cpp |
| @@ -18,14 +18,13 @@ |
| 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 +57,11 @@ Storage* DOMWindowStorage::localStorage(DOMWindow& window, |
| Storage* DOMWindowStorage::sessionStorage( |
| ExceptionState& exceptionState) const { |
| - if (!m_window->isCurrentlyDisplayedInFrame()) |
|
haraken
2017/01/06 01:54:40
This is checking if the frame is detached. It can
|
| - 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 +76,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 +90,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()) |
|
haraken
2017/01/06 01:54:40
Ditto.
|
| - 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)) |
| @@ -133,11 +130,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; |
| } |