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

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

Issue 2695883003: Change uses of base::JoinString to pass StringPieces where possible. (Closed)
Patch Set: Remove dependency CL. Created 3 years, 9 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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <tuple> 9 #include <tuple>
10 10
11 #include "base/auto_reset.h" 11 #include "base/auto_reset.h"
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/i18n/case_conversion.h" 14 #include "base/i18n/case_conversion.h"
15 #include "base/location.h" 15 #include "base/location.h"
16 #include "base/metrics/field_trial.h" 16 #include "base/metrics/field_trial.h"
17 #include "base/single_thread_task_runner.h" 17 #include "base/single_thread_task_runner.h"
18 #include "base/strings/string_piece.h"
18 #include "base/strings/string_split.h" 19 #include "base/strings/string_split.h"
19 #include "base/strings/string_util.h" 20 #include "base/strings/string_util.h"
20 #include "base/strings/utf_string_conversions.h" 21 #include "base/strings/utf_string_conversions.h"
21 #include "base/threading/thread_task_runner_handle.h" 22 #include "base/threading/thread_task_runner_handle.h"
22 #include "base/time/time.h" 23 #include "base/time/time.h"
23 #include "build/build_config.h" 24 #include "build/build_config.h"
24 #include "components/autofill/content/renderer/form_autofill_util.h" 25 #include "components/autofill/content/renderer/form_autofill_util.h"
25 #include "components/autofill/content/renderer/page_click_tracker.h" 26 #include "components/autofill/content/renderer/page_click_tracker.h"
26 #include "components/autofill/content/renderer/password_autofill_agent.h" 27 #include "components/autofill/content/renderer/password_autofill_agent.h"
27 #include "components/autofill/content/renderer/password_generation_agent.h" 28 #include "components/autofill/content/renderer/password_generation_agent.h"
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 } 428 }
428 429
429 void AutofillAgent::DoAcceptDataListSuggestion( 430 void AutofillAgent::DoAcceptDataListSuggestion(
430 const base::string16& suggested_value) { 431 const base::string16& suggested_value) {
431 WebInputElement* input_element = toWebInputElement(&element_); 432 WebInputElement* input_element = toWebInputElement(&element_);
432 DCHECK(input_element); 433 DCHECK(input_element);
433 base::string16 new_value = suggested_value; 434 base::string16 new_value = suggested_value;
434 // If this element takes multiple values then replace the last part with 435 // If this element takes multiple values then replace the last part with
435 // the suggestion. 436 // the suggestion.
436 if (input_element->isMultiple() && input_element->isEmailField()) { 437 if (input_element->isMultiple() && input_element->isEmailField()) {
437 std::vector<base::string16> parts = base::SplitString( 438 std::vector<base::StringPiece16> parts = base::SplitStringPiece(
438 input_element->editingValue().utf16(), base::ASCIIToUTF16(","), 439 input_element->editingValue().utf16(), base::ASCIIToUTF16(","),
439 base::KEEP_WHITESPACE, base::SPLIT_WANT_ALL); 440 base::KEEP_WHITESPACE, base::SPLIT_WANT_ALL);
440 if (parts.size() == 0) 441 if (parts.size() == 0)
441 parts.push_back(base::string16()); 442 parts.push_back(base::StringPiece16());
442 443
443 base::string16 last_part = parts.back(); 444 base::string16 last_part = parts.back().as_string();
444 // We want to keep just the leading whitespace. 445 // We want to keep just the leading whitespace.
445 for (size_t i = 0; i < last_part.size(); ++i) { 446 for (size_t i = 0; i < last_part.size(); ++i) {
446 if (!base::IsUnicodeWhitespace(last_part[i])) { 447 if (!base::IsUnicodeWhitespace(last_part[i])) {
447 last_part = last_part.substr(0, i); 448 last_part = last_part.substr(0, i);
448 break; 449 break;
449 } 450 }
450 } 451 }
451 last_part.append(suggested_value); 452 last_part.append(suggested_value);
452 parts.back() = last_part; 453 parts.back() = last_part;
453 454
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
817 void AutofillAgent::LegacyAutofillAgent::OnDestruct() { 818 void AutofillAgent::LegacyAutofillAgent::OnDestruct() {
818 // No-op. Don't delete |this|. 819 // No-op. Don't delete |this|.
819 } 820 }
820 821
821 void AutofillAgent::LegacyAutofillAgent::FocusChangeComplete() { 822 void AutofillAgent::LegacyAutofillAgent::FocusChangeComplete() {
822 if (agent_) 823 if (agent_)
823 agent_->FocusChangeComplete(); 824 agent_->FocusChangeComplete();
824 } 825 }
825 826
826 } // namespace autofill 827 } // namespace autofill
OLDNEW
« no previous file with comments | « chromeos/network/onc/onc_validator.cc ('k') | components/autofill/core/browser/autofill_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698