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

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

Issue 2110163002: Correctly set initiated_in_secure_context on requests from shared/service workers, (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@skip-service-worker-foreign-fetch
Patch Set: wrap layout test at 80 columns Created 4 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 unified diff | Download patch
« no previous file with comments | « no previous file | content/renderer/service_worker/service_worker_context_client.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 bool initiated_in_secure_context) { 62 bool initiated_in_secure_context) {
63 if (!context_wrapper) 63 if (!context_wrapper)
64 return; 64 return;
65 65
66 if (skip_service_worker == SkipServiceWorker::ALL) 66 if (skip_service_worker == SkipServiceWorker::ALL)
67 return; 67 return;
68 68
69 if (!initiated_in_secure_context) 69 if (!initiated_in_secure_context)
70 return; 70 return;
71 71
72 if (ServiceWorkerUtils::IsMainResourceType(resource_type))
73 return;
74
75 if (request->initiator().IsSameOriginWith(url::Origin(request->url())))
76 return;
77
72 if (!context_wrapper->OriginHasForeignFetchRegistrations( 78 if (!context_wrapper->OriginHasForeignFetchRegistrations(
73 request->url().GetOrigin())) { 79 request->url().GetOrigin())) {
74 return; 80 return;
75 } 81 }
76 82
77 if (request->initiator().IsSameOriginWith(url::Origin(request->url())))
78 return;
79
80 if (ServiceWorkerUtils::IsMainResourceType(resource_type))
81 return;
82
83 // Any more precise checks to see if the request should be intercepted are 83 // Any more precise checks to see if the request should be intercepted are
84 // asynchronous, so just create our handler in all cases. 84 // asynchronous, so just create our handler in all cases.
85 std::unique_ptr<ForeignFetchRequestHandler> handler( 85 std::unique_ptr<ForeignFetchRequestHandler> handler(
86 new ForeignFetchRequestHandler( 86 new ForeignFetchRequestHandler(
87 context_wrapper, blob_storage_context->AsWeakPtr(), request_mode, 87 context_wrapper, blob_storage_context->AsWeakPtr(), request_mode,
88 credentials_mode, redirect_mode, resource_type, request_context_type, 88 credentials_mode, redirect_mode, resource_type, request_context_type,
89 frame_type, body)); 89 frame_type, body));
90 request->SetUserData(&kUserDataKey, handler.release()); 90 request->SetUserData(&kUserDataKey, handler.release());
91 } 91 }
92 92
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 } 228 }
229 return target_worker_.get(); 229 return target_worker_.get();
230 } 230 }
231 231
232 void ForeignFetchRequestHandler::ClearJob() { 232 void ForeignFetchRequestHandler::ClearJob() {
233 job_.reset(); 233 job_.reset();
234 target_worker_ = nullptr; 234 target_worker_ = nullptr;
235 } 235 }
236 236
237 } // namespace content 237 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/renderer/service_worker/service_worker_context_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698