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

Side by Side Diff: components/autofill/core/browser/password_generator.cc

Issue 1192403003: Avoid checking of VerifyPassword() 2 times when generated password is proper. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/autofill/core/browser/password_generator.h" 5 #include "components/autofill/core/browser/password_generator.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 PasswordGenerator::~PasswordGenerator() {} 81 PasswordGenerator::~PasswordGenerator() {}
82 82
83 std::string PasswordGenerator::Generate() const { 83 std::string PasswordGenerator::Generate() const {
84 char password[255]; 84 char password[255];
85 char unused_hypenated_password[255]; 85 char unused_hypenated_password[255];
86 // Generate passwords that have numbers and upper and lower case letters. 86 // Generate passwords that have numbers and upper and lower case letters.
87 // No special characters included for now. 87 // No special characters included for now.
88 unsigned int mode = S_NB | S_CL | S_SL; 88 unsigned int mode = S_NB | S_CL | S_SL;
89 89
90 // gen_pron_pass() doesn't guarantee that it includes all of the type given 90 // gen_pron_pass() doesn't guarantee that it includes all of the type given
91 // in mode, so regenerate a few times if neccessary. 91 // in mode, so if generated password is not proper we will force fix this by
92 // TODO(gcasto): Is it worth regenerating at all? 92 // |ForceFixPassword| as lowercase letters are default in generated password.
AKV 2015/06/22 09:39:18 Can we reduce this password generation loop furthe
Deepak 2015/06/22 10:50:31 ok, I will raise the bug and discuss this.
93 for (int i = 0; i < 10; ++i) { 93 gen_pron_pass(password, unused_hypenated_password, password_length_,
94 gen_pron_pass(password, unused_hypenated_password, 94 password_length_, mode);
95 password_length_, password_length_, mode); 95 if (VerifyPassword(password))
96 if (VerifyPassword(password)) 96 return std::string(password);
AKV 2015/06/22 09:39:18 Looks legitimate.
Deepak 2015/06/22 10:50:31 Done.
97 break;
98 }
99 97
100 // If the password still isn't conforming after a few iterations, force it 98 // As the password isn't conforming force it to be so. This may change a
101 // to be so. This may change a syllable in the password. 99 // syllable in the password.
102 std::string str_password(password); 100 std::string str_password(password);
103 if (!VerifyPassword(str_password)) { 101 ForceFixPassword(&str_password);
104 ForceFixPassword(&str_password);
105 }
106 return str_password; 102 return str_password;
107 } 103 }
108 104
109 } // namespace autofill 105 } // namespace autofill
OLDNEW
« 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