Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(83)

Side by Side Diff: components/autofill/content/renderer/password_generation_agent.h

Issue 2274783002: Revert of [Autofill] Migrate ContentPasswordManagerDriver<-->Password{Autofill,Generation}Agent IPCs to mojo. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <stddef.h> 8 #include <stddef.h>
9 9
10 #include <map> 10 #include <map>
11 #include <memory> 11 #include <memory>
12 #include <utility> 12 #include <utility>
13 #include <vector> 13 #include <vector>
14 14
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "base/memory/linked_ptr.h" 16 #include "base/memory/linked_ptr.h"
17 #include "components/autofill/content/public/interfaces/autofill_agent.mojom.h"
18 #include "components/autofill/content/public/interfaces/autofill_driver.mojom.h"
19 #include "content/public/renderer/render_frame_observer.h" 17 #include "content/public/renderer/render_frame_observer.h"
20 #include "mojo/public/cpp/bindings/binding.h"
21 #include "third_party/WebKit/public/web/WebInputElement.h" 18 #include "third_party/WebKit/public/web/WebInputElement.h"
22 #include "url/gurl.h" 19 #include "url/gurl.h"
23 20
24 namespace blink { 21 namespace blink {
25 class WebDocument; 22 class WebDocument;
26 } 23 }
27 24
28 namespace autofill { 25 namespace autofill {
29 26
30 struct FormData; 27 struct FormData;
31 struct PasswordForm; 28 struct PasswordForm;
32 struct PasswordFormGenerationData; 29 struct PasswordFormGenerationData;
33 class PasswordAutofillAgent; 30 class PasswordAutofillAgent;
34 31
35 // This class is responsible for controlling communication for password 32 // This class is responsible for controlling communication for password
36 // generation between the browser (which shows the popup and generates 33 // generation between the browser (which shows the popup and generates
37 // passwords) and WebKit (shows the generation icon in the password field). 34 // passwords) and WebKit (shows the generation icon in the password field).
38 class PasswordGenerationAgent : public content::RenderFrameObserver, 35 class PasswordGenerationAgent : public content::RenderFrameObserver {
39 public mojom::PasswordGenerationAgent {
40 public: 36 public:
41 PasswordGenerationAgent(content::RenderFrame* render_frame, 37 PasswordGenerationAgent(content::RenderFrame* render_frame,
42 PasswordAutofillAgent* password_agent); 38 PasswordAutofillAgent* password_agent);
43 ~PasswordGenerationAgent() override; 39 ~PasswordGenerationAgent() override;
44 40
45 void BindRequest(mojom::PasswordGenerationAgentRequest request);
46
47 // mojom::PasswordGenerationAgent:
48 void FormNotBlacklisted(const PasswordForm& form) override;
49 void GeneratedPasswordAccepted(const base::string16& password) override;
50 void FoundFormsEligibleForGeneration(
51 const std::vector<PasswordFormGenerationData>& forms) override;
52 // Sets |generation_element_| to the focused password field and shows a
53 // generation popup at this field.
54 void UserTriggeredGeneratePassword() override;
55 // Enables the form classifier.
56 void AllowToRunFormClassifier() override;
57
58 // Returns true if the field being changed is one where a generated password 41 // Returns true if the field being changed is one where a generated password
59 // is being offered. Updates the state of the popup if necessary. 42 // is being offered. Updates the state of the popup if necessary.
60 bool TextDidChangeInTextField(const blink::WebInputElement& element); 43 bool TextDidChangeInTextField(const blink::WebInputElement& element);
61 44
62 // Returns true if the newly focused node caused the generation UI to show. 45 // Returns true if the newly focused node caused the generation UI to show.
63 bool FocusedNodeHasChanged(const blink::WebNode& node); 46 bool FocusedNodeHasChanged(const blink::WebNode& node);
64 47
65 // Called when new form controls are inserted. 48 // Called when new form controls are inserted.
66 void OnDynamicFormsSeen(); 49 void OnDynamicFormsSeen();
67 50
(...skipping 16 matching lines...) Expand all
84 AccountCreationFormData( 67 AccountCreationFormData(
85 linked_ptr<PasswordForm> form, 68 linked_ptr<PasswordForm> form,
86 std::vector<blink::WebInputElement> password_elements); 69 std::vector<blink::WebInputElement> password_elements);
87 AccountCreationFormData(const AccountCreationFormData& other); 70 AccountCreationFormData(const AccountCreationFormData& other);
88 ~AccountCreationFormData(); 71 ~AccountCreationFormData();
89 }; 72 };
90 73
91 typedef std::vector<AccountCreationFormData> AccountCreationFormDataList; 74 typedef std::vector<AccountCreationFormData> AccountCreationFormDataList;
92 75
93 // RenderFrameObserver: 76 // RenderFrameObserver:
77 bool OnMessageReceived(const IPC::Message& message) override;
94 void DidFinishDocumentLoad() override; 78 void DidFinishDocumentLoad() override;
95 void DidFinishLoad() override; 79 void DidFinishLoad() override;
96 void OnDestruct() override; 80 void OnDestruct() override;
97 81
98 const mojom::PasswordManagerDriverPtr& GetPasswordManagerDriver(); 82 // Message handlers.
83 void OnFormNotBlacklisted(const PasswordForm& form);
84 void OnPasswordAccepted(const base::string16& password);
85 void OnFormsEligibleForGenerationFound(
86 const std::vector<autofill::PasswordFormGenerationData>& forms);
99 87
100 // Helper function that will try and populate |password_elements_| and 88 // Helper function that will try and populate |password_elements_| and
101 // |possible_account_creation_form_|. 89 // |possible_account_creation_form_|.
102 void FindPossibleGenerationForm(); 90 void FindPossibleGenerationForm();
103 91
104 // Helper function to decide if |passwords_| contains password fields for 92 // Helper function to decide if |passwords_| contains password fields for
105 // an account creation form. Sets |generation_element_| to the field that 93 // an account creation form. Sets |generation_element_| to the field that
106 // we want to trigger the generation UI on. 94 // we want to trigger the generation UI on.
107 void DetermineGenerationElement(); 95 void DetermineGenerationElement();
108 96
109 // Show password generation UI anchored at |generation_element_|. 97 // Show password generation UI anchored at |generation_element_|.
110 void ShowGenerationPopup(); 98 void ShowGenerationPopup();
111 99
112 // Show UI for editing a generated password at |generation_element_|. 100 // Show UI for editing a generated password at |generation_element_|.
113 void ShowEditingPopup(); 101 void ShowEditingPopup();
114 102
115 // Hides a password generation popup if one exists. 103 // Hides a password generation popup if one exists.
116 void HidePopup(); 104 void HidePopup();
117 105
106 // Sets |generation_element_| to the focused password field and shows a
107 // generation popup at this field.
108 void OnUserTriggeredGeneratePassword();
109
110 // Enables the form classifier.
111 void OnAllowToRunFormClassifier();
112
118 // Runs HTML parsing based classifier and saves its outcome to proto. 113 // Runs HTML parsing based classifier and saves its outcome to proto.
119 // TODO(crbug.com/621442): Remove client-side form classifier when server-side 114 // TODO(crbug.com/621442): Remove client-side form classifier when server-side
120 // classifier is ready. 115 // classifier is ready.
121 void RunFormClassifierAndSaveVote(const blink::WebFormElement& web_form, 116 void RunFormClassifierAndSaveVote(const blink::WebFormElement& web_form,
122 const PasswordForm& form); 117 const PasswordForm& form);
123 118
124 // Creates a password form to presave a generated password. It copies behavior 119 // Creates a password form to presave a generated password. It copies behavior
125 // of CreatePasswordFormFromWebForm/FromUnownedInputElements, but takes 120 // of CreatePasswordFormFromWebForm/FromUnownedInputElements, but takes
126 // |password_value| from |generation_element_| and empties |username_value|. 121 // |password_value| from |generation_element_| and empties |username_value|.
127 // If a form creating is failed, returns an empty unique_ptr. 122 // If a form creating is failed, returns an empty unique_ptr.
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 // If this feature is enabled. Controlled by Finch. 170 // If this feature is enabled. Controlled by Finch.
176 bool enabled_; 171 bool enabled_;
177 172
178 // If the form classifier should run. 173 // If the form classifier should run.
179 bool form_classifier_enabled_; 174 bool form_classifier_enabled_;
180 175
181 // Unowned pointer. Used to notify PassowrdAutofillAgent when values 176 // Unowned pointer. Used to notify PassowrdAutofillAgent when values
182 // in password fields are updated. 177 // in password fields are updated.
183 PasswordAutofillAgent* password_agent_; 178 PasswordAutofillAgent* password_agent_;
184 179
185 mojo::Binding<mojom::PasswordGenerationAgent> binding_;
186
187 DISALLOW_COPY_AND_ASSIGN(PasswordGenerationAgent); 180 DISALLOW_COPY_AND_ASSIGN(PasswordGenerationAgent);
188 }; 181 };
189 182
190 } // namespace autofill 183 } // namespace autofill
191 184
192 #endif // COMPONENTS_AUTOFILL_CONTENT_RENDERER_PASSWORD_GENERATION_AGENT_H_ 185 #endif // COMPONENTS_AUTOFILL_CONTENT_RENDERER_PASSWORD_GENERATION_AGENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698