Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(57)

Side by Side Diff: components/autofill/content/renderer/autofill_agent.cc

Issue 1234973004: Update SplitString calls in components (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixes Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 WebElementCollection options = element.dataListOptions(); 83 WebElementCollection options = element.dataListOptions();
84 if (options.isNull()) 84 if (options.isNull())
85 return; 85 return;
86 86
87 base::string16 prefix; 87 base::string16 prefix;
88 if (!ignore_current_value) { 88 if (!ignore_current_value) {
89 prefix = element.editingValue(); 89 prefix = element.editingValue();
90 if (element.isMultiple() && element.isEmailField()) { 90 if (element.isMultiple() && element.isEmailField()) {
91 const base::char16 comma[2] = { ',', 0 }; 91 const base::char16 comma[2] = { ',', 0 };
92 std::vector<base::string16> parts = base::SplitString( 92 std::vector<base::string16> parts = base::SplitString(
93 prefix, comma, base::KEEP_WHITESPACE, base::SPLIT_WANT_ALL); 93 prefix, comma, base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
94 if (parts.size() > 0) { 94 if (parts.size() > 0) {
95 base::TrimWhitespace(parts[parts.size() - 1], base::TRIM_LEADING, 95 base::TrimWhitespace(parts[parts.size() - 1], base::TRIM_LEADING,
96 &prefix); 96 &prefix);
97 } 97 }
98 } 98 }
99 } 99 }
100 prefix = base::i18n::ToLower(prefix); 100 prefix = base::i18n::ToLower(prefix);
101 for (WebOptionElement option = options.firstItem().to<WebOptionElement>(); 101 for (WebOptionElement option = options.firstItem().to<WebOptionElement>();
102 !option.isNull(); option = options.nextItem().to<WebOptionElement>()) { 102 !option.isNull(); option = options.nextItem().to<WebOptionElement>()) {
103 if (!base::StartsWith(base::i18n::ToLower(base::string16(option.value())), 103 if (!base::StartsWith(base::i18n::ToLower(base::string16(option.value())),
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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
OLDNEW
« no previous file with comments | « components/autofill/content/browser/wallet/wallet_address.cc ('k') | components/autofill/core/browser/address.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698