OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 CHROME_RENDERER_AUTOFILL_HELPER_H_ | 5 #ifndef CHROME_RENDERER_AUTOFILL_HELPER_H_ |
6 #define CHROME_RENDERER_AUTOFILL_HELPER_H_ | 6 #define CHROME_RENDERER_AUTOFILL_HELPER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 14 matching lines...) Expand all Loading... |
25 // This code was originally part of RenderView. | 25 // This code was originally part of RenderView. |
26 // Note that AutoFill encompasses: | 26 // Note that AutoFill encompasses: |
27 // - single text field suggestions, that we usually refer to as Autocomplete | 27 // - single text field suggestions, that we usually refer to as Autocomplete |
28 // - entire form fill based on one field entry, referred to as form AutoFill. | 28 // - entire form fill based on one field entry, referred to as form AutoFill. |
29 | 29 |
30 class AutoFillHelper : public PageClickListener { | 30 class AutoFillHelper : public PageClickListener { |
31 public: | 31 public: |
32 explicit AutoFillHelper(RenderView* render_view); | 32 explicit AutoFillHelper(RenderView* render_view); |
33 | 33 |
34 // Queries the browser for Autocomplete and AutoFill suggestions for the given | 34 // Queries the browser for Autocomplete and AutoFill suggestions for the given |
35 // |node|. | 35 // |node|. If |autofill_disabled| is true, the query is guaranteed to return |
36 void QueryAutoFillSuggestions(const WebKit::WebNode& node); | 36 // no results, but might return a descriptive warning message. |
| 37 void QueryAutoFillSuggestions(const WebKit::WebNode& node, |
| 38 bool autofill_disabled); |
37 | 39 |
38 // Removes the Autocomplete suggestion |value| for the field named |name|. | 40 // Removes the Autocomplete suggestion |value| for the field named |name|. |
39 void RemoveAutocompleteSuggestion(const WebKit::WebString& name, | 41 void RemoveAutocompleteSuggestion(const WebKit::WebString& name, |
40 const WebKit::WebString& value); | 42 const WebKit::WebString& value); |
41 | 43 |
42 // Called when we have received AutoFill suggestions from the browser. | 44 // Called when we have received AutoFill suggestions from the browser. |
43 void SuggestionsReceived(int query_id, | 45 void SuggestionsReceived(int query_id, |
44 const std::vector<string16>& values, | 46 const std::vector<string16>& values, |
45 const std::vector<string16>& labels, | 47 const std::vector<string16>& labels, |
46 const std::vector<string16>& icons, | 48 const std::vector<string16>& icons, |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 bool was_focused, | 102 bool was_focused, |
101 bool is_focused); | 103 bool is_focused); |
102 | 104 |
103 // Shows the autocomplete suggestions for |element|. | 105 // Shows the autocomplete suggestions for |element|. |
104 // This call is asynchronous and may or may not lead to the showing of a | 106 // This call is asynchronous and may or may not lead to the showing of a |
105 // suggestion popup (no popup is shown if there are no available suggestions). | 107 // suggestion popup (no popup is shown if there are no available suggestions). |
106 // |autofill_on_empty_values| specifies whether suggestions should be shown | 108 // |autofill_on_empty_values| specifies whether suggestions should be shown |
107 // when |element| contains no text. | 109 // when |element| contains no text. |
108 // |requires_caret_at_end| specifies whether suggestions should be shown when | 110 // |requires_caret_at_end| specifies whether suggestions should be shown when |
109 // the caret is not after the last character in |element|. | 111 // the caret is not after the last character in |element|. |
| 112 // |display_warning_if_disabled| specifies whether a warning should be |
| 113 // displayed to the user if AutoFill has suggestions available, but cannot |
| 114 // fill them because it is disabled (e.g. when trying to fill a credit card |
| 115 // form on a non-secure website). |
110 void ShowSuggestions(const WebKit::WebInputElement& element, | 116 void ShowSuggestions(const WebKit::WebInputElement& element, |
111 bool autofill_on_empty_values, | 117 bool autofill_on_empty_values, |
112 bool requires_caret_at_end); | 118 bool requires_caret_at_end, |
| 119 bool display_warning_if_disabled); |
113 | 120 |
114 // Queries the AutoFillManager for form data for the form containing |node|. | 121 // Queries the AutoFillManager for form data for the form containing |node|. |
115 // |value| is the current text in the field, and |unique_id| is the selected | 122 // |value| is the current text in the field, and |unique_id| is the selected |
116 // profile's unique ID. |action| specifies whether to Fill or Preview the | 123 // profile's unique ID. |action| specifies whether to Fill or Preview the |
117 // values returned from the AutoFillManager. | 124 // values returned from the AutoFillManager. |
118 void QueryAutoFillFormData(const WebKit::WebNode& node, | 125 void QueryAutoFillFormData(const WebKit::WebNode& node, |
119 int unique_id, | 126 int unique_id, |
120 AutoFillAction action); | 127 AutoFillAction action); |
121 | 128 |
122 // Scans the given frame for forms and sends them up to the browser. | 129 // Scans the given frame for forms and sends them up to the browser. |
123 void SendForms(WebKit::WebFrame* frame); | 130 void SendForms(WebKit::WebFrame* frame); |
124 | 131 |
125 // Weak reference. | 132 // Weak reference. |
126 RenderView* render_view_; | 133 RenderView* render_view_; |
127 | 134 |
128 FormManager form_manager_; | 135 FormManager form_manager_; |
129 | 136 |
130 // The ID of the last request sent for form field AutoFill. Used to ignore | 137 // The ID of the last request sent for form field AutoFill. Used to ignore |
131 // out of date responses. | 138 // out of date responses. |
132 int autofill_query_id_; | 139 int autofill_query_id_; |
133 | 140 |
134 // The node corresponding to the last request sent for form field AutoFill. | 141 // The node corresponding to the last request sent for form field AutoFill. |
135 WebKit::WebNode autofill_query_node_; | 142 WebKit::WebNode autofill_query_node_; |
136 | 143 |
| 144 // Whether autofill is disabled for |autofill_query_node_| by the website. |
| 145 bool autofill_disabled_; |
| 146 |
137 // The action to take when receiving AutoFill data from the AutoFillManager. | 147 // The action to take when receiving AutoFill data from the AutoFillManager. |
138 AutoFillAction autofill_action_; | 148 AutoFillAction autofill_action_; |
139 | 149 |
140 // The menu index of the "Clear" menu item. | 150 // The menu index of the "Clear" menu item. |
141 int suggestions_clear_index_; | 151 int suggestions_clear_index_; |
142 | 152 |
143 // The menu index of the "AutoFill options..." menu item. | 153 // The menu index of the "AutoFill options..." menu item. |
144 int suggestions_options_index_; | 154 int suggestions_options_index_; |
145 | 155 |
146 DISALLOW_COPY_AND_ASSIGN(AutoFillHelper); | 156 DISALLOW_COPY_AND_ASSIGN(AutoFillHelper); |
147 }; | 157 }; |
148 | 158 |
149 #endif // CHROME_RENDERER_AUTOFILL_HELPER_H_ | 159 #endif // CHROME_RENDERER_AUTOFILL_HELPER_H_ |
OLD | NEW |