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