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

Unified Diff: components/autofill/core/browser/password_generator.cc

Issue 1495463002: Calling gen_pron_pass() for generating password only once and Force Fixing it if needed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changes as per review comments. Created 5 years 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/autofill/core/browser/password_generator.cc
diff --git a/components/autofill/core/browser/password_generator.cc b/components/autofill/core/browser/password_generator.cc
index 84ca65edeb575612ddb646f0dba62a90365eaae6..3dcd1f296bff7f17e1eb995f03f3123fd503e2de 100644
--- a/components/autofill/core/browser/password_generator.cc
+++ b/components/autofill/core/browser/password_generator.cc
@@ -86,22 +86,16 @@ std::string PasswordGenerator::Generate() const {
// No special characters included for now.
unsigned int mode = S_NB | S_CL | S_SL;
- // gen_pron_pass() doesn't guarantee that it includes all of the type given
- // in mode, so regenerate a few times if neccessary.
- // TODO(gcasto): Is it worth regenerating at all?
- for (int i = 0; i < 10; ++i) {
- gen_pron_pass(password, unused_hypenated_password,
- password_length_, password_length_, mode);
- if (VerifyPassword(password))
- return std::string(password);
- }
+ // Generate the password by gen_pron_pass(), if it is not conforming then
+ // force fix it.
+ gen_pron_pass(password, unused_hypenated_password, password_length_,
+ password_length_, mode);
- // If the password still isn't conforming after a few iterations, force it
- // to be so. This may change a syllable in the password.
std::string str_password(password);
- if (!VerifyPassword(str_password)) {
- ForceFixPassword(&str_password);
- }
+ if (VerifyPassword(str_password))
+ return str_password;
+
+ ForceFixPassword(&str_password);
return str_password;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698