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" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 NavigatorServiceWorker* NavigatorServiceWorker::toNavigatorServiceWorker(Navigat
or& navigator) | 47 NavigatorServiceWorker* NavigatorServiceWorker::toNavigatorServiceWorker(Navigat
or& navigator) |
48 { | 48 { |
49 return static_cast<NavigatorServiceWorker*>(HeapSupplement<Navigator>::from(
navigator, supplementName())); | 49 return static_cast<NavigatorServiceWorker*>(HeapSupplement<Navigator>::from(
navigator, supplementName())); |
50 } | 50 } |
51 | 51 |
52 const char* NavigatorServiceWorker::supplementName() | 52 const char* NavigatorServiceWorker::supplementName() |
53 { | 53 { |
54 return "NavigatorServiceWorker"; | 54 return "NavigatorServiceWorker"; |
55 } | 55 } |
56 | 56 |
57 ServiceWorkerContainer* NavigatorServiceWorker::serviceWorker(Navigator& navigat
or, ExceptionState& exceptionState) | 57 ServiceWorkerContainer* NavigatorServiceWorker::serviceWorker(ExecutionContext*
executionContext, Navigator& navigator, ExceptionState& exceptionState) |
58 { | 58 { |
| 59 ASSERT(!navigator.frame() || executionContext->securityOrigin()->canAccessCh
eckSuborigins(navigator.frame()->securityContext()->securityOrigin())); |
59 return NavigatorServiceWorker::from(navigator).serviceWorker(exceptionState)
; | 60 return NavigatorServiceWorker::from(navigator).serviceWorker(exceptionState)
; |
60 } | 61 } |
61 | 62 |
62 ServiceWorkerContainer* NavigatorServiceWorker::serviceWorker(ExceptionState& ex
ceptionState) | 63 ServiceWorkerContainer* NavigatorServiceWorker::serviceWorker(ExceptionState& ex
ceptionState) |
63 { | 64 { |
64 if (frame() && !frame()->securityContext()->securityOrigin()->canAccessServi
ceWorkers()) { | 65 if (frame() && !frame()->securityContext()->securityOrigin()->canAccessServi
ceWorkers()) { |
65 if (frame()->securityContext()->isSandboxed(SandboxOrigin)) | 66 if (frame()->securityContext()->isSandboxed(SandboxOrigin)) |
66 exceptionState.throwSecurityError("Service worker is disabled becaus
e the context is sandboxed and lacks the 'allow-same-origin' flag."); | 67 exceptionState.throwSecurityError("Service worker is disabled becaus
e the context is sandboxed and lacks the 'allow-same-origin' flag."); |
67 else | 68 else |
68 exceptionState.throwSecurityError("Access to service workers is deni
ed in this document origin."); | 69 exceptionState.throwSecurityError("Access to service workers is deni
ed in this document origin."); |
(...skipping 15 matching lines...) Expand all Loading... |
84 } | 85 } |
85 | 86 |
86 DEFINE_TRACE(NavigatorServiceWorker) | 87 DEFINE_TRACE(NavigatorServiceWorker) |
87 { | 88 { |
88 visitor->trace(m_serviceWorker); | 89 visitor->trace(m_serviceWorker); |
89 HeapSupplement<Navigator>::trace(visitor); | 90 HeapSupplement<Navigator>::trace(visitor); |
90 DOMWindowProperty::trace(visitor); | 91 DOMWindowProperty::trace(visitor); |
91 } | 92 } |
92 | 93 |
93 } // namespace blink | 94 } // namespace blink |
OLD | NEW |