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

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

Issue 2853623002: [refactor] Fix autofill features for payments when the form is inside an OOPIF (Closed)
Patch Set: Created 3 years, 7 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_AUTOFILL_AGENT_H_ 5 #ifndef COMPONENTS_AUTOFILL_CONTENT_RENDERER_AUTOFILL_AGENT_H_
6 #define COMPONENTS_AUTOFILL_CONTENT_RENDERER_AUTOFILL_AGENT_H_ 6 #define COMPONENTS_AUTOFILL_CONTENT_RENDERER_AUTOFILL_AGENT_H_
7 7
8 #include <set> 8 #include <set>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "base/strings/string16.h" 14 #include "base/strings/string16.h"
15 #include "base/time/time.h" 15 #include "base/time/time.h"
16 #include "components/autofill/content/common/autofill_agent.mojom.h" 16 #include "components/autofill/content/common/autofill_agent.mojom.h"
17 #include "components/autofill/content/common/autofill_driver.mojom.h" 17 #include "components/autofill/content/common/autofill_driver.mojom.h"
18 #include "components/autofill/content/renderer/form_cache.h" 18 #include "components/autofill/content/renderer/form_cache.h"
19 #include "components/autofill/content/renderer/page_click_listener.h" 19 #include "components/autofill/content/renderer/page_click_listener.h"
20 #include "components/autofill/content/renderer/page_click_tracker.h"
20 #include "content/public/renderer/render_frame_observer.h" 21 #include "content/public/renderer/render_frame_observer.h"
21 #include "content/public/renderer/render_view_observer.h"
22 #include "mojo/public/cpp/bindings/binding.h" 22 #include "mojo/public/cpp/bindings/binding.h"
23 #include "third_party/WebKit/public/web/WebAutofillClient.h" 23 #include "third_party/WebKit/public/web/WebAutofillClient.h"
24 #include "third_party/WebKit/public/web/WebFormControlElement.h" 24 #include "third_party/WebKit/public/web/WebFormControlElement.h"
25 #include "third_party/WebKit/public/web/WebFormElement.h" 25 #include "third_party/WebKit/public/web/WebFormElement.h"
26 #include "third_party/WebKit/public/web/WebInputElement.h" 26 #include "third_party/WebKit/public/web/WebInputElement.h"
27 27
28 namespace blink { 28 namespace blink {
29 class WebNode; 29 class WebNode;
30 class WebView; 30 class WebView;
31 } 31 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 void FillPasswordSuggestion(const base::string16& username, 77 void FillPasswordSuggestion(const base::string16& username,
78 const base::string16& password) override; 78 const base::string16& password) override;
79 void PreviewPasswordSuggestion(const base::string16& username, 79 void PreviewPasswordSuggestion(const base::string16& username,
80 const base::string16& password) override; 80 const base::string16& password) override;
81 void ShowInitialPasswordAccountSuggestions( 81 void ShowInitialPasswordAccountSuggestions(
82 int32_t key, 82 int32_t key,
83 const PasswordFormFillData& form_data) override; 83 const PasswordFormFillData& form_data) override;
84 84
85 void ShowNotSecureWarning(const blink::WebInputElement& element); 85 void ShowNotSecureWarning(const blink::WebInputElement& element);
86 86
87 void set_page_click_tracker_for_testing(
88 std::unique_ptr<PageClickTracker> page_click_tracker) {
89 page_click_tracker_ = std::move(page_click_tracker);
90 }
91
87 protected: 92 protected:
88 // blink::WebAutofillClient: 93 // blink::WebAutofillClient:
89 void DidAssociateFormControlsDynamically() override; 94 void DidAssociateFormControlsDynamically() override;
90 95
91 private: 96 private:
92 // Functor used as a simplified comparison function for FormData. Only 97 // Functor used as a simplified comparison function for FormData. Only
93 // compares forms at a high level (notably name, origin, action). 98 // compares forms at a high level (notably name, origin, action).
94 struct FormDataCompare { 99 struct FormDataCompare {
95 bool operator()(const FormData& lhs, const FormData& rhs) const; 100 bool operator()(const FormData& lhs, const FormData& rhs) const;
96 }; 101 };
97 102
98 // Thunk class for RenderViewObserver methods that haven't yet been migrated
99 // to RenderFrameObserver. Should eventually be removed.
100 // http://crbug.com/433486
101 class LegacyAutofillAgent : public content::RenderViewObserver {
102 public:
103 LegacyAutofillAgent(content::RenderView* render_view, AutofillAgent* agent);
104 ~LegacyAutofillAgent() override;
105
106 // Shuts the LegacyAutofillAgent down on RenderFrame deletion. Safe to call
107 // multiple times.
108 void Shutdown();
109
110 private:
111 // content::RenderViewObserver:
112 void OnDestruct() override;
113 void FocusChangeComplete() override;
114
115 AutofillAgent* agent_;
116
117 DISALLOW_COPY_AND_ASSIGN(LegacyAutofillAgent);
118 };
119 friend class LegacyAutofillAgent;
120
121 // Flags passed to ShowSuggestions. 103 // Flags passed to ShowSuggestions.
122 struct ShowSuggestionsOptions { 104 struct ShowSuggestionsOptions {
123 // All fields are default initialized to false. 105 // All fields are default initialized to false.
124 ShowSuggestionsOptions(); 106 ShowSuggestionsOptions();
125 107
126 // Specifies that suggestions should be shown when |element| contains no 108 // Specifies that suggestions should be shown when |element| contains no
127 // text. 109 // text.
128 bool autofill_on_empty_values; 110 bool autofill_on_empty_values;
129 111
130 // Specifies that suggestions should be shown when the caret is not 112 // Specifies that suggestions should be shown when the caret is not
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 // submitted_forms_ contents to ensure no duplicate submissions of 144 // submitted_forms_ contents to ensure no duplicate submissions of
163 // AutofillHostMsg_WillSubmitForm. 145 // AutofillHostMsg_WillSubmitForm.
164 void FireHostSubmitEvents(const blink::WebFormElement& form, 146 void FireHostSubmitEvents(const blink::WebFormElement& form,
165 bool form_submitted); 147 bool form_submitted);
166 void FireHostSubmitEvents(const FormData& form_data, bool form_submitted); 148 void FireHostSubmitEvents(const FormData& form_data, bool form_submitted);
167 149
168 // Shuts the AutofillAgent down on RenderFrame deletion. Safe to call multiple 150 // Shuts the AutofillAgent down on RenderFrame deletion. Safe to call multiple
169 // times. 151 // times.
170 void Shutdown(); 152 void Shutdown();
171 153
172 // Pass-through from LegacyAutofillAgent. This correlates with the
173 // RenderViewObserver method.
174 void FocusChangeComplete();
175
176 // PageClickListener: 154 // PageClickListener:
177 void FormControlElementClicked(const blink::WebFormControlElement& element, 155 void FormControlElementClicked(const blink::WebFormControlElement& element,
178 bool was_focused) override; 156 bool was_focused) override;
179 157
180 // blink::WebAutofillClient: 158 // blink::WebAutofillClient:
181 void TextFieldDidEndEditing(const blink::WebInputElement& element) override; 159 void TextFieldDidEndEditing(const blink::WebInputElement& element) override;
182 void TextFieldDidChange(const blink::WebFormControlElement& element) override; 160 void TextFieldDidChange(const blink::WebFormControlElement& element) override;
183 void TextFieldDidReceiveKeyDown( 161 void TextFieldDidReceiveKeyDown(
184 const blink::WebInputElement& element, 162 const blink::WebInputElement& element,
185 const blink::WebKeyboardEvent& event) override; 163 const blink::WebKeyboardEvent& event) override;
186 void OpenTextDataListChooser(const blink::WebInputElement& element) override; 164 void OpenTextDataListChooser(const blink::WebInputElement& element) override;
187 void DataListOptionsChanged(const blink::WebInputElement& element) override; 165 void DataListOptionsChanged(const blink::WebInputElement& element) override;
188 void UserGestureObserved() override; 166 void UserGestureObserved() override;
189 void AjaxSucceeded() override; 167 void AjaxSucceeded() override;
168 void DidCompleteFocusChangeInFrame() override;
169 void DidReceiveLeftMouseDownOrGestureTapInNode(
170 const blink::WebNode& node) override;
190 171
191 // Called when a same-document navigation is detected. 172 // Called when a same-document navigation is detected.
192 void OnSameDocumentNavigationCompleted(); 173 void OnSameDocumentNavigationCompleted();
193 // Helper method which collects unowned elements (i.e., those not inside a 174 // Helper method which collects unowned elements (i.e., those not inside a
194 // form tag) and writes them into |output|. Returns true if the process is 175 // form tag) and writes them into |output|. Returns true if the process is
195 // successful, and all conditions for firing events are true. 176 // successful, and all conditions for firing events are true.
196 bool CollectFormlessElements(FormData* output); 177 bool CollectFormlessElements(FormData* output);
197 FRIEND_TEST_ALL_PREFIXES(FormAutocompleteTest, CollectFormlessElements); 178 FRIEND_TEST_ALL_PREFIXES(FormAutocompleteTest, CollectFormlessElements);
198 179
199 // Called in a posted task by textFieldDidChange() to work-around a WebKit bug 180 // Called in a posted task by textFieldDidChange() to work-around a WebKit bug
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 // frame. 233 // frame.
253 FormCache form_cache_; 234 FormCache form_cache_;
254 235
255 // Keeps track of the forms for which a "will submit" message has been sent in 236 // Keeps track of the forms for which a "will submit" message has been sent in
256 // this frame's current load. We use a simplified comparison function. 237 // this frame's current load. We use a simplified comparison function.
257 std::set<FormData, FormDataCompare> submitted_forms_; 238 std::set<FormData, FormDataCompare> submitted_forms_;
258 239
259 PasswordAutofillAgent* password_autofill_agent_; // Weak reference. 240 PasswordAutofillAgent* password_autofill_agent_; // Weak reference.
260 PasswordGenerationAgent* password_generation_agent_; // Weak reference. 241 PasswordGenerationAgent* password_generation_agent_; // Weak reference.
261 242
262 // Passes through RenderViewObserver methods to |this|.
263 LegacyAutofillAgent legacy_;
264
265 // The ID of the last request sent for form field Autofill. Used to ignore 243 // The ID of the last request sent for form field Autofill. Used to ignore
266 // out of date responses. 244 // out of date responses.
267 int autofill_query_id_; 245 int autofill_query_id_;
268 246
269 // The element corresponding to the last request sent for form field Autofill. 247 // The element corresponding to the last request sent for form field Autofill.
270 blink::WebFormControlElement element_; 248 blink::WebFormControlElement element_;
271 249
272 // The form element currently requesting an interactive autocomplete. 250 // The form element currently requesting an interactive autocomplete.
273 blink::WebFormElement in_flight_request_form_; 251 blink::WebFormElement in_flight_request_form_;
274 252
(...skipping 16 matching lines...) Expand all
291 // performance improvement, so that the IPC channel isn't flooded with 269 // performance improvement, so that the IPC channel isn't flooded with
292 // messages to close the Autofill popup when it can't possibly be showing. 270 // messages to close the Autofill popup when it can't possibly be showing.
293 bool is_popup_possibly_visible_; 271 bool is_popup_possibly_visible_;
294 272
295 // If the generation popup is possibly visible. This is tracked to prevent 273 // If the generation popup is possibly visible. This is tracked to prevent
296 // generation UI from displaying at the same time as password manager UI. 274 // generation UI from displaying at the same time as password manager UI.
297 // This is needed because generation is shown on field focus vs. field click 275 // This is needed because generation is shown on field focus vs. field click
298 // for the password manager. TODO(gcasto): Have both UIs show on focus. 276 // for the password manager. TODO(gcasto): Have both UIs show on focus.
299 bool is_generation_popup_possibly_visible_; 277 bool is_generation_popup_possibly_visible_;
300 278
279 std::unique_ptr<PageClickTracker> page_click_tracker_;
280
301 mojo::Binding<mojom::AutofillAgent> binding_; 281 mojo::Binding<mojom::AutofillAgent> binding_;
302 282
303 mojom::AutofillDriverPtr autofill_driver_; 283 mojom::AutofillDriverPtr autofill_driver_;
304 284
305 base::WeakPtrFactory<AutofillAgent> weak_ptr_factory_; 285 base::WeakPtrFactory<AutofillAgent> weak_ptr_factory_;
306 286
307 DISALLOW_COPY_AND_ASSIGN(AutofillAgent); 287 DISALLOW_COPY_AND_ASSIGN(AutofillAgent);
308 }; 288 };
309 289
310 } // namespace autofill 290 } // namespace autofill
311 291
312 #endif // COMPONENTS_AUTOFILL_CONTENT_RENDERER_AUTOFILL_AGENT_H_ 292 #endif // COMPONENTS_AUTOFILL_CONTENT_RENDERER_AUTOFILL_AGENT_H_
OLDNEW
« no previous file with comments | « chrome/renderer/autofill/page_click_tracker_browsertest.cc ('k') | components/autofill/content/renderer/autofill_agent.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698