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

Unified Diff: components/password_manager/core/browser/password_manager.cc

Issue 1182423004: Adding UMA stat when generated password set for newly created PasswordFormManager. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changes as per review comments. Created 5 years, 6 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
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/password_manager/core/browser/password_manager.cc
diff --git a/components/password_manager/core/browser/password_manager.cc b/components/password_manager/core/browser/password_manager.cc
index d256dd3ec43f141320a388e7d989025b190335a4..fb8178bc02c49ada89127b90f3aa58ee54d92117 100644
--- a/components/password_manager/core/browser/password_manager.cc
+++ b/components/password_manager/core/browser/password_manager.cc
@@ -167,20 +167,50 @@ void PasswordManager::SetHasGeneratedPasswordForForm(
bool password_is_generated) {
DCHECK(client_->IsSavingEnabledForCurrentPage());
+ ScopedVector<PasswordFormManager>::iterator matched_manager_it =
+ pending_login_managers_.end();
+ PasswordFormManager::MatchResultMask current_match_result =
+ PasswordFormManager::RESULT_NO_MATCH;
+
for (ScopedVector<PasswordFormManager>::iterator iter =
pending_login_managers_.begin();
iter != pending_login_managers_.end(); ++iter) {
- if ((*iter)->DoesManage(form) ==
- PasswordFormManager::RESULT_COMPLETE_MATCH) {
- (*iter)->set_has_generated_password(password_is_generated);
- return;
+ PasswordFormManager::MatchResultMask result = (*iter)->DoesManage(form);
+
+ if (result == PasswordFormManager::RESULT_NO_MATCH)
+ continue;
+
+ if (result == PasswordFormManager::RESULT_COMPLETE_MATCH) {
+ // If we find a manager that exactly matches the submitted form including
+ // the action URL, exit the loop.
+ matched_manager_it = iter;
+ break;
+ } else if (result == (PasswordFormManager::RESULT_COMPLETE_MATCH &
+ ~PasswordFormManager::RESULT_ACTION_MATCH) &&
+ result > current_match_result) {
+ // If the current manager matches the submitted form excluding the action
+ // URL, remember it as a candidate and continue searching for an exact
+ // match. See http://crbug.com/27246 for an example where actions can
+ // change.
+ matched_manager_it = iter;
+ current_match_result = result;
+ } else if (result > current_match_result) {
+ matched_manager_it = iter;
+ current_match_result = result;
}
}
- if (!password_is_generated) {
+ if (matched_manager_it != pending_login_managers_.end()) {
+ (*matched_manager_it)->set_has_generated_password(password_is_generated);
return;
}
+ UMA_HISTOGRAM_BOOLEAN("PasswordManager.GeneratedFormHasNoFormManager",
+ password_is_generated);
+
+ if (!password_is_generated)
+ return;
+
// If there is no corresponding PasswordFormManager, we create one. This is
// not the common case, and should only happen when there is a bug in our
// ability to detect forms.
@@ -189,7 +219,6 @@ void PasswordManager::SetHasGeneratedPasswordForForm(
this, client_, driver->AsWeakPtr(), form, ssl_valid);
pending_login_managers_.push_back(manager);
manager->set_has_generated_password(true);
- // TODO(gcasto): Add UMA stats to track this.
}
void PasswordManager::ProvisionallySavePassword(const PasswordForm& form) {
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698