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

Unified Diff: content/browser/service_worker/service_worker_url_request_job.cc

Issue 1242953007: Skip the Service Worker CORS fallback for same origin requests. [2/2 chromium] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/service_worker/service_worker_url_request_job.cc
diff --git a/content/browser/service_worker/service_worker_url_request_job.cc b/content/browser/service_worker/service_worker_url_request_job.cc
index ddfa92b6d695c61add533da7014bf8c793d1af5a..159ea78cefd7ea65dd0e5d30f5e2fba44efa6e37 100644
--- a/content/browser/service_worker/service_worker_url_request_job.cc
+++ b/content/browser/service_worker/service_worker_url_request_job.cc
@@ -602,12 +602,15 @@ void ServiceWorkerURLRequestJob::DidDispatchFetchEvent(
}
if (fetch_result == SERVICE_WORKER_FETCH_EVENT_RESULT_FALLBACK) {
- // When the request_mode is |CORS| or |CORS-with-forced-preflight| we can't
- // simply fallback to the network in the browser process. It is because the
- // CORS preflight logic is implemented in the renderer. So we returns a
- // fall_back_required response to the renderer.
- if (request_mode_ == FETCH_REQUEST_MODE_CORS ||
- request_mode_ == FETCH_REQUEST_MODE_CORS_WITH_FORCED_PREFLIGHT) {
+ // When the request_mode is |CORS| or |CORS-with-forced-preflight| and the
+ // origin of the request URL is different from the security origin of the
+ // document, we can't simply fallback to the network in the browser process.
+ // It is because the CORS preflight logic is implemented in the renderer. So
+ // we returns a fall_back_required response to the renderer.
+ if ((request_mode_ == FETCH_REQUEST_MODE_CORS ||
+ request_mode_ == FETCH_REQUEST_MODE_CORS_WITH_FORCED_PREFLIGHT) &&
+ provider_host_->document_url().GetOrigin() !=
+ request()->url().GetOrigin()) {
fall_back_required_ = true;
RecordResult(ServiceWorkerMetrics::REQUEST_JOB_FALLBACK_FOR_CORS);
CreateResponseHeader(
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698