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

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

Issue 2790693002: Split CSP into pre- and post-upgrade checks (Closed)
Patch Set: add unit tests Created 3 years, 8 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 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 callbacks->OnError(WebServiceWorkerError( 239 callbacks->OnError(WebServiceWorkerError(
240 WebServiceWorkerError::kErrorTypeType, 240 WebServiceWorkerError::kErrorTypeType,
241 WebString::FromUTF8("Failed to register a ServiceWorker: " + 241 WebString::FromUTF8("Failed to register a ServiceWorker: " +
242 web_error_message.Utf8()))); 242 web_error_message.Utf8())));
243 return; 243 return;
244 } 244 }
245 245
246 ContentSecurityPolicy* csp = execution_context->GetContentSecurityPolicy(); 246 ContentSecurityPolicy* csp = execution_context->GetContentSecurityPolicy();
247 if (csp) { 247 if (csp) {
248 if (!(csp->AllowRequestWithoutIntegrity( 248 if (!(csp->AllowRequestWithoutIntegrity(
249 WebURLRequest::kRequestContextServiceWorker, script_url) && 249 WebURLRequest::kRequestContextServiceWorker, script_url,
250 ResourceRequest::RedirectStatus::kNoRedirect,
251 SecurityViolationReportingPolicy::kReport,
252 kContentSecurityPolicyHeaderTypeEnforce) &&
250 csp->AllowWorkerContextFromSource( 253 csp->AllowWorkerContextFromSource(
251 script_url, ResourceRequest::RedirectStatus::kNoRedirect, 254 script_url, ResourceRequest::RedirectStatus::kNoRedirect,
252 SecurityViolationReportingPolicy::kReport))) { 255 SecurityViolationReportingPolicy::kReport,
256 kContentSecurityPolicyHeaderTypeEnforce))) {
253 callbacks->OnError(WebServiceWorkerError( 257 callbacks->OnError(WebServiceWorkerError(
254 WebServiceWorkerError::kErrorTypeSecurity, 258 WebServiceWorkerError::kErrorTypeSecurity,
255 String( 259 String(
256 "Failed to register a ServiceWorker: The provided scriptURL ('" + 260 "Failed to register a ServiceWorker: The provided scriptURL ('" +
257 script_url.GetString() + 261 script_url.GetString() +
258 "') violates the Content Security Policy."))); 262 "') violates the Content Security Policy.")));
259 return; 263 return;
260 } 264 }
261 } 265 }
262 266
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 490
487 if (ServiceWorkerContainerClient* client = 491 if (ServiceWorkerContainerClient* client =
488 ServiceWorkerContainerClient::From(execution_context)) { 492 ServiceWorkerContainerClient::From(execution_context)) {
489 provider_ = client->Provider(); 493 provider_ = client->Provider();
490 if (provider_) 494 if (provider_)
491 provider_->SetClient(this); 495 provider_->SetClient(this);
492 } 496 }
493 } 497 }
494 498
495 } // namespace blink 499 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698