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

Side by Side Diff: content/browser/service_worker/foreign_fetch_request_handler.cc

Issue 1870743002: Foreign fetch should not intercept same origin or main resource requests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add same origin test, and unregister service workers in tests Created 4 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 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/service_worker/foreign_fetch_request_handler.h" 5 #include "content/browser/service_worker/foreign_fetch_request_handler.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "content/browser/service_worker/service_worker_context_wrapper.h" 10 #include "content/browser/service_worker/service_worker_context_wrapper.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 scoped_refptr<ResourceRequestBody> body) { 60 scoped_refptr<ResourceRequestBody> body) {
61 if (!context_wrapper) { 61 if (!context_wrapper) {
62 return; 62 return;
63 } 63 }
64 64
65 if (!context_wrapper->OriginHasForeignFetchRegistrations( 65 if (!context_wrapper->OriginHasForeignFetchRegistrations(
66 request->url().GetOrigin())) { 66 request->url().GetOrigin())) {
67 return; 67 return;
68 } 68 }
69 69
70 if (request->initiator().IsSameOriginWith(url::Origin(request->url())))
71 return;
72 if (ServiceWorkerUtils::IsMainResourceType(resource_type))
73 return;
74
70 // Any more precise checks to see if the request should be intercepted are 75 // Any more precise checks to see if the request should be intercepted are
71 // asynchronous, so just create our handler in all cases. 76 // asynchronous, so just create our handler in all cases.
72 scoped_ptr<ForeignFetchRequestHandler> handler(new ForeignFetchRequestHandler( 77 scoped_ptr<ForeignFetchRequestHandler> handler(new ForeignFetchRequestHandler(
73 context_wrapper, blob_storage_context->AsWeakPtr(), request_mode, 78 context_wrapper, blob_storage_context->AsWeakPtr(), request_mode,
74 credentials_mode, redirect_mode, resource_type, request_context_type, 79 credentials_mode, redirect_mode, resource_type, request_context_type,
75 frame_type, body)); 80 frame_type, body));
76 request->SetUserData(&kUserDataKey, handler.release()); 81 request->SetUserData(&kUserDataKey, handler.release());
77 } 82 }
78 83
79 ForeignFetchRequestHandler* ForeignFetchRequestHandler::GetHandler( 84 ForeignFetchRequestHandler* ForeignFetchRequestHandler::GetHandler(
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 } 230 }
226 return target_worker_.get(); 231 return target_worker_.get();
227 } 232 }
228 233
229 void ForeignFetchRequestHandler::ClearJob() { 234 void ForeignFetchRequestHandler::ClearJob() {
230 job_.reset(); 235 job_.reset();
231 target_worker_ = nullptr; 236 target_worker_ = nullptr;
232 } 237 }
233 238
234 } // namespace content 239 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698