| 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_request_info.h" | 10 #include "content/browser/frame_host/navigation_request_info.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 break; | 46 break; |
| 47 } | 47 } |
| 48 return load_flags; | 48 return load_flags; |
| 49 } | 49 } |
| 50 | 50 |
| 51 } // namespace | 51 } // namespace |
| 52 | 52 |
| 53 // static | 53 // static |
| 54 scoped_ptr<NavigationRequest> NavigationRequest::CreateBrowserInitiated( | 54 scoped_ptr<NavigationRequest> NavigationRequest::CreateBrowserInitiated( |
| 55 FrameTreeNode* frame_tree_node, | 55 FrameTreeNode* frame_tree_node, |
| 56 const GURL& dest_url, |
| 57 const Referrer& dest_referrer, |
| 56 const FrameNavigationEntry& frame_entry, | 58 const FrameNavigationEntry& frame_entry, |
| 57 const NavigationEntryImpl& entry, | 59 const NavigationEntryImpl& entry, |
| 58 FrameMsg_Navigate_Type::Value navigation_type, | 60 FrameMsg_Navigate_Type::Value navigation_type, |
| 59 bool is_same_document_history_load, | 61 bool is_same_document_history_load, |
| 60 base::TimeTicks navigation_start, | 62 base::TimeTicks navigation_start, |
| 61 NavigationControllerImpl* controller) { | 63 NavigationControllerImpl* controller) { |
| 62 std::string method = entry.GetHasPostData() ? "POST" : "GET"; | 64 std::string method = entry.GetHasPostData() ? "POST" : "GET"; |
| 63 | 65 |
| 64 // Copy existing headers and add necessary headers that may not be present | 66 // Copy existing headers and add necessary headers that may not be present |
| 65 // in the RequestNavigationParams. | 67 // in the RequestNavigationParams. |
| 66 net::HttpRequestHeaders headers; | 68 net::HttpRequestHeaders headers; |
| 67 headers.AddHeadersFromString(entry.extra_headers()); | 69 headers.AddHeadersFromString(entry.extra_headers()); |
| 68 headers.SetHeaderIfMissing(net::HttpRequestHeaders::kUserAgent, | 70 headers.SetHeaderIfMissing(net::HttpRequestHeaders::kUserAgent, |
| 69 GetContentClient()->GetUserAgent()); | 71 GetContentClient()->GetUserAgent()); |
| 70 // TODO(clamy): match what blink is doing with accept headers. | 72 // TODO(clamy): match what blink is doing with accept headers. |
| 71 headers.SetHeaderIfMissing("Accept", "*/*"); | 73 headers.SetHeaderIfMissing("Accept", "*/*"); |
| 72 | 74 |
| 73 // Fill POST data from the browser in the request body. | 75 // Fill POST data from the browser in the request body. |
| 74 scoped_refptr<ResourceRequestBody> request_body; | 76 scoped_refptr<ResourceRequestBody> request_body; |
| 75 if (entry.GetHasPostData()) { | 77 if (entry.GetHasPostData()) { |
| 76 request_body = new ResourceRequestBody(); | 78 request_body = new ResourceRequestBody(); |
| 77 request_body->AppendBytes( | 79 request_body->AppendBytes( |
| 78 reinterpret_cast<const char *>( | 80 reinterpret_cast<const char *>( |
| 79 entry.GetBrowserInitiatedPostData()->front()), | 81 entry.GetBrowserInitiatedPostData()->front()), |
| 80 entry.GetBrowserInitiatedPostData()->size()); | 82 entry.GetBrowserInitiatedPostData()->size()); |
| 81 } | 83 } |
| 82 | 84 |
| 83 scoped_ptr<NavigationRequest> navigation_request(new NavigationRequest( | 85 scoped_ptr<NavigationRequest> navigation_request(new NavigationRequest( |
| 84 frame_tree_node, | 86 frame_tree_node, |
| 85 entry.ConstructCommonNavigationParams(frame_entry, navigation_type), | 87 entry.ConstructCommonNavigationParams(dest_url, dest_referrer, |
| 88 frame_entry, navigation_type), |
| 86 BeginNavigationParams(method, headers.ToString(), | 89 BeginNavigationParams(method, headers.ToString(), |
| 87 LoadFlagFromNavigationType(navigation_type), false), | 90 LoadFlagFromNavigationType(navigation_type), false), |
| 88 entry.ConstructRequestNavigationParams( | 91 entry.ConstructRequestNavigationParams( |
| 89 frame_entry, navigation_start, is_same_document_history_load, | 92 frame_entry, navigation_start, is_same_document_history_load, |
| 90 controller->HasCommittedRealLoad(frame_tree_node), | 93 controller->HasCommittedRealLoad(frame_tree_node), |
| 91 controller->GetPendingEntryIndex() == -1, | 94 controller->GetPendingEntryIndex() == -1, |
| 92 controller->GetIndexOfEntry(&entry), | 95 controller->GetIndexOfEntry(&entry), |
| 93 controller->GetLastCommittedEntryIndex(), | 96 controller->GetLastCommittedEntryIndex(), |
| 94 controller->GetEntryCount()), | 97 controller->GetEntryCount()), |
| 95 request_body, true, &frame_entry, &entry)); | 98 request_body, true, &frame_entry, &entry)); |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 frame_tree_node_->navigator()->FailedNavigation( | 223 frame_tree_node_->navigator()->FailedNavigation( |
| 221 frame_tree_node_, has_stale_copy_in_cache, net_error); | 224 frame_tree_node_, has_stale_copy_in_cache, net_error); |
| 222 } | 225 } |
| 223 | 226 |
| 224 void NavigationRequest::OnRequestStarted(base::TimeTicks timestamp) { | 227 void NavigationRequest::OnRequestStarted(base::TimeTicks timestamp) { |
| 225 frame_tree_node_->navigator()->LogResourceRequestTime(timestamp, | 228 frame_tree_node_->navigator()->LogResourceRequestTime(timestamp, |
| 226 common_params_.url); | 229 common_params_.url); |
| 227 } | 230 } |
| 228 | 231 |
| 229 } // namespace content | 232 } // namespace content |
| OLD | NEW |