| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 "config.h" | 5 #include "config.h" |
| 6 #include "modules/serviceworkers/NavigatorServiceWorker.h" | 6 #include "modules/serviceworkers/NavigatorServiceWorker.h" |
| 7 | 7 |
| 8 #include "core/dom/Document.h" | 8 #include "core/dom/Document.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/Navigator.h" | 11 #include "core/frame/Navigator.h" |
| 12 #include "modules/serviceworkers/ServiceWorkerContainer.h" | 12 #include "modules/serviceworkers/ServiceWorkerContainer.h" |
| 13 | 13 |
| 14 namespace blink { | 14 namespace blink { |
| 15 | 15 |
| 16 NavigatorServiceWorker::NavigatorServiceWorker(Navigator& navigator) | 16 NavigatorServiceWorker::NavigatorServiceWorker(Navigator& navigator) |
| 17 : DOMWindowProperty(navigator.frame()) | 17 : DOMWindowProperty(navigator.frame()) |
| 18 { | 18 { |
| 19 } | 19 } |
| 20 | 20 |
| 21 NavigatorServiceWorker::~NavigatorServiceWorker() | 21 NavigatorServiceWorker::~NavigatorServiceWorker() |
| 22 { | 22 { |
| 23 } | 23 } |
| 24 | 24 |
| 25 NavigatorServiceWorker* NavigatorServiceWorker::from(Document& document) | 25 NavigatorServiceWorker* NavigatorServiceWorker::from(Document& document) |
| 26 { | 26 { |
| 27 if (!document.frame() || !document.frame()->domWindow()) | 27 if (!document.frame() || !document.frame()->domWindow()) |
| 28 return nullptr; | 28 return nullptr; |
| 29 Navigator& navigator = *document.frame()->domWindow()->navigator(); | 29 Navigator* navigator = document.frame()->domWindow()->navigator(); |
| 30 return &from(navigator); | 30 if (!navigator) |
| 31 return nullptr; |
| 32 return &from(*navigator); |
| 31 } | 33 } |
| 32 | 34 |
| 33 NavigatorServiceWorker& NavigatorServiceWorker::from(Navigator& navigator) | 35 NavigatorServiceWorker& NavigatorServiceWorker::from(Navigator& navigator) |
| 34 { | 36 { |
| 35 NavigatorServiceWorker* supplement = toNavigatorServiceWorker(navigator); | 37 NavigatorServiceWorker* supplement = toNavigatorServiceWorker(navigator); |
| 36 if (!supplement) { | 38 if (!supplement) { |
| 37 supplement = new NavigatorServiceWorker(navigator); | 39 supplement = new NavigatorServiceWorker(navigator); |
| 38 provideTo(navigator, supplementName(), supplement); | 40 provideTo(navigator, supplementName(), supplement); |
| 39 if (navigator.frame() && navigator.frame()->securityContext()->securityO
rigin()->canAccessServiceWorkers()) { | 41 if (navigator.frame() && navigator.frame()->securityContext()->securityO
rigin()->canAccessServiceWorkers()) { |
| 40 // Initialize ServiceWorkerContainer too. | 42 // Initialize ServiceWorkerContainer too. |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 } | 86 } |
| 85 | 87 |
| 86 DEFINE_TRACE(NavigatorServiceWorker) | 88 DEFINE_TRACE(NavigatorServiceWorker) |
| 87 { | 89 { |
| 88 visitor->trace(m_serviceWorker); | 90 visitor->trace(m_serviceWorker); |
| 89 HeapSupplement<Navigator>::trace(visitor); | 91 HeapSupplement<Navigator>::trace(visitor); |
| 90 DOMWindowProperty::trace(visitor); | 92 DOMWindowProperty::trace(visitor); |
| 91 } | 93 } |
| 92 | 94 |
| 93 } // namespace blink | 95 } // namespace blink |
| OLD | NEW |