OLD | NEW |
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 <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/metrics/histogram_macros.h" | 13 #include "base/metrics/histogram_macros.h" |
14 #include "base/pickle.h" | 14 #include "base/pickle.h" |
15 #include "base/strings/string_util.h" | 15 #include "base/strings/string_util.h" |
16 #include "base/strings/stringprintf.h" | 16 #include "base/strings/stringprintf.h" |
17 #include "base/time/time.h" | 17 #include "base/time/time.h" |
18 #include "components/autofill/core/common/password_form.h" | 18 #include "components/autofill/core/common/password_form.h" |
19 #include "components/password_manager/core/browser/affiliation_utils.h" | 19 #include "components/password_manager/core/browser/affiliation_utils.h" |
20 #include "components/password_manager/core/browser/password_manager_client.h" | 20 #include "components/password_manager/core/browser/password_manager_client.h" |
21 #include "components/password_manager/core/browser/password_manager_metrics_util
.h" | 21 #include "components/password_manager/core/browser/password_manager_metrics_util
.h" |
22 #include "google_apis/gaia/gaia_auth_util.h" | 22 #include "google_apis/gaia/gaia_auth_util.h" |
23 #include "google_apis/gaia/gaia_urls.h" | 23 #include "google_apis/gaia/gaia_urls.h" |
24 #include "sql/connection.h" | 24 #include "sql/connection.h" |
25 #include "sql/statement.h" | 25 #include "sql/statement.h" |
26 #include "sql/transaction.h" | 26 #include "sql/transaction.h" |
| 27 #include "url/url_constants.h" |
27 | 28 |
28 using autofill::PasswordForm; | 29 using autofill::PasswordForm; |
29 | 30 |
30 namespace password_manager { | 31 namespace password_manager { |
31 | 32 |
32 const int kCurrentVersionNumber = 13; | 33 const int kCurrentVersionNumber = 13; |
33 static const int kCompatibleVersionNumber = 1; | 34 static const int kCompatibleVersionNumber = 1; |
34 | 35 |
35 base::Pickle SerializeVector(const std::vector<base::string16>& vec) { | 36 base::Pickle SerializeVector(const std::vector<base::string16>& vec) { |
36 base::Pickle p; | 37 base::Pickle p; |
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
520 "WHERE a.blacklisted_by_user=0 AND a.username_value='' " | 521 "WHERE a.blacklisted_by_user=0 AND a.username_value='' " |
521 "AND NOT EXISTS (SELECT * FROM logins b " | 522 "AND NOT EXISTS (SELECT * FROM logins b " |
522 "WHERE b.blacklisted_by_user=0 AND b.username_value!='' " | 523 "WHERE b.blacklisted_by_user=0 AND b.username_value!='' " |
523 "AND a.signon_realm = b.signon_realm)")); | 524 "AND a.signon_realm = b.signon_realm)")); |
524 if (standalone_empty_usernames_statement.Step()) { | 525 if (standalone_empty_usernames_statement.Step()) { |
525 int num_entries = standalone_empty_usernames_statement.ColumnInt(0); | 526 int num_entries = standalone_empty_usernames_statement.ColumnInt(0); |
526 UMA_HISTOGRAM_COUNTS_100( | 527 UMA_HISTOGRAM_COUNTS_100( |
527 "PasswordManager.EmptyUsernames.WithoutCorrespondingNonempty", | 528 "PasswordManager.EmptyUsernames.WithoutCorrespondingNonempty", |
528 num_entries); | 529 num_entries); |
529 } | 530 } |
| 531 |
| 532 sql::Statement invalid_ssl_cert_statement(db_.GetCachedStatement( |
| 533 SQL_FROM_HERE, "SELECT origin_url, ssl_valid FROM logins;")); |
| 534 |
| 535 if (!invalid_ssl_cert_statement.is_valid()) |
| 536 return; |
| 537 |
| 538 while (invalid_ssl_cert_statement.Step()) { |
| 539 GURL url = GURL(invalid_ssl_cert_statement.ColumnString(0)); |
| 540 |
| 541 if (url.SchemeIs(url::kHttpsScheme)) { |
| 542 metrics_util::LogUMAHistogramBoolean( |
| 543 "PasswordManager.UserStoredPasswordWithInvalidSSLCert", |
| 544 invalid_ssl_cert_statement.ColumnInt(1) == 0); |
| 545 } |
| 546 } |
530 } | 547 } |
531 | 548 |
532 PasswordStoreChangeList LoginDatabase::AddLogin(const PasswordForm& form) { | 549 PasswordStoreChangeList LoginDatabase::AddLogin(const PasswordForm& form) { |
533 PasswordStoreChangeList list; | 550 PasswordStoreChangeList list; |
534 if (!DoesMatchConstraints(form)) | 551 if (!DoesMatchConstraints(form)) |
535 return list; | 552 return list; |
536 std::string encrypted_password; | 553 std::string encrypted_password; |
537 if (EncryptedString( | 554 if (EncryptedString( |
538 clear_password_values_ ? base::string16() : form.password_value, | 555 clear_password_values_ ? base::string16() : form.password_value, |
539 &encrypted_password) != ENCRYPTION_RESULT_SUCCESS) | 556 &encrypted_password) != ENCRYPTION_RESULT_SUCCESS) |
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
957 UMA_HISTOGRAM_ENUMERATION("PasswordManager.PslDomainMatchTriggering", | 974 UMA_HISTOGRAM_ENUMERATION("PasswordManager.PslDomainMatchTriggering", |
958 psl_domain_match_metric, PSL_DOMAIN_MATCH_COUNT); | 975 psl_domain_match_metric, PSL_DOMAIN_MATCH_COUNT); |
959 } | 976 } |
960 | 977 |
961 if (!statement->Succeeded()) | 978 if (!statement->Succeeded()) |
962 return false; | 979 return false; |
963 return true; | 980 return true; |
964 } | 981 } |
965 | 982 |
966 } // namespace password_manager | 983 } // namespace password_manager |
OLD | NEW |