Chromium Code Reviews| 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_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/forms_seen_state.h" | 18 #include "components/autofill/core/common/forms_seen_state.h" |
| 19 #include "content/public/renderer/render_view_observer.h" | 19 #include "content/public/renderer/render_view_observer.h" |
| 20 #include "third_party/WebKit/public/web/WebAutofillClient.h" | 20 #include "third_party/WebKit/public/web/WebAutofillClient.h" |
| 21 #include "third_party/WebKit/public/web/WebFormControlElement.h" | |
| 21 #include "third_party/WebKit/public/web/WebFormElement.h" | 22 #include "third_party/WebKit/public/web/WebFormElement.h" |
| 22 #include "third_party/WebKit/public/web/WebInputElement.h" | 23 #include "third_party/WebKit/public/web/WebInputElement.h" |
| 24 #include "third_party/WebKit/public/web/WebTextAreaElement.h" | |
| 23 | 25 |
| 24 namespace blink { | 26 namespace blink { |
| 25 class WebNode; | 27 class WebNode; |
| 26 class WebView; | 28 class WebView; |
| 27 } | 29 } |
| 28 | 30 |
| 29 namespace autofill { | 31 namespace autofill { |
| 30 | 32 |
| 31 struct FormData; | 33 struct FormData; |
| 32 struct FormFieldData; | 34 struct FormFieldData; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 71 const blink::WebFormElement& form) OVERRIDE; | 73 const blink::WebFormElement& form) OVERRIDE; |
| 72 virtual void ZoomLevelChanged() OVERRIDE; | 74 virtual void ZoomLevelChanged() OVERRIDE; |
| 73 virtual void DidChangeScrollOffset(blink::WebFrame* frame) OVERRIDE; | 75 virtual void DidChangeScrollOffset(blink::WebFrame* frame) OVERRIDE; |
| 74 virtual void FocusedNodeChanged(const blink::WebNode& node) OVERRIDE; | 76 virtual void FocusedNodeChanged(const blink::WebNode& node) OVERRIDE; |
| 75 virtual void OrientationChangeEvent(int orientation) OVERRIDE; | 77 virtual void OrientationChangeEvent(int orientation) OVERRIDE; |
| 76 | 78 |
| 77 // PageClickListener: | 79 // PageClickListener: |
| 78 virtual void InputElementClicked(const blink::WebInputElement& element, | 80 virtual void InputElementClicked(const blink::WebInputElement& element, |
| 79 bool was_focused, | 81 bool was_focused, |
| 80 bool is_focused) OVERRIDE; | 82 bool is_focused) OVERRIDE; |
| 81 virtual void InputElementLostFocus() OVERRIDE; | 83 virtual void FormControlElementLostFocus() OVERRIDE; |
| 84 virtual void TextAreaElementClicked( | |
| 85 const blink::WebTextAreaElement& element, | |
| 86 bool was_focused, | |
| 87 bool is_focused) OVERRIDE; | |
| 82 | 88 |
| 83 // blink::WebAutofillClient: | 89 // blink::WebAutofillClient: |
| 84 virtual void textFieldDidEndEditing( | 90 virtual void textFieldDidEndEditing( |
| 85 const blink::WebInputElement& element) OVERRIDE; | 91 const blink::WebInputElement& element) OVERRIDE; |
| 92 // To be removed once next Blink roll is done | |
|
Ilya Sherman
2014/02/14 02:44:40
Please annotate with a TODO.
ziran.sun
2014/02/17 15:43:45
Done.
| |
| 86 virtual void textFieldDidChange( | 93 virtual void textFieldDidChange( |
| 87 const blink::WebInputElement& element) OVERRIDE; | 94 const blink::WebInputElement& element); |
| 95 // OVERRIDE this function once next Blink roll is done | |
|
Ilya Sherman
2014/02/14 02:44:40
Please annotate with a TODO.
ziran.sun
2014/02/17 15:43:45
Done.
| |
| 96 virtual void textFieldDidChange( | |
| 97 const blink::WebFormControlElement& element); | |
| 88 virtual void textFieldDidReceiveKeyDown( | 98 virtual void textFieldDidReceiveKeyDown( |
| 89 const blink::WebInputElement& element, | 99 const blink::WebInputElement& element, |
| 90 const blink::WebKeyboardEvent& event) OVERRIDE; | 100 const blink::WebKeyboardEvent& event) OVERRIDE; |
| 91 virtual void didRequestAutocomplete( | 101 virtual void didRequestAutocomplete( |
| 92 blink::WebFrame* frame, | 102 blink::WebFrame* frame, |
| 93 const blink::WebFormElement& form) OVERRIDE; | 103 const blink::WebFormElement& form) OVERRIDE; |
| 94 virtual void setIgnoreTextChanges(bool ignore) OVERRIDE; | 104 virtual void setIgnoreTextChanges(bool ignore) OVERRIDE; |
| 95 virtual void didAssociateFormControls( | 105 virtual void didAssociateFormControls( |
| 96 const blink::WebVector<blink::WebNode>& nodes) OVERRIDE; | 106 const blink::WebVector<blink::WebNode>& nodes) OVERRIDE; |
| 97 virtual void openTextDataListChooser(const blink::WebInputElement& element); | 107 virtual void openTextDataListChooser(const blink::WebInputElement& element); |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 117 // Called when an autocomplete request succeeds or fails with the |result|. | 127 // Called when an autocomplete request succeeds or fails with the |result|. |
| 118 void FinishAutocompleteRequest( | 128 void FinishAutocompleteRequest( |
| 119 blink::WebFormElement::AutocompleteResult result); | 129 blink::WebFormElement::AutocompleteResult result); |
| 120 | 130 |
| 121 // Called when the page is actually shown in the browser, as opposed to simply | 131 // Called when the page is actually shown in the browser, as opposed to simply |
| 122 // being preloaded. | 132 // being preloaded. |
| 123 void OnPageShown(); | 133 void OnPageShown(); |
| 124 | 134 |
| 125 // Called in a posted task by textFieldDidChange() to work-around a WebKit bug | 135 // Called in a posted task by textFieldDidChange() to work-around a WebKit bug |
| 126 // http://bugs.webkit.org/show_bug.cgi?id=16976 | 136 // http://bugs.webkit.org/show_bug.cgi?id=16976 |
| 127 void TextFieldDidChangeImpl(const blink::WebInputElement& element); | 137 void TextFieldDidChangeImpl(const blink::WebFormControlElement& element); |
| 128 | 138 |
| 129 // Shows the autofill suggestions for |element|. | 139 // Shows the autofill suggestions for |element|. |
| 130 // This call is asynchronous and may or may not lead to the showing of a | 140 // This call is asynchronous and may or may not lead to the showing of a |
| 131 // suggestion popup (no popup is shown if there are no available suggestions). | 141 // suggestion popup (no popup is shown if there are no available suggestions). |
| 132 // |autofill_on_empty_values| specifies whether suggestions should be shown | 142 // |autofill_on_empty_values| specifies whether suggestions should be shown |
| 133 // when |element| contains no text. | 143 // when |element| contains no text. |
| 134 // |requires_caret_at_end| specifies whether suggestions should be shown when | 144 // |requires_caret_at_end| specifies whether suggestions should be shown when |
| 135 // the caret is not after the last character in |element|. | 145 // the caret is not after the last character in |element|. |
| 136 // |display_warning_if_disabled| specifies whether a warning should be | 146 // |display_warning_if_disabled| specifies whether a warning should be |
| 137 // displayed to the user if Autofill has suggestions available, but cannot | 147 // displayed to the user if Autofill has suggestions available, but cannot |
| 138 // fill them because it is disabled (e.g. when trying to fill a credit card | 148 // fill them because it is disabled (e.g. when trying to fill a credit card |
| 139 // form on a non-secure website). | 149 // form on a non-secure website). |
| 140 // |datalist_only| specifies whether all of <datalist> suggestions and no | 150 // |datalist_only| specifies whether all of <datalist> suggestions and no |
| 141 // autofill suggestions are shown. |autofill_on_empty_values| and | 151 // autofill suggestions are shown. |autofill_on_empty_values| and |
| 142 // |requires_caret_at_end| are ignored if |datalist_only| is true. | 152 // |requires_caret_at_end| are ignored if |datalist_only| is true. |
| 143 void ShowSuggestions(const blink::WebInputElement& element, | 153 void ShowSuggestions(const blink::WebFormControlElement& element, |
| 144 bool autofill_on_empty_values, | 154 bool autofill_on_empty_values, |
| 145 bool requires_caret_at_end, | 155 bool requires_caret_at_end, |
| 146 bool display_warning_if_disabled, | 156 bool display_warning_if_disabled, |
| 147 bool datalist_only); | 157 bool datalist_only); |
| 148 | 158 |
| 149 // Queries the browser for Autocomplete and Autofill suggestions for the given | 159 // Queries the browser for Autocomplete and Autofill suggestions for the given |
| 150 // |element|. | 160 // |element|. |
| 151 void QueryAutofillSuggestions(const blink::WebInputElement& element, | 161 void QueryAutofillSuggestions(const blink::WebFormControlElement& element, |
| 152 bool display_warning_if_disabled, | 162 bool display_warning_if_disabled, |
| 153 bool datalist_only); | 163 bool datalist_only); |
| 154 | 164 |
| 155 // Sets the element value to reflect the selected |suggested_value|. | 165 // Sets the element value to reflect the selected |suggested_value|. |
| 156 void AcceptDataListSuggestion(const base::string16& suggested_value); | 166 void AcceptDataListSuggestion(const base::string16& suggested_value); |
| 157 | 167 |
| 158 // Queries the AutofillManager for form data for the form containing |node|. | 168 // Queries the AutofillManager for form data for the form containing |node|. |
| 159 // |value| is the current text in the field, and |unique_id| is the selected | 169 // |value| is the current text in the field, and |unique_id| is the selected |
| 160 // profile's unique ID. |action| specifies whether to Fill or Preview the | 170 // profile's unique ID. |action| specifies whether to Fill or Preview the |
| 161 // values returned from the AutofillManager. | 171 // values returned from the AutofillManager. |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 179 FormCache form_cache_; | 189 FormCache form_cache_; |
| 180 | 190 |
| 181 PasswordAutofillAgent* password_autofill_agent_; // Weak reference. | 191 PasswordAutofillAgent* password_autofill_agent_; // Weak reference. |
| 182 PasswordGenerationAgent* password_generation_agent_; // Weak reference. | 192 PasswordGenerationAgent* password_generation_agent_; // Weak reference. |
| 183 | 193 |
| 184 // The ID of the last request sent for form field Autofill. Used to ignore | 194 // The ID of the last request sent for form field Autofill. Used to ignore |
| 185 // out of date responses. | 195 // out of date responses. |
| 186 int autofill_query_id_; | 196 int autofill_query_id_; |
| 187 | 197 |
| 188 // The element corresponding to the last request sent for form field Autofill. | 198 // The element corresponding to the last request sent for form field Autofill. |
| 189 blink::WebInputElement element_; | 199 blink::WebFormControlElement element_; |
| 190 | 200 |
| 191 // The form element currently requesting an interactive autocomplete. | 201 // The form element currently requesting an interactive autocomplete. |
| 192 blink::WebFormElement in_flight_request_form_; | 202 blink::WebFormElement in_flight_request_form_; |
| 193 | 203 |
| 194 // All the form elements seen in the top frame. | 204 // All the form elements seen in the top frame. |
| 195 std::vector<blink::WebFormElement> form_elements_; | 205 std::vector<blink::WebFormElement> form_elements_; |
| 196 | 206 |
| 197 // The action to take when receiving Autofill data from the AutofillManager. | 207 // The action to take when receiving Autofill data from the AutofillManager. |
| 198 AutofillAction autofill_action_; | 208 AutofillAction autofill_action_; |
| 199 | 209 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 238 FRIEND_TEST_ALL_PREFIXES( | 248 FRIEND_TEST_ALL_PREFIXES( |
| 239 PasswordAutofillAgentTest, | 249 PasswordAutofillAgentTest, |
| 240 PasswordAutofillTriggersOnChangeEventsWaitForUsername); | 250 PasswordAutofillTriggersOnChangeEventsWaitForUsername); |
| 241 | 251 |
| 242 DISALLOW_COPY_AND_ASSIGN(AutofillAgent); | 252 DISALLOW_COPY_AND_ASSIGN(AutofillAgent); |
| 243 }; | 253 }; |
| 244 | 254 |
| 245 } // namespace autofill | 255 } // namespace autofill |
| 246 | 256 |
| 247 #endif // COMPONENTS_AUTOFILL_CONTENT_RENDERER_AUTOFILL_AGENT_H_ | 257 #endif // COMPONENTS_AUTOFILL_CONTENT_RENDERER_AUTOFILL_AGENT_H_ |
| OLD | NEW |