| 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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 // FIXME: This should use the container's execution context, not | 115 // FIXME: This should use the container's execution context, not |
| 116 // the callers. | 116 // the callers. |
| 117 ExecutionContext* executionContext = scriptState->executionContext(); | 117 ExecutionContext* executionContext = scriptState->executionContext(); |
| 118 RefPtr<SecurityOrigin> documentOrigin = executionContext->securityOrigin(); | 118 RefPtr<SecurityOrigin> documentOrigin = executionContext->securityOrigin(); |
| 119 String errorMessage; | 119 String errorMessage; |
| 120 if (!documentOrigin->canAccessFeatureRequiringSecureOrigin(errorMessage)) { | 120 if (!documentOrigin->canAccessFeatureRequiringSecureOrigin(errorMessage)) { |
| 121 resolver->reject(DOMException::create(NotSupportedError, errorMessage)); | 121 resolver->reject(DOMException::create(NotSupportedError, errorMessage)); |
| 122 return promise; | 122 return promise; |
| 123 } | 123 } |
| 124 | 124 |
| 125 if (!executionContext->url().protocolIsInHTTPFamily()) { |
| 126 resolver->reject(DOMException::create(SecurityError, "The URL protocol o
f the current origin is not supported: " + executionContext->url().protocol())); |
| 127 return promise; |
| 128 } |
| 129 |
| 125 KURL patternURL = executionContext->completeURL(options.scope()); | 130 KURL patternURL = executionContext->completeURL(options.scope()); |
| 126 patternURL.removeFragmentIdentifier(); | 131 patternURL.removeFragmentIdentifier(); |
| 127 if (!documentOrigin->canRequest(patternURL)) { | 132 if (!documentOrigin->canRequest(patternURL)) { |
| 128 resolver->reject(DOMException::create(SecurityError, "The scope must mat
ch the current origin.")); | 133 resolver->reject(DOMException::create(SecurityError, "The scope must mat
ch the current origin.")); |
| 129 return promise; | 134 return promise; |
| 130 } | 135 } |
| 131 | 136 |
| 132 KURL scriptURL = executionContext->completeURL(url); | 137 KURL scriptURL = executionContext->completeURL(url); |
| 133 scriptURL.removeFragmentIdentifier(); | 138 scriptURL.removeFragmentIdentifier(); |
| 134 if (!documentOrigin->canRequest(scriptURL)) { | 139 if (!documentOrigin->canRequest(scriptURL)) { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 // FIXME: This should use the container's execution context, not | 178 // FIXME: This should use the container's execution context, not |
| 174 // the callers. | 179 // the callers. |
| 175 ExecutionContext* executionContext = scriptState->executionContext(); | 180 ExecutionContext* executionContext = scriptState->executionContext(); |
| 176 RefPtr<SecurityOrigin> documentOrigin = executionContext->securityOrigin(); | 181 RefPtr<SecurityOrigin> documentOrigin = executionContext->securityOrigin(); |
| 177 String errorMessage; | 182 String errorMessage; |
| 178 if (!documentOrigin->canAccessFeatureRequiringSecureOrigin(errorMessage)) { | 183 if (!documentOrigin->canAccessFeatureRequiringSecureOrigin(errorMessage)) { |
| 179 resolver->reject(DOMException::create(NotSupportedError, errorMessage)); | 184 resolver->reject(DOMException::create(NotSupportedError, errorMessage)); |
| 180 return promise; | 185 return promise; |
| 181 } | 186 } |
| 182 | 187 |
| 188 if (!executionContext->url().protocolIsInHTTPFamily()) { |
| 189 resolver->reject(DOMException::create(SecurityError, "The URL protocol o
f the current origin is not supported: " + executionContext->url().protocol())); |
| 190 return promise; |
| 191 } |
| 192 |
| 183 KURL completedURL = executionContext->completeURL(documentURL); | 193 KURL completedURL = executionContext->completeURL(documentURL); |
| 184 completedURL.removeFragmentIdentifier(); | 194 completedURL.removeFragmentIdentifier(); |
| 185 if (!documentOrigin->canRequest(completedURL)) { | 195 if (!documentOrigin->canRequest(completedURL)) { |
| 186 resolver->reject(DOMException::create(SecurityError, "The documentURL mu
st match the current origin.")); | 196 resolver->reject(DOMException::create(SecurityError, "The documentURL mu
st match the current origin.")); |
| 187 return promise; | 197 return promise; |
| 188 } | 198 } |
| 189 m_provider->getRegistration(completedURL, new GetRegistrationCallback(resolv
er)); | 199 m_provider->getRegistration(completedURL, new GetRegistrationCallback(resolv
er)); |
| 190 | 200 |
| 191 return promise; | 201 return promise; |
| 192 } | 202 } |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 m_ready = createReadyProperty(); | 279 m_ready = createReadyProperty(); |
| 270 | 280 |
| 271 if (ServiceWorkerContainerClient* client = ServiceWorkerContainerClient::fro
m(executionContext)) { | 281 if (ServiceWorkerContainerClient* client = ServiceWorkerContainerClient::fro
m(executionContext)) { |
| 272 m_provider = client->provider(); | 282 m_provider = client->provider(); |
| 273 if (m_provider) | 283 if (m_provider) |
| 274 m_provider->setClient(this); | 284 m_provider->setClient(this); |
| 275 } | 285 } |
| 276 } | 286 } |
| 277 | 287 |
| 278 } // namespace blink | 288 } // namespace blink |
| OLD | NEW |