| Index: content/browser/service_worker/service_worker_request_handler.cc
|
| diff --git a/content/browser/service_worker/service_worker_request_handler.cc b/content/browser/service_worker/service_worker_request_handler.cc
|
| index da735b64d764019e65a045a9767a9155e93ee1f0..5313642584c9a220e395d828ce31f555803467da 100644
|
| --- a/content/browser/service_worker/service_worker_request_handler.cc
|
| +++ b/content/browser/service_worker/service_worker_request_handler.cc
|
| @@ -6,6 +6,8 @@
|
|
|
| #include <string>
|
|
|
| +#include "base/command_line.h"
|
| +#include "content/browser/loader/navigation_url_loader_impl_core.h"
|
| #include "content/browser/service_worker/service_worker_context_core.h"
|
| #include "content/browser/service_worker/service_worker_context_wrapper.h"
|
| #include "content/browser/service_worker/service_worker_provider_host.h"
|
| @@ -15,6 +17,7 @@
|
| #include "content/common/service_worker/service_worker_types.h"
|
| #include "content/common/service_worker/service_worker_utils.h"
|
| #include "content/public/browser/resource_context.h"
|
| +#include "content/public/common/content_switches.h"
|
| #include "content/public/common/origin_util.h"
|
| #include "net/base/net_util.h"
|
| #include "net/url_request/url_request.h"
|
| @@ -64,7 +67,8 @@ void ServiceWorkerRequestHandler::InitializeHandler(
|
| ResourceType resource_type,
|
| RequestContextType request_context_type,
|
| RequestContextFrameType frame_type,
|
| - scoped_refptr<ResourceRequestBody> body) {
|
| + scoped_refptr<ResourceRequestBody> body,
|
| + NavigationURLLoaderImplCore* loader) {
|
| if (!OriginCanAccessServiceWorkers(request->url()))
|
| return;
|
|
|
| @@ -73,13 +77,27 @@ void ServiceWorkerRequestHandler::InitializeHandler(
|
| return;
|
| }
|
|
|
| - ServiceWorkerProviderHost* provider_host =
|
| - context_wrapper->context()->GetProviderHost(process_id, provider_id);
|
| + ServiceWorkerProviderHost* provider_host = nullptr;
|
| + if (provider_id < kInvalidServiceWorkerProviderId) {
|
| + // PlzNavigate
|
| + // Initialize a dummy SWProviderHost for browser-initiated navigations.
|
| + CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch(
|
| + switches::kEnableBrowserSideNavigation));
|
| + scoped_ptr<ServiceWorkerProviderHost> scoped_provider_host(
|
| + context_wrapper->context()->CreateBrowserProviderHost(provider_id));
|
| + provider_host = scoped_provider_host.get();
|
| + loader->SetServiceWorkerProviderHost(scoped_provider_host.Pass());
|
| + } else {
|
| + provider_host =
|
| + context_wrapper->context()->GetProviderHost(process_id, provider_id);
|
| + }
|
| +
|
| if (!provider_host || !provider_host->IsContextAlive())
|
| return;
|
|
|
| if (skip_service_worker) {
|
| if (ServiceWorkerUtils::IsMainResourceType(resource_type)) {
|
| + // TODO(horo): Does this work properly for PlzNavigate?
|
| provider_host->SetDocumentUrl(net::SimplifyUrlForRequest(request->url()));
|
| provider_host->SetTopmostFrameUrl(request->first_party_for_cookies());
|
| // A page load with skip_service_worker should be triggered by
|
|
|