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

Side by Side Diff: chrome/browser/ui/autofill/generated_credit_card_bubble_controller.cc

Issue 24012002: Move Range code to gfx. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: d Created 7 years, 3 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 | Annotate | Revision Log
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 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 while (!pieces.empty()) { 189 while (!pieces.empty()) {
190 base::string16 piece = pieces.front(); 190 base::string16 piece = pieces.front();
191 191
192 // Every second piece should be bolded. Because |base::SplitString*()| 192 // Every second piece should be bolded. Because |base::SplitString*()|
193 // leaves an empty "" even if '|' is the first character, this is guaranteed 193 // leaves an empty "" even if '|' is the first character, this is guaranteed
194 // to work for "|highlighting| starts here". Ignore empty pieces because 194 // to work for "|highlighting| starts here". Ignore empty pieces because
195 // there's nothing to highlight. 195 // there's nothing to highlight.
196 if (!piece.empty() && pieces.size() % 2 == 0) { 196 if (!piece.empty() && pieces.size() % 2 == 0) {
197 const size_t start = contents_text_.size(); 197 const size_t start = contents_text_.size();
198 TextRange bold_text; 198 TextRange bold_text;
199 bold_text.range = ui::Range(start, start + piece.size()); 199 bold_text.range = gfx::Range(start, start + piece.size());
200 bold_text.is_link = false; 200 bold_text.is_link = false;
201 contents_text_ranges_.push_back(bold_text); 201 contents_text_ranges_.push_back(bold_text);
202 } 202 }
203 203
204 // Append the piece whether it's bolded or not and move on to the next one. 204 // Append the piece whether it's bolded or not and move on to the next one.
205 contents_text_.append(piece); 205 contents_text_.append(piece);
206 pieces.erase(pieces.begin(), pieces.begin() + 1); 206 pieces.erase(pieces.begin(), pieces.begin() + 1);
207 } 207 }
208 208
209 // Add a "Learn more" link at the end of the header text if it's a generated 209 // Add a "Learn more" link at the end of the header text if it's a generated
210 // card bubble. 210 // card bubble.
211 base::string16 learn_more = l10n_util::GetStringUTF16(IDS_LEARN_MORE); 211 base::string16 learn_more = l10n_util::GetStringUTF16(IDS_LEARN_MORE);
212 contents_text_.append(ASCIIToUTF16(" ") + learn_more); 212 contents_text_.append(ASCIIToUTF16(" ") + learn_more);
213 const size_t header_size = contents_text_.size(); 213 const size_t header_size = contents_text_.size();
214 TextRange end_link; 214 TextRange end_link;
215 end_link.range = ui::Range(header_size - learn_more.size(), header_size); 215 end_link.range = gfx::Range(header_size - learn_more.size(), header_size);
216 end_link.is_link = true; 216 end_link.is_link = true;
217 contents_text_ranges_.push_back(end_link); 217 contents_text_ranges_.push_back(end_link);
218 218
219 UpdateAnchor(); 219 UpdateAnchor();
220 220
221 if (ShouldDisplayBubbleInitially()) 221 if (ShouldDisplayBubbleInitially())
222 Show(false); 222 Show(false);
223 } 223 }
224 224
225 void GeneratedCreditCardBubbleController::Show(bool was_anchor_click) { 225 void GeneratedCreditCardBubbleController::Show(bool was_anchor_click) {
(...skipping 25 matching lines...) Expand all
251 if (browser && browser->window() && browser->window()->GetLocationBar()) 251 if (browser && browser->window() && browser->window()->GetLocationBar())
252 browser->window()->GetLocationBar()->UpdateGeneratedCreditCardView(); 252 browser->window()->GetLocationBar()->UpdateGeneratedCreditCardView();
253 } 253 }
254 254
255 void GeneratedCreditCardBubbleController::Hide() { 255 void GeneratedCreditCardBubbleController::Hide() {
256 if (bubble_ && !bubble_->IsHiding()) 256 if (bubble_ && !bubble_->IsHiding())
257 bubble_->Hide(); 257 bubble_->Hide();
258 } 258 }
259 259
260 } // namespace autofill 260 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698