| 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 "core/dom/Document.h" | 8 #include "core/dom/Document.h" |
| 9 #include "core/frame/DOMWindow.h" | 9 #include "core/frame/DOMWindow.h" |
| 10 #include "core/frame/LocalFrame.h" | 10 #include "core/frame/LocalFrame.h" |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 | 83 |
| 84 ServiceWorkerContainer* container = NavigatorServiceWorker::serviceWorker( | 84 ServiceWorkerContainer* container = NavigatorServiceWorker::serviceWorker( |
| 85 &document, *document.frame()->domWindow()->navigator(), exceptionState); | 85 &document, *document.frame()->domWindow()->navigator(), exceptionState); |
| 86 | 86 |
| 87 if (!container) { | 87 if (!container) { |
| 88 DCHECK(exceptionState.hadException()); | 88 DCHECK(exceptionState.hadException()); |
| 89 String message = exceptionState.message(); | 89 String message = exceptionState.message(); |
| 90 document.addConsoleMessage(ConsoleMessage::create( | 90 document.addConsoleMessage(ConsoleMessage::create( |
| 91 JSMessageSource, ErrorMessageLevel, | 91 JSMessageSource, ErrorMessageLevel, |
| 92 "Cannot register service worker with <link> element. " + message)); | 92 "Cannot register service worker with <link> element. " + message)); |
| 93 wrapUnique(new RegistrationCallback(m_owner)) | 93 makeUnique<RegistrationCallback>(m_owner)->onError(WebServiceWorkerError( |
| 94 ->onError(WebServiceWorkerError( | 94 WebServiceWorkerError::ErrorTypeSecurity, message)); |
| 95 WebServiceWorkerError::ErrorTypeSecurity, message)); | |
| 96 return; | 95 return; |
| 97 } | 96 } |
| 98 | 97 |
| 99 container->registerServiceWorkerImpl( | 98 container->registerServiceWorkerImpl( |
| 100 &document, scriptURL, scopeURL, | 99 &document, scriptURL, scopeURL, |
| 101 wrapUnique(new RegistrationCallback(m_owner))); | 100 makeUnique<RegistrationCallback>(m_owner)); |
| 102 } | 101 } |
| 103 | 102 |
| 104 bool ServiceWorkerLinkResource::hasLoaded() const { | 103 bool ServiceWorkerLinkResource::hasLoaded() const { |
| 105 return false; | 104 return false; |
| 106 } | 105 } |
| 107 | 106 |
| 108 void ServiceWorkerLinkResource::ownerRemoved() { | 107 void ServiceWorkerLinkResource::ownerRemoved() { |
| 109 process(); | 108 process(); |
| 110 } | 109 } |
| 111 | 110 |
| 112 ServiceWorkerLinkResource::ServiceWorkerLinkResource(HTMLLinkElement* owner) | 111 ServiceWorkerLinkResource::ServiceWorkerLinkResource(HTMLLinkElement* owner) |
| 113 : LinkResource(owner) {} | 112 : LinkResource(owner) {} |
| 114 | 113 |
| 115 } // namespace blink | 114 } // namespace blink |
| OLD | NEW |