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 #ifndef CHROME_BROWSER_AUTOFILL_PASSWORD_GENERATOR_H_ | 5 #ifndef CHROME_BROWSER_AUTOFILL_PASSWORD_GENERATOR_H_ |
| 6 #define CHROME_BROWSER_AUTOFILL_PASSWORD_GENERATOR_H_ | 6 #define CHROME_BROWSER_AUTOFILL_PASSWORD_GENERATOR_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 | 12 |
| 13 const unsigned int kDefaultPasswordLength = 12; | |
|
Ilya Sherman
2012/06/01 01:09:55
This should still be a member of the PasswordGener
zysxqn
2012/06/01 19:01:32
Hm, can you elaborate more on this? In that case w
Ilya Sherman
2012/06/01 19:32:10
There is only one test that needs access to this c
zysxqn
2012/06/01 22:32:54
Done.
| |
| 14 | |
| 13 namespace autofill { | 15 namespace autofill { |
| 14 | 16 |
| 15 // Class to generate random passwords. Currently we just use a generic algorithm | 17 // Class to generate random passwords. Currently we just use a generic algorithm |
| 16 // for all sites, but eventually we can incorporate additional information to | 18 // for all sites, but eventually we can incorporate additional information to |
| 17 // determine passwords that are likely to be accepted (i.e. use pattern field, | 19 // determine passwords that are likely to be accepted (i.e. use pattern field, |
| 18 // previous generated passwords, crowdsourcing, etc.) | 20 // previous generated passwords, crowdsourcing, etc.) |
| 19 class PasswordGenerator { | 21 class PasswordGenerator { |
| 20 public: | 22 public: |
| 21 PasswordGenerator(); | 23 PasswordGenerator(); |
|
Ilya Sherman
2012/06/01 01:09:55
nit: Is this constructor still needed?
zysxqn
2012/06/01 19:01:32
Prefer to keep it in case some application just wa
Ilya Sherman
2012/06/01 19:32:10
It's easy enough to re-add in case it's ever neede
zysxqn
2012/06/01 22:32:54
I'm fine with either way so I remove it as you sug
| |
| 24 explicit PasswordGenerator(int max_length); | |
|
Ilya Sherman
2012/06/01 01:09:55
nit: Please comment on the meaning of |max_length|
zysxqn
2012/06/01 19:01:32
Done.
| |
| 22 ~PasswordGenerator(); | 25 ~PasswordGenerator(); |
| 23 | 26 |
| 24 // Returns a random password. The string is guaranteed to be printable and | 27 // Returns a random password such that: |
| 25 // will not include whitespace characters. | 28 // (1) Each of its character is guaranteed to be printable and will not |
| 29 // include whitespace characters. | |
|
Ilya Sherman
2012/06/01 01:09:55
nit: Perhaps: "Each character is guaranteed to be
zysxqn
2012/06/01 19:01:32
Done.
| |
| 30 // (2) The generated password will contain AT LEAST one upper case letter, one | |
| 31 // lower case letter, one digit, and one other symbol. | |
| 32 // (3) The length of the password is determined by |max_length|, which is | |
| 33 // passed through the corresponding renderer by examining the | |
| 34 // InputElementAttribute. In particular, if |max_length| is reasonable | |
| 35 // (i.e. [4, 20]), we set the |password_length_| to it. Otherwise, we use | |
| 36 // the default length of 12. | |
|
Ilya Sherman
2012/06/01 01:09:55
nit: This includes too many implementation details
zysxqn
2012/06/01 19:01:32
Done.
| |
| 26 std::string Generate(); | 37 std::string Generate(); |
| 27 | 38 |
| 28 private: | 39 private: |
| 40 // The length of the generated password. | |
| 41 int password_length_; | |
|
Ilya Sherman
2012/06/01 01:09:55
nit: const size_t?
zysxqn
2012/06/01 19:01:32
Won't this make comparisons more complex since all
Ilya Sherman
2012/06/01 19:32:10
The other numbers should probably also all be unsi
zysxqn
2012/06/01 22:32:54
Changed all variables related to password length t
| |
| 29 | 42 |
| 30 DISALLOW_COPY_AND_ASSIGN(PasswordGenerator); | 43 DISALLOW_COPY_AND_ASSIGN(PasswordGenerator); |
| 31 }; | 44 }; |
| 32 | 45 |
| 33 } // namespace autofill | 46 } // namespace autofill |
| 34 | 47 |
| 35 #endif // CHROME_BROWSER_AUTOFILL_PASSWORD_GENERATOR_H_ | 48 #endif // CHROME_BROWSER_AUTOFILL_PASSWORD_GENERATOR_H_ |
| OLD | NEW |