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/navigation_params.h" |
15 #include "content/common/resource_request_body.h" | 16 #include "content/common/resource_request_body.h" |
16 #include "content/public/browser/navigation_controller.h" | 17 #include "content/public/browser/navigation_controller.h" |
17 #include "content/public/browser/stream_handle.h" | 18 #include "content/public/browser/stream_handle.h" |
18 #include "content/public/common/content_client.h" | 19 #include "content/public/common/content_client.h" |
19 #include "net/base/load_flags.h" | 20 #include "net/base/load_flags.h" |
20 #include "net/http/http_request_headers.h" | 21 #include "net/http/http_request_headers.h" |
21 #include "net/url_request/redirect_info.h" | 22 #include "net/url_request/redirect_info.h" |
22 | 23 |
23 namespace content { | 24 namespace content { |
24 | 25 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 const GURL& dest_url, | 58 const GURL& dest_url, |
58 const Referrer& dest_referrer, | 59 const Referrer& dest_referrer, |
59 const FrameNavigationEntry& frame_entry, | 60 const FrameNavigationEntry& frame_entry, |
60 const NavigationEntryImpl& entry, | 61 const NavigationEntryImpl& entry, |
61 FrameMsg_Navigate_Type::Value navigation_type, | 62 FrameMsg_Navigate_Type::Value navigation_type, |
62 bool is_same_document_history_load, | 63 bool is_same_document_history_load, |
63 base::TimeTicks navigation_start, | 64 base::TimeTicks navigation_start, |
64 NavigationControllerImpl* controller) { | 65 NavigationControllerImpl* controller) { |
65 std::string method = entry.GetHasPostData() ? "POST" : "GET"; | 66 std::string method = entry.GetHasPostData() ? "POST" : "GET"; |
66 | 67 |
| 68 // TODO(megjablon): Do we want to turn LoFi off on reloads? Need decision. |
| 69 LoFiState lofi_state = |
| 70 (navigation_type == FrameMsg_Navigate_Type::RELOAD || |
| 71 navigation_type == FrameMsg_Navigate_Type::RELOAD_IGNORING_CACHE || |
| 72 navigation_type == FrameMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL) ? |
| 73 LOFI_OFF : LOFI_DEFAULT; |
| 74 |
67 // Copy existing headers and add necessary headers that may not be present | 75 // Copy existing headers and add necessary headers that may not be present |
68 // in the RequestNavigationParams. | 76 // in the RequestNavigationParams. |
69 net::HttpRequestHeaders headers; | 77 net::HttpRequestHeaders headers; |
70 headers.AddHeadersFromString(entry.extra_headers()); | 78 headers.AddHeadersFromString(entry.extra_headers()); |
71 headers.SetHeaderIfMissing(net::HttpRequestHeaders::kUserAgent, | 79 headers.SetHeaderIfMissing(net::HttpRequestHeaders::kUserAgent, |
72 GetContentClient()->GetUserAgent()); | 80 GetContentClient()->GetUserAgent()); |
73 // TODO(clamy): match what blink is doing with accept headers. | 81 // TODO(clamy): match what blink is doing with accept headers. |
74 headers.SetHeaderIfMissing("Accept", "*/*"); | 82 headers.SetHeaderIfMissing("Accept", "*/*"); |
75 | 83 |
76 // Fill POST data from the browser in the request body. | 84 // Fill POST data from the browser in the request body. |
(...skipping 11 matching lines...) Expand all Loading... |
88 entry.ConstructCommonNavigationParams(dest_url, dest_referrer, | 96 entry.ConstructCommonNavigationParams(dest_url, dest_referrer, |
89 frame_entry, navigation_type), | 97 frame_entry, navigation_type), |
90 BeginNavigationParams(method, headers.ToString(), | 98 BeginNavigationParams(method, headers.ToString(), |
91 LoadFlagFromNavigationType(navigation_type), false), | 99 LoadFlagFromNavigationType(navigation_type), false), |
92 entry.ConstructRequestNavigationParams( | 100 entry.ConstructRequestNavigationParams( |
93 frame_entry, navigation_start, is_same_document_history_load, | 101 frame_entry, navigation_start, is_same_document_history_load, |
94 frame_tree_node->has_committed_real_load(), | 102 frame_tree_node->has_committed_real_load(), |
95 controller->GetPendingEntryIndex() == -1, | 103 controller->GetPendingEntryIndex() == -1, |
96 controller->GetIndexOfEntry(&entry), | 104 controller->GetIndexOfEntry(&entry), |
97 controller->GetLastCommittedEntryIndex(), | 105 controller->GetLastCommittedEntryIndex(), |
98 controller->GetEntryCount()), | 106 controller->GetEntryCount(), lofi_state), |
99 request_body, true, &frame_entry, &entry)); | 107 request_body, true, &frame_entry, &entry)); |
100 return navigation_request.Pass(); | 108 return navigation_request.Pass(); |
101 } | 109 } |
102 | 110 |
103 // static | 111 // static |
104 scoped_ptr<NavigationRequest> NavigationRequest::CreateRendererInitiated( | 112 scoped_ptr<NavigationRequest> NavigationRequest::CreateRendererInitiated( |
105 FrameTreeNode* frame_tree_node, | 113 FrameTreeNode* frame_tree_node, |
106 const CommonNavigationParams& common_params, | 114 const CommonNavigationParams& common_params, |
107 const BeginNavigationParams& begin_params, | 115 const BeginNavigationParams& begin_params, |
108 scoped_refptr<ResourceRequestBody> body, | 116 scoped_refptr<ResourceRequestBody> body, |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 frame_tree_node_->navigator()->FailedNavigation( | 245 frame_tree_node_->navigator()->FailedNavigation( |
238 frame_tree_node_, has_stale_copy_in_cache, net_error); | 246 frame_tree_node_, has_stale_copy_in_cache, net_error); |
239 } | 247 } |
240 | 248 |
241 void NavigationRequest::OnRequestStarted(base::TimeTicks timestamp) { | 249 void NavigationRequest::OnRequestStarted(base::TimeTicks timestamp) { |
242 frame_tree_node_->navigator()->LogResourceRequestTime(timestamp, | 250 frame_tree_node_->navigator()->LogResourceRequestTime(timestamp, |
243 common_params_.url); | 251 common_params_.url); |
244 } | 252 } |
245 | 253 |
246 } // namespace content | 254 } // namespace content |
OLD | NEW |