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 "chrome/browser/password_manager/native_backend_kwallet_x.h" | 5 #include "chrome/browser/password_manager/native_backend_kwallet_x.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
(...skipping 18 matching lines...) Expand all Loading... |
29 #include "ui/base/l10n/l10n_util.h" | 29 #include "ui/base/l10n/l10n_util.h" |
30 #include "url/origin.h" | 30 #include "url/origin.h" |
31 | 31 |
32 using autofill::PasswordForm; | 32 using autofill::PasswordForm; |
33 using content::BrowserThread; | 33 using content::BrowserThread; |
34 | 34 |
35 namespace { | 35 namespace { |
36 | 36 |
37 // In case the fields in the pickle ever change, version them so we can try to | 37 // In case the fields in the pickle ever change, version them so we can try to |
38 // read old pickles. (Note: do not eat old pickles past the expiration date.) | 38 // read old pickles. (Note: do not eat old pickles past the expiration date.) |
39 const int kPickleVersion = 8; | 39 const int kPickleVersion = 9; |
40 | 40 |
41 // We could localize this string, but then changing your locale would cause | 41 // We could localize this string, but then changing your locale would cause |
42 // you to lose access to all your stored passwords. Maybe best not to do that. | 42 // you to lose access to all your stored passwords. Maybe best not to do that. |
43 // Name of the folder to store passwords in. | 43 // Name of the folder to store passwords in. |
44 const char kKWalletFolder[] = "Chrome Form Data"; | 44 const char kKWalletFolder[] = "Chrome Form Data"; |
45 | 45 |
46 // Checks a serialized list of PasswordForms for sanity. Returns true if OK. | 46 // Checks a serialized list of PasswordForms for sanity. Returns true if OK. |
47 // Note that |realm| is only used for generating a useful warning message. | 47 // Note that |realm| is only used for generating a useful warning message. |
48 bool CheckSerializedValue(const uint8_t* byte_array, | 48 bool CheckSerializedValue(const uint8_t* byte_array, |
49 size_t length, | 49 size_t length, |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 for (size_t i = 0; i < count; ++i) { | 157 for (size_t i = 0; i < count; ++i) { |
158 std::unique_ptr<PasswordForm> form(new PasswordForm()); | 158 std::unique_ptr<PasswordForm> form(new PasswordForm()); |
159 form->signon_realm.assign(signon_realm); | 159 form->signon_realm.assign(signon_realm); |
160 | 160 |
161 int scheme = 0; | 161 int scheme = 0; |
162 int64_t date_created = 0; | 162 int64_t date_created = 0; |
163 int type = 0; | 163 int type = 0; |
164 int generation_upload_status = 0; | 164 int generation_upload_status = 0; |
165 // Note that these will be read back in the order listed due to | 165 // Note that these will be read back in the order listed due to |
166 // short-circuit evaluation. This is important. | 166 // short-circuit evaluation. This is important. |
167 if (!iter.ReadInt(&scheme) || | 167 if (!iter.ReadInt(&scheme) || !ReadGURL(&iter, warn_only, &form->origin) || |
168 !ReadGURL(&iter, warn_only, &form->origin) || | |
169 !ReadGURL(&iter, warn_only, &form->action) || | 168 !ReadGURL(&iter, warn_only, &form->action) || |
170 !iter.ReadString16(&form->username_element) || | 169 !iter.ReadString16(&form->username_element) || |
171 !iter.ReadString16(&form->username_value) || | 170 !iter.ReadString16(&form->username_value) || |
172 !iter.ReadString16(&form->password_element) || | 171 !iter.ReadString16(&form->password_element) || |
173 !iter.ReadString16(&form->password_value) || | 172 !iter.ReadString16(&form->password_value) || |
174 !iter.ReadString16(&form->submit_element) || | 173 !iter.ReadString16(&form->submit_element)) { |
175 !iter.ReadBool(&form->ssl_valid) || | 174 LogDeserializationWarning(version, signon_realm, warn_only); |
176 !iter.ReadBool(&form->preferred) || | 175 return false; |
| 176 } |
| 177 if (version <= 8) { |
| 178 bool dummy_unused_flag = false; |
| 179 if (!iter.ReadBool(&dummy_unused_flag)) { |
| 180 LogDeserializationWarning(version, signon_realm, warn_only); |
| 181 return false; |
| 182 } |
| 183 } |
| 184 if (!iter.ReadBool(&form->preferred) || |
177 !iter.ReadBool(&form->blacklisted_by_user) || | 185 !iter.ReadBool(&form->blacklisted_by_user) || |
178 !iter.ReadInt64(&date_created)) { | 186 !iter.ReadInt64(&date_created)) { |
179 LogDeserializationWarning(version, signon_realm, warn_only); | 187 LogDeserializationWarning(version, signon_realm, warn_only); |
180 return false; | 188 return false; |
181 } | 189 } |
182 form->scheme = static_cast<PasswordForm::Scheme>(scheme); | 190 form->scheme = static_cast<PasswordForm::Scheme>(scheme); |
183 | 191 |
184 if (version > 1) { | 192 if (version > 1) { |
185 if (!iter.ReadInt(&type) || | 193 if (!iter.ReadInt(&type) || |
186 !iter.ReadInt(&form->times_used) || | 194 !iter.ReadInt(&form->times_used) || |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 pickle->WriteUInt64(forms.size()); | 255 pickle->WriteUInt64(forms.size()); |
248 for (autofill::PasswordForm* form : forms) { | 256 for (autofill::PasswordForm* form : forms) { |
249 pickle->WriteInt(form->scheme); | 257 pickle->WriteInt(form->scheme); |
250 pickle->WriteString(form->origin.spec()); | 258 pickle->WriteString(form->origin.spec()); |
251 pickle->WriteString(form->action.spec()); | 259 pickle->WriteString(form->action.spec()); |
252 pickle->WriteString16(form->username_element); | 260 pickle->WriteString16(form->username_element); |
253 pickle->WriteString16(form->username_value); | 261 pickle->WriteString16(form->username_value); |
254 pickle->WriteString16(form->password_element); | 262 pickle->WriteString16(form->password_element); |
255 pickle->WriteString16(form->password_value); | 263 pickle->WriteString16(form->password_value); |
256 pickle->WriteString16(form->submit_element); | 264 pickle->WriteString16(form->submit_element); |
257 pickle->WriteBool(form->ssl_valid); | |
258 pickle->WriteBool(form->preferred); | 265 pickle->WriteBool(form->preferred); |
259 pickle->WriteBool(form->blacklisted_by_user); | 266 pickle->WriteBool(form->blacklisted_by_user); |
260 pickle->WriteInt64(form->date_created.ToInternalValue()); | 267 pickle->WriteInt64(form->date_created.ToInternalValue()); |
261 pickle->WriteInt(form->type); | 268 pickle->WriteInt(form->type); |
262 pickle->WriteInt(form->times_used); | 269 pickle->WriteInt(form->times_used); |
263 autofill::SerializeFormData(form->form_data, pickle); | 270 autofill::SerializeFormData(form->form_data, pickle); |
264 pickle->WriteInt64(form->date_synced.ToInternalValue()); | 271 pickle->WriteInt64(form->date_synced.ToInternalValue()); |
265 pickle->WriteString16(form->display_name); | 272 pickle->WriteString16(form->display_name); |
266 pickle->WriteString(form->icon_url.spec()); | 273 pickle->WriteString(form->icon_url.spec()); |
267 // We serialize unique origins as "", in order to make other systems that | 274 // We serialize unique origins as "", in order to make other systems that |
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
827 } | 834 } |
828 | 835 |
829 return handle; | 836 return handle; |
830 } | 837 } |
831 | 838 |
832 std::string NativeBackendKWallet::GetProfileSpecificFolderName() const { | 839 std::string NativeBackendKWallet::GetProfileSpecificFolderName() const { |
833 // Originally, the folder name was always just "Chrome Form Data". | 840 // Originally, the folder name was always just "Chrome Form Data". |
834 // Now we use it to distinguish passwords for different profiles. | 841 // Now we use it to distinguish passwords for different profiles. |
835 return base::StringPrintf("%s (%d)", kKWalletFolder, profile_id_); | 842 return base::StringPrintf("%s (%d)", kKWalletFolder, profile_id_); |
836 } | 843 } |
OLD | NEW |