Skip to content

Commit

Permalink
Add a histogram to count empty and/or duplicate usernames in the acco…
Browse files Browse the repository at this point in the history
…unt chooser.

BUG=400674

Review-Url: https://codereview.chromium.org/2077933002
Cr-Commit-Position: refs/heads/master@{#400935}
  • Loading branch information
vasilii authored and Commit bot committed Jun 21, 2016
1 parent a9a1730 commit 3b69835
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,46 @@

#include "components/password_manager/core/browser/credential_manager_pending_request_task.h"

#include <algorithm>
#include <utility>

#include "components/autofill/core/common/password_form.h"
#include "components/password_manager/core/browser/affiliated_match_helper.h"
#include "components/password_manager/core/browser/password_bubble_experiment.h"
#include "components/password_manager/core/browser/password_manager_client.h"
#include "components/password_manager/core/browser/password_manager_metrics_util.h"
#include "components/password_manager/core/browser/password_manager_util.h"
#include "components/password_manager/core/common/credential_manager_types.h"
#include "url/gurl.h"
#include "url/origin.h"

namespace password_manager {
namespace {

// Send a UMA histogram about if |local_results| has empty or duplicate
// usernames.
void ReportAccountChooserMetrics(
const ScopedVector<autofill::PasswordForm>& local_results) {
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)
metric = metrics_util::ACCOUNT_CHOOSER_EMPTY_USERNAME_AND_DUPLICATES;
else if (has_empty_username)
metric = metrics_util::ACCOUNT_CHOOSER_EMPTY_USERNAME;
else if (has_duplicates)
metric = metrics_util::ACCOUNT_CHOOSER_DUPLICATES;
else
metric = metrics_util::ACCOUNT_CHOOSER_LOOKS_OK;
metrics_util::LogAccountChooserUsability(metric);
}

} // namespace

CredentialManagerPendingRequestTask::CredentialManagerPendingRequestTask(
CredentialManagerPendingRequestTaskDelegate* delegate,
Expand Down Expand Up @@ -118,6 +146,8 @@ void CredentialManagerPendingRequestTask::OnGetPasswordStoreResults(
// user chooses if they pick one.
std::unique_ptr<autofill::PasswordForm> potential_autosignin_form(
new autofill::PasswordForm(*local_results[0]));
if (!zero_click_only_)
ReportAccountChooserMetrics(local_results);
if (zero_click_only_ ||
!delegate_->client()->PromptUserToChooseCredentials(
std::move(local_results), std::move(federated_results), origin_,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,11 @@ void LogAutoSigninPromoUserAction(SyncSignInUserAction action) {
CHROME_SIGNIN_ACTION_COUNT);
}

void LogAccountChooserUsability(AccountChooserUsabilityMetric usability) {
UMA_HISTOGRAM_ENUMERATION("PasswordManager.AccountChooserDialogUsability",
usability, ACCOUNT_CHOOSER_USABILITY_COUNT);
}

} // namespace metrics_util

} // namespace password_manager
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,14 @@ enum SyncSignInUserAction {
CHROME_SIGNIN_ACTION_COUNT
};

enum AccountChooserUsabilityMetric {
ACCOUNT_CHOOSER_LOOKS_OK,
ACCOUNT_CHOOSER_EMPTY_USERNAME,
ACCOUNT_CHOOSER_DUPLICATES,
ACCOUNT_CHOOSER_EMPTY_USERNAME_AND_DUPLICATES,
ACCOUNT_CHOOSER_USABILITY_COUNT,
};

// A version of the UMA_HISTOGRAM_BOOLEAN macro that allows the |name|
// to vary over the program's runtime.
void LogUMAHistogramBoolean(const std::string& name, bool sample);
Expand Down Expand Up @@ -181,6 +189,9 @@ void LogAccountChooserUserActionManyAccounts(AccountChooserUserAction action);
// Log a user action on showing the Chrome sign in promo.
void LogAutoSigninPromoUserAction(SyncSignInUserAction action);

// Log if the account chooser has empty username or duplicate usernames.
void LogAccountChooserUsability(AccountChooserUsabilityMetric usability);

} // namespace metrics_util

} // namespace password_manager
Expand Down
15 changes: 15 additions & 0 deletions tools/metrics/histograms/histograms.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37297,6 +37297,14 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries.
</summary>
</histogram>

<histogram name="PasswordManager.AccountChooserDialogUsability"
enum="AccountChooserUsabilityState">
<owner>vasilii@chromium.org</owner>
<summary>
Whether the account chooser includes an empty username or any duplicates
</summary>
</histogram>

<histogram name="PasswordManager.AccountsPerSite">
<owner>gcasto@chromium.org</owner>
<owner>vabr@chromium.org</owner>
Expand Down Expand Up @@ -64309,6 +64317,13 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries.
<int value="2" label="Sign in clicked"/>
</enum>

<enum name="AccountChooserUsabilityState" type="int">
<int value="0" label="Looks OK"/>
<int value="1" label="Empty username"/>
<int value="2" label="Duplicate usernames"/>
<int value="3" label="Empty and duplicate usernames"/>
</enum>

<enum name="AccountRelation" type="int">
<int value="0" label="Empty cookie jar"/>
<int value="1" label="No signed in, single signed out match"/>
Expand Down

0 comments on commit 3b69835

Please sign in to comment.