| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 RefPtr<ScriptPromiseResolverWithContext> resolver = ScriptPromiseResolverWit
hContext::create(ScriptState::current(toIsolate(executionContext))); | 80 RefPtr<ScriptPromiseResolverWithContext> resolver = ScriptPromiseResolverWit
hContext::create(ScriptState::current(toIsolate(executionContext))); |
| 81 ScriptPromise promise = resolver->promise(); | 81 ScriptPromise promise = resolver->promise(); |
| 82 | 82 |
| 83 if (!m_provider) { | 83 if (!m_provider) { |
| 84 resolver->reject(DOMException::create(InvalidStateError, "No associated
provider is available")); | 84 resolver->reject(DOMException::create(InvalidStateError, "No associated
provider is available")); |
| 85 return promise; | 85 return promise; |
| 86 } | 86 } |
| 87 | 87 |
| 88 RefPtr<SecurityOrigin> documentOrigin = executionContext->securityOrigin(); | 88 RefPtr<SecurityOrigin> documentOrigin = executionContext->securityOrigin(); |
| 89 KURL patternURL = executionContext->completeURL(options.scope); | 89 KURL patternURL = executionContext->completeURL(options.scope); |
| 90 patternURL.removeFragmentIdentifier(); |
| 90 if (!documentOrigin->canRequest(patternURL)) { | 91 if (!documentOrigin->canRequest(patternURL)) { |
| 91 resolver->reject(DOMException::create(SecurityError, "Can only register
for patterns in the document's origin.")); | 92 resolver->reject(DOMException::create(SecurityError, "Can only register
for patterns in the document's origin.")); |
| 92 return promise; | 93 return promise; |
| 93 } | 94 } |
| 94 | 95 |
| 95 KURL scriptURL = executionContext->completeURL(url); | 96 KURL scriptURL = executionContext->completeURL(url); |
| 97 scriptURL.removeFragmentIdentifier(); |
| 96 if (!documentOrigin->canRequest(scriptURL)) { | 98 if (!documentOrigin->canRequest(scriptURL)) { |
| 97 resolver->reject(DOMException::create(SecurityError, "Script must be in
document's origin.")); | 99 resolver->reject(DOMException::create(SecurityError, "Script must be in
document's origin.")); |
| 98 return promise; | 100 return promise; |
| 99 } | 101 } |
| 100 | 102 |
| 101 m_provider->registerServiceWorker(patternURL, scriptURL, new CallbackPromise
Adapter<ServiceWorker, ServiceWorkerError>(resolver)); | 103 m_provider->registerServiceWorker(patternURL, scriptURL, new CallbackPromise
Adapter<ServiceWorker, ServiceWorkerError>(resolver)); |
| 102 return promise; | 104 return promise; |
| 103 } | 105 } |
| 104 | 106 |
| 105 class UndefinedValue { | 107 class UndefinedValue { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 121 RefPtr<ScriptPromiseResolverWithContext> resolver = ScriptPromiseResolverWit
hContext::create(ScriptState::current(toIsolate(executionContext))); | 123 RefPtr<ScriptPromiseResolverWithContext> resolver = ScriptPromiseResolverWit
hContext::create(ScriptState::current(toIsolate(executionContext))); |
| 122 ScriptPromise promise = resolver->promise(); | 124 ScriptPromise promise = resolver->promise(); |
| 123 | 125 |
| 124 if (!m_provider) { | 126 if (!m_provider) { |
| 125 resolver->reject(DOMException::create(InvalidStateError, "No associated
provider is available")); | 127 resolver->reject(DOMException::create(InvalidStateError, "No associated
provider is available")); |
| 126 return promise; | 128 return promise; |
| 127 } | 129 } |
| 128 | 130 |
| 129 RefPtr<SecurityOrigin> documentOrigin = executionContext->securityOrigin(); | 131 RefPtr<SecurityOrigin> documentOrigin = executionContext->securityOrigin(); |
| 130 KURL patternURL = executionContext->completeURL(pattern); | 132 KURL patternURL = executionContext->completeURL(pattern); |
| 133 patternURL.removeFragmentIdentifier(); |
| 131 if (!pattern.isEmpty() && !documentOrigin->canRequest(patternURL)) { | 134 if (!pattern.isEmpty() && !documentOrigin->canRequest(patternURL)) { |
| 132 resolver->reject(DOMException::create(SecurityError, "Can only unregiste
r for patterns in the document's origin.")); | 135 resolver->reject(DOMException::create(SecurityError, "Can only unregiste
r for patterns in the document's origin.")); |
| 133 return promise; | 136 return promise; |
| 134 } | 137 } |
| 135 | 138 |
| 136 m_provider->unregisterServiceWorker(patternURL, new CallbackPromiseAdapter<U
ndefinedValue, ServiceWorkerError>(resolver)); | 139 m_provider->unregisterServiceWorker(patternURL, new CallbackPromiseAdapter<U
ndefinedValue, ServiceWorkerError>(resolver)); |
| 137 return promise; | 140 return promise; |
| 138 } | 141 } |
| 139 | 142 |
| 140 void ServiceWorkerContainer::setCurrentServiceWorker(blink::WebServiceWorker* se
rviceWorker) | 143 void ServiceWorkerContainer::setCurrentServiceWorker(blink::WebServiceWorker* se
rviceWorker) |
| (...skipping 24 matching lines...) Expand all Loading... |
| 165 return; | 168 return; |
| 166 | 169 |
| 167 if (ServiceWorkerContainerClient* client = ServiceWorkerContainerClient::fro
m(executionContext)) { | 170 if (ServiceWorkerContainerClient* client = ServiceWorkerContainerClient::fro
m(executionContext)) { |
| 168 m_provider = client->provider(); | 171 m_provider = client->provider(); |
| 169 if (m_provider) | 172 if (m_provider) |
| 170 m_provider->setClient(this); | 173 m_provider->setClient(this); |
| 171 } | 174 } |
| 172 } | 175 } |
| 173 | 176 |
| 174 } // namespace WebCore | 177 } // namespace WebCore |
| OLD | NEW |