OLD | NEW |
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 Loading... |
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 std::unique_ptr<ForeignFetchRequestHandler> handler( | 77 std::unique_ptr<ForeignFetchRequestHandler> handler( |
73 new ForeignFetchRequestHandler( | 78 new ForeignFetchRequestHandler( |
74 context_wrapper, blob_storage_context->AsWeakPtr(), request_mode, | 79 context_wrapper, blob_storage_context->AsWeakPtr(), request_mode, |
75 credentials_mode, redirect_mode, resource_type, request_context_type, | 80 credentials_mode, redirect_mode, resource_type, request_context_type, |
76 frame_type, body)); | 81 frame_type, body)); |
77 request->SetUserData(&kUserDataKey, handler.release()); | 82 request->SetUserData(&kUserDataKey, handler.release()); |
78 } | 83 } |
79 | 84 |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 } | 231 } |
227 return target_worker_.get(); | 232 return target_worker_.get(); |
228 } | 233 } |
229 | 234 |
230 void ForeignFetchRequestHandler::ClearJob() { | 235 void ForeignFetchRequestHandler::ClearJob() { |
231 job_.reset(); | 236 job_.reset(); |
232 target_worker_ = nullptr; | 237 target_worker_ = nullptr; |
233 } | 238 } |
234 | 239 |
235 } // namespace content | 240 } // namespace content |
OLD | NEW |