Chromium Code Reviews| 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 #include "components/autofill/content/renderer/autofill_agent.h" | 5 #include "components/autofill/content/renderer/autofill_agent.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/strings/string_split.h" | 10 #include "base/strings/string_split.h" |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 341 void AutofillAgent::textFieldDidEndEditing(const WebInputElement& element) { | 341 void AutofillAgent::textFieldDidEndEditing(const WebInputElement& element) { |
| 342 password_autofill_agent_->TextFieldDidEndEditing(element); | 342 password_autofill_agent_->TextFieldDidEndEditing(element); |
| 343 has_shown_autofill_popup_for_current_edit_ = false; | 343 has_shown_autofill_popup_for_current_edit_ = false; |
| 344 Send(new AutofillHostMsg_DidEndTextFieldEditing(routing_id())); | 344 Send(new AutofillHostMsg_DidEndTextFieldEditing(routing_id())); |
| 345 } | 345 } |
| 346 | 346 |
| 347 void AutofillAgent::textFieldDidChange(const WebFormControlElement& element) { | 347 void AutofillAgent::textFieldDidChange(const WebFormControlElement& element) { |
| 348 if (ignore_text_changes_) | 348 if (ignore_text_changes_) |
| 349 return; | 349 return; |
| 350 | 350 |
| 351 DCHECK(toWebInputElement(&element) || IsTextAreaElement(element)); | 351 if (!toWebInputElement(&element) && !IsTextAreaElement(element)) |
| 352 return; | |
|
Ilya Sherman
2014/04/22 21:08:45
Why is this code reachable?
| |
| 352 | 353 |
| 353 if (did_set_node_text_) { | 354 if (did_set_node_text_) { |
| 354 did_set_node_text_ = false; | 355 did_set_node_text_ = false; |
| 355 return; | 356 return; |
| 356 } | 357 } |
| 357 | 358 |
| 358 // We post a task for doing the Autofill as the caret position is not set | 359 // We post a task for doing the Autofill as the caret position is not set |
| 359 // properly at this point (http://bugs.webkit.org/show_bug.cgi?id=16976) and | 360 // properly at this point (http://bugs.webkit.org/show_bug.cgi?id=16976) and |
| 360 // it is needed to trigger autofill. | 361 // it is needed to trigger autofill. |
| 361 weak_ptr_factory_.InvalidateWeakPtrs(); | 362 weak_ptr_factory_.InvalidateWeakPtrs(); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 412 ShowSuggestions(element, true, true, true, false); | 413 ShowSuggestions(element, true, true, true, false); |
| 413 } | 414 } |
| 414 | 415 |
| 415 void AutofillAgent::openTextDataListChooser(const WebInputElement& element) { | 416 void AutofillAgent::openTextDataListChooser(const WebInputElement& element) { |
| 416 ShowSuggestions(element, true, false, false, true); | 417 ShowSuggestions(element, true, false, false, true); |
| 417 } | 418 } |
| 418 | 419 |
| 419 void AutofillAgent::AcceptDataListSuggestion( | 420 void AutofillAgent::AcceptDataListSuggestion( |
| 420 const base::string16& suggested_value) { | 421 const base::string16& suggested_value) { |
| 421 WebInputElement* input_element = toWebInputElement(&element_); | 422 WebInputElement* input_element = toWebInputElement(&element_); |
| 422 DCHECK(input_element); | 423 if (!input_element) |
| 424 return; | |
|
Ilya Sherman
2014/04/22 21:08:45
Why is this code reachable?
| |
| 425 | |
| 423 base::string16 new_value = suggested_value; | 426 base::string16 new_value = suggested_value; |
| 424 // If this element takes multiple values then replace the last part with | 427 // If this element takes multiple values then replace the last part with |
| 425 // the suggestion. | 428 // the suggestion. |
| 426 if (input_element->isMultiple() && | 429 if (input_element->isMultiple() && |
| 427 input_element->formControlType() == WebString::fromUTF8("email")) { | 430 input_element->formControlType() == WebString::fromUTF8("email")) { |
| 428 std::vector<base::string16> parts; | 431 std::vector<base::string16> parts; |
| 429 | 432 |
| 430 base::SplitStringDontTrim(input_element->editingValue(), ',', &parts); | 433 base::SplitStringDontTrim(input_element->editingValue(), ',', &parts); |
| 431 if (parts.size() == 0) | 434 if (parts.size() == 0) |
| 432 parts.push_back(base::string16()); | 435 parts.push_back(base::string16()); |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 697 // Only monitors dynamic forms created in the top frame. Dynamic forms | 700 // Only monitors dynamic forms created in the top frame. Dynamic forms |
| 698 // inserted in iframes are not captured yet. | 701 // inserted in iframes are not captured yet. |
| 699 if (frame && !frame->parent()) { | 702 if (frame && !frame->parent()) { |
| 700 password_autofill_agent_->OnDynamicFormsSeen(frame); | 703 password_autofill_agent_->OnDynamicFormsSeen(frame); |
| 701 return; | 704 return; |
| 702 } | 705 } |
| 703 } | 706 } |
| 704 } | 707 } |
| 705 | 708 |
| 706 } // namespace autofill | 709 } // namespace autofill |
| OLD | NEW |