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

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

Issue 23033016: Remove autocheckout code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Even more deletes, and Ilya review. Created 7 years, 3 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 | Annotate | Revision Log
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 "base/timer/timer.h" 15 #include "base/timer/timer.h"
16 #include "components/autofill/content/renderer/form_cache.h" 16 #include "components/autofill/content/renderer/form_cache.h"
17 #include "components/autofill/content/renderer/page_click_listener.h" 17 #include "components/autofill/content/renderer/page_click_listener.h"
18 #include "components/autofill/core/common/autocheckout_status.h"
19 #include "components/autofill/core/common/forms_seen_state.h" 18 #include "components/autofill/core/common/forms_seen_state.h"
20 #include "content/public/renderer/render_view_observer.h" 19 #include "content/public/renderer/render_view_observer.h"
21 #include "third_party/WebKit/public/web/WebAutofillClient.h" 20 #include "third_party/WebKit/public/web/WebAutofillClient.h"
22 #include "third_party/WebKit/public/web/WebFormElement.h" 21 #include "third_party/WebKit/public/web/WebFormElement.h"
23 #include "third_party/WebKit/public/web/WebInputElement.h" 22 #include "third_party/WebKit/public/web/WebInputElement.h"
24 23
25 namespace WebKit { 24 namespace WebKit {
26 class WebNode; 25 class WebNode;
27 class WebView; 26 class WebView;
28 } 27 }
(...skipping 25 matching lines...) Expand all
54 private: 53 private:
55 enum AutofillAction { 54 enum AutofillAction {
56 AUTOFILL_NONE, // No state set. 55 AUTOFILL_NONE, // No state set.
57 AUTOFILL_FILL, // Fill the Autofill form data. 56 AUTOFILL_FILL, // Fill the Autofill form data.
58 AUTOFILL_PREVIEW, // Preview the Autofill form data. 57 AUTOFILL_PREVIEW, // Preview the Autofill form data.
59 }; 58 };
60 59
61 // RenderView::Observer: 60 // RenderView::Observer:
62 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 61 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
63 virtual void DidFinishDocumentLoad(WebKit::WebFrame* frame) OVERRIDE; 62 virtual void DidFinishDocumentLoad(WebKit::WebFrame* frame) OVERRIDE;
64 virtual void DidStartProvisionalLoad(WebKit::WebFrame* frame) OVERRIDE;
65 virtual void DidFailProvisionalLoad(
66 WebKit::WebFrame* frame,
67 const WebKit::WebURLError& error) OVERRIDE;
68 virtual void DidCommitProvisionalLoad(WebKit::WebFrame* frame, 63 virtual void DidCommitProvisionalLoad(WebKit::WebFrame* frame,
69 bool is_new_navigation) OVERRIDE; 64 bool is_new_navigation) OVERRIDE;
70 virtual void FrameDetached(WebKit::WebFrame* frame) OVERRIDE; 65 virtual void FrameDetached(WebKit::WebFrame* frame) OVERRIDE;
71 virtual void WillSubmitForm(WebKit::WebFrame* frame, 66 virtual void WillSubmitForm(WebKit::WebFrame* frame,
72 const WebKit::WebFormElement& form) OVERRIDE; 67 const WebKit::WebFormElement& form) OVERRIDE;
73 virtual void ZoomLevelChanged() OVERRIDE; 68 virtual void ZoomLevelChanged() OVERRIDE;
74 virtual void DidChangeScrollOffset(WebKit::WebFrame* frame) OVERRIDE; 69 virtual void DidChangeScrollOffset(WebKit::WebFrame* frame) OVERRIDE;
75 virtual void FocusedNodeChanged(const WebKit::WebNode& node) OVERRIDE; 70 virtual void FocusedNodeChanged(const WebKit::WebNode& node) OVERRIDE;
76 virtual void OrientationChangeEvent(int orientation) OVERRIDE; 71 virtual void OrientationChangeEvent(int orientation) OVERRIDE;
77 72
(...skipping 24 matching lines...) Expand all
102 const std::vector<FormDataPredictions>& forms); 97 const std::vector<FormDataPredictions>& forms);
103 98
104 // For external Autofill selection. 99 // For external Autofill selection.
105 void OnSetAutofillActionFill(); 100 void OnSetAutofillActionFill();
106 void OnClearForm(); 101 void OnClearForm();
107 void OnSetAutofillActionPreview(); 102 void OnSetAutofillActionPreview();
108 void OnClearPreviewedForm(); 103 void OnClearPreviewedForm();
109 void OnSetNodeText(const base::string16& value); 104 void OnSetNodeText(const base::string16& value);
110 void OnAcceptDataListSuggestion(const base::string16& value); 105 void OnAcceptDataListSuggestion(const base::string16& value);
111 void OnAcceptPasswordAutofillSuggestion(const base::string16& value); 106 void OnAcceptPasswordAutofillSuggestion(const base::string16& value);
112 void OnGetAllForms();
113 107
114 // Called when interactive autocomplete finishes. 108 // Called when interactive autocomplete finishes.
115 void OnRequestAutocompleteResult( 109 void OnRequestAutocompleteResult(
116 WebKit::WebFormElement::AutocompleteResult result, 110 WebKit::WebFormElement::AutocompleteResult result,
117 const FormData& form_data); 111 const FormData& form_data);
118 112
119 // Called when an autocomplete request succeeds or fails with the |result|. 113 // Called when an autocomplete request succeeds or fails with the |result|.
120 void FinishAutocompleteRequest( 114 void FinishAutocompleteRequest(
121 WebKit::WebFormElement::AutocompleteResult result); 115 WebKit::WebFormElement::AutocompleteResult result);
122 116
123 // Called when the Autofill server hints that this page should be filled using
124 // Autocheckout. All the relevant form fields in |form_data| will be filled
125 // and then element specified by |element_descriptor| will be clicked to
126 // proceed to the next step of the form.
127 void OnFillFormsAndClick(
128 const std::vector<FormData>& form_data,
129 const std::vector<WebElementDescriptor>& click_elements_before_form_fill,
130 const std::vector<WebElementDescriptor>& click_elements_after_form_fill,
131 const WebElementDescriptor& element_descriptor);
132
133 // Called when |topmost_frame_| is supported for Autocheckout.
134 void OnAutocheckoutSupported();
135
136 // Called when the page is actually shown in the browser, as opposed to simply 117 // Called when the page is actually shown in the browser, as opposed to simply
137 // being preloaded. 118 // being preloaded.
138 void OnPageShown(); 119 void OnPageShown();
139 120
140 // Called when an Autocheckout page is completed by the renderer.
141 void CompleteAutocheckoutPage(autofill::AutocheckoutStatus status);
142
143 // Called when clicking an Autocheckout proceed element fails to do anything.
144 void ClickFailed();
145
146 // Called in a posted task by textFieldDidChange() to work-around a WebKit bug 121 // Called in a posted task by textFieldDidChange() to work-around a WebKit bug
147 // http://bugs.webkit.org/show_bug.cgi?id=16976 122 // http://bugs.webkit.org/show_bug.cgi?id=16976
148 void TextFieldDidChangeImpl(const WebKit::WebInputElement& element); 123 void TextFieldDidChangeImpl(const WebKit::WebInputElement& element);
149 124
150 // Shows the autofill suggestions for |element|. 125 // Shows the autofill suggestions for |element|.
151 // This call is asynchronous and may or may not lead to the showing of a 126 // This call is asynchronous and may or may not lead to the showing of a
152 // suggestion popup (no popup is shown if there are no available suggestions). 127 // suggestion popup (no popup is shown if there are no available suggestions).
153 // |autofill_on_empty_values| specifies whether suggestions should be shown 128 // |autofill_on_empty_values| specifies whether suggestions should be shown
154 // when |element| contains no text. 129 // when |element| contains no text.
155 // |requires_caret_at_end| specifies whether suggestions should be shown when 130 // |requires_caret_at_end| specifies whether suggestions should be shown when
(...skipping 29 matching lines...) Expand all
185 const WebKit::WebNode& node, 160 const WebKit::WebNode& node,
186 FormData* form, 161 FormData* form,
187 FormFieldData* field) WARN_UNUSED_RESULT; 162 FormFieldData* field) WARN_UNUSED_RESULT;
188 163
189 // Set |node| to display the given |value|. 164 // Set |node| to display the given |value|.
190 void SetNodeText(const base::string16& value, WebKit::WebInputElement* node); 165 void SetNodeText(const base::string16& value, WebKit::WebInputElement* node);
191 166
192 // Hides any currently showing Autofill UI. 167 // Hides any currently showing Autofill UI.
193 void HideAutofillUI(); 168 void HideAutofillUI();
194 169
195 void MaybeSendDynamicFormsSeen();
196
197 // Send |AutofillHostMsg_MaybeShowAutocheckoutBubble| to browser if needed.
198 void MaybeShowAutocheckoutBubble();
199
200 FormCache form_cache_; 170 FormCache form_cache_;
201 171
202 PasswordAutofillAgent* password_autofill_agent_; // WEAK reference. 172 PasswordAutofillAgent* password_autofill_agent_; // WEAK reference.
203 173
204 // The ID of the last request sent for form field Autofill. Used to ignore 174 // The ID of the last request sent for form field Autofill. Used to ignore
205 // out of date responses. 175 // out of date responses.
206 int autofill_query_id_; 176 int autofill_query_id_;
207 177
208 // The element corresponding to the last request sent for form field Autofill. 178 // The element corresponding to the last request sent for form field Autofill.
209 WebKit::WebInputElement element_; 179 WebKit::WebInputElement element_;
210 180
211 // The form element currently requesting an interactive autocomplete. 181 // The form element currently requesting an interactive autocomplete.
212 WebKit::WebFormElement in_flight_request_form_; 182 WebKit::WebFormElement in_flight_request_form_;
213 183
214 // All the form elements seen in the top frame. 184 // All the form elements seen in the top frame.
215 std::vector<WebKit::WebFormElement> form_elements_; 185 std::vector<WebKit::WebFormElement> form_elements_;
216 186
217 // The action to take when receiving Autofill data from the AutofillManager. 187 // The action to take when receiving Autofill data from the AutofillManager.
218 AutofillAction autofill_action_; 188 AutofillAction autofill_action_;
219 189
220 // Pointer to the current topmost frame. Used in autocheckout flows so
221 // elements can be clicked.
222 WebKit::WebFrame* topmost_frame_;
223
224 // Pointer to the WebView. Used to access page scale factor. 190 // Pointer to the WebView. Used to access page scale factor.
225 WebKit::WebView* web_view_; 191 WebKit::WebView* web_view_;
226 192
227 // Should we display a warning if autofill is disabled? 193 // Should we display a warning if autofill is disabled?
228 bool display_warning_if_disabled_; 194 bool display_warning_if_disabled_;
229 195
230 // Was the query node autofilled prior to previewing the form? 196 // Was the query node autofilled prior to previewing the form?
231 bool was_query_node_autofilled_; 197 bool was_query_node_autofilled_;
232 198
233 // Have we already shown Autofill suggestions for the field the user is 199 // Have we already shown Autofill suggestions for the field the user is
234 // currently editing? Used to keep track of state for metrics logging. 200 // currently editing? Used to keep track of state for metrics logging.
235 bool has_shown_autofill_popup_for_current_edit_; 201 bool has_shown_autofill_popup_for_current_edit_;
236 202
237 // If true we just set the node text so we shouldn't show the popup. 203 // If true we just set the node text so we shouldn't show the popup.
238 bool did_set_node_text_; 204 bool did_set_node_text_;
239 205
240 // Watchdog timer for clicking in Autocheckout flows.
241 base::OneShotTimer<AutofillAgent> click_timer_;
242
243 // Used to signal that we need to watch for loading failures in an
244 // Autocheckout flow.
245 bool autocheckout_click_in_progress_;
246
247 // Whether or not |topmost_frame_| is whitelisted for Autocheckout.
248 bool is_autocheckout_supported_;
249
250 // Whether or not new forms/fields have been dynamically added 206 // Whether or not new forms/fields have been dynamically added
251 // since the last loaded forms were sent to the browser process. 207 // since the last loaded forms were sent to the browser process.
252 bool has_new_forms_for_browser_; 208 bool has_new_forms_for_browser_;
253 209
254 // Whether or not to ignore text changes. Useful for when we're committing 210 // Whether or not to ignore text changes. Useful for when we're committing
255 // a composition when we are defocusing the WebView and we don't want to 211 // a composition when we are defocusing the WebView and we don't want to
256 // trigger an autofill popup to show. 212 // trigger an autofill popup to show.
257 bool ignore_text_changes_; 213 bool ignore_text_changes_;
258 214
259 // Timestamp of first time forms are seen. 215 // Timestamp of first time forms are seen.
260 base::TimeTicks forms_seen_timestamp_; 216 base::TimeTicks forms_seen_timestamp_;
261 217
262 base::WeakPtrFactory<AutofillAgent> weak_ptr_factory_; 218 base::WeakPtrFactory<AutofillAgent> weak_ptr_factory_;
263 219
264 friend class PasswordAutofillAgentTest; 220 friend class PasswordAutofillAgentTest;
265 FRIEND_TEST_ALL_PREFIXES(ChromeRenderViewTest, FillFormElement); 221 FRIEND_TEST_ALL_PREFIXES(ChromeRenderViewTest, FillFormElement);
266 FRIEND_TEST_ALL_PREFIXES(ChromeRenderViewTest, SendForms); 222 FRIEND_TEST_ALL_PREFIXES(ChromeRenderViewTest, SendForms);
267 FRIEND_TEST_ALL_PREFIXES(ChromeRenderViewTest, SendDynamicForms); 223 FRIEND_TEST_ALL_PREFIXES(ChromeRenderViewTest, SendDynamicForms);
268 FRIEND_TEST_ALL_PREFIXES(ChromeRenderViewTest, ShowAutofillWarning); 224 FRIEND_TEST_ALL_PREFIXES(ChromeRenderViewTest, ShowAutofillWarning);
269 FRIEND_TEST_ALL_PREFIXES(PasswordAutofillAgentTest, WaitUsername); 225 FRIEND_TEST_ALL_PREFIXES(PasswordAutofillAgentTest, WaitUsername);
270 FRIEND_TEST_ALL_PREFIXES(PasswordAutofillAgentTest, SuggestionAccept); 226 FRIEND_TEST_ALL_PREFIXES(PasswordAutofillAgentTest, SuggestionAccept);
271 FRIEND_TEST_ALL_PREFIXES(PasswordAutofillAgentTest, SuggestionSelect); 227 FRIEND_TEST_ALL_PREFIXES(PasswordAutofillAgentTest, SuggestionSelect);
272 228
273 DISALLOW_COPY_AND_ASSIGN(AutofillAgent); 229 DISALLOW_COPY_AND_ASSIGN(AutofillAgent);
274 }; 230 };
275 231
276 } // namespace autofill 232 } // namespace autofill
277 233
278 #endif // COMPONENTS_AUTOFILL_CONTENT_RENDERER_AUTOFILL_AGENT_H_ 234 #endif // COMPONENTS_AUTOFILL_CONTENT_RENDERER_AUTOFILL_AGENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698