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

Side by Side Diff: chrome/browser/autofill/password_generator.h

Issue 10458018: This CL does the following: (1) Pass the max_length attribute to the password generator; (2) Update… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Some changes based on the code review. Created 8 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 | Annotate | Revision Log
OLDNEW
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;
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();
24 // |max_length| is used as a hint for the generated password's length.
25 explicit PasswordGenerator(int max_length);
22 ~PasswordGenerator(); 26 ~PasswordGenerator();
23 27
24 // Returns a random password. The string is guaranteed to be printable and 28 // Returns a random password such that:
25 // will not include whitespace characters. 29 // (1) Each character is guaranteed to be a non-whitespace printable ASCII
26 std::string Generate(); 30 // character.
31 // (2) The generated password will contain AT LEAST one upper case letter, one
32 // lower case letter, one digit, and one other symbol.
33 // (3) The password length will be equal to |password_length_| (see comment
34 // for the constructor).
35 std::string Generate() const;
27 36
28 private: 37 private:
38 // The length of the generated password.
39 int password_length_;
40
41 // A helper function to set the |password_length_| according to |max_length|.
42 int SetLength(int max_length);
Ilya Sherman 2012/06/01 19:32:10 nit: Please tuck this into the anonymous namespace
zysxqn 2012/06/01 22:32:54 Done.
29 43
30 DISALLOW_COPY_AND_ASSIGN(PasswordGenerator); 44 DISALLOW_COPY_AND_ASSIGN(PasswordGenerator);
31 }; 45 };
32 46
33 } // namespace autofill 47 } // namespace autofill
34 48
35 #endif // CHROME_BROWSER_AUTOFILL_PASSWORD_GENERATOR_H_ 49 #endif // CHROME_BROWSER_AUTOFILL_PASSWORD_GENERATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698