| 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 "core/dom/Document.h" | 8 #include "core/dom/Document.h" |
| 8 #include "core/frame/DOMWindow.h" | 9 #include "core/frame/DOMWindow.h" |
| 9 #include "core/frame/LocalFrame.h" | 10 #include "core/frame/LocalFrame.h" |
| 10 #include "core/html/HTMLLinkElement.h" | 11 #include "core/html/HTMLLinkElement.h" |
| 12 #include "core/inspector/ConsoleMessage.h" |
| 11 #include "core/loader/FrameLoaderClient.h" | 13 #include "core/loader/FrameLoaderClient.h" |
| 12 #include "modules/serviceworkers/NavigatorServiceWorker.h" | 14 #include "modules/serviceworkers/NavigatorServiceWorker.h" |
| 13 #include "modules/serviceworkers/ServiceWorkerContainer.h" | 15 #include "modules/serviceworkers/ServiceWorkerContainer.h" |
| 14 #include "public/platform/Platform.h" | 16 #include "public/platform/Platform.h" |
| 15 #include "public/platform/WebScheduler.h" | 17 #include "public/platform/WebScheduler.h" |
| 16 #include "wtf/PtrUtil.h" | 18 #include "wtf/PtrUtil.h" |
| 17 | 19 |
| 18 namespace blink { | 20 namespace blink { |
| 19 | 21 |
| 20 namespace { | 22 namespace { |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 String scope = m_owner->scope(); | 68 String scope = m_owner->scope(); |
| 67 KURL scopeURL; | 69 KURL scopeURL; |
| 68 if (scope.isNull()) | 70 if (scope.isNull()) |
| 69 scopeURL = KURL(scriptURL, "./"); | 71 scopeURL = KURL(scriptURL, "./"); |
| 70 else | 72 else |
| 71 scopeURL = document.completeURL(scope); | 73 scopeURL = document.completeURL(scope); |
| 72 scopeURL.removeFragmentIdentifier(); | 74 scopeURL.removeFragmentIdentifier(); |
| 73 | 75 |
| 74 TrackExceptionState exceptionState; | 76 TrackExceptionState exceptionState; |
| 75 | 77 |
| 76 NavigatorServiceWorker::serviceWorker(&document, *document.frame()->domWindo
w()->navigator(), exceptionState)->registerServiceWorkerImpl(&document, scriptUR
L, scopeURL, wrapUnique(new RegistrationCallback(m_owner))); | 78 ServiceWorkerContainer* container = NavigatorServiceWorker::serviceWorker(&d
ocument, *document.frame()->domWindow()->navigator(), exceptionState); |
| 79 |
| 80 if (!container) { |
| 81 DCHECK(exceptionState.hadException()); |
| 82 String message = exceptionState.message(); |
| 83 document.addConsoleMessage(ConsoleMessage::create(JSMessageSource, Error
MessageLevel, "Cannot register service worker with <link> element. " + message))
; |
| 84 wrapUnique(new RegistrationCallback(m_owner))->onError(WebServiceWorkerE
rror(WebServiceWorkerError::ErrorTypeSecurity, message)); |
| 85 return; |
| 86 } |
| 87 |
| 88 container->registerServiceWorkerImpl(&document, scriptURL, scopeURL, wrapUni
que(new RegistrationCallback(m_owner))); |
| 77 } | 89 } |
| 78 | 90 |
| 79 bool ServiceWorkerLinkResource::hasLoaded() const | 91 bool ServiceWorkerLinkResource::hasLoaded() const |
| 80 { | 92 { |
| 81 return false; | 93 return false; |
| 82 } | 94 } |
| 83 | 95 |
| 84 void ServiceWorkerLinkResource::ownerRemoved() | 96 void ServiceWorkerLinkResource::ownerRemoved() |
| 85 { | 97 { |
| 86 process(); | 98 process(); |
| 87 } | 99 } |
| 88 | 100 |
| 89 ServiceWorkerLinkResource::ServiceWorkerLinkResource(HTMLLinkElement* owner) | 101 ServiceWorkerLinkResource::ServiceWorkerLinkResource(HTMLLinkElement* owner) |
| 90 : LinkResource(owner) | 102 : LinkResource(owner) |
| 91 { | 103 { |
| 92 } | 104 } |
| 93 | 105 |
| 94 } // namespace blink | 106 } // namespace blink |
| OLD | NEW |