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

Side by Side Diff: chrome/browser/ui/location_bar/location_bar_util.cc

Issue 381953002: New avatar button: Consolidate text elision between Mac and Win/Linux (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: use gfx::BreakType Created 6 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 | Annotate | Revision Log
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/location_bar/location_bar_util.h" 5 #include "chrome/browser/ui/location_bar/location_bar_util.h"
6 6
7 #include "base/i18n/rtl.h" 7 #include "base/i18n/rtl.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "ui/gfx/text_elider.h" 10 #include "ui/gfx/text_elider.h"
11 11
12 namespace location_bar_util { 12 namespace location_bar_util {
13 13
14 base::string16 CalculateMinString(const base::string16& description) { 14 base::string16 CalculateMinString(const base::string16& description) {
15 // Chop at the first '.' or whitespace. 15 // Chop at the first '.' or whitespace.
16 const size_t chop_index = description.find_first_of( 16 const size_t chop_index = description.find_first_of(
17 base::kWhitespaceUTF16 + base::ASCIIToUTF16(".")); 17 base::kWhitespaceUTF16 + base::ASCIIToUTF16("."));
18 base::string16 min_string((chop_index == base::string16::npos) ? 18 base::string16 min_string((chop_index == base::string16::npos) ?
19 gfx::TruncateString(description, 3) : description.substr(0, chop_index)); 19 gfx::TruncateString(description, 3, gfx::WORD_BREAK) :
20 description.substr(0, chop_index));
20 base::i18n::AdjustStringForLocaleDirection(&min_string); 21 base::i18n::AdjustStringForLocaleDirection(&min_string);
21 return min_string; 22 return min_string;
22 } 23 }
23 24
24 } // namespace location_bar_util 25 } // namespace location_bar_util
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698