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

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: 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 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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 regenerate a few times if neccessary.
92 // TODO(gcasto): Is it worth regenerating at all? 92 // TODO(gcasto): Is it worth regenerating at all?
93 for (int i = 0; i < 10; ++i) { 93 for (int i = 0; i < 10; ++i) {
94 gen_pron_pass(password, unused_hypenated_password, 94 gen_pron_pass(password, unused_hypenated_password,
95 password_length_, password_length_, mode); 95 password_length_, password_length_, mode);
96 if (VerifyPassword(password)) 96 if (VerifyPassword(password))
97 break; 97 return std::string(password);
98 } 98 }
99 99
100 // If the password still isn't conforming after a few iterations, force it 100 // If the password still isn't conforming after a few iterations, force it
101 // to be so. This may change a syllable in the password. 101 // to be so. This may change a syllable in the password.
102 std::string str_password(password); 102 std::string str_password(password);
103 if (!VerifyPassword(str_password)) { 103 if (!VerifyPassword(str_password)) {
104 ForceFixPassword(&str_password); 104 ForceFixPassword(&str_password);
105 } 105 }
106 return str_password; 106 return str_password;
107 } 107 }
108 108
109 } // namespace autofill 109 } // 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