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 struct FormData; |
| 18 class FormStructure; |
17 class PasswordGenerator; | 19 class PasswordGenerator; |
18 } | 20 } |
19 | 21 |
20 namespace content { | 22 namespace content { |
21 struct PasswordForm; | 23 struct PasswordForm; |
22 } | 24 } |
23 | 25 |
24 namespace user_prefs { | 26 namespace user_prefs { |
25 class PrefRegistrySyncable; | 27 class PrefRegistrySyncable; |
26 } | 28 } |
(...skipping 15 matching lines...) Expand all Loading... |
42 // if the user chooses to generate a password. | 44 // if the user chooses to generate a password. |
43 class PasswordGenerationManager | 45 class PasswordGenerationManager |
44 : public ProfileSyncServiceObserver, | 46 : public ProfileSyncServiceObserver, |
45 public content::WebContentsObserver, | 47 public content::WebContentsObserver, |
46 public content::WebContentsUserData<PasswordGenerationManager> { | 48 public content::WebContentsUserData<PasswordGenerationManager> { |
47 public: | 49 public: |
48 static void CreateForWebContents(content::WebContents* contents); | 50 static void CreateForWebContents(content::WebContents* contents); |
49 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); | 51 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
50 virtual ~PasswordGenerationManager(); | 52 virtual ~PasswordGenerationManager(); |
51 | 53 |
| 54 // Detect account creation forms from forms with autofill type annotated. |
| 55 void DetectAccountCreationForms( |
| 56 const std::vector<autofill::FormStructure*>& forms); |
| 57 |
52 protected: | 58 protected: |
53 explicit PasswordGenerationManager(content::WebContents* contents); | 59 explicit PasswordGenerationManager(content::WebContents* contents); |
54 | 60 |
55 private: | 61 private: |
56 friend class content::WebContentsUserData<PasswordGenerationManager>; | 62 friend class content::WebContentsUserData<PasswordGenerationManager>; |
57 friend class PasswordGenerationManagerTest; | 63 friend class PasswordGenerationManagerTest; |
58 | 64 |
59 // WebContentsObserver: | 65 // WebContentsObserver: |
60 virtual void RenderViewCreated(content::RenderViewHost* host) OVERRIDE; | 66 virtual void RenderViewCreated(content::RenderViewHost* host) OVERRIDE; |
61 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 67 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
(...skipping 12 matching lines...) Expand all Loading... |
74 | 80 |
75 // Determines current state of password generation and sends this information | 81 // Determines current state of password generation and sends this information |
76 // to the renderer if it is different from |enabled_| or if |new_renderer| | 82 // to the renderer if it is different from |enabled_| or if |new_renderer| |
77 // is true. | 83 // is true. |
78 void UpdateState(content::RenderViewHost* host, bool new_renderer); | 84 void UpdateState(content::RenderViewHost* host, bool new_renderer); |
79 | 85 |
80 // Sends a message to the renderer enabling or disabling this feature. This | 86 // Sends a message to the renderer enabling or disabling this feature. This |
81 // is a separate function to aid in testing. | 87 // is a separate function to aid in testing. |
82 virtual void SendStateToRenderer(content::RenderViewHost* host, bool enabled); | 88 virtual void SendStateToRenderer(content::RenderViewHost* host, bool enabled); |
83 | 89 |
| 90 virtual void SendAccountCreationFormsToRenderer( |
| 91 content::RenderViewHost* host, |
| 92 const std::vector<autofill::FormData>& forms); |
| 93 |
84 // Causes the password generation bubble UI to be shown for the specified | 94 // Causes the password generation bubble UI to be shown for the specified |
85 // form. The popup will be anchored at |icon_bounds|. The generated | 95 // form. The popup will be anchored at |icon_bounds|. The generated |
86 // password will be no longer than |max_length|. | 96 // password will be no longer than |max_length|. |
87 void OnShowPasswordGenerationPopup(const gfx::Rect& icon_bounds, | 97 void OnShowPasswordGenerationPopup(const gfx::Rect& icon_bounds, |
88 int max_length, | 98 int max_length, |
89 const content::PasswordForm& form); | 99 const content::PasswordForm& form); |
90 | 100 |
91 // Whether password generation is enabled. | 101 // Whether password generation is enabled. |
92 bool enabled_; | 102 bool enabled_; |
93 | 103 |
94 // Listens for changes to the state of the password generation pref. | 104 // Listens for changes to the state of the password generation pref. |
95 PrefChangeRegistrar registrar_; | 105 PrefChangeRegistrar registrar_; |
96 | 106 |
97 // For vending a weak_ptr for |registrar_|. | 107 // For vending a weak_ptr for |registrar_|. |
98 base::WeakPtrFactory<PasswordGenerationManager> weak_factory_; | 108 base::WeakPtrFactory<PasswordGenerationManager> weak_factory_; |
99 | 109 |
100 // Controls how passwords are generated. | 110 // Controls how passwords are generated. |
101 scoped_ptr<autofill::PasswordGenerator> password_generator_; | 111 scoped_ptr<autofill::PasswordGenerator> password_generator_; |
102 | 112 |
103 DISALLOW_COPY_AND_ASSIGN(PasswordGenerationManager); | 113 DISALLOW_COPY_AND_ASSIGN(PasswordGenerationManager); |
104 }; | 114 }; |
105 | 115 |
106 #endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_GENERATION_MANAGER_H_ | 116 #endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_GENERATION_MANAGER_H_ |
OLD | NEW |