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

Side by Side Diff: chrome/browser/ui/views/autofill/expanding_textfield.cc

Issue 1240183002: Update SplitString calls in chrome. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chrome/browser/ui/views/autofill/expanding_textfield.h" 5 #include "chrome/browser/ui/views/autofill/expanding_textfield.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/strings/string_split.h" 8 #include "base/strings/string_split.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 } 43 }
44 44
45 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 45 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0,
46 kManualInputRowPadding)); 46 kManualInputRowPadding));
47 } 47 }
48 48
49 ExpandingTextfield::~ExpandingTextfield() {} 49 ExpandingTextfield::~ExpandingTextfield() {}
50 50
51 void ExpandingTextfield::SetText(const base::string16& text) { 51 void ExpandingTextfield::SetText(const base::string16& text) {
52 textfields_.front()->SetText(text); 52 textfields_.front()->SetText(text);
53 std::vector<base::string16> strings; 53 std::vector<base::string16> strings = base::SplitString(
54 base::SplitStringDontTrim(text, '\n', &strings); 54 text, base::string16(1, '\n'),
55 base::KEEP_WHITESPACE, base::SPLIT_WANT_ALL);
55 56
56 size_t i = 0; 57 size_t i = 0;
57 for (std::list<DecoratedTextfield*>::iterator iter = textfields_.begin(); 58 for (std::list<DecoratedTextfield*>::iterator iter = textfields_.begin();
58 iter != textfields_.end(); ++iter) { 59 iter != textfields_.end(); ++iter) {
59 (*iter)->SetText(i < strings.size() ? strings[i++] : base::string16()); 60 (*iter)->SetText(i < strings.size() ? strings[i++] : base::string16());
60 } 61 }
61 62
62 for (; i < strings.size(); ++i) { 63 for (; i < strings.size(); ++i) {
63 textfields_.push_back(new DecoratedTextfield( 64 textfields_.push_back(new DecoratedTextfield(
64 strings[i], 65 strings[i],
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 void ExpandingTextfield::ForEachTextfield( 138 void ExpandingTextfield::ForEachTextfield(
138 void (BaseType::* f)(Param), Param p) const { 139 void (BaseType::* f)(Param), Param p) const {
139 for (std::list<DecoratedTextfield*>::const_iterator iter = 140 for (std::list<DecoratedTextfield*>::const_iterator iter =
140 textfields_.begin(); 141 textfields_.begin();
141 iter != textfields_.end(); ++iter) { 142 iter != textfields_.end(); ++iter) {
142 base::Bind(f, base::Unretained(*iter), p).Run(); 143 base::Bind(f, base::Unretained(*iter), p).Run();
143 } 144 }
144 } 145 }
145 146
146 } // namespace autofill 147 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698