OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/serviceworkers/ServiceWorkerLinkResource.h" | 5 #include "modules/serviceworkers/ServiceWorkerLinkResource.h" |
6 | 6 |
7 #include "bindings/core/v8/ExceptionState.h" | 7 #include "bindings/core/v8/ExceptionState.h" |
8 #include "bindings/core/v8/ScriptState.h" | 8 #include "bindings/core/v8/ScriptState.h" |
9 #include "core/dom/Document.h" | 9 #include "core/dom/Document.h" |
10 #include "core/frame/DOMWindow.h" | 10 #include "core/frame/DOMWindow.h" |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 KURL scriptURL = m_owner->href(); | 73 KURL scriptURL = m_owner->href(); |
74 | 74 |
75 String scope = m_owner->scope(); | 75 String scope = m_owner->scope(); |
76 KURL scopeURL; | 76 KURL scopeURL; |
77 if (scope.isNull()) | 77 if (scope.isNull()) |
78 scopeURL = KURL(scriptURL, "./"); | 78 scopeURL = KURL(scriptURL, "./"); |
79 else | 79 else |
80 scopeURL = document.completeURL(scope); | 80 scopeURL = document.completeURL(scope); |
81 scopeURL.removeFragmentIdentifier(); | 81 scopeURL.removeFragmentIdentifier(); |
82 | 82 |
| 83 bool useCache = m_owner->useCache(); |
| 84 |
83 String errorMessage; | 85 String errorMessage; |
84 ServiceWorkerContainer* container = NavigatorServiceWorker::serviceWorker( | 86 ServiceWorkerContainer* container = NavigatorServiceWorker::serviceWorker( |
85 ScriptState::forMainWorld(m_owner->document().frame()), | 87 ScriptState::forMainWorld(m_owner->document().frame()), |
86 *document.frame()->domWindow()->navigator(), errorMessage); | 88 *document.frame()->domWindow()->navigator(), errorMessage); |
87 | 89 |
88 if (!container) { | 90 if (!container) { |
89 document.addConsoleMessage(ConsoleMessage::create( | 91 document.addConsoleMessage(ConsoleMessage::create( |
90 JSMessageSource, ErrorMessageLevel, | 92 JSMessageSource, ErrorMessageLevel, |
91 "Cannot register service worker with <link> element. " + errorMessage)); | 93 "Cannot register service worker with <link> element. " + errorMessage)); |
92 WTF::makeUnique<RegistrationCallback>(m_owner)->onError( | 94 WTF::makeUnique<RegistrationCallback>(m_owner)->onError( |
93 WebServiceWorkerError(WebServiceWorkerError::ErrorTypeSecurity, | 95 WebServiceWorkerError(WebServiceWorkerError::ErrorTypeSecurity, |
94 errorMessage)); | 96 errorMessage)); |
95 return; | 97 return; |
96 } | 98 } |
97 | 99 |
98 container->registerServiceWorkerImpl( | 100 container->registerServiceWorkerImpl( |
99 &document, scriptURL, scopeURL, | 101 &document, scriptURL, scopeURL, useCache, |
100 WTF::makeUnique<RegistrationCallback>(m_owner)); | 102 WTF::makeUnique<RegistrationCallback>(m_owner)); |
101 } | 103 } |
102 | 104 |
103 bool ServiceWorkerLinkResource::hasLoaded() const { | 105 bool ServiceWorkerLinkResource::hasLoaded() const { |
104 return false; | 106 return false; |
105 } | 107 } |
106 | 108 |
107 void ServiceWorkerLinkResource::ownerRemoved() { | 109 void ServiceWorkerLinkResource::ownerRemoved() { |
108 process(); | 110 process(); |
109 } | 111 } |
110 | 112 |
111 ServiceWorkerLinkResource::ServiceWorkerLinkResource(HTMLLinkElement* owner) | 113 ServiceWorkerLinkResource::ServiceWorkerLinkResource(HTMLLinkElement* owner) |
112 : LinkResource(owner) {} | 114 : LinkResource(owner) {} |
113 | 115 |
114 } // namespace blink | 116 } // namespace blink |
OLD | NEW |