| Index: components/password_manager/core/browser/credential_manager_pending_request_task.cc
|
| diff --git a/components/password_manager/core/browser/credential_manager_pending_request_task.cc b/components/password_manager/core/browser/credential_manager_pending_request_task.cc
|
| index 26fb40ecd68e119ba209c1419c7bffb23f2ea8b3..dc995b0ad2a013c860242e2081edc6c6166207f9 100644
|
| --- a/components/password_manager/core/browser/credential_manager_pending_request_task.cc
|
| +++ b/components/password_manager/core/browser/credential_manager_pending_request_task.cc
|
| @@ -23,18 +23,18 @@ namespace {
|
| // Send a UMA histogram about if |local_results| has empty or duplicate
|
| // usernames.
|
| void ReportAccountChooserMetrics(
|
| - const ScopedVector<autofill::PasswordForm>& local_results) {
|
| + const ScopedVector<autofill::PasswordForm>& local_results,
|
| + bool had_empty_username) {
|
| std::vector<base::string16> usernames;
|
| for (const auto& form : local_results)
|
| usernames.push_back(form->username_value);
|
| std::sort(usernames.begin(), usernames.end());
|
| - bool has_empty_username = !usernames.empty() && usernames[0].empty();
|
| bool has_duplicates =
|
| std::adjacent_find(usernames.begin(), usernames.end()) != usernames.end();
|
| metrics_util::AccountChooserUsabilityMetric metric;
|
| - if (has_empty_username && has_duplicates)
|
| + if (had_empty_username && has_duplicates)
|
| metric = metrics_util::ACCOUNT_CHOOSER_EMPTY_USERNAME_AND_DUPLICATES;
|
| - else if (has_empty_username)
|
| + else if (had_empty_username)
|
| metric = metrics_util::ACCOUNT_CHOOSER_EMPTY_USERNAME;
|
| else if (has_duplicates)
|
| metric = metrics_util::ACCOUNT_CHOOSER_DUPLICATES;
|
| @@ -115,6 +115,14 @@ void CredentialManagerPendingRequestTask::OnGetPasswordStoreResults(
|
| affiliated_results.weak_clear();
|
| }
|
|
|
| + // Remove empty usernames from the list.
|
| + auto begin_empty = std::partition(local_results.begin(), local_results.end(),
|
| + [](autofill::PasswordForm* form) {
|
| + return !form->username_value.empty();
|
| + });
|
| + const bool has_empty_username = (begin_empty != local_results.end());
|
| + local_results.erase(begin_empty, local_results.end());
|
| +
|
| if ((local_results.empty() && federated_results.empty())) {
|
| delegate_->SendCredential(send_callback_, CredentialInfo());
|
| return;
|
| @@ -147,7 +155,7 @@ void CredentialManagerPendingRequestTask::OnGetPasswordStoreResults(
|
| std::unique_ptr<autofill::PasswordForm> potential_autosignin_form(
|
| new autofill::PasswordForm(*local_results[0]));
|
| if (!zero_click_only_)
|
| - ReportAccountChooserMetrics(local_results);
|
| + ReportAccountChooserMetrics(local_results, has_empty_username);
|
| if (zero_click_only_ ||
|
| !delegate_->client()->PromptUserToChooseCredentials(
|
| std::move(local_results), std::move(federated_results), origin_,
|
|
|