| 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_request_info.h" | 9 #include "content/browser/frame_host/navigation_request_info.h" |
| 10 #include "content/browser/frame_host/navigator.h" | 10 #include "content/browser/frame_host/navigator.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 // Data urls should not make network requests. | 54 // Data urls should not make network requests. |
| 55 // TODO(clamy): same document navigations should not make network requests. | 55 // TODO(clamy): same document navigations should not make network requests. |
| 56 return !url.SchemeIs(url::kDataScheme); | 56 return !url.SchemeIs(url::kDataScheme); |
| 57 } | 57 } |
| 58 | 58 |
| 59 // static | 59 // static |
| 60 scoped_ptr<NavigationRequest> NavigationRequest::CreateBrowserInitiated( | 60 scoped_ptr<NavigationRequest> NavigationRequest::CreateBrowserInitiated( |
| 61 FrameTreeNode* frame_tree_node, | 61 FrameTreeNode* frame_tree_node, |
| 62 const NavigationEntryImpl& entry, | 62 const NavigationEntryImpl& entry, |
| 63 FrameMsg_Navigate_Type::Value navigation_type, | 63 FrameMsg_Navigate_Type::Value navigation_type, |
| 64 base::TimeTicks navigation_start) { | 64 base::TimeTicks navigation_start, |
| 65 const HistoryNavigationParams& history_params) { |
| 65 std::string method = entry.GetHasPostData() ? "POST" : "GET"; | 66 std::string method = entry.GetHasPostData() ? "POST" : "GET"; |
| 66 | 67 |
| 67 // Copy existing headers and add necessary headers that may not be present | 68 // Copy existing headers and add necessary headers that may not be present |
| 68 // in the RequestNavigationParams. | 69 // in the RequestNavigationParams. |
| 69 net::HttpRequestHeaders headers; | 70 net::HttpRequestHeaders headers; |
| 70 headers.AddHeadersFromString(entry.extra_headers()); | 71 headers.AddHeadersFromString(entry.extra_headers()); |
| 71 headers.SetHeaderIfMissing(net::HttpRequestHeaders::kUserAgent, | 72 headers.SetHeaderIfMissing(net::HttpRequestHeaders::kUserAgent, |
| 72 GetContentClient()->GetUserAgent()); | 73 GetContentClient()->GetUserAgent()); |
| 73 // TODO(clamy): match what blink is doing with accept headers. | 74 // TODO(clamy): match what blink is doing with accept headers. |
| 74 headers.SetHeaderIfMissing("Accept", "*/*"); | 75 headers.SetHeaderIfMissing("Accept", "*/*"); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 87 FrameMsg_UILoadMetricsReportType::NO_REPORT; | 88 FrameMsg_UILoadMetricsReportType::NO_REPORT; |
| 88 base::TimeTicks ui_timestamp = base::TimeTicks(); | 89 base::TimeTicks ui_timestamp = base::TimeTicks(); |
| 89 #if defined(OS_ANDROID) | 90 #if defined(OS_ANDROID) |
| 90 if (!entry.intent_received_timestamp().is_null()) | 91 if (!entry.intent_received_timestamp().is_null()) |
| 91 report_type = FrameMsg_UILoadMetricsReportType::REPORT_INTENT; | 92 report_type = FrameMsg_UILoadMetricsReportType::REPORT_INTENT; |
| 92 ui_timestamp = entry.intent_received_timestamp(); | 93 ui_timestamp = entry.intent_received_timestamp(); |
| 93 #endif | 94 #endif |
| 94 | 95 |
| 95 scoped_ptr<NavigationRequest> navigation_request(new NavigationRequest( | 96 scoped_ptr<NavigationRequest> navigation_request(new NavigationRequest( |
| 96 frame_tree_node, | 97 frame_tree_node, |
| 97 CommonNavigationParams(entry.GetURL(), entry.GetReferrer(), | 98 CommonNavigationParams( |
| 98 entry.GetTransitionType(), navigation_type, | 99 entry.GetURL(), entry.GetReferrer(), entry.GetTransitionType(), |
| 99 !entry.IsViewSourceMode(),ui_timestamp, | 100 navigation_type, !entry.IsViewSourceMode(), ui_timestamp, report_type, |
| 100 report_type, entry.GetBaseURLForDataURL(), | 101 entry.GetBaseURLForDataURL(), entry.GetHistoryURLForDataURL()), |
| 101 entry.GetHistoryURLForDataURL()), | |
| 102 BeginNavigationParams(method, headers.ToString(), | 102 BeginNavigationParams(method, headers.ToString(), |
| 103 LoadFlagFromNavigationType(navigation_type), | 103 LoadFlagFromNavigationType(navigation_type), false), |
| 104 false), | 104 CommitNavigationParams(entry.GetIsOverridingUserAgent(), |
| 105 CommitNavigationParams(entry.GetPageState(), | |
| 106 entry.GetIsOverridingUserAgent(), | |
| 107 navigation_start), | 105 navigation_start), |
| 108 request_body, true, &entry)); | 106 history_params, request_body, true, &entry)); |
| 109 return navigation_request.Pass(); | 107 return navigation_request.Pass(); |
| 110 } | 108 } |
| 111 | 109 |
| 112 // static | 110 // static |
| 113 scoped_ptr<NavigationRequest> NavigationRequest::CreateRendererInitiated( | 111 scoped_ptr<NavigationRequest> NavigationRequest::CreateRendererInitiated( |
| 114 FrameTreeNode* frame_tree_node, | 112 FrameTreeNode* frame_tree_node, |
| 115 const CommonNavigationParams& common_params, | 113 const CommonNavigationParams& common_params, |
| 116 const BeginNavigationParams& begin_params, | 114 const BeginNavigationParams& begin_params, |
| 117 scoped_refptr<ResourceRequestBody> body) { | 115 scoped_refptr<ResourceRequestBody> body, |
| 116 int current_history_list_offset, |
| 117 int current_history_list_length) { |
| 118 // TODO(clamy): Check if some PageState should be provided here. | 118 // TODO(clamy): Check if some PageState should be provided here. |
| 119 // TODO(clamy): See how we should handle override of the user agent when the | 119 // TODO(clamy): See how we should handle override of the user agent when the |
| 120 // navigation may start in a renderer and commit in another one. | 120 // navigation may start in a renderer and commit in another one. |
| 121 // TODO(clamy): See if the navigation start time should be measured in the | 121 // TODO(clamy): See if the navigation start time should be measured in the |
| 122 // renderer and sent to the browser instead of being measured here. | 122 // renderer and sent to the browser instead of being measured here. |
| 123 scoped_ptr<NavigationRequest> navigation_request(new NavigationRequest( | 123 scoped_ptr<NavigationRequest> navigation_request(new NavigationRequest( |
| 124 frame_tree_node, common_params, begin_params, | 124 frame_tree_node, common_params, begin_params, |
| 125 CommitNavigationParams(PageState(), false, base::TimeTicks::Now()), | 125 CommitNavigationParams(false, base::TimeTicks::Now()), |
| 126 HistoryNavigationParams(PageState(), -1, -1, current_history_list_offset, |
| 127 current_history_list_length, false), |
| 126 body, false, nullptr)); | 128 body, false, nullptr)); |
| 127 return navigation_request.Pass(); | 129 return navigation_request.Pass(); |
| 128 } | 130 } |
| 129 | 131 |
| 130 NavigationRequest::NavigationRequest( | 132 NavigationRequest::NavigationRequest( |
| 131 FrameTreeNode* frame_tree_node, | 133 FrameTreeNode* frame_tree_node, |
| 132 const CommonNavigationParams& common_params, | 134 const CommonNavigationParams& common_params, |
| 133 const BeginNavigationParams& begin_params, | 135 const BeginNavigationParams& begin_params, |
| 134 const CommitNavigationParams& commit_params, | 136 const CommitNavigationParams& commit_params, |
| 137 const HistoryNavigationParams& history_params, |
| 135 scoped_refptr<ResourceRequestBody> body, | 138 scoped_refptr<ResourceRequestBody> body, |
| 136 bool browser_initiated, | 139 bool browser_initiated, |
| 137 const NavigationEntryImpl* entry) | 140 const NavigationEntryImpl* entry) |
| 138 : frame_tree_node_(frame_tree_node), | 141 : frame_tree_node_(frame_tree_node), |
| 139 common_params_(common_params), | 142 common_params_(common_params), |
| 140 begin_params_(begin_params), | 143 begin_params_(begin_params), |
| 141 commit_params_(commit_params), | 144 commit_params_(commit_params), |
| 145 history_params_(history_params), |
| 142 browser_initiated_(browser_initiated), | 146 browser_initiated_(browser_initiated), |
| 143 state_(NOT_STARTED), | 147 state_(NOT_STARTED), |
| 144 restore_type_(NavigationEntryImpl::RESTORE_NONE), | 148 restore_type_(NavigationEntryImpl::RESTORE_NONE), |
| 145 is_view_source_(false), | 149 is_view_source_(false), |
| 146 bindings_(NavigationEntryImpl::kInvalidBindings) { | 150 bindings_(NavigationEntryImpl::kInvalidBindings) { |
| 147 if (entry) { | 151 if (entry) { |
| 148 source_site_instance_ = entry->source_site_instance(); | 152 source_site_instance_ = entry->source_site_instance(); |
| 149 dest_site_instance_ = entry->site_instance(); | 153 dest_site_instance_ = entry->site_instance(); |
| 150 restore_type_ = entry->restore_type(); | 154 restore_type_ = entry->restore_type(); |
| 151 is_view_source_ = entry->IsViewSourceMode(); | 155 is_view_source_ = entry->IsViewSourceMode(); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 // TODO(davidben): Network failures should display a network error page. | 220 // TODO(davidben): Network failures should display a network error page. |
| 217 NOTIMPLEMENTED() << " where net_error=" << net_error; | 221 NOTIMPLEMENTED() << " where net_error=" << net_error; |
| 218 } | 222 } |
| 219 | 223 |
| 220 void NavigationRequest::OnRequestStarted(base::TimeTicks timestamp) { | 224 void NavigationRequest::OnRequestStarted(base::TimeTicks timestamp) { |
| 221 frame_tree_node_->navigator()->LogResourceRequestTime(timestamp, | 225 frame_tree_node_->navigator()->LogResourceRequestTime(timestamp, |
| 222 common_params_.url); | 226 common_params_.url); |
| 223 } | 227 } |
| 224 | 228 |
| 225 } // namespace content | 229 } // namespace content |
| OLD | NEW |