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

Side by Side Diff: chrome/browser/ui/autofill/generated_credit_card_bubble_controller.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
« no previous file with comments | « chrome/browser/ui/autofill/autofill_dialog_types.cc ('k') | chrome/browser/ui/elide_url.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "chrome/browser/ui/autofill/generated_credit_card_bubble_controller.h" 5 #include "chrome/browser/ui/autofill/generated_credit_card_bubble_controller.h"
6 6
7 #include <climits> 7 #include <climits>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 contents_text_.clear(); 186 contents_text_.clear();
187 contents_text_ranges_.clear(); 187 contents_text_ranges_.clear();
188 188
189 base::string16 to_split = l10n_util::GetStringFUTF16( 189 base::string16 to_split = l10n_util::GetStringFUTF16(
190 IDS_AUTOFILL_GENERATED_CREDIT_CARD_BUBBLE_CONTENTS, 190 IDS_AUTOFILL_GENERATED_CREDIT_CARD_BUBBLE_CONTENTS,
191 fronting_card_name_, 191 fronting_card_name_,
192 backing_card_name_); 192 backing_card_name_);
193 193
194 // Split the full text on '|' to highlight certain parts. For example, "sly" 194 // Split the full text on '|' to highlight certain parts. For example, "sly"
195 // and "jumped" would be bolded in "The |sly| fox |jumped| over the lazy dog". 195 // and "jumped" would be bolded in "The |sly| fox |jumped| over the lazy dog".
196 std::vector<base::string16> pieces; 196 std::vector<base::string16> pieces = base::SplitString(
197 base::SplitStringDontTrim(to_split, kRangeSeparator, &pieces); 197 to_split, base::string16(1, kRangeSeparator),
198 base::KEEP_WHITESPACE, base::SPLIT_WANT_ALL);
198 199
199 while (!pieces.empty()) { 200 while (!pieces.empty()) {
200 base::string16 piece = pieces.front(); 201 base::string16 piece = pieces.front();
201 202
202 // Every second piece should be bolded. Because |base::SplitString*()| 203 // Every second piece should be bolded. Because SPLIT_WANT_ALL makes
203 // leaves an empty "" even if '|' is the first character, this is guaranteed 204 // SplitString leave an empty "" even if '|' is the first character, this
204 // to work for "|highlighting| starts here". Ignore empty pieces because 205 // is guaranteed to work for "|highlighting| starts here". Ignore empty
205 // there's nothing to highlight. 206 // pieces because there's nothing to highlight.
206 if (!piece.empty() && pieces.size() % 2 == 0) { 207 if (!piece.empty() && pieces.size() % 2 == 0) {
207 const size_t start = contents_text_.size(); 208 const size_t start = contents_text_.size();
208 TextRange bold_text; 209 TextRange bold_text;
209 bold_text.range = gfx::Range(start, start + piece.size()); 210 bold_text.range = gfx::Range(start, start + piece.size());
210 bold_text.is_link = false; 211 bold_text.is_link = false;
211 contents_text_ranges_.push_back(bold_text); 212 contents_text_ranges_.push_back(bold_text);
212 } 213 }
213 214
214 // Append the piece whether it's bolded or not and move on to the next one. 215 // Append the piece whether it's bolded or not and move on to the next one.
215 contents_text_.append(piece); 216 contents_text_.append(piece);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 if (browser && browser->window() && browser->window()->GetLocationBar()) 262 if (browser && browser->window() && browser->window()->GetLocationBar())
262 browser->window()->GetLocationBar()->UpdateGeneratedCreditCardView(); 263 browser->window()->GetLocationBar()->UpdateGeneratedCreditCardView();
263 } 264 }
264 265
265 void GeneratedCreditCardBubbleController::Hide() { 266 void GeneratedCreditCardBubbleController::Hide() {
266 if (bubble_ && !bubble_->IsHiding()) 267 if (bubble_ && !bubble_->IsHiding())
267 bubble_->Hide(); 268 bubble_->Hide();
268 } 269 }
269 270
270 } // namespace autofill 271 } // namespace autofill
OLDNEW
« no previous file with comments | « chrome/browser/ui/autofill/autofill_dialog_types.cc ('k') | chrome/browser/ui/elide_url.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698