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

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

Issue 707173004: Refactor Autofill for out of process iframes (OOPIF). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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 <vector> 8 #include <vector>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/gtest_prod_util.h" 12 #include "base/gtest_prod_util.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "base/time/time.h" 14 #include "base/time/time.h"
15 #include "components/autofill/content/renderer/form_cache.h" 15 #include "components/autofill/content/renderer/form_cache.h"
16 #include "components/autofill/content/renderer/page_click_listener.h" 16 #include "components/autofill/content/renderer/page_click_listener.h"
17 #include "components/autofill/content/renderer/page_click_tracker.h"
18 #include "content/public/renderer/render_frame_observer.h"
17 #include "content/public/renderer/render_view_observer.h" 19 #include "content/public/renderer/render_view_observer.h"
18 #include "third_party/WebKit/public/web/WebAutofillClient.h" 20 #include "third_party/WebKit/public/web/WebAutofillClient.h"
19 #include "third_party/WebKit/public/web/WebFormControlElement.h" 21 #include "third_party/WebKit/public/web/WebFormControlElement.h"
20 #include "third_party/WebKit/public/web/WebFormElement.h" 22 #include "third_party/WebKit/public/web/WebFormElement.h"
21 #include "third_party/WebKit/public/web/WebInputElement.h" 23 #include "third_party/WebKit/public/web/WebInputElement.h"
22 24
23 namespace blink { 25 namespace blink {
24 class WebNode; 26 class WebNode;
25 class WebView; 27 class WebView;
26 } 28 }
27 29
28 namespace autofill { 30 namespace autofill {
29 31
30 struct FormData; 32 struct FormData;
31 struct FormFieldData; 33 struct FormFieldData;
32 struct WebElementDescriptor; 34 struct WebElementDescriptor;
33 class PasswordAutofillAgent; 35 class PasswordAutofillAgent;
34 class PasswordGenerationAgent; 36 class PasswordGenerationAgent;
35 37
36 // AutofillAgent deals with Autofill related communications between WebKit and 38 // AutofillAgent deals with Autofill related communications between WebKit and
37 // the browser. There is one AutofillAgent per RenderView. 39 // the browser. There is one AutofillAgent per RenderFrame.
38 // This code was originally part of RenderView.
39 // Note that Autofill encompasses: 40 // Note that Autofill encompasses:
40 // - single text field suggestions, that we usually refer to as Autocomplete, 41 // - single text field suggestions, that we usually refer to as Autocomplete,
41 // - password form fill, refered to as Password Autofill, and 42 // - password form fill, refered to as Password Autofill, and
42 // - entire form fill based on one field entry, referred to as Form Autofill. 43 // - entire form fill based on one field entry, referred to as Form Autofill.
43 44
44 class AutofillAgent : public content::RenderViewObserver, 45 class AutofillAgent : public content::RenderFrameObserver,
45 public PageClickListener, 46 public PageClickListener,
46 public blink::WebAutofillClient { 47 public blink::WebAutofillClient {
47 public: 48 public:
48 // PasswordAutofillAgent is guaranteed to outlive AutofillAgent. 49 // PasswordAutofillAgent is guaranteed to outlive AutofillAgent.
49 // PasswordGenerationAgent may be NULL. If it is not, then it is also 50 // PasswordGenerationAgent may be NULL. If it is not, then it is also
50 // guaranteed to outlive AutofillAgent. 51 // guaranteed to outlive AutofillAgent.
51 AutofillAgent(content::RenderView* render_view, 52 AutofillAgent(content::RenderFrame* render_frame,
52 PasswordAutofillAgent* password_autofill_manager, 53 PasswordAutofillAgent* password_autofill_manager,
53 PasswordGenerationAgent* password_generation_agent); 54 PasswordGenerationAgent* password_generation_agent);
54 virtual ~AutofillAgent(); 55 virtual ~AutofillAgent();
55 56
56 private: 57 private:
57 // content::RenderViewObserver: 58 // Thunk class for RenderViewObserver methods that haven't yet been migrated
59 // to RenderFrameObserver. Should eventually be removed.
vabr (Chromium) 2014/11/10 14:34:39 nit: Bug reference to track the progress of moving
Evan Stade 2014/11/14 23:25:49 Done.
60 class LegacyAutofillAgent : public content::RenderViewObserver {
61 public:
62 LegacyAutofillAgent(content::RenderView* render_view, AutofillAgent* agent);
63 ~LegacyAutofillAgent() override;
64
65 private:
66 // content::RenderViewObserver:
67 void OnDestruct() override;
68 void FrameDetached(blink::WebFrame* frame) override;
69 void WillSubmitForm(blink::WebLocalFrame* frame,
70 const blink::WebFormElement& form) override;
71 void DidChangeScrollOffset(blink::WebLocalFrame* frame) override;
72 void FocusedNodeChanged(const blink::WebNode& node) override;
73 void OrientationChangeEvent() override;
74 void Resized() override;
75
76 AutofillAgent* agent_;
77
78 DISALLOW_COPY_AND_ASSIGN(LegacyAutofillAgent);
79 };
80 friend class LegacyAutofillAgent;
81
82 // content::RenderFrameObserver:
58 bool OnMessageReceived(const IPC::Message& message) override; 83 bool OnMessageReceived(const IPC::Message& message) override;
59 void DidFinishDocumentLoad(blink::WebLocalFrame* frame) override; 84 void DidCommitProvisionalLoad(bool is_new_navigation) override;
60 void DidCommitProvisionalLoad(blink::WebLocalFrame* frame, 85 void DidFinishDocumentLoad() override;
61 bool is_new_navigation) override; 86 void FrameWillClose() override;
62 void FrameDetached(blink::WebFrame* frame) override; 87
63 void FrameWillClose(blink::WebFrame* frame) override; 88 // Pass-throughs from LegacyAutofillAgent. These correlate with
89 // RenderViewObserver methods.
90 void FrameDetached(blink::WebFrame* frame);
64 void WillSubmitForm(blink::WebLocalFrame* frame, 91 void WillSubmitForm(blink::WebLocalFrame* frame,
65 const blink::WebFormElement& form) override; 92 const blink::WebFormElement& form);
66 void DidChangeScrollOffset(blink::WebLocalFrame* frame) override; 93 void DidChangeScrollOffset(blink::WebLocalFrame* frame);
67 void FocusedNodeChanged(const blink::WebNode& node) override; 94 void FocusedNodeChanged(const blink::WebNode& node);
68 void OrientationChangeEvent() override; 95 void OrientationChangeEvent();
69 void Resized() override; 96 void Resized();
70 97
71 // PageClickListener: 98 // PageClickListener:
72 void FormControlElementClicked(const blink::WebFormControlElement& element, 99 void FormControlElementClicked(const blink::WebFormControlElement& element,
73 bool was_focused) override; 100 bool was_focused) override;
74 101
75 // blink::WebAutofillClient: 102 // blink::WebAutofillClient:
76 virtual void textFieldDidEndEditing( 103 virtual void textFieldDidEndEditing(
77 const blink::WebInputElement& element); 104 const blink::WebInputElement& element);
78 virtual void textFieldDidChange( 105 virtual void textFieldDidChange(
79 const blink::WebFormControlElement& element); 106 const blink::WebFormControlElement& element);
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 // Set |node| to display the given |value|. 193 // Set |node| to display the given |value|.
167 void FillFieldWithValue(const base::string16& value, 194 void FillFieldWithValue(const base::string16& value,
168 blink::WebInputElement* node); 195 blink::WebInputElement* node);
169 196
170 // Set |node| to display the given |value| as a preview. The preview is 197 // Set |node| to display the given |value| as a preview. The preview is
171 // visible on screen to the user, but not visible to the page via the DOM or 198 // visible on screen to the user, but not visible to the page via the DOM or
172 // JavaScript. 199 // JavaScript.
173 void PreviewFieldWithValue(const base::string16& value, 200 void PreviewFieldWithValue(const base::string16& value,
174 blink::WebInputElement* node); 201 blink::WebInputElement* node);
175 202
176 // Notifies browser of new fillable forms in |frame|. 203 // Notifies browser of new fillable forms in |render_frame|.
177 void ProcessForms(const blink::WebLocalFrame& frame); 204 void ProcessForms();
178 205
179 // Hides any currently showing Autofill popup. 206 // Hides any currently showing Autofill popup.
180 void HidePopup(); 207 void HidePopup();
181 208
182 FormCache form_cache_; 209 FormCache form_cache_;
vabr (Chromium) 2014/11/10 14:34:39 nit: This could use a comment about its purpose, a
Evan Stade 2014/11/14 23:25:49 Done.
183 210
184 PasswordAutofillAgent* password_autofill_agent_; // Weak reference. 211 PasswordAutofillAgent* password_autofill_agent_; // Weak reference.
185 PasswordGenerationAgent* password_generation_agent_; // Weak reference. 212 PasswordGenerationAgent* password_generation_agent_; // Weak reference.
186 213
214 // Passes through RenderViewObserver methods to |this|.
215 LegacyAutofillAgent legacy_;
216
217 // Tracks clicks on the RenderViewHost, informs |this|.
218 PageClickTracker page_click_tracker_;
219
187 // The ID of the last request sent for form field Autofill. Used to ignore 220 // The ID of the last request sent for form field Autofill. Used to ignore
188 // out of date responses. 221 // out of date responses.
189 int autofill_query_id_; 222 int autofill_query_id_;
190 223
191 // The element corresponding to the last request sent for form field Autofill. 224 // The element corresponding to the last request sent for form field Autofill.
192 blink::WebFormControlElement element_; 225 blink::WebFormControlElement element_;
193 226
194 // The form element currently requesting an interactive autocomplete. 227 // The form element currently requesting an interactive autocomplete.
195 blink::WebFormElement in_flight_request_form_; 228 blink::WebFormElement in_flight_request_form_;
196 229
197 // Pointer to the WebView. Used to access page scale factor.
198 blink::WebView* web_view_;
199
200 // Should we display a warning if autofill is disabled? 230 // Should we display a warning if autofill is disabled?
201 bool display_warning_if_disabled_; 231 bool display_warning_if_disabled_;
202 232
203 // Was the query node autofilled prior to previewing the form? 233 // Was the query node autofilled prior to previewing the form?
204 bool was_query_node_autofilled_; 234 bool was_query_node_autofilled_;
205 235
206 // Have we already shown Autofill suggestions for the field the user is 236 // Have we already shown Autofill suggestions for the field the user is
207 // currently editing? Used to keep track of state for metrics logging. 237 // currently editing? Used to keep track of state for metrics logging.
208 bool has_shown_autofill_popup_for_current_edit_; 238 bool has_shown_autofill_popup_for_current_edit_;
209 239
210 // If true we just set the node text so we shouldn't show the popup. 240 // If true we just set the node text so we shouldn't show the popup.
211 bool did_set_node_text_; 241 bool did_set_node_text_;
212 242
213 // Whether or not to ignore text changes. Useful for when we're committing 243 // Whether or not to ignore text changes. Useful for when we're committing
214 // a composition when we are defocusing the WebView and we don't want to 244 // a composition when we are defocusing the WebView and we don't want to
215 // trigger an autofill popup to show. 245 // trigger an autofill popup to show.
216 bool ignore_text_changes_; 246 bool ignore_text_changes_;
217 247
218 // Whether the Autofill popup is possibly visible. This is tracked as a 248 // Whether the Autofill popup is possibly visible. This is tracked as a
219 // performance improvement, so that the IPC channel isn't flooded with 249 // performance improvement, so that the IPC channel isn't flooded with
220 // messages to close the Autofill popup when it can't possibly be showing. 250 // messages to close the Autofill popup when it can't possibly be showing.
221 bool is_popup_possibly_visible_; 251 bool is_popup_possibly_visible_;
222 252
223 // True if a message has already been sent about forms for the main frame. 253 // True if a message has already been sent about forms for the main frame.
224 // When the main frame is first loaded, a message is sent even if no forms 254 // When the main frame is first loaded, a message is sent even if no forms
225 // exist in the frame. Otherwise, such messages are supressed. 255 // exist in the frame. Otherwise, such messages are supressed.
226 bool main_frame_processed_; 256 bool main_frame_processed_;
vabr (Chromium) 2014/11/10 14:34:39 Should the comment for this member variable be upd
Evan Stade 2014/11/14 23:25:49 yea I think we can just remove it
227 257
228 base::WeakPtrFactory<AutofillAgent> weak_ptr_factory_; 258 base::WeakPtrFactory<AutofillAgent> weak_ptr_factory_;
229 259
230 DISALLOW_COPY_AND_ASSIGN(AutofillAgent); 260 DISALLOW_COPY_AND_ASSIGN(AutofillAgent);
231 }; 261 };
232 262
233 } // namespace autofill 263 } // namespace autofill
234 264
235 #endif // COMPONENTS_AUTOFILL_CONTENT_RENDERER_AUTOFILL_AGENT_H_ 265 #endif // COMPONENTS_AUTOFILL_CONTENT_RENDERER_AUTOFILL_AGENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698