Chromium Code Reviews| Index: chrome/renderer/autofill_helper.cc |
| diff --git a/chrome/renderer/autofill_helper.cc b/chrome/renderer/autofill_helper.cc |
| index 2832f0dbaa83f61e744f2dc04047f1f6b1bc579d..e5974738f818271969e675b4c58e41e1e26e3ee0 100644 |
| --- a/chrome/renderer/autofill_helper.cc |
| +++ b/chrome/renderer/autofill_helper.cc |
| @@ -54,7 +54,8 @@ AutoFillHelper::AutoFillHelper(RenderView* render_view) |
| suggestions_options_index_(-1) { |
| } |
| -void AutoFillHelper::QueryAutoFillSuggestions(const WebNode& node) { |
| +void AutoFillHelper::QueryAutoFillSuggestions(const WebNode& node, |
| + bool autofill_disabled) { |
| static int query_counter = 0; |
| autofill_query_id_ = query_counter++; |
| autofill_query_node_ = node; |
| @@ -72,7 +73,8 @@ void AutoFillHelper::QueryAutoFillSuggestions(const WebNode& node) { |
| bool field_autofilled = NodeIsAutoFilled(node); |
| render_view_->Send(new ViewHostMsg_QueryFormFieldAutoFill( |
| - render_view_->routing_id(), autofill_query_id_, field_autofilled, field)); |
| + render_view_->routing_id(), autofill_query_id_, field_autofilled, field, |
| + autofill_disabled)); |
| } |
| void AutoFillHelper::RemoveAutocompleteSuggestion( |
| @@ -123,7 +125,7 @@ void AutoFillHelper::SuggestionsReceived(int query_id, |
| // items, identified by |unique_ids| having at least one valid value. |
| bool show_options = false; |
| for (size_t i = 0; i < ids.size(); ++i) { |
| - if (ids[i] != 0) { |
| + if (ids[i] > 0) { |
| show_options = true; |
| break; |
| } |
| @@ -226,33 +228,29 @@ void AutoFillHelper::FrameDetached(WebFrame* frame) { |
| } |
| void AutoFillHelper::TextDidChangeInTextField(const WebInputElement& element) { |
| - ShowSuggestions(element, false, true); |
| + ShowSuggestions(element, false, true, false); |
| } |
| bool AutoFillHelper::InputElementClicked(const WebInputElement& element, |
| bool was_focused, |
| bool is_focused) { |
| if (was_focused) |
| - ShowSuggestions(element, true, false); |
| + ShowSuggestions(element, true, false, true); |
| return false; |
| } |
| - |
| -void AutoFillHelper::ShowSuggestions( |
| - const WebInputElement& const_element, |
| - bool autofill_on_empty_values, |
| - bool requires_caret_at_end) { |
| - // We need to call non-const methods. |
| - WebInputElement element(const_element); |
| - if (!element.isEnabledFormControl() || |
| - !element.isText() || |
| - element.isPasswordField() || |
| - !element.autoComplete() || element.isReadOnly()) { |
| +void AutoFillHelper::ShowSuggestions(const WebInputElement& element, |
| + bool autofill_on_empty_values, |
| + bool requires_caret_at_end, |
| + bool display_warning_if_disabled) { |
| + bool autofill_disabled = !element.isEnabledFormControl() || |
| + !element.isText() || element.isPasswordField() || |
| + !element.autoComplete() || element.isReadOnly(); |
| + if (autofill_disabled && !display_warning_if_disabled) |
| return; |
| - } |
| - WebString name = element.nameForAutofill(); |
| - if (name.isEmpty()) // If the field has no name, then we won't have values. |
| + // If the field has no name, then we won't have values. |
| + if (element.nameForAutofill().isEmpty()) |
| return; |
| // Don't attempt to autofill with values that are too large. |
| @@ -265,11 +263,10 @@ void AutoFillHelper::ShowSuggestions( |
| if (requires_caret_at_end && |
| (element.selectionStart() != element.selectionEnd() || |
| - element.selectionEnd() != static_cast<int>(value.length()))) { |
| + element.selectionEnd() != static_cast<int>(value.length()))) |
| return; |
| - } |
| - QueryAutoFillSuggestions(element); |
| + QueryAutoFillSuggestions(element, autofill_disabled); |
|
dhollowa
2010/11/12 01:52:03
Could we avoid the IPC call here in the case that
Ilya Sherman
2010/11/12 05:15:38
The thing is, we don't want to show a warning if t
|
| } |
| void AutoFillHelper::QueryAutoFillFormData(const WebNode& node, |