| 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 <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 return INIT_SUCCESS; | 265 return INIT_SUCCESS; |
| 266 } | 266 } |
| 267 | 267 |
| 268 password_manager::PasswordStoreChangeList NativeBackendKWallet::AddLogin( | 268 password_manager::PasswordStoreChangeList NativeBackendKWallet::AddLogin( |
| 269 const PasswordForm& form) { | 269 const PasswordForm& form) { |
| 270 int wallet_handle = WalletHandle(); | 270 int wallet_handle = WalletHandle(); |
| 271 if (wallet_handle == kInvalidKWalletHandle) | 271 if (wallet_handle == kInvalidKWalletHandle) |
| 272 return password_manager::PasswordStoreChangeList(); | 272 return password_manager::PasswordStoreChangeList(); |
| 273 | 273 |
| 274 ScopedVector<autofill::PasswordForm> forms; | 274 ScopedVector<autofill::PasswordForm> forms; |
| 275 GetLoginsList(&forms.get(), form.signon_realm, wallet_handle); | 275 GetLoginsList(form.signon_realm, wallet_handle, &forms); |
| 276 | 276 |
| 277 // We search for a login to update, rather than unconditionally appending the | 277 // We search for a login to update, rather than unconditionally appending the |
| 278 // login, because in some cases (especially involving sync) we can be asked to | 278 // login, because in some cases (especially involving sync) we can be asked to |
| 279 // add a login that already exists. In these cases we want to just update. | 279 // add a login that already exists. In these cases we want to just update. |
| 280 bool updated = false; | 280 bool updated = false; |
| 281 password_manager::PasswordStoreChangeList changes; | 281 password_manager::PasswordStoreChangeList changes; |
| 282 for (size_t i = 0; i < forms.size(); ++i) { | 282 for (size_t i = 0; i < forms.size(); ++i) { |
| 283 // Use the more restrictive removal comparison, so that we never have | 283 // Use the more restrictive removal comparison, so that we never have |
| 284 // duplicate logins that would all be removed together by RemoveLogin(). | 284 // duplicate logins that would all be removed together by RemoveLogin(). |
| 285 if (CompareForms(form, *forms[i], false)) { | 285 if (CompareForms(form, *forms[i], false)) { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 304 bool NativeBackendKWallet::UpdateLogin( | 304 bool NativeBackendKWallet::UpdateLogin( |
| 305 const PasswordForm& form, | 305 const PasswordForm& form, |
| 306 password_manager::PasswordStoreChangeList* changes) { | 306 password_manager::PasswordStoreChangeList* changes) { |
| 307 DCHECK(changes); | 307 DCHECK(changes); |
| 308 changes->clear(); | 308 changes->clear(); |
| 309 int wallet_handle = WalletHandle(); | 309 int wallet_handle = WalletHandle(); |
| 310 if (wallet_handle == kInvalidKWalletHandle) | 310 if (wallet_handle == kInvalidKWalletHandle) |
| 311 return false; | 311 return false; |
| 312 | 312 |
| 313 ScopedVector<autofill::PasswordForm> forms; | 313 ScopedVector<autofill::PasswordForm> forms; |
| 314 GetLoginsList(&forms.get(), form.signon_realm, wallet_handle); | 314 GetLoginsList(form.signon_realm, wallet_handle, &forms); |
| 315 | 315 |
| 316 bool updated = false; | 316 bool updated = false; |
| 317 for (size_t i = 0; i < forms.size(); ++i) { | 317 for (size_t i = 0; i < forms.size(); ++i) { |
| 318 if (CompareForms(form, *forms[i], true)) { | 318 if (CompareForms(form, *forms[i], true)) { |
| 319 *forms[i] = form; | 319 *forms[i] = form; |
| 320 updated = true; | 320 updated = true; |
| 321 } | 321 } |
| 322 } | 322 } |
| 323 if (!updated) | 323 if (!updated) |
| 324 return true; | 324 return true; |
| 325 | 325 |
| 326 if (SetLoginsList(forms.get(), form.signon_realm, wallet_handle)) { | 326 if (SetLoginsList(forms.get(), form.signon_realm, wallet_handle)) { |
| 327 changes->push_back(password_manager::PasswordStoreChange( | 327 changes->push_back(password_manager::PasswordStoreChange( |
| 328 password_manager::PasswordStoreChange::UPDATE, form)); | 328 password_manager::PasswordStoreChange::UPDATE, form)); |
| 329 return true; | 329 return true; |
| 330 } | 330 } |
| 331 | 331 |
| 332 return false; | 332 return false; |
| 333 } | 333 } |
| 334 | 334 |
| 335 bool NativeBackendKWallet::RemoveLogin(const PasswordForm& form) { | 335 bool NativeBackendKWallet::RemoveLogin(const PasswordForm& form) { |
| 336 int wallet_handle = WalletHandle(); | 336 int wallet_handle = WalletHandle(); |
| 337 if (wallet_handle == kInvalidKWalletHandle) | 337 if (wallet_handle == kInvalidKWalletHandle) |
| 338 return false; | 338 return false; |
| 339 | 339 |
| 340 PasswordFormList all_forms; | 340 ScopedVector<autofill::PasswordForm> all_forms; |
| 341 GetLoginsList(&all_forms, form.signon_realm, wallet_handle); | 341 GetLoginsList(form.signon_realm, wallet_handle, &all_forms); |
| 342 | 342 |
| 343 PasswordFormList kept_forms; | 343 ScopedVector<autofill::PasswordForm> kept_forms; |
| 344 kept_forms.reserve(all_forms.size()); | 344 kept_forms.reserve(all_forms.size()); |
| 345 for (size_t i = 0; i < all_forms.size(); ++i) { | 345 for (auto& saved_form : all_forms) { |
| 346 if (CompareForms(form, *all_forms[i], false)) | 346 if (!CompareForms(form, *saved_form, false)) { |
| 347 delete all_forms[i]; | 347 kept_forms.push_back(saved_form); |
| 348 else | 348 saved_form = nullptr; |
| 349 kept_forms.push_back(all_forms[i]); | 349 } |
| 350 } | 350 } |
| 351 | 351 |
| 352 // Update the entry in the wallet, possibly deleting it. | 352 // Update the entry in the wallet, possibly deleting it. |
| 353 bool ok = SetLoginsList(kept_forms, form.signon_realm, wallet_handle); | 353 return SetLoginsList(kept_forms.get(), form.signon_realm, wallet_handle); |
| 354 | |
| 355 STLDeleteElements(&kept_forms); | |
| 356 return ok; | |
| 357 } | 354 } |
| 358 | 355 |
| 359 bool NativeBackendKWallet::RemoveLoginsCreatedBetween( | 356 bool NativeBackendKWallet::RemoveLoginsCreatedBetween( |
| 360 base::Time delete_begin, | 357 base::Time delete_begin, |
| 361 base::Time delete_end, | 358 base::Time delete_end, |
| 362 password_manager::PasswordStoreChangeList* changes) { | 359 password_manager::PasswordStoreChangeList* changes) { |
| 363 return RemoveLoginsBetween( | 360 return RemoveLoginsBetween( |
| 364 delete_begin, delete_end, CREATION_TIMESTAMP, changes); | 361 delete_begin, delete_end, CREATION_TIMESTAMP, changes); |
| 365 } | 362 } |
| 366 | 363 |
| 367 bool NativeBackendKWallet::RemoveLoginsSyncedBetween( | 364 bool NativeBackendKWallet::RemoveLoginsSyncedBetween( |
| 368 base::Time delete_begin, | 365 base::Time delete_begin, |
| 369 base::Time delete_end, | 366 base::Time delete_end, |
| 370 password_manager::PasswordStoreChangeList* changes) { | 367 password_manager::PasswordStoreChangeList* changes) { |
| 371 return RemoveLoginsBetween(delete_begin, delete_end, SYNC_TIMESTAMP, changes); | 368 return RemoveLoginsBetween(delete_begin, delete_end, SYNC_TIMESTAMP, changes); |
| 372 } | 369 } |
| 373 | 370 |
| 374 bool NativeBackendKWallet::GetLogins(const PasswordForm& form, | 371 bool NativeBackendKWallet::GetLogins( |
| 375 PasswordFormList* forms) { | 372 const PasswordForm& form, |
| 373 ScopedVector<autofill::PasswordForm>* forms) { |
| 376 int wallet_handle = WalletHandle(); | 374 int wallet_handle = WalletHandle(); |
| 377 if (wallet_handle == kInvalidKWalletHandle) | 375 if (wallet_handle == kInvalidKWalletHandle) |
| 378 return false; | 376 return false; |
| 379 return GetLoginsList(forms, form.signon_realm, wallet_handle); | 377 return GetLoginsList(form.signon_realm, wallet_handle, forms); |
| 380 } | 378 } |
| 381 | 379 |
| 382 bool NativeBackendKWallet::GetAutofillableLogins(PasswordFormList* forms) { | 380 bool NativeBackendKWallet::GetAutofillableLogins( |
| 381 ScopedVector<autofill::PasswordForm>* forms) { |
| 383 int wallet_handle = WalletHandle(); | 382 int wallet_handle = WalletHandle(); |
| 384 if (wallet_handle == kInvalidKWalletHandle) | 383 if (wallet_handle == kInvalidKWalletHandle) |
| 385 return false; | 384 return false; |
| 386 return GetLoginsList(forms, true, wallet_handle); | 385 return GetLoginsList(true, wallet_handle, forms); |
| 387 } | 386 } |
| 388 | 387 |
| 389 bool NativeBackendKWallet::GetBlacklistLogins(PasswordFormList* forms) { | 388 bool NativeBackendKWallet::GetBlacklistLogins( |
| 389 ScopedVector<autofill::PasswordForm>* forms) { |
| 390 int wallet_handle = WalletHandle(); | 390 int wallet_handle = WalletHandle(); |
| 391 if (wallet_handle == kInvalidKWalletHandle) | 391 if (wallet_handle == kInvalidKWalletHandle) |
| 392 return false; | 392 return false; |
| 393 return GetLoginsList(forms, false, wallet_handle); | 393 return GetLoginsList(false, wallet_handle, forms); |
| 394 } | 394 } |
| 395 | 395 |
| 396 bool NativeBackendKWallet::GetLoginsList(PasswordFormList* forms, | 396 bool NativeBackendKWallet::GetLoginsList( |
| 397 const std::string& signon_realm, | 397 const std::string& signon_realm, |
| 398 int wallet_handle) { | 398 int wallet_handle, |
| 399 ScopedVector<autofill::PasswordForm>* forms) { |
| 399 // Is there an entry in the wallet? | 400 // Is there an entry in the wallet? |
| 400 { | 401 { |
| 401 dbus::MethodCall method_call(kKWalletInterface, "hasEntry"); | 402 dbus::MethodCall method_call(kKWalletInterface, "hasEntry"); |
| 402 dbus::MessageWriter builder(&method_call); | 403 dbus::MessageWriter builder(&method_call); |
| 403 builder.AppendInt32(wallet_handle); // handle | 404 builder.AppendInt32(wallet_handle); // handle |
| 404 builder.AppendString(folder_name_); // folder | 405 builder.AppendString(folder_name_); // folder |
| 405 builder.AppendString(signon_realm); // key | 406 builder.AppendString(signon_realm); // key |
| 406 builder.AppendString(app_name_); // appid | 407 builder.AppendString(app_name_); // appid |
| 407 scoped_ptr<dbus::Response> response( | 408 scoped_ptr<dbus::Response> response( |
| 408 kwallet_proxy_->CallMethodAndBlock( | 409 kwallet_proxy_->CallMethodAndBlock( |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 451 if (!CheckSerializedValue(bytes, length, signon_realm)) { | 452 if (!CheckSerializedValue(bytes, length, signon_realm)) { |
| 452 // This is weird, but we choose not to call it an error. There is an | 453 // This is weird, but we choose not to call it an error. There is an |
| 453 // invalid entry somehow, but by just ignoring it, we make it easier to | 454 // invalid entry somehow, but by just ignoring it, we make it easier to |
| 454 // repair without having to delete it using kwalletmanager (that is, by | 455 // repair without having to delete it using kwalletmanager (that is, by |
| 455 // just saving a new password within this realm to overwrite it). | 456 // just saving a new password within this realm to overwrite it). |
| 456 return true; | 457 return true; |
| 457 } | 458 } |
| 458 | 459 |
| 459 // Can't we all just agree on whether bytes are signed or not? Please? | 460 // Can't we all just agree on whether bytes are signed or not? Please? |
| 460 Pickle pickle(reinterpret_cast<const char*>(bytes), length); | 461 Pickle pickle(reinterpret_cast<const char*>(bytes), length); |
| 461 PasswordFormList all_forms; | |
| 462 DeserializeValue(signon_realm, pickle, forms); | 462 DeserializeValue(signon_realm, pickle, forms); |
| 463 } | 463 } |
| 464 | 464 |
| 465 return true; | 465 return true; |
| 466 } | 466 } |
| 467 | 467 |
| 468 bool NativeBackendKWallet::GetLoginsList(PasswordFormList* forms, | 468 bool NativeBackendKWallet::GetLoginsList( |
| 469 bool autofillable, | 469 bool autofillable, |
| 470 int wallet_handle) { | 470 int wallet_handle, |
| 471 PasswordFormList all_forms; | 471 ScopedVector<autofill::PasswordForm>* forms) { |
| 472 if (!GetAllLogins(&all_forms, wallet_handle)) | 472 ScopedVector<autofill::PasswordForm> all_forms; |
| 473 if (!GetAllLogins(wallet_handle, &all_forms)) |
| 473 return false; | 474 return false; |
| 474 | 475 |
| 475 // We have to read all the entries, and then filter them here. | 476 // We have to read all the entries, and then filter them here. |
| 476 forms->reserve(forms->size() + all_forms.size()); | 477 forms->reserve(forms->size() + all_forms.size()); |
| 477 for (size_t i = 0; i < all_forms.size(); ++i) { | 478 for (auto& saved_form : all_forms) { |
| 478 if (all_forms[i]->blacklisted_by_user == !autofillable) | 479 if (saved_form->blacklisted_by_user == !autofillable) { |
| 479 forms->push_back(all_forms[i]); | 480 forms->push_back(saved_form); |
| 480 else | 481 saved_form = nullptr; |
| 481 delete all_forms[i]; | 482 } |
| 482 } | 483 } |
| 483 | 484 |
| 484 return true; | 485 return true; |
| 485 } | 486 } |
| 486 | 487 |
| 487 bool NativeBackendKWallet::GetAllLogins(PasswordFormList* forms, | 488 bool NativeBackendKWallet::GetAllLogins( |
| 488 int wallet_handle) { | 489 int wallet_handle, |
| 490 ScopedVector<autofill::PasswordForm>* forms) { |
| 489 // We could probably also use readEntryList here. | 491 // We could probably also use readEntryList here. |
| 490 std::vector<std::string> realm_list; | 492 std::vector<std::string> realm_list; |
| 491 { | 493 { |
| 492 dbus::MethodCall method_call(kKWalletInterface, "entryList"); | 494 dbus::MethodCall method_call(kKWalletInterface, "entryList"); |
| 493 dbus::MessageWriter builder(&method_call); | 495 dbus::MessageWriter builder(&method_call); |
| 494 builder.AppendInt32(wallet_handle); // handle | 496 builder.AppendInt32(wallet_handle); // handle |
| 495 builder.AppendString(folder_name_); // folder | 497 builder.AppendString(folder_name_); // folder |
| 496 builder.AppendString(app_name_); // appid | 498 builder.AppendString(app_name_); // appid |
| 497 scoped_ptr<dbus::Response> response( | 499 scoped_ptr<dbus::Response> response( |
| 498 kwallet_proxy_->CallMethodAndBlock( | 500 kwallet_proxy_->CallMethodAndBlock( |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 530 if (!reader.PopArrayOfBytes(&bytes, &length)) { | 532 if (!reader.PopArrayOfBytes(&bytes, &length)) { |
| 531 LOG(ERROR) << "Error reading response from kwalletd (readEntry): " | 533 LOG(ERROR) << "Error reading response from kwalletd (readEntry): " |
| 532 << response->ToString(); | 534 << response->ToString(); |
| 533 return false; | 535 return false; |
| 534 } | 536 } |
| 535 if (!bytes || !CheckSerializedValue(bytes, length, signon_realm)) | 537 if (!bytes || !CheckSerializedValue(bytes, length, signon_realm)) |
| 536 continue; | 538 continue; |
| 537 | 539 |
| 538 // Can't we all just agree on whether bytes are signed or not? Please? | 540 // Can't we all just agree on whether bytes are signed or not? Please? |
| 539 Pickle pickle(reinterpret_cast<const char*>(bytes), length); | 541 Pickle pickle(reinterpret_cast<const char*>(bytes), length); |
| 540 PasswordFormList all_forms; | |
| 541 DeserializeValue(signon_realm, pickle, forms); | 542 DeserializeValue(signon_realm, pickle, forms); |
| 542 } | 543 } |
| 543 return true; | 544 return true; |
| 544 } | 545 } |
| 545 | 546 |
| 546 bool NativeBackendKWallet::SetLoginsList(const PasswordFormList& forms, | 547 bool NativeBackendKWallet::SetLoginsList( |
| 547 const std::string& signon_realm, | 548 const std::vector<autofill::PasswordForm*>& forms, |
| 548 int wallet_handle) { | 549 const std::string& signon_realm, |
| 550 int wallet_handle) { |
| 549 if (forms.empty()) { | 551 if (forms.empty()) { |
| 550 // No items left? Remove the entry from the wallet. | 552 // No items left? Remove the entry from the wallet. |
| 551 dbus::MethodCall method_call(kKWalletInterface, "removeEntry"); | 553 dbus::MethodCall method_call(kKWalletInterface, "removeEntry"); |
| 552 dbus::MessageWriter builder(&method_call); | 554 dbus::MessageWriter builder(&method_call); |
| 553 builder.AppendInt32(wallet_handle); // handle | 555 builder.AppendInt32(wallet_handle); // handle |
| 554 builder.AppendString(folder_name_); // folder | 556 builder.AppendString(folder_name_); // folder |
| 555 builder.AppendString(signon_realm); // key | 557 builder.AppendString(signon_realm); // key |
| 556 builder.AppendString(app_name_); // appid | 558 builder.AppendString(app_name_); // appid |
| 557 scoped_ptr<dbus::Response> response( | 559 scoped_ptr<dbus::Response> response( |
| 558 kwallet_proxy_->CallMethodAndBlock( | 560 kwallet_proxy_->CallMethodAndBlock( |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 667 if (!reader.PopArrayOfBytes(&bytes, &length)) { | 669 if (!reader.PopArrayOfBytes(&bytes, &length)) { |
| 668 LOG(ERROR) << "Error reading response from kwalletd (readEntry): " | 670 LOG(ERROR) << "Error reading response from kwalletd (readEntry): " |
| 669 << response->ToString(); | 671 << response->ToString(); |
| 670 continue; | 672 continue; |
| 671 } | 673 } |
| 672 if (!bytes || !CheckSerializedValue(bytes, length, signon_realm)) | 674 if (!bytes || !CheckSerializedValue(bytes, length, signon_realm)) |
| 673 continue; | 675 continue; |
| 674 | 676 |
| 675 // Can't we all just agree on whether bytes are signed or not? Please? | 677 // Can't we all just agree on whether bytes are signed or not? Please? |
| 676 Pickle pickle(reinterpret_cast<const char*>(bytes), length); | 678 Pickle pickle(reinterpret_cast<const char*>(bytes), length); |
| 677 PasswordFormList all_forms; | 679 ScopedVector<autofill::PasswordForm> all_forms; |
| 678 DeserializeValue(signon_realm, pickle, &all_forms); | 680 DeserializeValue(signon_realm, pickle, &all_forms); |
| 679 | 681 |
| 680 PasswordFormList kept_forms; | 682 ScopedVector<autofill::PasswordForm> kept_forms; |
| 681 kept_forms.reserve(all_forms.size()); | 683 kept_forms.reserve(all_forms.size()); |
| 682 base::Time autofill::PasswordForm::*date_member = | 684 base::Time autofill::PasswordForm::*date_member = |
| 683 date_to_compare == CREATION_TIMESTAMP | 685 date_to_compare == CREATION_TIMESTAMP |
| 684 ? &autofill::PasswordForm::date_created | 686 ? &autofill::PasswordForm::date_created |
| 685 : &autofill::PasswordForm::date_synced; | 687 : &autofill::PasswordForm::date_synced; |
| 686 for (size_t i = 0; i < all_forms.size(); ++i) { | 688 for (auto& saved_form : all_forms) { |
| 687 if (delete_begin <= all_forms[i]->*date_member && | 689 if (delete_begin <= saved_form->*date_member && |
| 688 (delete_end.is_null() || all_forms[i]->*date_member < delete_end)) { | 690 (delete_end.is_null() || saved_form->*date_member < delete_end)) { |
| 689 changes->push_back(password_manager::PasswordStoreChange( | 691 changes->push_back(password_manager::PasswordStoreChange( |
| 690 password_manager::PasswordStoreChange::REMOVE, *all_forms[i])); | 692 password_manager::PasswordStoreChange::REMOVE, *saved_form)); |
| 691 delete all_forms[i]; | |
| 692 } else { | 693 } else { |
| 693 kept_forms.push_back(all_forms[i]); | 694 kept_forms.push_back(saved_form); |
| 695 saved_form = nullptr; |
| 694 } | 696 } |
| 695 } | 697 } |
| 696 | 698 |
| 697 if (!SetLoginsList(kept_forms, signon_realm, wallet_handle)) { | 699 if (!SetLoginsList(kept_forms.get(), signon_realm, wallet_handle)) { |
| 698 ok = false; | 700 ok = false; |
| 699 changes->clear(); | 701 changes->clear(); |
| 700 } | 702 } |
| 701 STLDeleteElements(&kept_forms); | |
| 702 } | 703 } |
| 703 return ok; | 704 return ok; |
| 704 } | 705 } |
| 705 | 706 |
| 706 // static | 707 // static |
| 707 void NativeBackendKWallet::SerializeValue(const PasswordFormList& forms, | 708 void NativeBackendKWallet::SerializeValue( |
| 708 Pickle* pickle) { | 709 const std::vector<autofill::PasswordForm*>& forms, |
| 710 Pickle* pickle) { |
| 709 pickle->WriteInt(kPickleVersion); | 711 pickle->WriteInt(kPickleVersion); |
| 710 pickle->WriteSizeT(forms.size()); | 712 pickle->WriteSizeT(forms.size()); |
| 711 for (PasswordFormList::const_iterator it = forms.begin(); | 713 for (autofill::PasswordForm* form : forms) { |
| 712 it != forms.end(); ++it) { | |
| 713 const PasswordForm* form = *it; | |
| 714 pickle->WriteInt(form->scheme); | 714 pickle->WriteInt(form->scheme); |
| 715 pickle->WriteString(form->origin.spec()); | 715 pickle->WriteString(form->origin.spec()); |
| 716 pickle->WriteString(form->action.spec()); | 716 pickle->WriteString(form->action.spec()); |
| 717 pickle->WriteString16(form->username_element); | 717 pickle->WriteString16(form->username_element); |
| 718 pickle->WriteString16(form->username_value); | 718 pickle->WriteString16(form->username_value); |
| 719 pickle->WriteString16(form->password_element); | 719 pickle->WriteString16(form->password_element); |
| 720 pickle->WriteString16(form->password_value); | 720 pickle->WriteString16(form->password_value); |
| 721 pickle->WriteString16(form->submit_element); | 721 pickle->WriteString16(form->submit_element); |
| 722 pickle->WriteBool(form->ssl_valid); | 722 pickle->WriteBool(form->ssl_valid); |
| 723 pickle->WriteBool(form->preferred); | 723 pickle->WriteBool(form->preferred); |
| 724 pickle->WriteBool(form->blacklisted_by_user); | 724 pickle->WriteBool(form->blacklisted_by_user); |
| 725 pickle->WriteInt64(form->date_created.ToTimeT()); | 725 pickle->WriteInt64(form->date_created.ToTimeT()); |
| 726 pickle->WriteInt(form->type); | 726 pickle->WriteInt(form->type); |
| 727 pickle->WriteInt(form->times_used); | 727 pickle->WriteInt(form->times_used); |
| 728 autofill::SerializeFormData(form->form_data, pickle); | 728 autofill::SerializeFormData(form->form_data, pickle); |
| 729 pickle->WriteInt64(form->date_synced.ToInternalValue()); | 729 pickle->WriteInt64(form->date_synced.ToInternalValue()); |
| 730 pickle->WriteString16(form->display_name); | 730 pickle->WriteString16(form->display_name); |
| 731 pickle->WriteString(form->avatar_url.spec()); | 731 pickle->WriteString(form->avatar_url.spec()); |
| 732 pickle->WriteString(form->federation_url.spec()); | 732 pickle->WriteString(form->federation_url.spec()); |
| 733 pickle->WriteBool(form->is_zero_click); | 733 pickle->WriteBool(form->is_zero_click); |
| 734 } | 734 } |
| 735 } | 735 } |
| 736 | 736 |
| 737 // static | 737 // static |
| 738 bool NativeBackendKWallet::DeserializeValueSize(const std::string& signon_realm, | 738 bool NativeBackendKWallet::DeserializeValueSize( |
| 739 const PickleIterator& init_iter, | 739 const std::string& signon_realm, |
| 740 int version, | 740 const PickleIterator& init_iter, |
| 741 bool size_32, | 741 int version, |
| 742 bool warn_only, | 742 bool size_32, |
| 743 PasswordFormList* forms) { | 743 bool warn_only, |
| 744 ScopedVector<autofill::PasswordForm>* forms) { |
| 744 PickleIterator iter = init_iter; | 745 PickleIterator iter = init_iter; |
| 745 | 746 |
| 746 size_t count = 0; | 747 size_t count = 0; |
| 747 if (size_32) { | 748 if (size_32) { |
| 748 uint32_t count_32 = 0; | 749 uint32_t count_32 = 0; |
| 749 if (!iter.ReadUInt32(&count_32)) { | 750 if (!iter.ReadUInt32(&count_32)) { |
| 750 LOG(ERROR) << "Failed to deserialize KWallet entry " | 751 LOG(ERROR) << "Failed to deserialize KWallet entry " |
| 751 << "(realm: " << signon_realm << ")"; | 752 << "(realm: " << signon_realm << ")"; |
| 752 return false; | 753 return false; |
| 753 } | 754 } |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 831 } | 832 } |
| 832 } | 833 } |
| 833 | 834 |
| 834 forms->push_back(form.release()); | 835 forms->push_back(form.release()); |
| 835 } | 836 } |
| 836 | 837 |
| 837 return true; | 838 return true; |
| 838 } | 839 } |
| 839 | 840 |
| 840 // static | 841 // static |
| 841 void NativeBackendKWallet::DeserializeValue(const std::string& signon_realm, | 842 void NativeBackendKWallet::DeserializeValue( |
| 842 const Pickle& pickle, | 843 const std::string& signon_realm, |
| 843 PasswordFormList* forms) { | 844 const Pickle& pickle, |
| 845 ScopedVector<autofill::PasswordForm>* forms) { |
| 844 PickleIterator iter(pickle); | 846 PickleIterator iter(pickle); |
| 845 | 847 |
| 846 int version = -1; | 848 int version = -1; |
| 847 if (!iter.ReadInt(&version) || | 849 if (!iter.ReadInt(&version) || |
| 848 version < 0 || version > kPickleVersion) { | 850 version < 0 || version > kPickleVersion) { |
| 849 LOG(ERROR) << "Failed to deserialize KWallet entry " | 851 LOG(ERROR) << "Failed to deserialize KWallet entry " |
| 850 << "(realm: " << signon_realm << ")"; | 852 << "(realm: " << signon_realm << ")"; |
| 851 return; | 853 return; |
| 852 } | 854 } |
| 853 | 855 |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 952 } | 954 } |
| 953 | 955 |
| 954 return handle; | 956 return handle; |
| 955 } | 957 } |
| 956 | 958 |
| 957 std::string NativeBackendKWallet::GetProfileSpecificFolderName() const { | 959 std::string NativeBackendKWallet::GetProfileSpecificFolderName() const { |
| 958 // Originally, the folder name was always just "Chrome Form Data". | 960 // Originally, the folder name was always just "Chrome Form Data". |
| 959 // Now we use it to distinguish passwords for different profiles. | 961 // Now we use it to distinguish passwords for different profiles. |
| 960 return base::StringPrintf("%s (%d)", kKWalletFolder, profile_id_); | 962 return base::StringPrintf("%s (%d)", kKWalletFolder, profile_id_); |
| 961 } | 963 } |
| OLD | NEW |