OLD | NEW |
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 #ifndef CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_GENERATION_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_GENERATION_MANAGER_H_ |
6 #define CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_GENERATION_MANAGER_H_ | 6 #define CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_GENERATION_MANAGER_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
11 #include "base/prefs/pref_change_registrar.h" | 11 #include "base/prefs/pref_change_registrar.h" |
12 #include "chrome/browser/sync/profile_sync_service_observer.h" | 12 #include "chrome/browser/sync/profile_sync_service_observer.h" |
13 #include "content/public/browser/web_contents_observer.h" | 13 #include "content/public/browser/web_contents_observer.h" |
14 #include "content/public/browser/web_contents_user_data.h" | 14 #include "content/public/browser/web_contents_user_data.h" |
15 | 15 |
16 namespace autofill { | 16 namespace autofill { |
17 class PasswordGenerator; | 17 class PasswordGenerator; |
18 } | 18 } |
19 | 19 |
20 namespace content { | 20 namespace content { |
21 struct PasswordForm; | 21 struct PasswordForm; |
22 } | 22 } |
23 | 23 |
| 24 namespace user_prefs { |
24 class PrefRegistrySyncable; | 25 class PrefRegistrySyncable; |
| 26 } |
25 | 27 |
26 // Per-tab manager for password generation. Will enable this feature only if | 28 // Per-tab manager for password generation. Will enable this feature only if |
27 // | 29 // |
28 // - Password manager is enabled | 30 // - Password manager is enabled |
29 // - Password sync is enabled | 31 // - Password sync is enabled |
30 // - Password generation pref is enabled | 32 // - Password generation pref is enabled |
31 // | 33 // |
32 // NOTE: At the moment, the creation of the renderer PasswordGenerationManager | 34 // NOTE: At the moment, the creation of the renderer PasswordGenerationManager |
33 // is controlled by a switch (--enable-password-generation) so this feature will | 35 // is controlled by a switch (--enable-password-generation) so this feature will |
34 // not be enabled regardless of the above criteria without the switch being | 36 // not be enabled regardless of the above criteria without the switch being |
35 // present. | 37 // present. |
36 // | 38 // |
37 // When enabled we will send a message enabling this feature in the renderer, | 39 // When enabled we will send a message enabling this feature in the renderer, |
38 // which will show an icon next to password fields which we think are associated | 40 // which will show an icon next to password fields which we think are associated |
39 // with account creation. This class also manages the popup which is created | 41 // with account creation. This class also manages the popup which is created |
40 // if the user chooses to generate a password. | 42 // if the user chooses to generate a password. |
41 class PasswordGenerationManager | 43 class PasswordGenerationManager |
42 : public ProfileSyncServiceObserver, | 44 : public ProfileSyncServiceObserver, |
43 public content::WebContentsObserver, | 45 public content::WebContentsObserver, |
44 public content::WebContentsUserData<PasswordGenerationManager> { | 46 public content::WebContentsUserData<PasswordGenerationManager> { |
45 public: | 47 public: |
46 static void CreateForWebContents(content::WebContents* contents); | 48 static void CreateForWebContents(content::WebContents* contents); |
47 static void RegisterUserPrefs(PrefRegistrySyncable* registry); | 49 static void RegisterUserPrefs(user_prefs::PrefRegistrySyncable* registry); |
48 virtual ~PasswordGenerationManager(); | 50 virtual ~PasswordGenerationManager(); |
49 | 51 |
50 protected: | 52 protected: |
51 explicit PasswordGenerationManager(content::WebContents* contents); | 53 explicit PasswordGenerationManager(content::WebContents* contents); |
52 | 54 |
53 private: | 55 private: |
54 friend class content::WebContentsUserData<PasswordGenerationManager>; | 56 friend class content::WebContentsUserData<PasswordGenerationManager>; |
55 friend class PasswordGenerationManagerTest; | 57 friend class PasswordGenerationManagerTest; |
56 | 58 |
57 // WebContentsObserver: | 59 // WebContentsObserver: |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 // For vending a weak_ptr for |registrar_|. | 97 // For vending a weak_ptr for |registrar_|. |
96 base::WeakPtrFactory<PasswordGenerationManager> weak_factory_; | 98 base::WeakPtrFactory<PasswordGenerationManager> weak_factory_; |
97 | 99 |
98 // Controls how passwords are generated. | 100 // Controls how passwords are generated. |
99 scoped_ptr<autofill::PasswordGenerator> password_generator_; | 101 scoped_ptr<autofill::PasswordGenerator> password_generator_; |
100 | 102 |
101 DISALLOW_COPY_AND_ASSIGN(PasswordGenerationManager); | 103 DISALLOW_COPY_AND_ASSIGN(PasswordGenerationManager); |
102 }; | 104 }; |
103 | 105 |
104 #endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_GENERATION_MANAGER_H_ | 106 #endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_GENERATION_MANAGER_H_ |
OLD | NEW |