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

Unified Diff: content/browser/frame_host/navigation_handle_impl.cc

Issue 1399363004: PlzNavigate: Make ServiceWorker work with PlzNavigate. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed Kinuko's comments Created 5 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/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 1c53047160e76b22808fd19b4d5c9fe045df5acc..2e30d1ed3be8f0c9f5b28d401e3233dc98a36262 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 {
@@ -45,6 +52,29 @@ NavigationHandleImpl::NavigationHandleImpl(const GURL& url,
is_transferring_(false),
frame_tree_node_(frame_tree_node),
next_index_(0) {
+ // 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));
+ }
+
GetDelegate()->DidStartNavigation(this);
}

Powered by Google App Engine
This is Rietveld 408576698