| 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 "bindings/core/v8/V8Binding.h" |
| 9 #include "core/dom/Document.h" | 10 #include "core/dom/Document.h" |
| 10 #include "core/frame/DOMWindow.h" | 11 #include "core/frame/DOMWindow.h" |
| 11 #include "core/frame/LocalFrame.h" | 12 #include "core/frame/LocalFrame.h" |
| 12 #include "core/frame/LocalFrameClient.h" | 13 #include "core/frame/LocalFrameClient.h" |
| 13 #include "core/html/HTMLLinkElement.h" | 14 #include "core/html/HTMLLinkElement.h" |
| 14 #include "core/inspector/ConsoleMessage.h" | 15 #include "core/inspector/ConsoleMessage.h" |
| 15 #include "modules/serviceworkers/NavigatorServiceWorker.h" | 16 #include "modules/serviceworkers/NavigatorServiceWorker.h" |
| 16 #include "modules/serviceworkers/ServiceWorkerContainer.h" | 17 #include "modules/serviceworkers/ServiceWorkerContainer.h" |
| 17 #include "public/platform/Platform.h" | 18 #include "public/platform/Platform.h" |
| 18 #include "public/platform/WebScheduler.h" | 19 #include "public/platform/WebScheduler.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 String scope = m_owner->scope(); | 76 String scope = m_owner->scope(); |
| 76 KURL scopeURL; | 77 KURL scopeURL; |
| 77 if (scope.isNull()) | 78 if (scope.isNull()) |
| 78 scopeURL = KURL(scriptURL, "./"); | 79 scopeURL = KURL(scriptURL, "./"); |
| 79 else | 80 else |
| 80 scopeURL = document.completeURL(scope); | 81 scopeURL = document.completeURL(scope); |
| 81 scopeURL.removeFragmentIdentifier(); | 82 scopeURL.removeFragmentIdentifier(); |
| 82 | 83 |
| 83 String errorMessage; | 84 String errorMessage; |
| 84 ServiceWorkerContainer* container = NavigatorServiceWorker::serviceWorker( | 85 ServiceWorkerContainer* container = NavigatorServiceWorker::serviceWorker( |
| 85 ScriptState::forMainWorld(m_owner->document().frame()), | 86 toScriptStateForMainWorld(m_owner->document().frame()), |
| 86 *document.frame()->domWindow()->navigator(), errorMessage); | 87 *document.frame()->domWindow()->navigator(), errorMessage); |
| 87 | 88 |
| 88 if (!container) { | 89 if (!container) { |
| 89 document.addConsoleMessage(ConsoleMessage::create( | 90 document.addConsoleMessage(ConsoleMessage::create( |
| 90 JSMessageSource, ErrorMessageLevel, | 91 JSMessageSource, ErrorMessageLevel, |
| 91 "Cannot register service worker with <link> element. " + errorMessage)); | 92 "Cannot register service worker with <link> element. " + errorMessage)); |
| 92 WTF::makeUnique<RegistrationCallback>(m_owner)->onError( | 93 WTF::makeUnique<RegistrationCallback>(m_owner)->onError( |
| 93 WebServiceWorkerError(WebServiceWorkerError::ErrorTypeSecurity, | 94 WebServiceWorkerError(WebServiceWorkerError::ErrorTypeSecurity, |
| 94 errorMessage)); | 95 errorMessage)); |
| 95 return; | 96 return; |
| 96 } | 97 } |
| 97 | 98 |
| 98 container->registerServiceWorkerImpl( | 99 container->registerServiceWorkerImpl( |
| 99 &document, scriptURL, scopeURL, | 100 &document, scriptURL, scopeURL, |
| 100 WTF::makeUnique<RegistrationCallback>(m_owner)); | 101 WTF::makeUnique<RegistrationCallback>(m_owner)); |
| 101 } | 102 } |
| 102 | 103 |
| 103 bool ServiceWorkerLinkResource::hasLoaded() const { | 104 bool ServiceWorkerLinkResource::hasLoaded() const { |
| 104 return false; | 105 return false; |
| 105 } | 106 } |
| 106 | 107 |
| 107 void ServiceWorkerLinkResource::ownerRemoved() { | 108 void ServiceWorkerLinkResource::ownerRemoved() { |
| 108 process(); | 109 process(); |
| 109 } | 110 } |
| 110 | 111 |
| 111 ServiceWorkerLinkResource::ServiceWorkerLinkResource(HTMLLinkElement* owner) | 112 ServiceWorkerLinkResource::ServiceWorkerLinkResource(HTMLLinkElement* owner) |
| 112 : LinkResource(owner) {} | 113 : LinkResource(owner) {} |
| 113 | 114 |
| 114 } // namespace blink | 115 } // namespace blink |
| OLD | NEW |