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

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

Issue 715193002: [Password Generation] Breakout UMA stats for generated passwords (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More Created 6 years, 1 month 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
« no previous file with comments | « no previous file | components/password_manager/core/browser/login_database_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 return false; 317 return false;
318 } 318 }
319 } 319 }
320 return true; 320 return true;
321 } 321 }
322 322
323 void LoginDatabase::ReportMetrics(const std::string& sync_username, 323 void LoginDatabase::ReportMetrics(const std::string& sync_username,
324 bool custom_passphrase_sync_enabled) { 324 bool custom_passphrase_sync_enabled) {
325 sql::Statement s(db_.GetCachedStatement( 325 sql::Statement s(db_.GetCachedStatement(
326 SQL_FROM_HERE, 326 SQL_FROM_HERE,
327 "SELECT signon_realm, blacklisted_by_user, COUNT(username_value) " 327 "SELECT signon_realm, password_type, blacklisted_by_user,"
328 "FROM logins GROUP BY signon_realm, blacklisted_by_user")); 328 "COUNT(username_value) FROM logins GROUP BY "
329 "signon_realm, password_type, blacklisted_by_user"));
329 330
330 if (!s.is_valid()) 331 if (!s.is_valid())
331 return; 332 return;
332 333
333 std::string custom_passphrase = "WithoutCustomPassphrase"; 334 std::string custom_passphrase = "WithoutCustomPassphrase";
334 if (custom_passphrase_sync_enabled) { 335 if (custom_passphrase_sync_enabled) {
335 custom_passphrase = "WithCustomPassphrase"; 336 custom_passphrase = "WithCustomPassphrase";
336 } 337 }
337 338
338 int total_accounts = 0; 339 int total_user_created_accounts = 0;
340 int total_generated_accounts = 0;
339 int blacklisted_sites = 0; 341 int blacklisted_sites = 0;
340 while (s.Step()) { 342 while (s.Step()) {
341 int blacklisted = s.ColumnInt(1); 343 PasswordForm::Type password_type =
342 int accounts_per_site = s.ColumnInt(2); 344 static_cast<PasswordForm::Type>(s.ColumnInt(1));
345 int blacklisted = s.ColumnInt(2);
346 int accounts_per_site = s.ColumnInt(3);
343 if (blacklisted) { 347 if (blacklisted) {
344 ++blacklisted_sites; 348 ++blacklisted_sites;
349 } else if (password_type == PasswordForm::TYPE_GENERATED) {
350 total_generated_accounts += accounts_per_site;
351 LogAccountStat(
352 base::StringPrintf("PasswordManager.AccountsPerSite.AutoGenerated.%s",
353 custom_passphrase.c_str()),
354 accounts_per_site);
345 } else { 355 } else {
346 total_accounts += accounts_per_site; 356 total_user_created_accounts += accounts_per_site;
347 LogAccountStat(base::StringPrintf("PasswordManager.AccountsPerSite.%s", 357 LogAccountStat(
348 custom_passphrase.c_str()), 358 base::StringPrintf("PasswordManager.AccountsPerSite.UserCreated.%s",
349 accounts_per_site); 359 custom_passphrase.c_str()),
360 accounts_per_site);
350 } 361 }
351 } 362 }
352 LogAccountStat(base::StringPrintf("PasswordManager.TotalAccounts.%s", 363 LogAccountStat(
353 custom_passphrase.c_str()), 364 base::StringPrintf("PasswordManager.TotalAccounts.UserCreated.%s",
354 total_accounts); 365 custom_passphrase.c_str()),
366 total_user_created_accounts);
367 LogAccountStat(
368 base::StringPrintf("PasswordManager.TotalAccounts.AutoGenerated.%s",
369 custom_passphrase.c_str()),
370 total_generated_accounts);
355 LogAccountStat(base::StringPrintf("PasswordManager.BlacklistedSites.%s", 371 LogAccountStat(base::StringPrintf("PasswordManager.BlacklistedSites.%s",
356 custom_passphrase.c_str()), 372 custom_passphrase.c_str()),
357 blacklisted_sites); 373 blacklisted_sites);
358 374
359 sql::Statement usage_statement(db_.GetCachedStatement( 375 sql::Statement usage_statement(db_.GetCachedStatement(
360 SQL_FROM_HERE, 376 SQL_FROM_HERE,
361 "SELECT password_type, times_used FROM logins")); 377 "SELECT password_type, times_used FROM logins"));
362 378
363 if (!usage_statement.is_valid()) 379 if (!usage_statement.is_valid())
364 return; 380 return;
365 381
366 while (usage_statement.Step()) { 382 while (usage_statement.Step()) {
367 PasswordForm::Type type = static_cast<PasswordForm::Type>( 383 PasswordForm::Type type = static_cast<PasswordForm::Type>(
368 usage_statement.ColumnInt(0)); 384 usage_statement.ColumnInt(0));
369 385
370 if (type == PasswordForm::TYPE_GENERATED) { 386 if (type == PasswordForm::TYPE_GENERATED) {
371 LogTimesUsedStat( 387 LogTimesUsedStat(base::StringPrintf(
372 base::StringPrintf("PasswordManager.TimesGeneratedPasswordUsed.%s", 388 "PasswordManager.TimesPasswordUsed.AutoGenerated.%s",
373 custom_passphrase.c_str()), 389 custom_passphrase.c_str()),
374 usage_statement.ColumnInt(1)); 390 usage_statement.ColumnInt(1));
375 } else { 391 } else {
376 LogTimesUsedStat( 392 LogTimesUsedStat(
377 base::StringPrintf("PasswordManager.TimesPasswordUsed.%s", 393 base::StringPrintf("PasswordManager.TimesPasswordUsed.UserCreated.%s",
378 custom_passphrase.c_str()), 394 custom_passphrase.c_str()),
379 usage_statement.ColumnInt(1)); 395 usage_statement.ColumnInt(1));
380 } 396 }
381 } 397 }
382 398
383 bool syncing_account_saved = false; 399 bool syncing_account_saved = false;
384 if (!sync_username.empty()) { 400 if (!sync_username.empty()) {
385 sql::Statement sync_statement(db_.GetCachedStatement( 401 sql::Statement sync_statement(db_.GetCachedStatement(
386 SQL_FROM_HERE, 402 SQL_FROM_HERE,
387 "SELECT username_value FROM logins " 403 "SELECT username_value FROM logins "
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
814 830
815 bool LoginDatabase::DeleteAndRecreateDatabaseFile() { 831 bool LoginDatabase::DeleteAndRecreateDatabaseFile() {
816 DCHECK(db_.is_open()); 832 DCHECK(db_.is_open());
817 meta_table_.Reset(); 833 meta_table_.Reset();
818 db_.Close(); 834 db_.Close();
819 sql::Connection::Delete(db_path_); 835 sql::Connection::Delete(db_path_);
820 return Init(db_path_); 836 return Init(db_path_);
821 } 837 }
822 838
823 } // namespace password_manager 839 } // namespace password_manager
OLDNEW
« no previous file with comments | « no previous file | components/password_manager/core/browser/login_database_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698