Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(377)

Side by Side Diff: components/password_manager/core/browser/login_database.cc

Issue 2909283002: Delete PasswordStoreMac and SimplePasswordStoreMac. (Closed)
Patch Set: test Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "components/password_manager/core/browser/login_database.h" 5 #include "components/password_manager/core/browser/login_database.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <algorithm> 9 #include <algorithm>
10 #include <limits> 10 #include <limits>
(...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 result.back() = ')'; 514 result.back() = ')';
515 for (size_t i = 1; i < 2 * count + 1; i += 2) { 515 for (size_t i = 1; i < 2 * count + 1; i += 2) {
516 result[i] = '?'; 516 result[i] = '?';
517 } 517 }
518 return result; 518 return result;
519 } 519 }
520 520
521 } // namespace 521 } // namespace
522 522
523 LoginDatabase::LoginDatabase(const base::FilePath& db_path) 523 LoginDatabase::LoginDatabase(const base::FilePath& db_path)
524 : db_path_(db_path), clear_password_values_(false) { 524 : db_path_(db_path) {}
525 }
526 525
527 LoginDatabase::~LoginDatabase() { 526 LoginDatabase::~LoginDatabase() {
528 } 527 }
529 528
530 bool LoginDatabase::Init() { 529 bool LoginDatabase::Init() {
531 // Set pragmas for a small, private database (based on WebDatabase). 530 // Set pragmas for a small, private database (based on WebDatabase).
532 db_.set_page_size(2048); 531 db_.set_page_size(2048);
533 db_.set_cache_size(32); 532 db_.set_cache_size(32);
534 db_.set_exclusive_locking(); 533 db_.set_exclusive_locking();
535 db_.set_restrict_to_user(); 534 db_.set_restrict_to_user();
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
807 806
808 for (const auto& password_to_realms : passwords_to_realms) 807 for (const auto& password_to_realms : passwords_to_realms)
809 LogPasswordReuseMetrics(password_to_realms.second); 808 LogPasswordReuseMetrics(password_to_realms.second);
810 } 809 }
811 810
812 PasswordStoreChangeList LoginDatabase::AddLogin(const PasswordForm& form) { 811 PasswordStoreChangeList LoginDatabase::AddLogin(const PasswordForm& form) {
813 PasswordStoreChangeList list; 812 PasswordStoreChangeList list;
814 if (!DoesMatchConstraints(form)) 813 if (!DoesMatchConstraints(form))
815 return list; 814 return list;
816 std::string encrypted_password; 815 std::string encrypted_password;
817 if (EncryptedString( 816 if (EncryptedString(form.password_value, &encrypted_password) !=
818 clear_password_values_ ? base::string16() : form.password_value, 817 ENCRYPTION_RESULT_SUCCESS)
819 &encrypted_password) != ENCRYPTION_RESULT_SUCCESS)
820 return list; 818 return list;
821 819
822 DCHECK(!add_statement_.empty()); 820 DCHECK(!add_statement_.empty());
823 sql::Statement s( 821 sql::Statement s(
824 db_.GetCachedStatement(SQL_FROM_HERE, add_statement_.c_str())); 822 db_.GetCachedStatement(SQL_FROM_HERE, add_statement_.c_str()));
825 BindAddStatement(form, encrypted_password, &s); 823 BindAddStatement(form, encrypted_password, &s);
826 db_.set_error_callback(base::Bind(&AddCallback)); 824 db_.set_error_callback(base::Bind(&AddCallback));
827 const bool success = s.Run(); 825 const bool success = s.Run();
828 db_.reset_error_callback(); 826 db_.reset_error_callback();
829 if (success) { 827 if (success) {
830 list.push_back(PasswordStoreChange(PasswordStoreChange::ADD, form)); 828 list.push_back(PasswordStoreChange(PasswordStoreChange::ADD, form));
831 return list; 829 return list;
832 } 830 }
833 // Repeat the same statement but with REPLACE semantic. 831 // Repeat the same statement but with REPLACE semantic.
834 DCHECK(!add_replace_statement_.empty()); 832 DCHECK(!add_replace_statement_.empty());
835 s.Assign( 833 s.Assign(
836 db_.GetCachedStatement(SQL_FROM_HERE, add_replace_statement_.c_str())); 834 db_.GetCachedStatement(SQL_FROM_HERE, add_replace_statement_.c_str()));
837 BindAddStatement(form, encrypted_password, &s); 835 BindAddStatement(form, encrypted_password, &s);
838 if (s.Run()) { 836 if (s.Run()) {
839 list.push_back(PasswordStoreChange(PasswordStoreChange::REMOVE, form)); 837 list.push_back(PasswordStoreChange(PasswordStoreChange::REMOVE, form));
840 list.push_back(PasswordStoreChange(PasswordStoreChange::ADD, form)); 838 list.push_back(PasswordStoreChange(PasswordStoreChange::ADD, form));
841 } 839 }
842 return list; 840 return list;
843 } 841 }
844 842
845 PasswordStoreChangeList LoginDatabase::UpdateLogin(const PasswordForm& form) { 843 PasswordStoreChangeList LoginDatabase::UpdateLogin(const PasswordForm& form) {
846 std::string encrypted_password; 844 std::string encrypted_password;
847 if (EncryptedString( 845 if (EncryptedString(form.password_value, &encrypted_password) !=
848 clear_password_values_ ? base::string16() : form.password_value, 846 ENCRYPTION_RESULT_SUCCESS)
849 &encrypted_password) != ENCRYPTION_RESULT_SUCCESS)
850 return PasswordStoreChangeList(); 847 return PasswordStoreChangeList();
851 848
852 #if defined(OS_IOS) 849 #if defined(OS_IOS)
853 DeleteEncryptedPassword(form); 850 DeleteEncryptedPassword(form);
854 #endif 851 #endif
855 // Replacement is necessary to deal with updating imported credentials. See 852 // Replacement is necessary to deal with updating imported credentials. See
856 // crbug.com/349138 for details. 853 // crbug.com/349138 for details.
857 DCHECK(!update_statement_.empty()); 854 DCHECK(!update_statement_.empty());
858 sql::Statement s( 855 sql::Statement s(
859 db_.GetCachedStatement(SQL_FROM_HERE, update_statement_.c_str())); 856 db_.GetCachedStatement(SQL_FROM_HERE, update_statement_.c_str()));
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after
1376 DCHECK(blacklisted_statement_.empty()); 1373 DCHECK(blacklisted_statement_.empty());
1377 blacklisted_statement_ = 1374 blacklisted_statement_ =
1378 "SELECT " + all_column_names + 1375 "SELECT " + all_column_names +
1379 " FROM logins WHERE blacklisted_by_user == ? ORDER BY origin_url"; 1376 " FROM logins WHERE blacklisted_by_user == ? ORDER BY origin_url";
1380 DCHECK(encrypted_statement_.empty()); 1377 DCHECK(encrypted_statement_.empty());
1381 encrypted_statement_ = 1378 encrypted_statement_ =
1382 "SELECT password_value FROM logins WHERE " + all_unique_key_column_names; 1379 "SELECT password_value FROM logins WHERE " + all_unique_key_column_names;
1383 } 1380 }
1384 1381
1385 } // namespace password_manager 1382 } // namespace password_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698