Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/frame_navigation_entry.h" | 5 #include "content/browser/frame_host/frame_navigation_entry.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/strings/utf_string_conversions.h" | |
| 10 #include "content/common/page_state_serialization.h" | |
| 11 | |
| 9 namespace content { | 12 namespace content { |
| 10 | 13 |
| 14 namespace { | |
| 15 | |
| 16 bool RecursivelyFillBody(const ExplodedFrameState& state, | |
| 17 const std::string& frame_name, | |
| 18 ResourceRequestBody* body) { | |
| 19 if (base::UTF16ToUTF8(state.target.string()) == frame_name) { | |
| 20 if (!GeneratePostData(state.http_body, body)) | |
| 21 return false; | |
| 22 return true; | |
| 23 } | |
| 24 | |
| 25 for (const ExplodedFrameState& child_state : state.children) { | |
| 26 if (RecursivelyFillBody(child_state, frame_name, body)) | |
| 27 return true; | |
| 28 } | |
| 29 | |
| 30 return false; | |
| 31 } | |
| 32 | |
| 33 } // namespace | |
| 34 | |
| 11 FrameNavigationEntry::FrameNavigationEntry() | 35 FrameNavigationEntry::FrameNavigationEntry() |
| 12 : item_sequence_number_(-1), document_sequence_number_(-1), post_id_(-1) {} | 36 : item_sequence_number_(-1), document_sequence_number_(-1), post_id_(-1) {} |
| 13 | 37 |
| 14 FrameNavigationEntry::FrameNavigationEntry( | 38 FrameNavigationEntry::FrameNavigationEntry( |
| 15 const std::string& frame_unique_name, | 39 const std::string& frame_unique_name, |
| 16 int64_t item_sequence_number, | 40 int64_t item_sequence_number, |
| 17 int64_t document_sequence_number, | 41 int64_t document_sequence_number, |
| 18 scoped_refptr<SiteInstanceImpl> site_instance, | 42 scoped_refptr<SiteInstanceImpl> site_instance, |
| 19 const GURL& url, | 43 const GURL& url, |
| 20 const Referrer& referrer, | 44 const Referrer& referrer, |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 66 // location.replace is classified as NEW_PAGE rather than EXISTING_PAGE. | 90 // location.replace is classified as NEW_PAGE rather than EXISTING_PAGE. |
| 67 // Same for document sequence number. See https://crbug.com/596707. | 91 // Same for document sequence number. See https://crbug.com/596707. |
| 68 item_sequence_number_ = item_sequence_number; | 92 item_sequence_number_ = item_sequence_number; |
| 69 } | 93 } |
| 70 | 94 |
| 71 void FrameNavigationEntry::set_document_sequence_number( | 95 void FrameNavigationEntry::set_document_sequence_number( |
| 72 int64_t document_sequence_number) { | 96 int64_t document_sequence_number) { |
| 73 document_sequence_number_ = document_sequence_number; | 97 document_sequence_number_ = document_sequence_number; |
| 74 } | 98 } |
| 75 | 99 |
| 100 scoped_refptr<ResourceRequestBody> FrameNavigationEntry::GetPostData() const { | |
| 101 scoped_refptr<ResourceRequestBody> body; | |
| 102 if (method_ != "POST") | |
| 103 return body; | |
| 104 | |
| 105 // Generate the body from the PageState. | |
| 106 ExplodedPageState exploded_state; | |
| 107 if (!DecodePageState(page_state_.ToEncodedData(), &exploded_state)) | |
| 108 return body; | |
| 109 | |
| 110 body = new ResourceRequestBody(); | |
| 111 if (!RecursivelyFillBody(exploded_state.top, frame_unique_name_, body.get())) | |
|
Charlie Reis
2016/05/11 00:00:23
Why is this recursive? The PageState on a FrameNa
clamy
2016/05/11 08:54:41
Ah I didn't know there was only one frame in the P
| |
| 112 return nullptr; | |
| 113 | |
| 114 return body; | |
| 115 } | |
| 116 | |
| 76 } // namespace content | 117 } // namespace content |
| OLD | NEW |