| 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|. If |autofill_disabled| is true, the query is guaranteed to return | 35 // |node|. |
| 36 // no results, but might return a descriptive warning message. | 36 void QueryAutoFillSuggestions(const WebKit::WebNode& node); |
| 37 void QueryAutoFillSuggestions(const WebKit::WebNode& node, | |
| 38 bool autofill_disabled); | |
| 39 | 37 |
| 40 // Removes the Autocomplete suggestion |value| for the field named |name|. | 38 // Removes the Autocomplete suggestion |value| for the field named |name|. |
| 41 void RemoveAutocompleteSuggestion(const WebKit::WebString& name, | 39 void RemoveAutocompleteSuggestion(const WebKit::WebString& name, |
| 42 const WebKit::WebString& value); | 40 const WebKit::WebString& value); |
| 43 | 41 |
| 44 // Called when we have received AutoFill suggestions from the browser. | 42 // Called when we have received AutoFill suggestions from the browser. |
| 45 void SuggestionsReceived(int query_id, | 43 void SuggestionsReceived(int query_id, |
| 46 const std::vector<string16>& values, | 44 const std::vector<string16>& values, |
| 47 const std::vector<string16>& labels, | 45 const std::vector<string16>& labels, |
| 48 const std::vector<string16>& icons, | 46 const std::vector<string16>& icons, |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 bool was_focused, | 100 bool was_focused, |
| 103 bool is_focused); | 101 bool is_focused); |
| 104 | 102 |
| 105 // Shows the autocomplete suggestions for |element|. | 103 // Shows the autocomplete suggestions for |element|. |
| 106 // This call is asynchronous and may or may not lead to the showing of a | 104 // This call is asynchronous and may or may not lead to the showing of a |
| 107 // suggestion popup (no popup is shown if there are no available suggestions). | 105 // suggestion popup (no popup is shown if there are no available suggestions). |
| 108 // |autofill_on_empty_values| specifies whether suggestions should be shown | 106 // |autofill_on_empty_values| specifies whether suggestions should be shown |
| 109 // when |element| contains no text. | 107 // when |element| contains no text. |
| 110 // |requires_caret_at_end| specifies whether suggestions should be shown when | 108 // |requires_caret_at_end| specifies whether suggestions should be shown when |
| 111 // the caret is not after the last character in |element|. | 109 // 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). | |
| 116 void ShowSuggestions(const WebKit::WebInputElement& element, | 110 void ShowSuggestions(const WebKit::WebInputElement& element, |
| 117 bool autofill_on_empty_values, | 111 bool autofill_on_empty_values, |
| 118 bool requires_caret_at_end, | 112 bool requires_caret_at_end); |
| 119 bool display_warning_if_disabled); | |
| 120 | 113 |
| 121 // Queries the AutoFillManager for form data for the form containing |node|. | 114 // Queries the AutoFillManager for form data for the form containing |node|. |
| 122 // |value| is the current text in the field, and |unique_id| is the selected | 115 // |value| is the current text in the field, and |unique_id| is the selected |
| 123 // profile's unique ID. |action| specifies whether to Fill or Preview the | 116 // profile's unique ID. |action| specifies whether to Fill or Preview the |
| 124 // values returned from the AutoFillManager. | 117 // values returned from the AutoFillManager. |
| 125 void QueryAutoFillFormData(const WebKit::WebNode& node, | 118 void QueryAutoFillFormData(const WebKit::WebNode& node, |
| 126 int unique_id, | 119 int unique_id, |
| 127 AutoFillAction action); | 120 AutoFillAction action); |
| 128 | 121 |
| 129 // Scans the given frame for forms and sends them up to the browser. | 122 // Scans the given frame for forms and sends them up to the browser. |
| 130 void SendForms(WebKit::WebFrame* frame); | 123 void SendForms(WebKit::WebFrame* frame); |
| 131 | 124 |
| 132 // Weak reference. | 125 // Weak reference. |
| 133 RenderView* render_view_; | 126 RenderView* render_view_; |
| 134 | 127 |
| 135 FormManager form_manager_; | 128 FormManager form_manager_; |
| 136 | 129 |
| 137 // The ID of the last request sent for form field AutoFill. Used to ignore | 130 // The ID of the last request sent for form field AutoFill. Used to ignore |
| 138 // out of date responses. | 131 // out of date responses. |
| 139 int autofill_query_id_; | 132 int autofill_query_id_; |
| 140 | 133 |
| 141 // The node corresponding to the last request sent for form field AutoFill. | 134 // The node corresponding to the last request sent for form field AutoFill. |
| 142 WebKit::WebNode autofill_query_node_; | 135 WebKit::WebNode autofill_query_node_; |
| 143 | 136 |
| 144 // Whether autofill is disabled for |autofill_query_node_| by the website. | |
| 145 bool autofill_disabled_; | |
| 146 | |
| 147 // The action to take when receiving AutoFill data from the AutoFillManager. | 137 // The action to take when receiving AutoFill data from the AutoFillManager. |
| 148 AutoFillAction autofill_action_; | 138 AutoFillAction autofill_action_; |
| 149 | 139 |
| 150 // The menu index of the "Clear" menu item. | 140 // The menu index of the "Clear" menu item. |
| 151 int suggestions_clear_index_; | 141 int suggestions_clear_index_; |
| 152 | 142 |
| 153 // The menu index of the "AutoFill options..." menu item. | 143 // The menu index of the "AutoFill options..." menu item. |
| 154 int suggestions_options_index_; | 144 int suggestions_options_index_; |
| 155 | 145 |
| 156 DISALLOW_COPY_AND_ASSIGN(AutoFillHelper); | 146 DISALLOW_COPY_AND_ASSIGN(AutoFillHelper); |
| 157 }; | 147 }; |
| 158 | 148 |
| 159 #endif // CHROME_RENDERER_AUTOFILL_HELPER_H_ | 149 #endif // CHROME_RENDERER_AUTOFILL_HELPER_H_ |
| OLD | NEW |