| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "modules/storage/DOMWindowStorage.h" | 5 #include "modules/storage/DOMWindowStorage.h" |
| 6 | 6 |
| 7 #include "core/dom/Document.h" | 7 #include "core/dom/Document.h" |
| 8 #include "core/frame/FrameHost.h" | 8 #include "core/frame/FrameHost.h" |
| 9 #include "core/frame/LocalDOMWindow.h" | 9 #include "core/frame/LocalDOMWindow.h" |
| 10 #include "core/frame/LocalFrame.h" | 10 #include "core/frame/LocalFrame.h" |
| 11 #include "core/frame/Settings.h" | 11 #include "core/frame/Settings.h" |
| 12 #include "core/page/Page.h" | 12 #include "core/page/Page.h" |
| 13 #include "modules/storage/Storage.h" | 13 #include "modules/storage/Storage.h" |
| 14 #include "modules/storage/StorageNamespace.h" | 14 #include "modules/storage/StorageNamespace.h" |
| 15 #include "modules/storage/StorageNamespaceController.h" | 15 #include "modules/storage/StorageNamespaceController.h" |
| 16 #include "wtf/PassRefPtr.h" | 16 #include "wtf/PassRefPtr.h" |
| 17 | 17 |
| 18 namespace blink { | 18 namespace blink { |
| 19 | 19 |
| 20 DOMWindowStorage::DOMWindowStorage(LocalDOMWindow& window) | 20 DOMWindowStorage::DOMWindowStorage(LocalDOMWindow& window) |
| 21 : DOMWindowProperty(window.frame()) | 21 : DOMWindowProperty(window.frame()) |
| 22 , m_window(&window) | 22 , m_window(&window) |
| 23 { | 23 { |
| 24 } | 24 } |
| 25 | 25 |
| 26 DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(DOMWindowStorage); | |
| 27 | |
| 28 DEFINE_TRACE(DOMWindowStorage) | 26 DEFINE_TRACE(DOMWindowStorage) |
| 29 { | 27 { |
| 30 visitor->trace(m_window); | 28 visitor->trace(m_window); |
| 31 visitor->trace(m_sessionStorage); | 29 visitor->trace(m_sessionStorage); |
| 32 visitor->trace(m_localStorage); | 30 visitor->trace(m_localStorage); |
| 33 WillBeHeapSupplement<LocalDOMWindow>::trace(visitor); | 31 HeapSupplement<LocalDOMWindow>::trace(visitor); |
| 34 DOMWindowProperty::trace(visitor); | 32 DOMWindowProperty::trace(visitor); |
| 35 } | 33 } |
| 36 | 34 |
| 37 // static | 35 // static |
| 38 const char* DOMWindowStorage::supplementName() | 36 const char* DOMWindowStorage::supplementName() |
| 39 { | 37 { |
| 40 return "DOMWindowStorage"; | 38 return "DOMWindowStorage"; |
| 41 } | 39 } |
| 42 | 40 |
| 43 // static | 41 // static |
| 44 DOMWindowStorage& DOMWindowStorage::from(LocalDOMWindow& window) | 42 DOMWindowStorage& DOMWindowStorage::from(LocalDOMWindow& window) |
| 45 { | 43 { |
| 46 DOMWindowStorage* supplement = static_cast<DOMWindowStorage*>(WillBeHeapSupp
lement<LocalDOMWindow>::from(window, supplementName())); | 44 DOMWindowStorage* supplement = static_cast<DOMWindowStorage*>(HeapSupplement
<LocalDOMWindow>::from(window, supplementName())); |
| 47 if (!supplement) { | 45 if (!supplement) { |
| 48 supplement = new DOMWindowStorage(window); | 46 supplement = new DOMWindowStorage(window); |
| 49 provideTo(window, supplementName(), adoptPtrWillBeNoop(supplement)); | 47 provideTo(window, supplementName(), (supplement)); |
| 50 } | 48 } |
| 51 return *supplement; | 49 return *supplement; |
| 52 } | 50 } |
| 53 | 51 |
| 54 // static | 52 // static |
| 55 Storage* DOMWindowStorage::sessionStorage(DOMWindow& window, ExceptionState& exc
eptionState) | 53 Storage* DOMWindowStorage::sessionStorage(DOMWindow& window, ExceptionState& exc
eptionState) |
| 56 { | 54 { |
| 57 return from(toLocalDOMWindow(window)).sessionStorage(exceptionState); | 55 return from(toLocalDOMWindow(window)).sessionStorage(exceptionState); |
| 58 } | 56 } |
| 59 | 57 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 StorageArea* storageArea = StorageNamespace::localStorageArea(document->secu
rityOrigin()); | 134 StorageArea* storageArea = StorageNamespace::localStorageArea(document->secu
rityOrigin()); |
| 137 if (!storageArea->canAccessStorage(m_window->frame())) { | 135 if (!storageArea->canAccessStorage(m_window->frame())) { |
| 138 exceptionState.throwSecurityError(accessDeniedMessage); | 136 exceptionState.throwSecurityError(accessDeniedMessage); |
| 139 return nullptr; | 137 return nullptr; |
| 140 } | 138 } |
| 141 m_localStorage = Storage::create(m_window->frame(), storageArea); | 139 m_localStorage = Storage::create(m_window->frame(), storageArea); |
| 142 return m_localStorage; | 140 return m_localStorage; |
| 143 } | 141 } |
| 144 | 142 |
| 145 } // namespace blink | 143 } // namespace blink |
| OLD | NEW |