Chromium Code Reviews| Index: content/browser/frame_host/navigation_request.cc |
| diff --git a/content/browser/frame_host/navigation_request.cc b/content/browser/frame_host/navigation_request.cc |
| index f515a696e5c12ff2909e01087258710c0f46e264..9ab2e7d72d0a1c7d9494455e5b05ca7aca2edf10 100644 |
| --- a/content/browser/frame_host/navigation_request.cc |
| +++ b/content/browser/frame_host/navigation_request.cc |
| @@ -4,6 +4,7 @@ |
| #include "content/browser/frame_host/navigation_request.h" |
| +#include "base/command_line.h" |
| #include "content/browser/frame_host/frame_tree.h" |
| #include "content/browser/frame_host/frame_tree_node.h" |
| #include "content/browser/frame_host/navigation_controller_impl.h" |
| @@ -11,15 +12,18 @@ |
| #include "content/browser/frame_host/navigation_request_info.h" |
| #include "content/browser/frame_host/navigator.h" |
| #include "content/browser/loader/navigation_url_loader.h" |
| +#include "content/browser/service_worker/service_worker_provider_host.h" |
| #include "content/browser/site_instance_impl.h" |
| #include "content/common/resource_request_body.h" |
| #include "content/public/browser/navigation_controller.h" |
| #include "content/public/browser/navigation_throttle.h" |
| #include "content/public/browser/stream_handle.h" |
| #include "content/public/common/content_client.h" |
| +#include "content/public/common/content_switches.h" |
| #include "net/base/load_flags.h" |
| #include "net/http/http_request_headers.h" |
| #include "net/url_request/redirect_info.h" |
| +#include "third_party/WebKit/public/web/WebSandboxFlags.h" |
| namespace content { |
| @@ -50,6 +54,29 @@ int LoadFlagFromNavigationType(FrameMsg_Navigate_Type::Value navigation_type) { |
| return load_flags; |
| } |
| + |
| +// PlzNavigate |
|
clamy
2015/10/02 10:34:44
No need for PlzNavigate prefix, this is a PlzNavig
Fabrice (no longer in Chrome)
2015/10/02 16:37:34
Done.
|
| +// Next ServiceWorkerProviderHost ID for navigations, starts at -2 and keeps |
| +// going down. |
| +int g_next_navigation_provider_id = -2; |
| + |
| +// PlzNavigate |
| +// Returns the next ServiceWorkerProviderHost ID for navigations. |
| +// Returns kInvalidServiceWorkerProviderId if sandbox_flags indicates a |
| +// sandboxed frame. |
| +// Returns kInvalidServiceWorkerProviderId for current navigation. |
| +int GetNextNavigationProviderId(blink::WebSandboxFlags sandbox_flags) { |
| + if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
|
clamy
2015/10/02 10:34:44
This is a PlzNavigate only class, so no need to ha
Fabrice (no longer in Chrome)
2015/10/02 16:37:34
Done.
|
| + switches::kEnableBrowserSideNavigation)) { |
| + bool sandboxed_frame = (sandbox_flags & blink::WebSandboxFlags::Origin) == |
| + blink::WebSandboxFlags::Origin; |
| + if (sandboxed_frame) |
| + return kInvalidServiceWorkerProviderId; |
| + return g_next_navigation_provider_id--; |
| + } |
| + return kInvalidServiceWorkerProviderId; |
| +} |
| + |
| } // namespace |
| // static |
| @@ -84,19 +111,26 @@ scoped_ptr<NavigationRequest> NavigationRequest::CreateBrowserInitiated( |
| entry.GetBrowserInitiatedPostData()->size()); |
| } |
| + blink::WebSandboxFlags sandbox_flags = |
| + frame_tree_node->current_replication_state().sandbox_flags; |
| scoped_ptr<NavigationRequest> navigation_request(new NavigationRequest( |
| frame_tree_node, |
| - entry.ConstructCommonNavigationParams(dest_url, dest_referrer, |
| - frame_entry, navigation_type), |
| - BeginNavigationParams(method, headers.ToString(), |
| - LoadFlagFromNavigationType(navigation_type), false), |
| + entry.ConstructCommonNavigationParams( |
| + dest_url, dest_referrer, frame_entry, navigation_type), |
| + BeginNavigationParams(method, |
| + headers.ToString(), |
| + LoadFlagFromNavigationType(navigation_type), |
| + false, // has_user_gestures |
| + false, // skip_service_worker |
| + REQUEST_CONTEXT_TYPE_HYPERLINK), |
| entry.ConstructRequestNavigationParams( |
| frame_entry, navigation_start, is_same_document_history_load, |
| frame_tree_node->has_committed_real_load(), |
| controller->GetPendingEntryIndex() == -1, |
| controller->GetIndexOfEntry(&entry), |
| controller->GetLastCommittedEntryIndex(), |
| - controller->GetEntryCount()), |
| + controller->GetEntryCount(), |
| + GetNextNavigationProviderId(sandbox_flags)), |
| request_body, true, &frame_entry, &entry)); |
| return navigation_request.Pass(); |
| } |
| @@ -109,6 +143,9 @@ scoped_ptr<NavigationRequest> NavigationRequest::CreateRendererInitiated( |
| scoped_refptr<ResourceRequestBody> body, |
| int current_history_list_offset, |
| int current_history_list_length) { |
| + blink::WebSandboxFlags sandbox_flags = |
| + frame_tree_node->current_replication_state().sandbox_flags; |
| + |
| // TODO(clamy): Check if some PageState should be provided here. |
| // TODO(clamy): See how we should handle override of the user agent when the |
| // navigation may start in a renderer and commit in another one. |
| @@ -116,9 +153,23 @@ scoped_ptr<NavigationRequest> NavigationRequest::CreateRendererInitiated( |
| // renderer and sent to the browser instead of being measured here. |
| // TODO(clamy): The pending history list offset should be properly set. |
| // TODO(clamy): Set has_committed_real_load. |
| - RequestNavigationParams request_params; |
| - request_params.current_history_list_offset = current_history_list_offset; |
| - request_params.current_history_list_length = current_history_list_length; |
| + RequestNavigationParams request_params( |
| + false, // is_overriding_user_agent |
| + base::TimeTicks::Now(), // browser_navigation_start |
| + std::vector<GURL>(), // redirects |
| + false, // can_load_local_resources |
| + base::Time::Now(), // request_time |
| + PageState(), // page_state |
| + -1, // page_id |
| + 0, // nav_entry_id |
| + false, // is_same_document_history_load |
| + false, // has_committed_real_load |
| + false, // intended_as_new_entry |
| + -1, // pending_history_list_offset |
| + current_history_list_offset, |
| + current_history_list_length, |
| + false, // should_clear_history_list |
| + GetNextNavigationProviderId(sandbox_flags)); |
| scoped_ptr<NavigationRequest> navigation_request( |
| new NavigationRequest(frame_tree_node, common_params, begin_params, |
| request_params, body, false, nullptr, nullptr)); |
| @@ -168,7 +219,8 @@ NavigationRequest::NavigationRequest( |
| info_.reset(new NavigationRequestInfo( |
| common_params, begin_params, first_party_for_cookies, |
| frame_tree_node->IsMainFrame(), parent_is_main_frame, |
| - frame_tree_node->frame_tree_node_id(), body)); |
| + frame_tree_node->frame_tree_node_id(), |
| + request_params.service_worker_provider_id, body)); |
| } |
| NavigationRequest::~NavigationRequest() { |
| @@ -213,7 +265,8 @@ bool NavigationRequest::BeginNavigation() { |
| void NavigationRequest::CreateNavigationHandle(NavigatorDelegate* delegate) { |
| navigation_handle_ = NavigationHandleImpl::Create( |
| - common_params_.url, frame_tree_node_->IsMainFrame(), delegate); |
| + common_params_.url, frame_tree_node_->IsMainFrame(), delegate, |
| + request_params_.service_worker_provider_id); |
| } |
| void NavigationRequest::TransferNavigationHandleOwnership( |