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

Unified Diff: chrome/browser/ui/views/passwords/credentials_selection_view.cc

Issue 1586613003: UMA histogram of user action on multi-account password update bubble. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reviewers comments addressed Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/views/passwords/credentials_selection_view.cc
diff --git a/chrome/browser/ui/views/passwords/credentials_selection_view.cc b/chrome/browser/ui/views/passwords/credentials_selection_view.cc
index 483b731ee5dcac1a3ed7b51204b700685215926a..aebd9e13d3d6d99f092c6a10f4fa75741ef4fa88 100644
--- a/chrome/browser/ui/views/passwords/credentials_selection_view.cc
+++ b/chrome/browser/ui/views/passwords/credentials_selection_view.cc
@@ -7,6 +7,7 @@
#include <stddef.h>
#include "chrome/browser/ui/passwords/manage_passwords_bubble_model.h"
+#include "components/password_manager/core/browser/password_manager_metrics_util.h"
#include "ui/base/models/simple_combobox_model.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/views/controls/button/button.h"
@@ -26,40 +27,14 @@ views::Label* GeneratePasswordLabel(const autofill::PasswordForm& form) {
return label;
}
-views::Combobox* GenerateUsernameCombobox(
- const std::vector<const autofill::PasswordForm*>& forms,
- const base::string16& best_matched_username) {
- std::vector<base::string16> usernames;
- size_t best_matched_username_index = forms.size();
- size_t preferred_form_index = forms.size();
- for (size_t index = 0; index < forms.size(); ++index) {
- usernames.push_back(forms[index]->username_value);
- if (forms[index]->username_value == best_matched_username) {
- best_matched_username_index = index;
- }
- if (forms[index]->preferred) {
- preferred_form_index = index;
- }
- }
-
- views::Combobox* combobox =
- new views::Combobox(new ui::SimpleComboboxModel(usernames));
-
- if (best_matched_username_index < forms.size()) {
- combobox->SetSelectedIndex(best_matched_username_index);
- } else if (preferred_form_index < forms.size()) {
- combobox->SetSelectedIndex(preferred_form_index);
- }
- return combobox;
-}
-
} // namespace
CredentialsSelectionView::CredentialsSelectionView(
ManagePasswordsBubbleModel* manage_passwords_bubble_model,
const std::vector<const autofill::PasswordForm*>& password_forms,
const base::string16& best_matched_username)
- : password_forms_(password_forms) {
+ : password_forms_(password_forms),
+ action_reported_(false) {
DCHECK(!password_forms.empty());
// Layout.
@@ -90,9 +65,93 @@ CredentialsSelectionView::CredentialsSelectionView(
GetLayoutManager()->Layout(this);
}
+CredentialsSelectionView::~CredentialsSelectionView() {
+ ReportUserActionOnce(true, -1);
+}
+
const autofill::PasswordForm*
CredentialsSelectionView::GetSelectedCredentials() {
DCHECK_EQ(password_forms_.size(),
static_cast<size_t>(combobox_->model()->GetItemCount()));
+ ReportUserActionOnce(false, combobox_->selected_index());
return password_forms_[combobox_->selected_index()];
}
+
+views::Combobox* CredentialsSelectionView::GenerateUsernameCombobox(
+ const std::vector<const autofill::PasswordForm*>& forms,
+ const base::string16& best_matched_username) {
+ std::vector<base::string16> usernames;
+ size_t best_matched_username_index = forms.size();
+ size_t preferred_form_index = forms.size();
+ for (size_t index = 0; index < forms.size(); ++index) {
+ usernames.push_back(forms[index]->username_value);
+ if (forms[index]->username_value == best_matched_username) {
+ best_matched_username_index = index;
+ }
+ if (forms[index]->preferred) {
+ preferred_form_index = index;
+ }
+ }
+
+ views::Combobox* combobox =
+ new views::Combobox(new ui::SimpleComboboxModel(usernames));
+
+ default_index_ = 0;
+ is_default_best_match_ = false;
+ is_default_preferred_ = false;
+
+ if (best_matched_username_index < forms.size()) {
+ is_default_best_match_ = true;
+ default_index_ = best_matched_username_index;
+ combobox->SetSelectedIndex(best_matched_username_index);
+ } else if (preferred_form_index < forms.size()) {
+ is_default_preferred_ = true;
+ default_index_ = preferred_form_index;
+ combobox->SetSelectedIndex(preferred_form_index);
+ }
+ return combobox;
+}
+
+void CredentialsSelectionView::ReportUserActionOnce(bool was_update_rejected,
+ int selected_index) {
+ if (action_reported_)
+ return;
+ password_manager::metrics_util::MultiAccountUpdateBubbleUserAction action;
+ if (was_update_rejected) {
+ if (is_default_best_match_) {
+ action = password_manager::metrics_util::
+ DEFAULT_ACCOUNT_MATCHED_BY_PASSWORD_USER_REJECTED_UPDATE;
+ } else if (is_default_preferred_) {
+ action = password_manager::metrics_util::
+ DEFAULT_ACCOUNT_PREFERRED_USER_REJECTED_UPDATE;
+ } else {
+ action = password_manager::metrics_util::
+ DEFAULT_ACCOUNT_FIRST_USER_REJECTED_UPDATE;
+ }
+ } else if (selected_index == default_index_) {
+ if (is_default_best_match_) {
+ action = password_manager::metrics_util::
+ DEFAULT_ACCOUNT_MATCHED_BY_PASSWORD_USER_NOT_CHANGED;
+ } else if (is_default_preferred_) {
+ action = password_manager::metrics_util::
+ DEFAULT_ACCOUNT_PREFERRED_USER_NOT_CHANGED;
+ } else {
+ action = password_manager::metrics_util::
+ DEFAULT_ACCOUNT_FIRST_USER_NOT_CHANGED;
+ }
+ } else {
+ if (is_default_best_match_) {
+ action = password_manager::metrics_util::
+ DEFAULT_ACCOUNT_MATCHED_BY_PASSWORD_USER_CHANGED;
+ } else if (is_default_preferred_) {
+ action = password_manager::metrics_util::
+ DEFAULT_ACCOUNT_PREFERRED_USER_CHANGED;
+ } else {
+ action =
+ password_manager::metrics_util::DEFAULT_ACCOUNT_FIRST_USER_CHANGED;
+ }
+ }
+
+ password_manager::metrics_util::LogMultiAccountUpdateBubbleUserAction(action);
+ action_reported_ = true;
+}

Powered by Google App Engine
This is Rietveld 408576698