OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "android_webview/native/state_serializer.h" | 5 #include "android_webview/native/state_serializer.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/memory/scoped_vector.h" | 9 #include "base/memory/scoped_vector.h" |
10 #include "base/pickle.h" | 10 #include "base/pickle.h" |
11 #include "base/time.h" | 11 #include "base/time.h" |
12 #include "content/public/browser/navigation_controller.h" | 12 #include "content/public/browser/navigation_controller.h" |
13 #include "content/public/browser/navigation_entry.h" | 13 #include "content/public/browser/navigation_entry.h" |
14 #include "content/public/browser/web_contents.h" | 14 #include "content/public/browser/web_contents.h" |
15 #include "content/public/common/page_state.h" | |
15 | 16 |
16 // Reasons for not re-using TabNavigation under chrome/ as of 20121116: | 17 // Reasons for not re-using TabNavigation under chrome/ as of 20121116: |
17 // * Android WebView has different requirements for fields to store since | 18 // * Android WebView has different requirements for fields to store since |
18 // we are the only ones using values like BaseURLForDataURL. | 19 // we are the only ones using values like BaseURLForDataURL. |
19 // * TabNavigation does unnecessary copying of data, which in Android | 20 // * TabNavigation does unnecessary copying of data, which in Android |
20 // WebView case, is undesired since save/restore is called in Android | 21 // WebView case, is undesired since save/restore is called in Android |
21 // very frequently. | 22 // very frequently. |
22 // * TabNavigation is tightly integrated with the rest of chrome session | 23 // * TabNavigation is tightly integrated with the rest of chrome session |
23 // restore and sync code, and has other purpose in addition to serializing | 24 // restore and sync code, and has other purpose in addition to serializing |
24 // NavigationEntry. | 25 // NavigationEntry. |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
139 | 140 |
140 const content::Referrer& referrer = entry.GetReferrer(); | 141 const content::Referrer& referrer = entry.GetReferrer(); |
141 if (!pickle->WriteString(referrer.url.spec())) | 142 if (!pickle->WriteString(referrer.url.spec())) |
142 return false; | 143 return false; |
143 if (!pickle->WriteInt(static_cast<int>(referrer.policy))) | 144 if (!pickle->WriteInt(static_cast<int>(referrer.policy))) |
144 return false; | 145 return false; |
145 | 146 |
146 if (!pickle->WriteString16(entry.GetTitle())) | 147 if (!pickle->WriteString16(entry.GetTitle())) |
147 return false; | 148 return false; |
148 | 149 |
149 if (!pickle->WriteString(entry.GetContentState())) | 150 if (!pickle->WriteString(entry.GetPageState().ToEncodedData())) |
joth
2013/05/28 22:04:34
does the alter the format it is written out to the
| |
150 return false; | 151 return false; |
151 | 152 |
152 if (!pickle->WriteBool(static_cast<int>(entry.GetHasPostData()))) | 153 if (!pickle->WriteBool(static_cast<int>(entry.GetHasPostData()))) |
153 return false; | 154 return false; |
154 | 155 |
155 if (!pickle->WriteString(entry.GetOriginalRequestURL().spec())) | 156 if (!pickle->WriteString(entry.GetOriginalRequestURL().spec())) |
156 return false; | 157 return false; |
157 | 158 |
158 if (!pickle->WriteString(entry.GetBaseURLForDataURL().spec())) | 159 if (!pickle->WriteString(entry.GetBaseURLForDataURL().spec())) |
159 return false; | 160 return false; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
204 string16 title; | 205 string16 title; |
205 if (!iterator->ReadString16(&title)) | 206 if (!iterator->ReadString16(&title)) |
206 return false; | 207 return false; |
207 entry->SetTitle(title); | 208 entry->SetTitle(title); |
208 } | 209 } |
209 | 210 |
210 { | 211 { |
211 string content_state; | 212 string content_state; |
212 if (!iterator->ReadString(&content_state)) | 213 if (!iterator->ReadString(&content_state)) |
213 return false; | 214 return false; |
214 entry->SetContentState(content_state); | 215 entry->SetPageState( |
216 content::PageState::CreateFromEncodedData(content_state)); | |
joth
2013/05/28 22:59:44
latent question.... what if |content_state| is bog
| |
215 } | 217 } |
216 | 218 |
217 { | 219 { |
218 bool has_post_data; | 220 bool has_post_data; |
219 if (!iterator->ReadBool(&has_post_data)) | 221 if (!iterator->ReadBool(&has_post_data)) |
220 return false; | 222 return false; |
221 entry->SetHasPostData(has_post_data); | 223 entry->SetHasPostData(has_post_data); |
222 } | 224 } |
223 | 225 |
224 { | 226 { |
(...skipping 23 matching lines...) Expand all Loading... | |
248 return false; | 250 return false; |
249 entry->SetTimestamp(base::Time::FromInternalValue(timestamp)); | 251 entry->SetTimestamp(base::Time::FromInternalValue(timestamp)); |
250 } | 252 } |
251 | 253 |
252 return true; | 254 return true; |
253 } | 255 } |
254 | 256 |
255 } // namespace internal | 257 } // namespace internal |
256 | 258 |
257 } // namespace android_webview | 259 } // namespace android_webview |
OLD | NEW |