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 "content/public/browser/web_contents_observer.h" | 11 #include "content/public/browser/web_contents_observer.h" |
11 #include "content/public/browser/web_contents_user_data.h" | 12 #include "content/public/browser/web_contents_user_data.h" |
| 13 #include "ui/gfx/rect.h" |
12 | 14 |
13 namespace autofill { | 15 namespace autofill { |
14 struct FormData; | 16 struct FormData; |
15 class FormStructure; | 17 class FormStructure; |
16 class PasswordGenerator; | 18 class PasswordGenerator; |
| 19 class PasswordGenerationPopupControllerImpl; |
| 20 class PasswordGenerationPopupObserver; |
17 struct PasswordForm; | 21 struct PasswordForm; |
18 } | 22 } |
19 | 23 |
20 namespace user_prefs { | 24 namespace user_prefs { |
21 class PrefRegistrySyncable; | 25 class PrefRegistrySyncable; |
22 } | 26 } |
23 | 27 |
24 // 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 |
25 // | 29 // |
26 // - Password manager is enabled | 30 // - Password manager is enabled |
(...skipping 12 matching lines...) Expand all Loading... |
39 public content::WebContentsUserData<PasswordGenerationManager> { | 43 public content::WebContentsUserData<PasswordGenerationManager> { |
40 public: | 44 public: |
41 virtual ~PasswordGenerationManager(); | 45 virtual ~PasswordGenerationManager(); |
42 | 46 |
43 // Detect account creation forms from forms with autofill type annotated. | 47 // Detect account creation forms from forms with autofill type annotated. |
44 // Will send a message to the renderer if we find a correctly annotated form | 48 // Will send a message to the renderer if we find a correctly annotated form |
45 // and the feature is enabled. | 49 // and the feature is enabled. |
46 void DetectAccountCreationForms( | 50 void DetectAccountCreationForms( |
47 const std::vector<autofill::FormStructure*>& forms); | 51 const std::vector<autofill::FormStructure*>& forms); |
48 | 52 |
| 53 // Hide any visible password generation related popups. |
| 54 void HidePopup(); |
| 55 |
| 56 // Observer for PasswordGenerationPopup events. Used for testing. |
| 57 void SetTestObserver(autofill::PasswordGenerationPopupObserver* observer); |
| 58 |
49 protected: | 59 protected: |
50 explicit PasswordGenerationManager(content::WebContents* contents); | 60 explicit PasswordGenerationManager(content::WebContents* contents); |
51 | 61 |
52 private: | 62 private: |
53 friend class content::WebContentsUserData<PasswordGenerationManager>; | 63 friend class content::WebContentsUserData<PasswordGenerationManager>; |
54 friend class PasswordGenerationManagerTest; | 64 friend class PasswordGenerationManagerTest; |
55 | 65 |
56 // WebContentsObserver: | 66 // WebContentsObserver: |
57 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 67 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
58 | 68 |
59 // Determines current state of password generation | 69 // Determines current state of password generation |
60 bool IsGenerationEnabled() const; | 70 bool IsGenerationEnabled() const; |
61 | 71 |
62 // Sends a message to the renderer specifying form(s) that we should enable | 72 // Sends a message to the renderer specifying form(s) that we should enable |
63 // password generation on. This is a separate function to aid in testing. | 73 // password generation on. This is a separate function to aid in testing. |
64 virtual void SendAccountCreationFormsToRenderer( | 74 virtual void SendAccountCreationFormsToRenderer( |
65 content::RenderViewHost* host, | 75 content::RenderViewHost* host, |
66 const std::vector<autofill::FormData>& forms); | 76 const std::vector<autofill::FormData>& forms); |
67 | 77 |
68 // Causes the password generation bubble UI to be shown for the specified | 78 // Given |bounds| in the renderers coordinate system, return the same bounds |
69 // form. The popup will be anchored at |icon_bounds|. The generated | 79 // in the screens coordinate system. |
70 // password will be no longer than |max_length|. | 80 gfx::RectF GetBoundsInScreenSpace(const gfx::RectF& bounds); |
71 void OnShowPasswordGenerationPopup(const gfx::Rect& icon_bounds, | 81 |
| 82 // Causes the password generation UI to be shown for the specified form. |
| 83 // The popup will be anchored at |element_bounds|. The generated password |
| 84 // will be no longer than |max_length|. |
| 85 void OnShowPasswordGenerationPopup(const gfx::RectF& element_bounds, |
72 int max_length, | 86 int max_length, |
73 const autofill::PasswordForm& form); | 87 const autofill::PasswordForm& form); |
74 | 88 |
| 89 // Causes the password editing UI to be shown anchored at |element_bounds|. |
| 90 void OnShowPasswordEditingPopup(const gfx::RectF& element_bounds); |
| 91 |
| 92 // Hide any visible UI. |
| 93 void OnHidePasswordGenerationPopup(); |
| 94 |
| 95 // Observer for password generation popup. |
| 96 autofill::PasswordGenerationPopupObserver* observer_; |
| 97 |
75 // Controls how passwords are generated. | 98 // Controls how passwords are generated. |
76 scoped_ptr<autofill::PasswordGenerator> password_generator_; | 99 scoped_ptr<autofill::PasswordGenerator> password_generator_; |
77 | 100 |
| 101 // Controls the popup |
| 102 base::WeakPtr< |
| 103 autofill::PasswordGenerationPopupControllerImpl> popup_controller_; |
| 104 |
78 DISALLOW_COPY_AND_ASSIGN(PasswordGenerationManager); | 105 DISALLOW_COPY_AND_ASSIGN(PasswordGenerationManager); |
79 }; | 106 }; |
80 | 107 |
81 #endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_GENERATION_MANAGER_H_ | 108 #endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_GENERATION_MANAGER_H_ |
OLD | NEW |