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 <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
10 #include "content/browser/appcache/appcache_navigation_handle.h" | 10 #include "content/browser/appcache/appcache_navigation_handle.h" |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
192 std::unique_ptr<NavigationRequest> NavigationRequest::CreateBrowserInitiated( | 192 std::unique_ptr<NavigationRequest> NavigationRequest::CreateBrowserInitiated( |
193 FrameTreeNode* frame_tree_node, | 193 FrameTreeNode* frame_tree_node, |
194 const GURL& dest_url, | 194 const GURL& dest_url, |
195 const Referrer& dest_referrer, | 195 const Referrer& dest_referrer, |
196 const FrameNavigationEntry& frame_entry, | 196 const FrameNavigationEntry& frame_entry, |
197 const NavigationEntryImpl& entry, | 197 const NavigationEntryImpl& entry, |
198 FrameMsg_Navigate_Type::Value navigation_type, | 198 FrameMsg_Navigate_Type::Value navigation_type, |
199 PreviewsState previews_state, | 199 PreviewsState previews_state, |
200 bool is_same_document_history_load, | 200 bool is_same_document_history_load, |
201 bool is_history_navigation_in_new_child, | 201 bool is_history_navigation_in_new_child, |
202 const scoped_refptr<ResourceRequestBodyImpl>& post_body, | |
202 const base::TimeTicks& navigation_start, | 203 const base::TimeTicks& navigation_start, |
203 NavigationControllerImpl* controller) { | 204 NavigationControllerImpl* controller) { |
204 // Fill POST data in the request body. | 205 // A form submission happens either because the navigation is a |
206 // renderer-initiated form submission that took the OpenURL path or either a | |
nasko
2017/05/16 04:08:21
nit: s/or either/or/
arthursonzogni
2017/05/16 12:45:58
Done.
| |
207 // back/forward/reload navigation the does a form resubmission. | |
205 scoped_refptr<ResourceRequestBodyImpl> request_body; | 208 scoped_refptr<ResourceRequestBodyImpl> request_body; |
206 if (frame_entry.method() == "POST") | 209 if (post_body) { |
210 // Standard form-submission from the renderer. | |
nasko
2017/05/16 04:08:21
nit: no need for "-" between form and submission
arthursonzogni
2017/05/16 12:45:58
Done.
| |
211 request_body = post_body; | |
212 } else if (frame_entry.method() == "POST") { | |
213 // Form resubmission during a back/forward/reload navigation. | |
207 request_body = frame_entry.GetPostData(); | 214 request_body = frame_entry.GetPostData(); |
215 } | |
216 // TODO(arthursonzogni): Form submission with the "GET" method is possible. | |
217 // This is not currently handled here. | |
218 bool is_form_submission = bool(request_body); | |
nasko
2017/05/16 04:08:21
nit: !!request_body?
arthursonzogni
2017/05/16 12:45:58
I would prefer not to. If you don't like: "bool(..
nasko
2017/05/16 14:02:09
The main point is to keep code consistent. I haven
| |
208 | 219 |
209 base::Optional<url::Origin> initiator = | 220 base::Optional<url::Origin> initiator = |
210 frame_tree_node->IsMainFrame() | 221 frame_tree_node->IsMainFrame() |
211 ? base::Optional<url::Origin>() | 222 ? base::Optional<url::Origin>() |
212 : base::Optional<url::Origin>( | 223 : base::Optional<url::Origin>( |
213 frame_tree_node->frame_tree()->root()->current_origin()); | 224 frame_tree_node->frame_tree()->root()->current_origin()); |
214 | 225 |
215 // While the navigation was started via the LoadURL path it may have come from | 226 // While the navigation was started via the LoadURL path it may have come from |
216 // the renderer in the first place as part of OpenURL. | 227 // the renderer in the first place as part of OpenURL. |
217 bool browser_initiated = !entry.is_renderer_initiated(); | 228 bool browser_initiated = !entry.is_renderer_initiated(); |
218 | 229 |
219 CommonNavigationParams common_params = entry.ConstructCommonNavigationParams( | 230 CommonNavigationParams common_params = entry.ConstructCommonNavigationParams( |
220 frame_entry, request_body, dest_url, dest_referrer, navigation_type, | 231 frame_entry, request_body, dest_url, dest_referrer, navigation_type, |
221 previews_state, navigation_start); | 232 previews_state, navigation_start); |
222 | 233 |
223 std::unique_ptr<NavigationRequest> navigation_request(new NavigationRequest( | 234 std::unique_ptr<NavigationRequest> navigation_request(new NavigationRequest( |
224 frame_tree_node, common_params, | 235 frame_tree_node, common_params, |
225 BeginNavigationParams(entry.extra_headers(), net::LOAD_NORMAL, | 236 BeginNavigationParams(entry.extra_headers(), net::LOAD_NORMAL, |
226 false, // has_user_gestures | 237 false, // has_user_gestures |
227 false, // skip_service_worker | 238 false, // skip_service_worker |
228 REQUEST_CONTEXT_TYPE_LOCATION, | 239 REQUEST_CONTEXT_TYPE_LOCATION, |
229 blink::WebMixedContentContextType::kBlockable, | 240 blink::WebMixedContentContextType::kBlockable, |
230 // TODO(arthursonzogni): It can be true for form | 241 is_form_submission, initiator), |
231 // resubmission when the user reloads the page. This | |
232 // needs to be fixed. | |
233 false, // is_form_submission | |
234 initiator), | |
235 entry.ConstructRequestNavigationParams( | 242 entry.ConstructRequestNavigationParams( |
236 frame_entry, common_params.url, common_params.method, | 243 frame_entry, common_params.url, common_params.method, |
237 is_history_navigation_in_new_child, | 244 is_history_navigation_in_new_child, |
238 entry.GetSubframeUniqueNames(frame_tree_node), | 245 entry.GetSubframeUniqueNames(frame_tree_node), |
239 frame_tree_node->has_committed_real_load(), | 246 frame_tree_node->has_committed_real_load(), |
240 controller->GetPendingEntryIndex() == -1, | 247 controller->GetPendingEntryIndex() == -1, |
241 controller->GetIndexOfEntry(&entry), | 248 controller->GetIndexOfEntry(&entry), |
242 controller->GetLastCommittedEntryIndex(), | 249 controller->GetLastCommittedEntryIndex(), |
243 controller->GetEntryCount()), | 250 controller->GetEntryCount()), |
244 browser_initiated, | 251 browser_initiated, |
(...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
862 DCHECK_EQ(request_params_.has_user_gesture, begin_params_.has_user_gesture); | 869 DCHECK_EQ(request_params_.has_user_gesture, begin_params_.has_user_gesture); |
863 | 870 |
864 render_frame_host->CommitNavigation(response_.get(), std::move(body_), | 871 render_frame_host->CommitNavigation(response_.get(), std::move(body_), |
865 std::move(handle_), common_params_, | 872 std::move(handle_), common_params_, |
866 request_params_, is_view_source_); | 873 request_params_, is_view_source_); |
867 | 874 |
868 frame_tree_node_->ResetNavigationRequest(true, true); | 875 frame_tree_node_->ResetNavigationRequest(true, true); |
869 } | 876 } |
870 | 877 |
871 } // namespace content | 878 } // namespace content |
OLD | NEW |