Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/password_form_manager.h" | 5 #include "components/password_manager/core/browser/password_form_manager.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <set> | |
|
vabr (Chromium)
2014/09/15 13:01:45
Is this related to your other changes in the CL? I
Pritam Nikam
2014/09/15 15:02:08
Done.
I've changed this to resolve Lint error. No
| |
| 8 | 9 |
| 9 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| 10 #include "base/metrics/user_metrics.h" | 11 #include "base/metrics/user_metrics.h" |
| 11 #include "base/strings/string_split.h" | 12 #include "base/strings/string_split.h" |
| 12 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
| 14 #include "components/autofill/core/browser/autofill_manager.h" | 15 #include "components/autofill/core/browser/autofill_manager.h" |
| 15 #include "components/autofill/core/browser/form_structure.h" | 16 #include "components/autofill/core/browser/form_structure.h" |
| 16 #include "components/autofill/core/browser/validation.h" | 17 #include "components/autofill/core/browser/validation.h" |
| 17 #include "components/autofill/core/common/password_form.h" | 18 #include "components/autofill/core/common/password_form.h" |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 88 PasswordFormManager::~PasswordFormManager() { | 89 PasswordFormManager::~PasswordFormManager() { |
| 89 UMA_HISTOGRAM_ENUMERATION( | 90 UMA_HISTOGRAM_ENUMERATION( |
| 90 "PasswordManager.ActionsTakenV3", GetActionsTaken(), kMaxNumActionsTaken); | 91 "PasswordManager.ActionsTakenV3", GetActionsTaken(), kMaxNumActionsTaken); |
| 91 if (has_generated_password_ && submit_result_ == kSubmitResultNotSubmitted) | 92 if (has_generated_password_ && submit_result_ == kSubmitResultNotSubmitted) |
| 92 LogPasswordGenerationSubmissionEvent(PASSWORD_NOT_SUBMITTED); | 93 LogPasswordGenerationSubmissionEvent(PASSWORD_NOT_SUBMITTED); |
| 93 } | 94 } |
| 94 | 95 |
| 95 int PasswordFormManager::GetActionsTaken() { | 96 int PasswordFormManager::GetActionsTaken() { |
| 96 return user_action_ + kUserActionMax * (manager_action_ + | 97 return user_action_ + kUserActionMax * (manager_action_ + |
| 97 kManagerActionMax * submit_result_); | 98 kManagerActionMax * submit_result_); |
| 98 }; | 99 } |
|
vabr (Chromium)
2014/09/15 13:01:45
Again, this does not seem related to the rest of t
Pritam Nikam
2014/09/15 15:02:08
Done.
Ditto!
| |
| 99 | 100 |
| 100 // TODO(timsteele): use a hash of some sort in the future? | 101 // TODO(timsteele): use a hash of some sort in the future? |
| 101 PasswordFormManager::MatchResultMask PasswordFormManager::DoesManage( | 102 PasswordFormManager::MatchResultMask PasswordFormManager::DoesManage( |
| 102 const PasswordForm& form) const { | 103 const PasswordForm& form) const { |
| 103 // Non-HTML form case. | 104 // Non-HTML form case. |
| 104 if (observed_form_.scheme != PasswordForm::SCHEME_HTML || | 105 if (observed_form_.scheme != PasswordForm::SCHEME_HTML || |
| 105 form.scheme != PasswordForm::SCHEME_HTML) { | 106 form.scheme != PasswordForm::SCHEME_HTML) { |
| 106 const bool forms_match = observed_form_.signon_realm == form.signon_realm && | 107 const bool forms_match = observed_form_.signon_realm == form.signon_realm && |
| 107 observed_form_.scheme == form.scheme; | 108 observed_form_.scheme == form.scheme; |
| 108 return forms_match ? RESULT_COMPLETE_MATCH : RESULT_NO_MATCH; | 109 return forms_match ? RESULT_COMPLETE_MATCH : RESULT_NO_MATCH; |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 219 // has already given consent, so we treat these cases the same. | 220 // has already given consent, so we treat these cases the same. |
| 220 return has_generated_password_; | 221 return has_generated_password_; |
| 221 } | 222 } |
| 222 | 223 |
| 223 bool PasswordFormManager::HasValidPasswordForm() { | 224 bool PasswordFormManager::HasValidPasswordForm() { |
| 224 DCHECK_EQ(state_, POST_MATCHING_PHASE); | 225 DCHECK_EQ(state_, POST_MATCHING_PHASE); |
| 225 // Non-HTML password forms (primarily HTTP and FTP autentication) | 226 // Non-HTML password forms (primarily HTTP and FTP autentication) |
| 226 // do not contain username_element and password_element values. | 227 // do not contain username_element and password_element values. |
| 227 if (observed_form_.scheme != PasswordForm::SCHEME_HTML) | 228 if (observed_form_.scheme != PasswordForm::SCHEME_HTML) |
| 228 return true; | 229 return true; |
| 229 return !observed_form_.username_element.empty() && | 230 return (!observed_form_.password_element.empty() || |
| 230 (!observed_form_.password_element.empty() || | |
| 231 !observed_form_.new_password_element.empty()); | 231 !observed_form_.new_password_element.empty()); |
| 232 } | 232 } |
| 233 | 233 |
| 234 bool PasswordFormManager::HasValidLogin() { | |
| 235 return !observed_form_.username_element.empty(); | |
| 236 } | |
| 237 | |
| 234 void PasswordFormManager::ProvisionallySave( | 238 void PasswordFormManager::ProvisionallySave( |
| 235 const PasswordForm& credentials, | 239 const PasswordForm& credentials, |
| 236 OtherPossibleUsernamesAction action) { | 240 OtherPossibleUsernamesAction action) { |
| 237 DCHECK_EQ(state_, POST_MATCHING_PHASE); | 241 DCHECK_EQ(state_, POST_MATCHING_PHASE); |
| 238 DCHECK_NE(RESULT_NO_MATCH, DoesManage(credentials)); | 242 DCHECK_NE(RESULT_NO_MATCH, DoesManage(credentials)); |
| 239 | 243 |
| 240 // If this was a sign-up or change password form, we want to persist the new | 244 // If this was a sign-up or change password form, we want to persist the new |
| 241 // password; if this was a login form, then the current password (which might | 245 // password; if this was a login form, then the current password (which might |
| 242 // still be "new" in the sense that we see these credentials for the first | 246 // still be "new" in the sense that we see these credentials for the first |
| 243 // time, or that the user manually entered his actual password to overwrite an | 247 // time, or that the user manually entered his actual password to overwrite an |
| (...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 773 LogPasswordGenerationSubmissionEvent(PASSWORD_SUBMITTED); | 777 LogPasswordGenerationSubmissionEvent(PASSWORD_SUBMITTED); |
| 774 } | 778 } |
| 775 | 779 |
| 776 void PasswordFormManager::SubmitFailed() { | 780 void PasswordFormManager::SubmitFailed() { |
| 777 submit_result_ = kSubmitResultFailed; | 781 submit_result_ = kSubmitResultFailed; |
| 778 if (has_generated_password_) | 782 if (has_generated_password_) |
| 779 LogPasswordGenerationSubmissionEvent(PASSWORD_SUBMISSION_FAILED); | 783 LogPasswordGenerationSubmissionEvent(PASSWORD_SUBMISSION_FAILED); |
| 780 } | 784 } |
| 781 | 785 |
| 782 } // namespace password_manager | 786 } // namespace password_manager |
| OLD | NEW |