| 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" |
| 23 | 24 |
| 24 namespace blink { | 25 namespace blink { |
| 25 class WebNode; | 26 class WebNode; |
| 26 class WebView; | 27 class WebView; |
| 27 } | 28 } |
| 28 | 29 |
| 29 namespace autofill { | 30 namespace autofill { |
| 30 | 31 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 61 virtual void DidFinishDocumentLoad(blink::WebFrame* frame) OVERRIDE; | 62 virtual void DidFinishDocumentLoad(blink::WebFrame* frame) OVERRIDE; |
| 62 virtual void FrameDetached(blink::WebFrame* frame) OVERRIDE; | 63 virtual void FrameDetached(blink::WebFrame* frame) OVERRIDE; |
| 63 virtual void WillSubmitForm(blink::WebFrame* frame, | 64 virtual void WillSubmitForm(blink::WebFrame* frame, |
| 64 const blink::WebFormElement& form) OVERRIDE; | 65 const blink::WebFormElement& form) OVERRIDE; |
| 65 virtual void ZoomLevelChanged() OVERRIDE; | 66 virtual void ZoomLevelChanged() OVERRIDE; |
| 66 virtual void DidChangeScrollOffset(blink::WebFrame* frame) OVERRIDE; | 67 virtual void DidChangeScrollOffset(blink::WebFrame* frame) OVERRIDE; |
| 67 virtual void FocusedNodeChanged(const blink::WebNode& node) OVERRIDE; | 68 virtual void FocusedNodeChanged(const blink::WebNode& node) OVERRIDE; |
| 68 virtual void OrientationChangeEvent(int orientation) OVERRIDE; | 69 virtual void OrientationChangeEvent(int orientation) OVERRIDE; |
| 69 | 70 |
| 70 // PageClickListener: | 71 // PageClickListener: |
| 71 virtual void InputElementClicked(const blink::WebInputElement& element, | 72 virtual void FormControlElementClicked( |
| 72 bool was_focused, | 73 const blink::WebFormControlElement& element, |
| 73 bool is_focused) OVERRIDE; | 74 bool was_focused) OVERRIDE; |
| 74 virtual void InputElementLostFocus() OVERRIDE; | 75 virtual void FormControlElementLostFocus() OVERRIDE; |
| 75 | 76 |
| 76 // blink::WebAutofillClient: | 77 // blink::WebAutofillClient: |
| 77 virtual void textFieldDidEndEditing( | 78 virtual void textFieldDidEndEditing( |
| 78 const blink::WebInputElement& element) OVERRIDE; | 79 const blink::WebInputElement& element) OVERRIDE; |
| 80 // TODO(ziran.sun): To be removed once next Blink roll is done |
| 79 virtual void textFieldDidChange( | 81 virtual void textFieldDidChange( |
| 80 const blink::WebInputElement& element) OVERRIDE; | 82 const blink::WebInputElement& element); |
| 83 // TODO(ziran.sun): OVERRIDE this function once next Blink roll is done |
| 84 virtual void textFieldDidChange( |
| 85 const blink::WebFormControlElement& element); |
| 81 virtual void textFieldDidReceiveKeyDown( | 86 virtual void textFieldDidReceiveKeyDown( |
| 82 const blink::WebInputElement& element, | 87 const blink::WebInputElement& element, |
| 83 const blink::WebKeyboardEvent& event) OVERRIDE; | 88 const blink::WebKeyboardEvent& event) OVERRIDE; |
| 84 virtual void didRequestAutocomplete( | 89 virtual void didRequestAutocomplete( |
| 85 blink::WebFrame* frame, | 90 blink::WebFrame* frame, |
| 86 const blink::WebFormElement& form) OVERRIDE; | 91 const blink::WebFormElement& form) OVERRIDE; |
| 87 virtual void setIgnoreTextChanges(bool ignore) OVERRIDE; | 92 virtual void setIgnoreTextChanges(bool ignore) OVERRIDE; |
| 88 virtual void didAssociateFormControls( | 93 virtual void didAssociateFormControls( |
| 89 const blink::WebVector<blink::WebNode>& nodes) OVERRIDE; | 94 const blink::WebVector<blink::WebNode>& nodes) OVERRIDE; |
| 90 virtual void openTextDataListChooser(const blink::WebInputElement& element); | 95 virtual void openTextDataListChooser(const blink::WebInputElement& element); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 106 void OnRequestAutocompleteResult( | 111 void OnRequestAutocompleteResult( |
| 107 blink::WebFormElement::AutocompleteResult result, | 112 blink::WebFormElement::AutocompleteResult result, |
| 108 const FormData& form_data); | 113 const FormData& form_data); |
| 109 | 114 |
| 110 // Called when an autocomplete request succeeds or fails with the |result|. | 115 // Called when an autocomplete request succeeds or fails with the |result|. |
| 111 void FinishAutocompleteRequest( | 116 void FinishAutocompleteRequest( |
| 112 blink::WebFormElement::AutocompleteResult result); | 117 blink::WebFormElement::AutocompleteResult result); |
| 113 | 118 |
| 114 // Called in a posted task by textFieldDidChange() to work-around a WebKit bug | 119 // Called in a posted task by textFieldDidChange() to work-around a WebKit bug |
| 115 // http://bugs.webkit.org/show_bug.cgi?id=16976 | 120 // http://bugs.webkit.org/show_bug.cgi?id=16976 |
| 116 void TextFieldDidChangeImpl(const blink::WebInputElement& element); | 121 void TextFieldDidChangeImpl(const blink::WebFormControlElement& element); |
| 117 | 122 |
| 118 // Shows the autofill suggestions for |element|. | 123 // Shows the autofill suggestions for |element|. |
| 119 // This call is asynchronous and may or may not lead to the showing of a | 124 // This call is asynchronous and may or may not lead to the showing of a |
| 120 // suggestion popup (no popup is shown if there are no available suggestions). | 125 // suggestion popup (no popup is shown if there are no available suggestions). |
| 121 // |autofill_on_empty_values| specifies whether suggestions should be shown | 126 // |autofill_on_empty_values| specifies whether suggestions should be shown |
| 122 // when |element| contains no text. | 127 // when |element| contains no text. |
| 123 // |requires_caret_at_end| specifies whether suggestions should be shown when | 128 // |requires_caret_at_end| specifies whether suggestions should be shown when |
| 124 // the caret is not after the last character in |element|. | 129 // the caret is not after the last character in |element|. |
| 125 // |display_warning_if_disabled| specifies whether a warning should be | 130 // |display_warning_if_disabled| specifies whether a warning should be |
| 126 // displayed to the user if Autofill has suggestions available, but cannot | 131 // displayed to the user if Autofill has suggestions available, but cannot |
| 127 // fill them because it is disabled (e.g. when trying to fill a credit card | 132 // fill them because it is disabled (e.g. when trying to fill a credit card |
| 128 // form on a non-secure website). | 133 // form on a non-secure website). |
| 129 // |datalist_only| specifies whether all of <datalist> suggestions and no | 134 // |datalist_only| specifies whether all of <datalist> suggestions and no |
| 130 // autofill suggestions are shown. |autofill_on_empty_values| and | 135 // autofill suggestions are shown. |autofill_on_empty_values| and |
| 131 // |requires_caret_at_end| are ignored if |datalist_only| is true. | 136 // |requires_caret_at_end| are ignored if |datalist_only| is true. |
| 132 void ShowSuggestions(const blink::WebInputElement& element, | 137 void ShowSuggestions(const blink::WebFormControlElement& element, |
| 133 bool autofill_on_empty_values, | 138 bool autofill_on_empty_values, |
| 134 bool requires_caret_at_end, | 139 bool requires_caret_at_end, |
| 135 bool display_warning_if_disabled, | 140 bool display_warning_if_disabled, |
| 136 bool datalist_only); | 141 bool datalist_only); |
| 137 | 142 |
| 138 // Queries the browser for Autocomplete and Autofill suggestions for the given | 143 // Queries the browser for Autocomplete and Autofill suggestions for the given |
| 139 // |element|. | 144 // |element|. |
| 140 void QueryAutofillSuggestions(const blink::WebInputElement& element, | 145 void QueryAutofillSuggestions(const blink::WebFormControlElement& element, |
| 141 bool display_warning_if_disabled, | 146 bool display_warning_if_disabled, |
| 142 bool datalist_only); | 147 bool datalist_only); |
| 143 | 148 |
| 144 // Sets the element value to reflect the selected |suggested_value|. | 149 // Sets the element value to reflect the selected |suggested_value|. |
| 145 void AcceptDataListSuggestion(const base::string16& suggested_value); | 150 void AcceptDataListSuggestion(const base::string16& suggested_value); |
| 146 | 151 |
| 147 // Fills |form| and |field| with the FormData and FormField corresponding to | 152 // Fills |form| and |field| with the FormData and FormField corresponding to |
| 148 // |node|. Returns true if the data was found; and false otherwise. | 153 // |node|. Returns true if the data was found; and false otherwise. |
| 149 bool FindFormAndFieldForNode( | 154 bool FindFormAndFieldForNode( |
| 150 const blink::WebNode& node, | 155 const blink::WebNode& node, |
| (...skipping 16 matching lines...) Expand all Loading... |
| 167 FormCache form_cache_; | 172 FormCache form_cache_; |
| 168 | 173 |
| 169 PasswordAutofillAgent* password_autofill_agent_; // Weak reference. | 174 PasswordAutofillAgent* password_autofill_agent_; // Weak reference. |
| 170 PasswordGenerationAgent* password_generation_agent_; // Weak reference. | 175 PasswordGenerationAgent* password_generation_agent_; // Weak reference. |
| 171 | 176 |
| 172 // The ID of the last request sent for form field Autofill. Used to ignore | 177 // The ID of the last request sent for form field Autofill. Used to ignore |
| 173 // out of date responses. | 178 // out of date responses. |
| 174 int autofill_query_id_; | 179 int autofill_query_id_; |
| 175 | 180 |
| 176 // The element corresponding to the last request sent for form field Autofill. | 181 // The element corresponding to the last request sent for form field Autofill. |
| 177 blink::WebInputElement element_; | 182 blink::WebFormControlElement element_; |
| 178 | 183 |
| 179 // The form element currently requesting an interactive autocomplete. | 184 // The form element currently requesting an interactive autocomplete. |
| 180 blink::WebFormElement in_flight_request_form_; | 185 blink::WebFormElement in_flight_request_form_; |
| 181 | 186 |
| 182 // All the form elements seen in the top frame. | 187 // All the form elements seen in the top frame. |
| 183 std::vector<blink::WebFormElement> form_elements_; | 188 std::vector<blink::WebFormElement> form_elements_; |
| 184 | 189 |
| 185 // Pointer to the WebView. Used to access page scale factor. | 190 // Pointer to the WebView. Used to access page scale factor. |
| 186 blink::WebView* web_view_; | 191 blink::WebView* web_view_; |
| 187 | 192 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 FRIEND_TEST_ALL_PREFIXES( | 232 FRIEND_TEST_ALL_PREFIXES( |
| 228 PasswordAutofillAgentTest, | 233 PasswordAutofillAgentTest, |
| 229 PasswordAutofillTriggersOnChangeEventsWaitForUsername); | 234 PasswordAutofillTriggersOnChangeEventsWaitForUsername); |
| 230 | 235 |
| 231 DISALLOW_COPY_AND_ASSIGN(AutofillAgent); | 236 DISALLOW_COPY_AND_ASSIGN(AutofillAgent); |
| 232 }; | 237 }; |
| 233 | 238 |
| 234 } // namespace autofill | 239 } // namespace autofill |
| 235 | 240 |
| 236 #endif // COMPONENTS_AUTOFILL_CONTENT_RENDERER_AUTOFILL_AGENT_H_ | 241 #endif // COMPONENTS_AUTOFILL_CONTENT_RENDERER_AUTOFILL_AGENT_H_ |
| OLD | NEW |