Chromium Code Reviews| Index: content/browser/frame_host/navigation_handle_impl.cc |
| diff --git a/content/browser/frame_host/navigation_handle_impl.cc b/content/browser/frame_host/navigation_handle_impl.cc |
| index 786d70a6f0ef84207091ce754ae456bc0ee03487..c5706e3e4f2bfc7b71dfa4995f0393e67378a113 100644 |
| --- a/content/browser/frame_host/navigation_handle_impl.cc |
| +++ b/content/browser/frame_host/navigation_handle_impl.cc |
| @@ -4,12 +4,19 @@ |
| #include "content/browser/frame_host/navigation_handle_impl.h" |
| +#include "base/command_line.h" |
| #include "content/browser/frame_host/frame_tree_node.h" |
| #include "content/browser/frame_host/navigator.h" |
| #include "content/browser/frame_host/navigator_delegate.h" |
| +#include "content/browser/service_worker/service_worker_context_wrapper.h" |
| +#include "content/browser/service_worker/service_worker_navigation_handle.h" |
| +#include "content/public/browser/browser_context.h" |
| #include "content/public/browser/content_browser_client.h" |
| +#include "content/public/browser/storage_partition.h" |
| #include "content/public/common/content_client.h" |
| +#include "content/public/common/content_switches.h" |
| #include "net/url_request/redirect_info.h" |
| +#include "third_party/WebKit/public/web/WebSandboxFlags.h" |
| namespace content { |
| @@ -34,6 +41,29 @@ NavigationHandleImpl::NavigationHandleImpl(const GURL& url, |
| state_(INITIAL), |
| is_transferring_(false), |
| frame_tree_node_(frame_tree_node) { |
| + // PlzNavigate |
| + // Initialize the ServiceWorkerNavigationHandle if it can be created for this |
| + // frame. |
| + bool can_create_service_worker = |
| + (frame_tree_node_->current_replication_state().sandbox_flags & |
| + blink::WebSandboxFlags::Origin) != blink::WebSandboxFlags::Origin; |
| + if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| + switches::kEnableBrowserSideNavigation) && |
| + can_create_service_worker) { |
| + BrowserContext* browser_context = |
| + frame_tree_node_->navigator()->GetController()->GetBrowserContext(); |
| + // TODO(clamy): Picking the partition based on the URL is incorrect. |
| + // See crbug.com/513539 |
| + StoragePartition* partition = |
| + BrowserContext::GetStoragePartitionForSite(browser_context, url_); |
| + DCHECK(partition); |
| + ServiceWorkerContextWrapper* service_worker_context = |
| + static_cast<ServiceWorkerContextWrapper*>( |
| + partition->GetServiceWorkerContext()); |
| + service_worker_handle_.reset( |
| + new ServiceWorkerNavigationHandle(service_worker_context)); |
| + } |
|
nasko
2015/10/20 23:07:42
Why put this code here instead of NavigationReques
clamy
2015/10/21 16:33:48
We need the SWHandle to persist until navigation c
|
| + |
| GetDelegate()->DidStartNavigation(this); |
| } |