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 COMPONENTS_AUTOFILL_CONTENT_RENDERER_PASSWORD_GENERATION_AGENT_H_ | 5 #ifndef COMPONENTS_AUTOFILL_CONTENT_RENDERER_PASSWORD_GENERATION_AGENT_H_ |
6 #define COMPONENTS_AUTOFILL_CONTENT_RENDERER_PASSWORD_GENERATION_AGENT_H_ | 6 #define COMPONENTS_AUTOFILL_CONTENT_RENDERER_PASSWORD_GENERATION_AGENT_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 20 matching lines...) Expand all Loading... |
31 explicit PasswordGenerationAgent(content::RenderView* render_view); | 31 explicit PasswordGenerationAgent(content::RenderView* render_view); |
32 virtual ~PasswordGenerationAgent(); | 32 virtual ~PasswordGenerationAgent(); |
33 | 33 |
34 // Returns true if the field being changed is one where a generated password | 34 // Returns true if the field being changed is one where a generated password |
35 // is being offered. Updates the state of the popup if necessary. | 35 // is being offered. Updates the state of the popup if necessary. |
36 bool TextDidChangeInTextField(const blink::WebInputElement& element); | 36 bool TextDidChangeInTextField(const blink::WebInputElement& element); |
37 | 37 |
38 // Returns true if the newly focused node caused the generation UI to show. | 38 // Returns true if the newly focused node caused the generation UI to show. |
39 bool FocusedNodeHasChanged(const blink::WebNode& node); | 39 bool FocusedNodeHasChanged(const blink::WebNode& node); |
40 | 40 |
| 41 // Called when new form controls are inserted. |
| 42 void OnDynamicFormsSeen(blink::WebLocalFrame* frame); |
| 43 |
41 // The length that a password can be before the UI is hidden. | 44 // The length that a password can be before the UI is hidden. |
42 static const size_t kMaximumOfferSize = 5; | 45 static const size_t kMaximumOfferSize = 5; |
43 | 46 |
44 protected: | 47 protected: |
45 // Returns true if this document is one that we should consider analyzing. | 48 // Returns true if this document is one that we should consider analyzing. |
46 // Virtual so that it can be overriden during testing. | 49 // Virtual so that it can be overriden during testing. |
47 virtual bool ShouldAnalyzeDocument(const blink::WebDocument& document) const; | 50 virtual bool ShouldAnalyzeDocument(const blink::WebDocument& document) const; |
48 | 51 |
49 // RenderViewObserver: | 52 // RenderViewObserver: |
50 virtual bool OnMessageReceived(const IPC::Message& message) override; | 53 virtual bool OnMessageReceived(const IPC::Message& message) override; |
51 | 54 |
52 // Use to force enable during testing. | 55 // Use to force enable during testing. |
53 void set_enabled(bool enabled) { enabled_ = enabled; } | 56 void set_enabled(bool enabled) { enabled_ = enabled; } |
54 | 57 |
55 private: | 58 private: |
56 // RenderViewObserver: | 59 // RenderViewObserver: |
57 virtual void DidFinishDocumentLoad(blink::WebLocalFrame* frame) override; | 60 virtual void DidFinishDocumentLoad(blink::WebLocalFrame* frame) override; |
58 virtual void DidFinishLoad(blink::WebLocalFrame* frame) override; | 61 virtual void DidFinishLoad(blink::WebLocalFrame* frame) override; |
59 | 62 |
60 // Message handlers. | 63 // Message handlers. |
61 void OnFormNotBlacklisted(const PasswordForm& form); | 64 void OnFormNotBlacklisted(const PasswordForm& form); |
62 void OnPasswordAccepted(const base::string16& password); | 65 void OnPasswordAccepted(const base::string16& password); |
63 void OnAccountCreationFormsDetected( | 66 void OnAccountCreationFormsDetected( |
64 const std::vector<autofill::FormData>& forms); | 67 const std::vector<autofill::FormData>& forms); |
65 | 68 |
| 69 // Helper function that will try and populate |password_elements_| and |
| 70 // |possible_account_creation_form_|. |
| 71 void FindPossibleGenerationForm(blink::WebLocalFrame* frame); |
| 72 |
66 // Helper function to decide if |passwords_| contains password fields for | 73 // Helper function to decide if |passwords_| contains password fields for |
67 // an account creation form. Sets |generation_element_| to the field that | 74 // an account creation form. Sets |generation_element_| to the field that |
68 // we want to trigger the generation UI on. | 75 // we want to trigger the generation UI on. |
69 void DetermineGenerationElement(); | 76 void DetermineGenerationElement(); |
70 | 77 |
71 // Show password generation UI anchored at |generation_element_|. | 78 // Show password generation UI anchored at |generation_element_|. |
72 void ShowGenerationPopup(); | 79 void ShowGenerationPopup(); |
73 | 80 |
74 // Show UI for editing a generated password at |generation_element_|. | 81 // Show UI for editing a generated password at |generation_element_|. |
75 void ShowEditingPopup(); | 82 void ShowEditingPopup(); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 | 125 |
119 // If this feature is enabled. Controlled by Finch. | 126 // If this feature is enabled. Controlled by Finch. |
120 bool enabled_; | 127 bool enabled_; |
121 | 128 |
122 DISALLOW_COPY_AND_ASSIGN(PasswordGenerationAgent); | 129 DISALLOW_COPY_AND_ASSIGN(PasswordGenerationAgent); |
123 }; | 130 }; |
124 | 131 |
125 } // namespace autofill | 132 } // namespace autofill |
126 | 133 |
127 #endif // COMPONENTS_AUTOFILL_CONTENT_RENDERER_PASSWORD_GENERATION_AGENT_H_ | 134 #endif // COMPONENTS_AUTOFILL_CONTENT_RENDERER_PASSWORD_GENERATION_AGENT_H_ |
OLD | NEW |