| 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 c0b739494a5b8f3a3ed10fd864a42329ca88eb35..9803571515cf1068c47fe0ce36e6c79764095a99 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/resource_request_body.h"
|
| #include "content/common/service_worker/service_worker_types.h"
|
| #include "content/public/browser/resource_context.h"
|
| +#include "content/public/common/content_switches.h"
|
| #include "net/base/net_util.h"
|
| #include "net/url_request/url_request.h"
|
| #include "net/url_request/url_request_interceptor.h"
|
| @@ -101,6 +104,44 @@ void ServiceWorkerRequestHandler::InitializeHandler(
|
| request->SetUserData(&kUserDataKey, handler.release());
|
| }
|
|
|
| +void ServiceWorkerRequestHandler::InitializeNavigationHandler(
|
| + net::URLRequest* request,
|
| + ServiceWorkerContextWrapper* context_wrapper,
|
| + storage::BlobStorageContext* blob_storage_context,
|
| + bool skip_service_worker,
|
| + bool is_main_frame,
|
| + scoped_refptr<ResourceRequestBody> body,
|
| + NavigationURLLoaderImplCore* loader) {
|
| + CHECK(base::CommandLine::ForCurrentProcess()->HasSwitch(
|
| + switches::kEnableBrowserSideNavigation));
|
| + if (!request->url().SchemeIsHTTPOrHTTPS())
|
| + return;
|
| + if (!context_wrapper || !context_wrapper->context())
|
| + return;
|
| + scoped_ptr<ServiceWorkerProviderHost> provider_host(
|
| + context_wrapper->context()->CreateNavigationProviderHost());
|
| + loader->SetServiceWorkerProviderHost(provider_host.Pass());
|
| + if (skip_service_worker) {
|
| + // TODO(horo): Does it work correctly?.
|
| + provider_host->SetDocumentUrl(net::SimplifyUrlForRequest(request->url()));
|
| + provider_host->SetTopmostFrameUrl(request->first_party_for_cookies());
|
| + provider_host->AddAllMatchingRegistrations();
|
| + return;
|
| + }
|
| + scoped_ptr<ServiceWorkerRequestHandler> handler(
|
| + loader->service_worker_provider_host()->CreateRequestHandler(
|
| + FETCH_REQUEST_MODE_NO_CORS, FETCH_CREDENTIALS_MODE_SAME_ORIGIN,
|
| + is_main_frame ? RESOURCE_TYPE_MAIN_FRAME : RESOURCE_TYPE_SUB_FRAME,
|
| + REQUEST_CONTEXT_TYPE_LOCATION, // TODO(horo): pass in
|
| + // FrameHostMsg_BeginNavigation
|
| + REQUEST_CONTEXT_FRAME_TYPE_TOP_LEVEL, // TODO(horo): pass in
|
| + // FrameHostMsg_BeginNavigation
|
| + blob_storage_context->AsWeakPtr(), body));
|
| + if (!handler)
|
| + return;
|
| + request->SetUserData(&kUserDataKey, handler.release());
|
| +}
|
| +
|
| ServiceWorkerRequestHandler* ServiceWorkerRequestHandler::GetHandler(
|
| net::URLRequest* request) {
|
| return static_cast<ServiceWorkerRequestHandler*>(
|
|
|