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

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

Issue 2009453002: service worker: Don't control a subframe of an insecure context (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: selfreview Created 4 years, 6 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/service_worker_controllee_request_handl er.h" 5 #include "content/browser/service_worker/service_worker_controllee_request_handl er.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 9
10 #include "base/trace_event/trace_event.h" 10 #include "base/trace_event/trace_event.h"
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 job_->FallbackToNetwork(); 205 job_->FallbackToNetwork();
206 TRACE_EVENT_ASYNC_END2( 206 TRACE_EVENT_ASYNC_END2(
207 "ServiceWorker", 207 "ServiceWorker",
208 "ServiceWorkerControlleeRequestHandler::PrepareForMainResource", 208 "ServiceWorkerControlleeRequestHandler::PrepareForMainResource",
209 job_.get(), 209 job_.get(),
210 "Status", status, 210 "Status", status,
211 "Info", "ServiceWorker is blocked"); 211 "Info", "ServiceWorker is blocked");
212 return; 212 return;
213 } 213 }
214 214
215 if (!provider_host_->is_parent_frame_secure()) {
216 std::set<std::string> schemes;
217 GetContentClient()
218 ->browser()
219 ->GetSchemesBypassingSecureContextCheckWhitelist(&schemes);
220 if (schemes.find(provider_host_->document_url().scheme()) ==
Marijn Kruisselbrink 2016/06/02 22:44:43 Would it make sense to combine both the is_parent_
falken 2016/06/03 08:22:05 I like that and ended up adopting your patch, than
221 schemes.end()) {
222 // TODO(falken): Figure out a way to surface in the page's DevTools
223 // console that the service worker was blocked for security.
224 job_->FallbackToNetwork();
225 TRACE_EVENT_ASYNC_END1(
226 "ServiceWorker",
227 "ServiceWorkerControlleeRequestHandler::PrepareForMainResource",
228 job_.get(), "Info", "Insecure context");
229 return;
230 }
231 }
232
215 if (need_to_update) { 233 if (need_to_update) {
216 force_update_started_ = true; 234 force_update_started_ = true;
217 context_->UpdateServiceWorker( 235 context_->UpdateServiceWorker(
218 registration.get(), true /* force_bypass_cache */, 236 registration.get(), true /* force_bypass_cache */,
219 true /* skip_script_comparison */, provider_host_.get(), 237 true /* skip_script_comparison */, provider_host_.get(),
220 base::Bind(&self::DidUpdateRegistration, weak_factory_.GetWeakPtr(), 238 base::Bind(&self::DidUpdateRegistration, weak_factory_.GetWeakPtr(),
221 registration)); 239 registration));
222 return; 240 return;
223 } 241 }
224 242
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 DCHECK(provider_host_); 425 DCHECK(provider_host_);
408 // Detach the controller so subresource requests also skip the worker. 426 // Detach the controller so subresource requests also skip the worker.
409 provider_host_->NotifyControllerLost(); 427 provider_host_->NotifyControllerLost();
410 } 428 }
411 429
412 void ServiceWorkerControlleeRequestHandler::ClearJob() { 430 void ServiceWorkerControlleeRequestHandler::ClearJob() {
413 job_.reset(); 431 job_.reset();
414 } 432 }
415 433
416 } // namespace content 434 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698