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

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

Issue 637243003: Service Worker: Obey content settings when deciding to control a page (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@content
Patch Set: explicit, and better log Created 6 years, 2 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
Index: content/browser/service_worker/service_worker_controllee_request_handler.cc
diff --git a/content/browser/service_worker/service_worker_controllee_request_handler.cc b/content/browser/service_worker/service_worker_controllee_request_handler.cc
index 82470e1af9fd9352f252fd5b42a29e34205c48c6..c5fc42f318b758ad533b878f0ce085e94fecd6a6 100644
--- a/content/browser/service_worker/service_worker_controllee_request_handler.cc
+++ b/content/browser/service_worker/service_worker_controllee_request_handler.cc
@@ -13,6 +13,8 @@
#include "content/browser/service_worker/service_worker_utils.h"
#include "content/common/resource_request_body.h"
#include "content/common/service_worker/service_worker_types.h"
+#include "content/public/browser/content_browser_client.h"
+#include "content/public/common/content_client.h"
#include "net/base/load_flags.h"
#include "net/base/net_util.h"
#include "net/url_request/url_request.h"
@@ -60,7 +62,8 @@ ServiceWorkerControlleeRequestHandler::
net::URLRequestJob* ServiceWorkerControlleeRequestHandler::MaybeCreateJob(
net::URLRequest* request,
- net::NetworkDelegate* network_delegate) {
+ net::NetworkDelegate* network_delegate,
+ ResourceContext* resource_context) {
if (!context_ || !provider_host_) {
// We can't do anything other than to fall back to network.
job_ = NULL;
@@ -93,6 +96,8 @@ net::URLRequestJob* ServiceWorkerControlleeRequestHandler::MaybeCreateJob(
request_context_type_,
frame_type_,
body_);
+ resource_context_ = resource_context;
+
if (is_main_resource_load_)
PrepareForMainResource(request);
else
@@ -175,6 +180,20 @@ ServiceWorkerControlleeRequestHandler::DidLookupRegistrationForMainResource(
}
DCHECK(registration.get());
+ if (!GetContentClient()->browser()->AllowServiceWorker(
+ registration->pattern(),
+ provider_host_->topmost_frame_url(),
+ resource_context_)) {
+ job_->FallbackToNetwork();
+ TRACE_EVENT_ASYNC_END2(
+ "ServiceWorker",
+ "ServiceWorkerControlleeRequestHandler::PrepareForMainResource",
+ job_.get(),
+ "Status", status,
+ "Info", "ServiceWorker is blocked");
+ return;
+ }
+
// Initiate activation of a waiting version.
// Usually a register job initiates activation but that
// doesn't happen if the browser exits prior to activation

Powered by Google App Engine
This is Rietveld 408576698