BookmarkManager: Fix 'new folder text field size changes on clicking it' issue.
[chromium-blink-merge.git] / chrome / browser / ui / location_bar / location_bar_util.cc
blob7f738b7f09d96da8007712a2f812f408edfe21e9
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
3 // found in the LICENSE file.
5 #include "chrome/browser/ui/location_bar/location_bar_util.h"
7 #include "base/i18n/rtl.h"
8 #include "base/strings/string_util.h"
9 #include "base/strings/utf_string_conversions.h"
10 #include "ui/gfx/text_elider.h"
12 namespace location_bar_util {
14 base::string16 CalculateMinString(const base::string16& description) {
15 // Chop at the first '.' or whitespace.
16 const size_t chop_index = description.find_first_of(
17 base::kWhitespaceUTF16 + base::ASCIIToUTF16("."));
18 base::string16 min_string((chop_index == base::string16::npos) ?
19 gfx::TruncateString(description, 3, gfx::WORD_BREAK) :
20 description.substr(0, chop_index));
21 base::i18n::AdjustStringForLocaleDirection(&min_string);
22 return min_string;
25 } // namespace location_bar_util