| 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/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/i18n/case_conversion.h" | 10 #include "base/i18n/case_conversion.h" |
| (...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 478 } | 478 } |
| 479 | 479 |
| 480 void AutofillAgent::AcceptDataListSuggestion( | 480 void AutofillAgent::AcceptDataListSuggestion( |
| 481 const base::string16& suggested_value) { | 481 const base::string16& suggested_value) { |
| 482 WebInputElement* input_element = toWebInputElement(&element_); | 482 WebInputElement* input_element = toWebInputElement(&element_); |
| 483 DCHECK(input_element); | 483 DCHECK(input_element); |
| 484 base::string16 new_value = suggested_value; | 484 base::string16 new_value = suggested_value; |
| 485 // If this element takes multiple values then replace the last part with | 485 // If this element takes multiple values then replace the last part with |
| 486 // the suggestion. | 486 // the suggestion. |
| 487 if (input_element->isMultiple() && input_element->isEmailField()) { | 487 if (input_element->isMultiple() && input_element->isEmailField()) { |
| 488 std::vector<base::string16> parts; | 488 std::vector<base::string16> parts = base::SplitString( |
| 489 | 489 base::StringPiece16(input_element->editingValue()), |
| 490 base::SplitStringDontTrim( | 490 base::ASCIIToUTF16(","), base::KEEP_WHITESPACE, base::SPLIT_WANT_ALL); |
| 491 base::StringPiece16(input_element->editingValue()), ',', &parts); | |
| 492 if (parts.size() == 0) | 491 if (parts.size() == 0) |
| 493 parts.push_back(base::string16()); | 492 parts.push_back(base::string16()); |
| 494 | 493 |
| 495 base::string16 last_part = parts.back(); | 494 base::string16 last_part = parts.back(); |
| 496 // We want to keep just the leading whitespace. | 495 // We want to keep just the leading whitespace. |
| 497 for (size_t i = 0; i < last_part.size(); ++i) { | 496 for (size_t i = 0; i < last_part.size(); ++i) { |
| 498 if (!base::IsUnicodeWhitespace(last_part[i])) { | 497 if (!base::IsUnicodeWhitespace(last_part[i])) { |
| 499 last_part = last_part.substr(0, i); | 498 last_part = last_part.substr(0, i); |
| 500 break; | 499 break; |
| 501 } | 500 } |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 803 | 802 |
| 804 void AutofillAgent::LegacyAutofillAgent::OnDestruct() { | 803 void AutofillAgent::LegacyAutofillAgent::OnDestruct() { |
| 805 // No-op. Don't delete |this|. | 804 // No-op. Don't delete |this|. |
| 806 } | 805 } |
| 807 | 806 |
| 808 void AutofillAgent::LegacyAutofillAgent::FocusChangeComplete() { | 807 void AutofillAgent::LegacyAutofillAgent::FocusChangeComplete() { |
| 809 agent_->FocusChangeComplete(); | 808 agent_->FocusChangeComplete(); |
| 810 } | 809 } |
| 811 | 810 |
| 812 } // namespace autofill | 811 } // namespace autofill |
| OLD | NEW |