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