OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/browser/frame_host/navigation_request.h" | 5 #include "content/browser/frame_host/navigation_request.h" |
6 | 6 |
7 #include "content/browser/frame_host/frame_tree.h" | 7 #include "content/browser/frame_host/frame_tree.h" |
8 #include "content/browser/frame_host/frame_tree_node.h" | 8 #include "content/browser/frame_host/frame_tree_node.h" |
9 #include "content/browser/frame_host/navigation_controller_impl.h" | 9 #include "content/browser/frame_host/navigation_controller_impl.h" |
10 #include "content/browser/frame_host/navigation_handle_impl.h" | 10 #include "content/browser/frame_host/navigation_handle_impl.h" |
11 #include "content/browser/frame_host/navigation_request_info.h" | 11 #include "content/browser/frame_host/navigation_request_info.h" |
12 #include "content/browser/frame_host/navigator.h" | 12 #include "content/browser/frame_host/navigator.h" |
13 #include "content/browser/loader/navigation_url_loader.h" | 13 #include "content/browser/loader/navigation_url_loader.h" |
14 #include "content/browser/site_instance_impl.h" | 14 #include "content/browser/site_instance_impl.h" |
15 #include "content/common/resource_request_body.h" | 15 #include "content/common/resource_request_body.h" |
16 #include "content/common/service_worker/service_worker_types.h" | |
16 #include "content/public/browser/navigation_controller.h" | 17 #include "content/public/browser/navigation_controller.h" |
17 #include "content/public/browser/navigation_throttle.h" | 18 #include "content/public/browser/navigation_throttle.h" |
18 #include "content/public/browser/stream_handle.h" | 19 #include "content/public/browser/stream_handle.h" |
19 #include "content/public/common/content_client.h" | 20 #include "content/public/common/content_client.h" |
20 #include "net/base/load_flags.h" | 21 #include "net/base/load_flags.h" |
21 #include "net/http/http_request_headers.h" | 22 #include "net/http/http_request_headers.h" |
22 #include "net/url_request/redirect_info.h" | 23 #include "net/url_request/redirect_info.h" |
24 #include "third_party/WebKit/public/web/WebSandboxFlags.h" | |
23 | 25 |
24 namespace content { | 26 namespace content { |
25 | 27 |
26 namespace { | 28 namespace { |
27 | 29 |
28 // Returns the net load flags to use based on the navigation type. | 30 // Returns the net load flags to use based on the navigation type. |
29 // TODO(clamy): unify the code with what is happening on the renderer side. | 31 // TODO(clamy): unify the code with what is happening on the renderer side. |
30 int LoadFlagFromNavigationType(FrameMsg_Navigate_Type::Value navigation_type) { | 32 int LoadFlagFromNavigationType(FrameMsg_Navigate_Type::Value navigation_type) { |
31 int load_flags = net::LOAD_NORMAL; | 33 int load_flags = net::LOAD_NORMAL; |
32 switch (navigation_type) { | 34 switch (navigation_type) { |
(...skipping 10 matching lines...) Expand all Loading... | |
43 case FrameMsg_Navigate_Type::RESTORE_WITH_POST: | 45 case FrameMsg_Navigate_Type::RESTORE_WITH_POST: |
44 load_flags |= net::LOAD_ONLY_FROM_CACHE; | 46 load_flags |= net::LOAD_ONLY_FROM_CACHE; |
45 break; | 47 break; |
46 case FrameMsg_Navigate_Type::NORMAL: | 48 case FrameMsg_Navigate_Type::NORMAL: |
47 default: | 49 default: |
48 break; | 50 break; |
49 } | 51 } |
50 return load_flags; | 52 return load_flags; |
51 } | 53 } |
52 | 54 |
55 // Next ServiceWorkerProviderHost ID for navigations, starts at -2 and keeps | |
56 // going down. | |
57 int g_next_navigation_provider_id = -2; | |
58 | |
59 // Returns the next ServiceWorkerProviderHost ID for navigations, | |
60 // kInvalidServiceWorkerProviderId if the frame is sandboxed. | |
61 int GetNextNavigationProviderId(blink::WebSandboxFlags sandbox_flags) { | |
62 if ((sandbox_flags & blink::WebSandboxFlags::Origin) == | |
63 blink::WebSandboxFlags::Origin) | |
64 return kInvalidServiceWorkerProviderId; | |
65 return g_next_navigation_provider_id--; | |
66 } | |
67 | |
53 } // namespace | 68 } // namespace |
54 | 69 |
55 // static | 70 // static |
56 scoped_ptr<NavigationRequest> NavigationRequest::CreateBrowserInitiated( | 71 scoped_ptr<NavigationRequest> NavigationRequest::CreateBrowserInitiated( |
57 FrameTreeNode* frame_tree_node, | 72 FrameTreeNode* frame_tree_node, |
58 const GURL& dest_url, | 73 const GURL& dest_url, |
59 const Referrer& dest_referrer, | 74 const Referrer& dest_referrer, |
60 const FrameNavigationEntry& frame_entry, | 75 const FrameNavigationEntry& frame_entry, |
61 const NavigationEntryImpl& entry, | 76 const NavigationEntryImpl& entry, |
62 FrameMsg_Navigate_Type::Value navigation_type, | 77 FrameMsg_Navigate_Type::Value navigation_type, |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
202 Referrer::SanitizeForRequest(common_params_.url, | 217 Referrer::SanitizeForRequest(common_params_.url, |
203 common_params_.referrer), | 218 common_params_.referrer), |
204 begin_params_.has_user_gesture, common_params_.transition, false); | 219 begin_params_.has_user_gesture, common_params_.transition, false); |
205 | 220 |
206 // Abort the request if needed. This will destroy the NavigationRequest. | 221 // Abort the request if needed. This will destroy the NavigationRequest. |
207 if (result == NavigationThrottle::CANCEL_AND_IGNORE) { | 222 if (result == NavigationThrottle::CANCEL_AND_IGNORE) { |
208 frame_tree_node_->ResetNavigationRequest(false); | 223 frame_tree_node_->ResetNavigationRequest(false); |
209 return false; | 224 return false; |
210 } | 225 } |
211 | 226 |
227 // Initialize the service_worker_provider_id here. | |
228 blink::WebSandboxFlags sandbox_flags = | |
229 frame_tree_node_->current_replication_state().sandbox_flags; | |
230 int service_worker_provider_id = GetNextNavigationProviderId(sandbox_flags); | |
231 | |
232 info_->service_worker_provider_id = service_worker_provider_id; | |
233 request_params_.service_worker_provider_id = service_worker_provider_id; | |
234 navigation_handle_->set_service_worker_provider_id( | |
michaeln
2015/10/07 01:16:44
Nice, deferring this swspecific init work until th
Fabrice (no longer in Chrome)
2015/10/07 12:59:43
One of the issues is that we are currently on the
michaeln
2015/10/08 02:18:51
Hmmm, but thats not right? First, this method runs
| |
235 service_worker_provider_id); | |
236 | |
212 loader_ = NavigationURLLoader::Create( | 237 loader_ = NavigationURLLoader::Create( |
213 frame_tree_node_->navigator()->GetController()->GetBrowserContext(), | 238 frame_tree_node_->navigator()->GetController()->GetBrowserContext(), |
214 info_.Pass(), this); | 239 info_.Pass(), this); |
215 return true; | 240 return true; |
216 } | 241 } |
217 | 242 |
218 // There is no need to make a network request for this navigation, so commit | 243 // There is no need to make a network request for this navigation, so commit |
219 // it immediately. | 244 // it immediately. |
220 state_ = RESPONSE_STARTED; | 245 state_ = RESPONSE_STARTED; |
221 frame_tree_node_->navigator()->CommitNavigation( | 246 frame_tree_node_->navigator()->CommitNavigation( |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
281 frame_tree_node_->navigator()->FailedNavigation( | 306 frame_tree_node_->navigator()->FailedNavigation( |
282 frame_tree_node_, has_stale_copy_in_cache, net_error); | 307 frame_tree_node_, has_stale_copy_in_cache, net_error); |
283 } | 308 } |
284 | 309 |
285 void NavigationRequest::OnRequestStarted(base::TimeTicks timestamp) { | 310 void NavigationRequest::OnRequestStarted(base::TimeTicks timestamp) { |
286 frame_tree_node_->navigator()->LogResourceRequestTime(timestamp, | 311 frame_tree_node_->navigator()->LogResourceRequestTime(timestamp, |
287 common_params_.url); | 312 common_params_.url); |
288 } | 313 } |
289 | 314 |
290 } // namespace content | 315 } // namespace content |
OLD | NEW |