| 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/DOMWindowStorageController.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 DOMWindowStorageController::DOMWindowStorageController(Document& document) |
| 16 : DOMWindowLifecycleObserver(document.domWindow()) |
| 17 , m_document(document) |
| 18 { |
| 19 } |
| 20 |
| 21 DOMWindowStorageController::~DOMWindowStorageController() |
| 22 { |
| 23 } |
| 24 |
| 25 // static |
| 26 const char* DOMWindowStorageController::supplementName() |
| 27 { |
| 28 return "DOMWindowStorageController"; |
| 29 } |
| 30 |
| 31 // static |
| 32 DOMWindowStorageController& DOMWindowStorageController::from(Document& document) |
| 33 { |
| 34 DOMWindowStorageController* controller = static_cast<DOMWindowStorageControl
ler*>(WillBeHeapSupplement<Document>::from(document, supplementName())); |
| 35 if (!controller) { |
| 36 controller = new DOMWindowStorageController(document); |
| 37 DocumentSupplement::provideTo(document, supplementName(), adoptPtrWillBe
Noop(controller)); |
| 38 } |
| 39 return *controller; |
| 40 } |
| 41 |
| 42 void DOMWindowStorageController::didAddEventListener(LocalDOMWindow* window, con
st AtomicString& 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 |