Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "config.h" | |
| 6 #include "core/storage/DOMWindowStorage.h" | |
| 7 | |
| 8 #include "core/dom/Document.h" | |
| 9 #include "core/events/Event.h" | |
| 10 #include "core/frame/LocalDOMWindow.h" | |
| 11 #include "core/page/Page.h" | |
| 12 | |
| 13 namespace blink { | |
| 14 | |
| 15 DOMWindowStorage::DOMWindowStorage(Document& document) | |
| 16 : DOMWindowLifecycleObserver(document.domWindow()) | |
| 17 , m_document(document) | |
| 18 { | |
| 19 } | |
| 20 | |
| 21 DOMWindowStorage::~DOMWindowStorage() | |
| 22 { | |
| 23 } | |
| 24 | |
| 25 // static | |
| 26 const char* DOMWindowStorage::supplementName() | |
| 27 { | |
| 28 return "DOMWindowStorage"; | |
| 29 } | |
| 30 | |
| 31 // static | |
| 32 DOMWindowStorage& DOMWindowStorage::from(Document& document) | |
| 33 { | |
| 34 DOMWindowStorage* controller = static_cast<DOMWindowStorage*>(WillBeHeapSupp lement<Document>::from(document, supplementName())); | |
|
michaeln
2014/12/16 00:12:11
I'm not familiar with how 'supplements' are typica
| |
| 35 if (!controller) { | |
| 36 controller = new DOMWindowStorage(document); | |
| 37 DocumentSupplement::provideTo(document, supplementName(), adoptPtrWillBe Noop(controller)); | |
| 38 } | |
| 39 return *controller; | |
| 40 } | |
| 41 | |
| 42 void DOMWindowStorage::didAddEventListener(LocalDOMWindow* window, const AtomicS tring& eventType) | |
| 43 { | |
| 44 if (eventType == EventTypeNames::storage) { | |
| 45 // Creating these blink::Storage objects informs the system that we'd li ke to receive | |
| 46 // notifications about storage events that might be triggered in other p rocesses. Rather | |
| 47 // than subscribe to these notifications explicitly, we subscribe to the m implicitly to | |
| 48 // simplify the work done by the system. | |
| 49 window->localStorage(IGNORE_EXCEPTION); | |
| 50 window->sessionStorage(IGNORE_EXCEPTION); | |
| 51 } | |
| 52 } | |
| 53 | |
| 54 } // namespace blink | |
| OLD | NEW |