Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(346)

Side by Side Diff: third_party/WebKit/Source/modules/serviceworkers/ServiceWorkerContainer.cpp

Issue 1373773003: Implement 'window.isSecureContext'. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: document. Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 } 201 }
202 202
203 ExecutionContext* executionContext = scriptState->executionContext(); 203 ExecutionContext* executionContext = scriptState->executionContext();
204 // FIXME: May be null due to worker termination: http://crbug.com/413518. 204 // FIXME: May be null due to worker termination: http://crbug.com/413518.
205 if (!executionContext) 205 if (!executionContext)
206 return ScriptPromise(); 206 return ScriptPromise();
207 207
208 RefPtr<SecurityOrigin> documentOrigin = executionContext->securityOrigin(); 208 RefPtr<SecurityOrigin> documentOrigin = executionContext->securityOrigin();
209 String errorMessage; 209 String errorMessage;
210 // Restrict to secure origins: https://w3c.github.io/webappsec/specs/powerfu lfeatures/#settings-privileged 210 // Restrict to secure origins: https://w3c.github.io/webappsec/specs/powerfu lfeatures/#settings-privileged
211 if (!executionContext->isPrivilegedContext(errorMessage)) { 211 if (!executionContext->isSecureContext(errorMessage)) {
212 resolver->reject(DOMException::create(NotSupportedError, errorMessage)); 212 resolver->reject(DOMException::create(NotSupportedError, errorMessage));
213 return promise; 213 return promise;
214 } 214 }
215 215
216 KURL pageURL = KURL(KURL(), documentOrigin->toString()); 216 KURL pageURL = KURL(KURL(), documentOrigin->toString());
217 if (!SchemeRegistry::shouldTreatURLSchemeAsAllowingServiceWorkers(pageURL.pr otocol())) { 217 if (!SchemeRegistry::shouldTreatURLSchemeAsAllowingServiceWorkers(pageURL.pr otocol())) {
218 resolver->reject(DOMException::create(SecurityError, "Failed to register a ServiceWorker: The URL protocol of the current origin ('" + documentOrigin->t oString() + "') is not supported.")); 218 resolver->reject(DOMException::create(SecurityError, "Failed to register a ServiceWorker: The URL protocol of the current origin ('" + documentOrigin->t oString() + "') is not supported."));
219 return promise; 219 return promise;
220 } 220 }
221 221
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 return promise; 269 return promise;
270 } 270 }
271 271
272 ExecutionContext* executionContext = scriptState->executionContext(); 272 ExecutionContext* executionContext = scriptState->executionContext();
273 // FIXME: May be null due to worker termination: http://crbug.com/413518. 273 // FIXME: May be null due to worker termination: http://crbug.com/413518.
274 if (!executionContext) 274 if (!executionContext)
275 return ScriptPromise(); 275 return ScriptPromise();
276 276
277 RefPtr<SecurityOrigin> documentOrigin = executionContext->securityOrigin(); 277 RefPtr<SecurityOrigin> documentOrigin = executionContext->securityOrigin();
278 String errorMessage; 278 String errorMessage;
279 if (!executionContext->isPrivilegedContext(errorMessage)) { 279 if (!executionContext->isSecureContext(errorMessage)) {
280 resolver->reject(DOMException::create(NotSupportedError, errorMessage)); 280 resolver->reject(DOMException::create(NotSupportedError, errorMessage));
281 return promise; 281 return promise;
282 } 282 }
283 283
284 KURL pageURL = KURL(KURL(), documentOrigin->toString()); 284 KURL pageURL = KURL(KURL(), documentOrigin->toString());
285 if (!SchemeRegistry::shouldTreatURLSchemeAsAllowingServiceWorkers(pageURL.pr otocol())) { 285 if (!SchemeRegistry::shouldTreatURLSchemeAsAllowingServiceWorkers(pageURL.pr otocol())) {
286 resolver->reject(DOMException::create(SecurityError, "Failed to get a Se rviceWorkerRegistration: The URL protocol of the current origin ('" + documentOr igin->toString() + "') is not supported.")); 286 resolver->reject(DOMException::create(SecurityError, "Failed to get a Se rviceWorkerRegistration: The URL protocol of the current origin ('" + documentOr igin->toString() + "') is not supported."));
287 return promise; 287 return promise;
288 } 288 }
289 289
(...skipping 15 matching lines...) Expand all
305 ScriptPromise promise = resolver->promise(); 305 ScriptPromise promise = resolver->promise();
306 306
307 if (!m_provider) { 307 if (!m_provider) {
308 resolver->reject(DOMException::create(InvalidStateError, "Failed to get ServiceWorkerRegistration objects: The document is in an invalid state.")); 308 resolver->reject(DOMException::create(InvalidStateError, "Failed to get ServiceWorkerRegistration objects: The document is in an invalid state."));
309 return promise; 309 return promise;
310 } 310 }
311 311
312 ExecutionContext* executionContext = scriptState->executionContext(); 312 ExecutionContext* executionContext = scriptState->executionContext();
313 RefPtr<SecurityOrigin> documentOrigin = executionContext->securityOrigin(); 313 RefPtr<SecurityOrigin> documentOrigin = executionContext->securityOrigin();
314 String errorMessage; 314 String errorMessage;
315 if (!executionContext->isPrivilegedContext(errorMessage)) { 315 if (!executionContext->isSecureContext(errorMessage)) {
316 resolver->reject(DOMException::create(NotSupportedError, errorMessage)); 316 resolver->reject(DOMException::create(NotSupportedError, errorMessage));
317 return promise; 317 return promise;
318 } 318 }
319 319
320 KURL pageURL = KURL(KURL(), documentOrigin->toString()); 320 KURL pageURL = KURL(KURL(), documentOrigin->toString());
321 if (!SchemeRegistry::shouldTreatURLSchemeAsAllowingServiceWorkers(pageURL.pr otocol())) { 321 if (!SchemeRegistry::shouldTreatURLSchemeAsAllowingServiceWorkers(pageURL.pr otocol())) {
322 resolver->reject(DOMException::create(SecurityError, "Failed to get Serv iceWorkerRegistration objects: The URL protocol of the current origin ('" + docu mentOrigin->toString() + "') is not supported.")); 322 resolver->reject(DOMException::create(SecurityError, "Failed to get Serv iceWorkerRegistration objects: The URL protocol of the current origin ('" + docu mentOrigin->toString() + "') is not supported."));
323 return promise; 323 return promise;
324 } 324 }
325 325
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 return; 398 return;
399 399
400 if (ServiceWorkerContainerClient* client = ServiceWorkerContainerClient::fro m(executionContext)) { 400 if (ServiceWorkerContainerClient* client = ServiceWorkerContainerClient::fro m(executionContext)) {
401 m_provider = client->provider(); 401 m_provider = client->provider();
402 if (m_provider) 402 if (m_provider)
403 m_provider->setClient(this); 403 m_provider->setClient(this);
404 } 404 }
405 } 405 }
406 406
407 } // namespace blink 407 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/modules/quota/StorageManager.cpp ('k') | third_party/WebKit/Source/web/WebDocument.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698