| 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 11 matching lines...) Expand all Loading... |
| 22 | 22 |
| 23 struct FormData; | 23 struct FormData; |
| 24 struct PasswordForm; | 24 struct PasswordForm; |
| 25 | 25 |
| 26 // This class is responsible for controlling communication for password | 26 // This class is responsible for controlling communication for password |
| 27 // generation between the browser (which shows the popup and generates | 27 // generation between the browser (which shows the popup and generates |
| 28 // passwords) and WebKit (shows the generation icon in the password field). | 28 // passwords) and WebKit (shows the generation icon in the password field). |
| 29 class PasswordGenerationAgent : public content::RenderViewObserver { | 29 class PasswordGenerationAgent : public content::RenderViewObserver { |
| 30 public: | 30 public: |
| 31 explicit PasswordGenerationAgent(content::RenderView* render_view); | 31 explicit PasswordGenerationAgent(content::RenderView* render_view); |
| 32 virtual ~PasswordGenerationAgent(); | 32 ~PasswordGenerationAgent() override; |
| 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. | 41 // Called when new form controls are inserted. |
| 42 void OnDynamicFormsSeen(blink::WebLocalFrame* frame); | 42 void OnDynamicFormsSeen(blink::WebLocalFrame* frame); |
| 43 | 43 |
| 44 // 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. |
| 45 static const size_t kMaximumOfferSize = 5; | 45 static const size_t kMaximumOfferSize = 5; |
| 46 | 46 |
| 47 protected: | 47 protected: |
| 48 // 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. |
| 49 // Virtual so that it can be overriden during testing. | 49 // Virtual so that it can be overriden during testing. |
| 50 virtual bool ShouldAnalyzeDocument(const blink::WebDocument& document) const; | 50 virtual bool ShouldAnalyzeDocument(const blink::WebDocument& document) const; |
| 51 | 51 |
| 52 // RenderViewObserver: | 52 // RenderViewObserver: |
| 53 virtual bool OnMessageReceived(const IPC::Message& message) override; | 53 bool OnMessageReceived(const IPC::Message& message) override; |
| 54 | 54 |
| 55 // Use to force enable during testing. | 55 // Use to force enable during testing. |
| 56 void set_enabled(bool enabled) { enabled_ = enabled; } | 56 void set_enabled(bool enabled) { enabled_ = enabled; } |
| 57 | 57 |
| 58 private: | 58 private: |
| 59 // RenderViewObserver: | 59 // RenderViewObserver: |
| 60 virtual void DidFinishDocumentLoad(blink::WebLocalFrame* frame) override; | 60 void DidFinishDocumentLoad(blink::WebLocalFrame* frame) override; |
| 61 virtual void DidFinishLoad(blink::WebLocalFrame* frame) override; | 61 void DidFinishLoad(blink::WebLocalFrame* frame) override; |
| 62 | 62 |
| 63 // Message handlers. | 63 // Message handlers. |
| 64 void OnFormNotBlacklisted(const PasswordForm& form); | 64 void OnFormNotBlacklisted(const PasswordForm& form); |
| 65 void OnPasswordAccepted(const base::string16& password); | 65 void OnPasswordAccepted(const base::string16& password); |
| 66 void OnAccountCreationFormsDetected( | 66 void OnAccountCreationFormsDetected( |
| 67 const std::vector<autofill::FormData>& forms); | 67 const std::vector<autofill::FormData>& forms); |
| 68 | 68 |
| 69 // Helper function that will try and populate |password_elements_| and | 69 // Helper function that will try and populate |password_elements_| and |
| 70 // |possible_account_creation_form_|. | 70 // |possible_account_creation_form_|. |
| 71 void FindPossibleGenerationForm(blink::WebLocalFrame* frame); | 71 void FindPossibleGenerationForm(blink::WebLocalFrame* frame); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 | 125 |
| 126 // If this feature is enabled. Controlled by Finch. | 126 // If this feature is enabled. Controlled by Finch. |
| 127 bool enabled_; | 127 bool enabled_; |
| 128 | 128 |
| 129 DISALLOW_COPY_AND_ASSIGN(PasswordGenerationAgent); | 129 DISALLOW_COPY_AND_ASSIGN(PasswordGenerationAgent); |
| 130 }; | 130 }; |
| 131 | 131 |
| 132 } // namespace autofill | 132 } // namespace autofill |
| 133 | 133 |
| 134 #endif // COMPONENTS_AUTOFILL_CONTENT_RENDERER_PASSWORD_GENERATION_AGENT_H_ | 134 #endif // COMPONENTS_AUTOFILL_CONTENT_RENDERER_PASSWORD_GENERATION_AGENT_H_ |
| OLD | NEW |