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" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 public: | 47 public: |
48 // PasswordAutofillAgent is guaranteed to outlive AutofillAgent. | 48 // PasswordAutofillAgent is guaranteed to outlive AutofillAgent. |
49 // PasswordGenerationAgent may be NULL. If it is not, then it is also | 49 // PasswordGenerationAgent may be NULL. If it is not, then it is also |
50 // guaranteed to outlive AutofillAgent. | 50 // guaranteed to outlive AutofillAgent. |
51 AutofillAgent(content::RenderView* render_view, | 51 AutofillAgent(content::RenderView* render_view, |
52 PasswordAutofillAgent* password_autofill_manager, | 52 PasswordAutofillAgent* password_autofill_manager, |
53 PasswordGenerationAgent* password_generation_agent); | 53 PasswordGenerationAgent* password_generation_agent); |
54 virtual ~AutofillAgent(); | 54 virtual ~AutofillAgent(); |
55 | 55 |
56 private: | 56 private: |
| 57 // Flags passed to ShowSuggestions. |
| 58 struct ShowSuggestionsOptions { |
| 59 // All fields are default initialized to false. |
| 60 ShowSuggestionsOptions(); |
| 61 |
| 62 // Specifies that suggestions should be shown when |element| contains no |
| 63 // text. |
| 64 bool autofill_on_empty_values; |
| 65 |
| 66 // Specifies that suggestions should be shown when the caret is not |
| 67 // after the last character in the element. |
| 68 bool requires_caret_at_end; |
| 69 |
| 70 // Specifies that a warning should be displayed to the user if Autofill has |
| 71 // suggestions available, but cannot fill them because it is disabled (e.g. |
| 72 // when trying to fill a credit card form on a non-secure website). |
| 73 bool display_warning_if_disabled; |
| 74 |
| 75 // Specifies that all of <datalist> suggestions and no autofill suggestions |
| 76 // are shown. |autofill_on_empty_values| and |requires_caret_at_end| are |
| 77 // ignored if |datalist_only| is true. |
| 78 bool datalist_only; |
| 79 |
| 80 // Specifies that all autofill suggestions should be shown and none should |
| 81 // be elided because of the current value of |element| (relevant for inline |
| 82 // autocomplete). |
| 83 bool show_full_suggestion_list; |
| 84 |
| 85 // Specifies that only show a suggestions box if |element| is part of a |
| 86 // password form, otherwise show no suggestions. |
| 87 bool show_password_suggestions_only; |
| 88 }; |
| 89 |
57 // content::RenderViewObserver: | 90 // content::RenderViewObserver: |
58 bool OnMessageReceived(const IPC::Message& message) override; | 91 bool OnMessageReceived(const IPC::Message& message) override; |
59 void DidFinishDocumentLoad(blink::WebLocalFrame* frame) override; | 92 void DidFinishDocumentLoad(blink::WebLocalFrame* frame) override; |
60 void DidCommitProvisionalLoad(blink::WebLocalFrame* frame, | 93 void DidCommitProvisionalLoad(blink::WebLocalFrame* frame, |
61 bool is_new_navigation) override; | 94 bool is_new_navigation) override; |
62 void FrameDetached(blink::WebFrame* frame) override; | 95 void FrameDetached(blink::WebFrame* frame) override; |
63 void FrameWillClose(blink::WebFrame* frame) override; | 96 void FrameWillClose(blink::WebFrame* frame) override; |
64 void WillSubmitForm(blink::WebLocalFrame* frame, | 97 void WillSubmitForm(blink::WebLocalFrame* frame, |
65 const blink::WebFormElement& form) override; | 98 const blink::WebFormElement& form) override; |
66 void DidChangeScrollOffset(blink::WebLocalFrame* frame) override; | 99 void DidChangeScrollOffset(blink::WebLocalFrame* frame) override; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 const FormData& form_data); | 146 const FormData& form_data); |
114 | 147 |
115 // Called when an autocomplete request succeeds or fails with the |result|. | 148 // Called when an autocomplete request succeeds or fails with the |result|. |
116 void FinishAutocompleteRequest( | 149 void FinishAutocompleteRequest( |
117 blink::WebFormElement::AutocompleteResult result); | 150 blink::WebFormElement::AutocompleteResult result); |
118 | 151 |
119 // Called in a posted task by textFieldDidChange() to work-around a WebKit bug | 152 // Called in a posted task by textFieldDidChange() to work-around a WebKit bug |
120 // http://bugs.webkit.org/show_bug.cgi?id=16976 | 153 // http://bugs.webkit.org/show_bug.cgi?id=16976 |
121 void TextFieldDidChangeImpl(const blink::WebFormControlElement& element); | 154 void TextFieldDidChangeImpl(const blink::WebFormControlElement& element); |
122 | 155 |
123 // Shows the autofill suggestions for |element|. | 156 // Shows the autofill suggestions for |element|. This call is asynchronous |
124 // This call is asynchronous and may or may not lead to the showing of a | 157 // and may or may not lead to the showing of a suggestion popup (no popup is |
125 // suggestion popup (no popup is shown if there are no available suggestions). | 158 // shown if there are no available suggestions). |
126 // |autofill_on_empty_values| specifies whether suggestions should be shown | |
127 // when |element| contains no text. | |
128 // |requires_caret_at_end| specifies whether suggestions should be shown when | |
129 // the caret is not after the last character in |element|. | |
130 // |display_warning_if_disabled| specifies whether a warning should be | |
131 // displayed to the user if Autofill has suggestions available, but cannot | |
132 // fill them because it is disabled (e.g. when trying to fill a credit card | |
133 // form on a non-secure website). | |
134 // |datalist_only| specifies whether all of <datalist> suggestions and no | |
135 // autofill suggestions are shown. |autofill_on_empty_values| and | |
136 // |requires_caret_at_end| are ignored if |datalist_only| is true. | |
137 // |show_full_suggestion_list| specifies that all autofill suggestions should | |
138 // be shown and none should be elided because of the current value of | |
139 // |element| (relevant for inline autocomplete). | |
140 // |show_password_suggestions_only| specifies that only show a suggestions box | |
141 // if |element| is part of a password form, otherwise show no suggestions. | |
142 void ShowSuggestions(const blink::WebFormControlElement& element, | 159 void ShowSuggestions(const blink::WebFormControlElement& element, |
143 bool autofill_on_empty_values, | 160 const ShowSuggestionsOptions& options); |
144 bool requires_caret_at_end, | |
145 bool display_warning_if_disabled, | |
146 bool datalist_only, | |
147 bool show_full_suggestion_list, | |
148 bool show_password_suggestions_only); | |
149 | 161 |
150 // Queries the browser for Autocomplete and Autofill suggestions for the given | 162 // Queries the browser for Autocomplete and Autofill suggestions for the given |
151 // |element|. | 163 // |element|. |
152 void QueryAutofillSuggestions(const blink::WebFormControlElement& element, | 164 void QueryAutofillSuggestions(const blink::WebFormControlElement& element, |
153 bool display_warning_if_disabled, | 165 bool display_warning_if_disabled, |
154 bool datalist_only); | 166 bool datalist_only); |
155 | 167 |
156 // Sets the element value to reflect the selected |suggested_value|. | 168 // Sets the element value to reflect the selected |suggested_value|. |
157 void AcceptDataListSuggestion(const base::string16& suggested_value); | 169 void AcceptDataListSuggestion(const base::string16& suggested_value); |
158 | 170 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 bool main_frame_processed_; | 238 bool main_frame_processed_; |
227 | 239 |
228 base::WeakPtrFactory<AutofillAgent> weak_ptr_factory_; | 240 base::WeakPtrFactory<AutofillAgent> weak_ptr_factory_; |
229 | 241 |
230 DISALLOW_COPY_AND_ASSIGN(AutofillAgent); | 242 DISALLOW_COPY_AND_ASSIGN(AutofillAgent); |
231 }; | 243 }; |
232 | 244 |
233 } // namespace autofill | 245 } // namespace autofill |
234 | 246 |
235 #endif // COMPONENTS_AUTOFILL_CONTENT_RENDERER_AUTOFILL_AGENT_H_ | 247 #endif // COMPONENTS_AUTOFILL_CONTENT_RENDERER_AUTOFILL_AGENT_H_ |
OLD | NEW |