summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-27 21:47:48 +0000
committertony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-27 21:47:48 +0000
commit25de8d0c1874566511d42d4e46276507bb88ce16 (patch)
treefda12f19796cd23765a87f4e1402e3758aa9ce9c
parentd1e7881403dd7f9fa28292beb38f0d6e01a7e3c0 (diff)
downloadchromium_src-25de8d0c1874566511d42d4e46276507bb88ce16.zip
chromium_src-25de8d0c1874566511d42d4e46276507bb88ce16.tar.gz
chromium_src-25de8d0c1874566511d42d4e46276507bb88ce16.tar.bz2
Convert ElideUrl to return a string16 instead of a wstring.
BUG=23581 Review URL: http://codereview.chromium.org/4115003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@64156 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--app/text_elider.cc209
-rw-r--r--app/text_elider.h8
-rw-r--r--app/text_elider_unittest.cc2
-rw-r--r--chrome/browser/cocoa/status_bubble_mac.mm8
-rw-r--r--chrome/browser/gtk/status_bubble_gtk.cc4
-rw-r--r--chrome/browser/message_box_handler.cc5
-rw-r--r--chrome/browser/views/bookmark_bar_view.cc7
-rw-r--r--chrome/browser/views/status_bubble_views.cc8
-rw-r--r--printing/printed_document.cc3
-rw-r--r--views/controls/label.cc3
10 files changed, 128 insertions, 129 deletions
diff --git a/app/text_elider.cc b/app/text_elider.cc
index 96a7593..79a865e 100644
--- a/app/text_elider.cc
+++ b/app/text_elider.cc
@@ -41,18 +41,6 @@ string16 CutString(const string16& text,
text.substr(text.length() - half_length, half_length);
}
-// TODO(tony): Get rid of wstrings.
-string16 GetDisplayStringInLTRDirectionality(const std::wstring& text) {
- return base::i18n::GetDisplayStringInLTRDirectionality(WideToUTF16(text));
-}
-
-// TODO(tony): This is just a crutch until we convert ElideUrl to string16.
-std::wstring ElideTextWide(const std::wstring& text, const gfx::Font& font,
- int available_pixel_width, bool elide_in_middle) {
- return UTF16ToWideHack(ElideText(WideToUTF16Hack(text), font,
- available_pixel_width, elide_in_middle));
-}
-
} // namespace
namespace gfx {
@@ -67,61 +55,61 @@ namespace gfx {
// kerning/ligatures/etc. issues potentially wrong by assuming that the width of
// a rendered string is always the sum of the widths of its substrings. Also I
// suspect it could be made simpler.
-std::wstring ElideUrl(const GURL& url,
- const gfx::Font& font,
- int available_pixel_width,
- const std::wstring& languages) {
+string16 ElideUrl(const GURL& url,
+ const gfx::Font& font,
+ int available_pixel_width,
+ const std::wstring& languages) {
// Get a formatted string and corresponding parsing of the url.
url_parse::Parsed parsed;
- std::wstring url_string = UTF16ToWideHack(net::FormatUrl(url,
- WideToUTF8(languages), net::kFormatUrlOmitAll, UnescapeRule::SPACES,
- &parsed, NULL, NULL));
+ string16 url_string = net::FormatUrl(url, WideToUTF8(languages),
+ net::kFormatUrlOmitAll, UnescapeRule::SPACES, &parsed, NULL, NULL);
if (available_pixel_width <= 0)
return url_string;
// If non-standard or not file type, return plain eliding.
if (!(url.SchemeIsFile() || url.IsStandard()))
- return ElideTextWide(url_string, font, available_pixel_width, false);
+ return ElideText(url_string, font, available_pixel_width, false);
// Now start eliding url_string to fit within available pixel width.
// Fist pass - check to see whether entire url_string fits.
- int pixel_width_url_string = font.GetStringWidth(url_string);
+ int pixel_width_url_string = font.GetStringWidth(UTF16ToWideHack(url_string));
if (available_pixel_width >= pixel_width_url_string)
return url_string;
// Get the path substring, including query and reference.
size_t path_start_index = parsed.path.begin;
size_t path_len = parsed.path.len;
- std::wstring url_path_query_etc = url_string.substr(path_start_index);
- std::wstring url_path = url_string.substr(path_start_index, path_len);
+ string16 url_path_query_etc = url_string.substr(path_start_index);
+ string16 url_path = url_string.substr(path_start_index, path_len);
// Return general elided text if url minus the query fits.
- std::wstring url_minus_query = url_string.substr(0, path_start_index +
- path_len);
- if (available_pixel_width >= font.GetStringWidth(url_minus_query))
- return ElideTextWide(url_string, font, available_pixel_width, false);
+ string16 url_minus_query = url_string.substr(0, path_start_index + path_len);
+ if (available_pixel_width >=
+ font.GetStringWidth(UTF16ToWideHack(url_minus_query)))
+ return ElideText(url_string, font, available_pixel_width, false);
// Get Host.
- std::wstring url_host = UTF8ToWide(url.host());
+ string16 url_host = UTF8ToUTF16(url.host());
// Get domain and registry information from the URL.
- std::wstring url_domain = UTF8ToWide(
+ string16 url_domain = UTF8ToUTF16(
net::RegistryControlledDomainService::GetDomainAndRegistry(url));
if (url_domain.empty())
url_domain = url_host;
// Add port if required.
if (!url.port().empty()) {
- url_host += L":" + UTF8ToWide(url.port());
- url_domain += L":" + UTF8ToWide(url.port());
+ url_host += UTF8ToUTF16(":" + url.port());
+ url_domain += UTF8ToUTF16(":" + url.port());
}
// Get sub domain.
- std::wstring url_subdomain;
+ string16 url_subdomain;
size_t domain_start_index = url_host.find(url_domain);
if (domain_start_index > 0)
url_subdomain = url_host.substr(0, domain_start_index);
- if ((url_subdomain == L"www." || url_subdomain.empty() ||
+ static const string16 kWwwPrefix = UTF8ToUTF16("www.");
+ if ((url_subdomain == kWwwPrefix || url_subdomain.empty() ||
url.SchemeIsFile())) {
url_subdomain.clear();
}
@@ -131,93 +119,100 @@ std::wstring ElideUrl(const GURL& url,
// domain is now C: - this is a nice hack for eliding to work pleasantly.
if (url.SchemeIsFile()) {
// Split the path string using ":"
- std::vector<std::wstring> file_path_split;
- base::SplitString(url_path, L':', &file_path_split);
+ std::vector<string16> file_path_split;
+ base::SplitString(url_path, ':', &file_path_split);
if (file_path_split.size() > 1) { // File is of type "file:///C:/.."
url_host.clear();
url_domain.clear();
url_subdomain.clear();
- url_host = url_domain = file_path_split.at(0).substr(1) + L":";
+ static const string16 kColon = UTF8ToUTF16(":");
+ url_host = url_domain = file_path_split.at(0).substr(1) + kColon;
url_path_query_etc = url_path = file_path_split.at(1);
}
}
// Second Pass - remove scheme - the rest fits.
- int pixel_width_url_host = font.GetStringWidth(url_host);
- int pixel_width_url_path = font.GetStringWidth(url_path_query_etc);
+ int pixel_width_url_host = font.GetStringWidth(UTF16ToWideHack(url_host));
+ int pixel_width_url_path = font.GetStringWidth(UTF16ToWideHack(
+ url_path_query_etc));
if (available_pixel_width >=
pixel_width_url_host + pixel_width_url_path)
return url_host + url_path_query_etc;
// Third Pass: Subdomain, domain and entire path fits.
- int pixel_width_url_domain = font.GetStringWidth(url_domain);
- int pixel_width_url_subdomain = font.GetStringWidth(url_subdomain);
+ int pixel_width_url_domain = font.GetStringWidth(UTF16ToWideHack(url_domain));
+ int pixel_width_url_subdomain = font.GetStringWidth(UTF16ToWideHack(
+ url_subdomain));
if (available_pixel_width >=
pixel_width_url_subdomain + pixel_width_url_domain +
pixel_width_url_path)
return url_subdomain + url_domain + url_path_query_etc;
// Query element.
- std::wstring url_query;
- const int pixel_width_dots_trailer = font.GetStringWidth(kEllipsis);
+ string16 url_query;
+ const int kPixelWidthDotsTrailer = font.GetStringWidth(kEllipsis);
if (parsed.query.is_nonempty()) {
- url_query = std::wstring(L"?") + url_string.substr(parsed.query.begin);
+ url_query = UTF8ToUTF16("?") + url_string.substr(parsed.query.begin);
if (available_pixel_width >= (pixel_width_url_subdomain +
pixel_width_url_domain + pixel_width_url_path -
- font.GetStringWidth(url_query))) {
- return ElideTextWide(url_subdomain + url_domain + url_path_query_etc,
- font, available_pixel_width, false);
+ font.GetStringWidth(UTF16ToWideHack(url_query)))) {
+ return ElideText(url_subdomain + url_domain + url_path_query_etc,
+ font, available_pixel_width, false);
}
}
// Parse url_path using '/'.
- std::vector<std::wstring> url_path_elements;
- base::SplitString(url_path, L'/', &url_path_elements);
+ static const string16 kForwardSlash = UTF8ToUTF16("/");
+ std::vector<string16> url_path_elements;
+ base::SplitString(url_path, kForwardSlash[0], &url_path_elements);
// Get filename - note that for a path ending with /
// such as www.google.com/intl/ads/, the file name is ads/.
- int url_path_number_of_elements = static_cast<int> (url_path_elements.
- size());
- std::wstring url_filename;
+ size_t url_path_number_of_elements = url_path_elements.size();
+ DCHECK(url_path_number_of_elements != 0);
+ string16 url_filename;
if ((url_path_elements.at(url_path_number_of_elements - 1)).length() > 0) {
- url_filename = *(url_path_elements.end()-1);
+ url_filename = *(url_path_elements.end() - 1);
} else if (url_path_number_of_elements > 1) { // Path ends with a '/'.
url_filename = url_path_elements.at(url_path_number_of_elements - 2) +
- L'/';
+ kForwardSlash;
url_path_number_of_elements--;
}
+ DCHECK(url_path_number_of_elements != 0);
- const int kMaxNumberOfUrlPathElementsAllowed = 1024;
+ const size_t kMaxNumberOfUrlPathElementsAllowed = 1024;
if (url_path_number_of_elements <= 1 ||
url_path_number_of_elements > kMaxNumberOfUrlPathElementsAllowed) {
// No path to elide, or too long of a path (could overflow in loop below)
// Just elide this as a text string.
- return ElideTextWide(url_subdomain + url_domain + url_path_query_etc, font,
- available_pixel_width, false);
+ return ElideText(url_subdomain + url_domain + url_path_query_etc, font,
+ available_pixel_width, false);
}
// Start eliding the path and replacing elements by "../".
- std::wstring an_ellipsis_and_a_slash(kEllipsis);
- an_ellipsis_and_a_slash += L'/';
- int pixel_width_url_filename = font.GetStringWidth(url_filename);
- int pixel_width_dot_dot_slash = font.GetStringWidth(an_ellipsis_and_a_slash);
+ static const string16 kEllipsisAndSlash = WideToUTF16(kEllipsis) +
+ kForwardSlash;
+ int pixel_width_url_filename = font.GetStringWidth(UTF16ToWideHack(
+ url_filename));
+ int pixel_width_dot_dot_slash = font.GetStringWidth(UTF16ToWideHack(
+ kEllipsisAndSlash));
int pixel_width_slash = font.GetStringWidth(L"/");
int pixel_width_url_path_elements[kMaxNumberOfUrlPathElementsAllowed];
- for (int i = 0; i < url_path_number_of_elements; ++i) {
+ for (size_t i = 0; i < url_path_number_of_elements; ++i) {
pixel_width_url_path_elements[i] =
- font.GetStringWidth(url_path_elements.at(i));
+ font.GetStringWidth(UTF16ToWideHack(url_path_elements.at(i)));
}
// Check with both subdomain and domain.
- std::wstring elided_path;
+ string16 elided_path;
int pixel_width_elided_path;
- for (int i = url_path_number_of_elements - 1; i >= 1; --i) {
+ for (size_t i = url_path_number_of_elements - 1; i >= 1; --i) {
// Add the initial elements of the path.
elided_path.clear();
pixel_width_elided_path = 0;
- for (int j = 0; j < i; ++j) {
- elided_path += url_path_elements.at(j) + L'/';
+ for (size_t j = 0; j < i; ++j) {
+ elided_path += url_path_elements.at(j) + kForwardSlash;
pixel_width_elided_path += pixel_width_url_path_elements[j] +
pixel_width_slash;
}
@@ -227,7 +222,7 @@ std::wstring ElideUrl(const GURL& url,
elided_path += url_filename;
pixel_width_elided_path += pixel_width_url_filename;
} else {
- elided_path += an_ellipsis_and_a_slash + url_filename;
+ elided_path += kEllipsisAndSlash + url_filename;
pixel_width_elided_path += pixel_width_dot_dot_slash +
pixel_width_url_filename;
}
@@ -235,8 +230,8 @@ std::wstring ElideUrl(const GURL& url,
if (available_pixel_width >=
pixel_width_url_subdomain + pixel_width_url_domain +
pixel_width_elided_path) {
- return ElideTextWide(url_subdomain + url_domain + elided_path + url_query,
- font, available_pixel_width, false);
+ return ElideText(url_subdomain + url_domain + elided_path + url_query,
+ font, available_pixel_width, false);
}
}
@@ -245,22 +240,22 @@ std::wstring ElideUrl(const GURL& url,
// This is added only if the subdomain pixel width is larger than
// the pixel width of kEllipsis. Otherwise, subdomain remains,
// which means that this case has been resolved earlier.
- std::wstring url_elided_domain = url_subdomain + url_domain;
+ string16 url_elided_domain = url_subdomain + url_domain;
int pixel_width_url_elided_domain = pixel_width_url_domain;
- if (pixel_width_url_subdomain > pixel_width_dots_trailer) {
+ if (pixel_width_url_subdomain > kPixelWidthDotsTrailer) {
if (!url_subdomain.empty()) {
- url_elided_domain = kEllipsis + url_domain;
- pixel_width_url_elided_domain += pixel_width_dots_trailer;
+ url_elided_domain = kEllipsisAndSlash[0] + url_domain;
+ pixel_width_url_elided_domain += kPixelWidthDotsTrailer;
} else {
url_elided_domain = url_domain;
}
- for (int i = url_path_number_of_elements - 1; i >= 1; --i) {
+ for (size_t i = url_path_number_of_elements - 1; i >= 1; --i) {
// Add the initial elements of the path.
elided_path.clear();
pixel_width_elided_path = 0;
- for (int j = 0; j < i; ++j) {
- elided_path += url_path_elements.at(j) + L'/';
+ for (size_t j = 0; j < i; ++j) {
+ elided_path += url_path_elements.at(j) + kForwardSlash;
pixel_width_elided_path += pixel_width_url_path_elements[j] +
pixel_width_slash;
}
@@ -270,69 +265,73 @@ std::wstring ElideUrl(const GURL& url,
elided_path += url_filename;
pixel_width_elided_path += pixel_width_url_filename;
} else {
- elided_path += an_ellipsis_and_a_slash + url_filename;
+ elided_path += kEllipsisAndSlash + url_filename;
pixel_width_elided_path += pixel_width_dot_dot_slash +
pixel_width_url_filename;
}
if (available_pixel_width >=
pixel_width_url_elided_domain + pixel_width_elided_path) {
- return ElideTextWide(url_elided_domain + elided_path + url_query, font,
- available_pixel_width, false);
+ return ElideText(url_elided_domain + elided_path + url_query, font,
+ available_pixel_width, false);
}
}
}
// Return elided domain/../filename anyway.
- std::wstring final_elided_url_string(url_elided_domain);
- if ((available_pixel_width - font.GetStringWidth(url_elided_domain)) >
- pixel_width_dot_dot_slash + pixel_width_dots_trailer +
+ string16 final_elided_url_string(url_elided_domain);
+ int url_elided_domain_width = font.GetStringWidth(UTF16ToWideHack(
+ url_elided_domain));
+ if ((available_pixel_width - url_elided_domain_width) >
+ pixel_width_dot_dot_slash + kPixelWidthDotsTrailer +
font.GetStringWidth(L"UV")) // A hack to prevent trailing "../...".
final_elided_url_string += elided_path;
else
final_elided_url_string += url_path;
- return ElideTextWide(final_elided_url_string, font, available_pixel_width,
- false);
+ return ElideText(final_elided_url_string, font, available_pixel_width, false);
}
string16 ElideFilename(const FilePath& filename,
const gfx::Font& font,
int available_pixel_width) {
- int full_width = font.GetStringWidth(filename.ToWStringHack());
- if (full_width <= available_pixel_width) {
- std::wstring elided_name = filename.ToWStringHack();
- return GetDisplayStringInLTRDirectionality(elided_name);
- }
-
#if defined(OS_WIN)
- std::wstring extension = filename.Extension();
+ string16 filename_utf16 = filename.value();
+ string16 extension = filename.Extension();
+ string16 rootname = filename.BaseName().RemoveExtension().value();
#elif defined(OS_POSIX)
- std::wstring extension = base::SysNativeMBToWide(filename.Extension());
+ string16 filename_utf16 = WideToUTF16(base::SysNativeMBToWide(
+ filename.value()));
+ string16 extension = WideToUTF16(base::SysNativeMBToWide(
+ filename.Extension()));
+ string16 rootname = WideToUTF16(base::SysNativeMBToWide(
+ filename.BaseName().RemoveExtension().value()));
#endif
- std::wstring rootname =
- filename.BaseName().RemoveExtension().ToWStringHack();
+
+ int full_width = font.GetStringWidth(UTF16ToWideHack(filename_utf16));
+ if (full_width <= available_pixel_width)
+ return base::i18n::GetDisplayStringInLTRDirectionality(filename_utf16);
if (rootname.empty() || extension.empty()) {
- std::wstring elided_name = ElideTextWide(filename.ToWStringHack(), font,
- available_pixel_width, false);
- return GetDisplayStringInLTRDirectionality(elided_name);
+ string16 elided_name = ElideText(filename_utf16, font,
+ available_pixel_width, false);
+ return base::i18n::GetDisplayStringInLTRDirectionality(elided_name);
}
- int ext_width = font.GetStringWidth(extension);
- int root_width = font.GetStringWidth(rootname);
+ int ext_width = font.GetStringWidth(UTF16ToWideHack(extension));
+ int root_width = font.GetStringWidth(UTF16ToWideHack(rootname));
// We may have trimmed the path.
if (root_width + ext_width <= available_pixel_width) {
- std::wstring elided_name = rootname + extension;
- return GetDisplayStringInLTRDirectionality(elided_name);
+ string16 elided_name = rootname + extension;
+ return base::i18n::GetDisplayStringInLTRDirectionality(elided_name);
}
int available_root_width = available_pixel_width - ext_width;
- std::wstring elided_name =
- ElideTextWide(rootname, font, available_root_width, false);
+ string16 elided_name =
+ ElideText(rootname, font, available_root_width, false);
elided_name += extension;
- return GetDisplayStringInLTRDirectionality(elided_name);
+ return base::i18n::GetDisplayStringInLTRDirectionality(elided_name);
}
// This function adds an ellipsis at the end of the text if the text
@@ -371,7 +370,7 @@ string16 ElideText(const string16& text,
for (size_t guess = (lo + hi) / 2; guess != lo; guess = (lo + hi) / 2) {
// We check the length of the whole desired string at once to ensure we
// handle kerning/ligatures/etc. correctly.
- int guess_length = font.GetStringWidth(UTF16ToWide(
+ int guess_length = font.GetStringWidth(UTF16ToWideHack(
CutString(text, guess, elide_in_middle, true)));
// Check again that we didn't hit a Pango width overflow. If so, cut the
// current string in half and start over.
diff --git a/app/text_elider.h b/app/text_elider.h
index 8a5653d..36d12ae 100644
--- a/app/text_elider.h
+++ b/app/text_elider.h
@@ -32,10 +32,10 @@ namespace gfx {
// as an LTR string (using base::i18n::WrapStringWithLTRFormatting()) so that it
// is displayed properly in an RTL context. Please refer to
// http://crbug.com/6487 for more information.
-std::wstring ElideUrl(const GURL& url,
- const gfx::Font& font,
- int available_pixel_width,
- const std::wstring& languages);
+string16 ElideUrl(const GURL& url,
+ const gfx::Font& font,
+ int available_pixel_width,
+ const std::wstring& languages);
// Elides |text| to fit in |available_pixel_width|. If |elide_in_middle| is
// set the ellipsis is placed in the middle of the string; otherwise it is
diff --git a/app/text_elider_unittest.cc b/app/text_elider_unittest.cc
index cc65165..8bb224c 100644
--- a/app/text_elider_unittest.cc
+++ b/app/text_elider_unittest.cc
@@ -43,7 +43,7 @@ void RunTest(Testcase* testcases, size_t num_testcases) {
const GURL url(testcases[i].input);
// Should we test with non-empty language list?
// That's kinda redundant with net_util_unittests.
- EXPECT_EQ(testcases[i].output,
+ EXPECT_EQ(WideToUTF16(testcases[i].output),
ElideUrl(url, font, font.GetStringWidth(testcases[i].output),
std::wstring()));
}
diff --git a/chrome/browser/cocoa/status_bubble_mac.mm b/chrome/browser/cocoa/status_bubble_mac.mm
index 447d263..58da593 100644
--- a/chrome/browser/cocoa/status_bubble_mac.mm
+++ b/chrome/browser/cocoa/status_bubble_mac.mm
@@ -152,8 +152,8 @@ void StatusBubbleMac::SetURL(const GURL& url, const string16& languages) {
[font pointSize]);
string16 original_url_text = net::FormatUrl(url, UTF16ToUTF8(languages));
- string16 status = WideToUTF16(gfx::ElideUrl(url, font_chr, text_width,
- UTF16ToWideHack(languages)));
+ string16 status = gfx::ElideUrl(url, font_chr, text_width,
+ UTF16ToWideHack(languages));
SetText(status, true);
@@ -608,8 +608,8 @@ void StatusBubbleMac::ExpandBubble() {
NSFont* font = [[window_ contentView] font];
gfx::Font font_chr(base::SysNSStringToWide([font fontName]),
[font pointSize]);
- string16 expanded_url = WideToUTF16(gfx::ElideUrl(url_, font_chr,
- max_bubble_width, UTF16ToWide(languages_)));
+ string16 expanded_url = gfx::ElideUrl(url_, font_chr,
+ max_bubble_width, UTF16ToWideHack(languages_));
// Scale width from gfx::Font in view coordinates to window coordinates.
int required_width_for_string =
diff --git a/chrome/browser/gtk/status_bubble_gtk.cc b/chrome/browser/gtk/status_bubble_gtk.cc
index bc6f9b3..e99fea0 100644
--- a/chrome/browser/gtk/status_bubble_gtk.cc
+++ b/chrome/browser/gtk/status_bubble_gtk.cc
@@ -106,8 +106,8 @@ void StatusBubbleGtk::SetStatusTextToURL() {
// TODO(tc): We don't actually use gfx::Font as the font in the status
// bubble. We should extend gfx::ElideUrl to take some sort of pango font.
- url_text_ = WideToUTF8(gfx::ElideUrl(url_, gfx::Font(), desired_width,
- UTF16ToWideHack(languages_)));
+ url_text_ = UTF16ToUTF8(gfx::ElideUrl(url_, gfx::Font(), desired_width,
+ UTF16ToWideHack(languages_)));
SetStatusTextTo(url_text_);
}
diff --git a/chrome/browser/message_box_handler.cc b/chrome/browser/message_box_handler.cc
index 1f5831a..c39d1b7 100644
--- a/chrome/browser/message_box_handler.cc
+++ b/chrome/browser/message_box_handler.cc
@@ -46,10 +46,9 @@ static std::wstring GetTitle(Profile* profile,
// TODO(brettw) it should be easier than this to do the correct language
// handling without getting the accept language from the profile.
- string16 base_address = WideToUTF16(gfx::ElideUrl(frame_url.GetOrigin(),
+ string16 base_address = gfx::ElideUrl(frame_url.GetOrigin(),
gfx::Font(), 0,
- UTF8ToWide(
- profile->GetPrefs()->GetString(prefs::kAcceptLanguages))));
+ UTF8ToWide(profile->GetPrefs()->GetString(prefs::kAcceptLanguages)));
// Force URL to have LTR directionality.
base_address = base::i18n::GetDisplayStringInLTRDirectionality(
diff --git a/chrome/browser/views/bookmark_bar_view.cc b/chrome/browser/views/bookmark_bar_view.cc
index 8ce71e7..db38163 100644
--- a/chrome/browser/views/bookmark_bar_view.cc
+++ b/chrome/browser/views/bookmark_bar_view.cc
@@ -160,10 +160,9 @@ static std::wstring CreateToolTipForURLAndTitle(const gfx::Point& screen_loc,
// "/http://www.yahoo.com" when rendered, as is, in an RTL context since
// the Unicode BiDi algorithm puts certain characters on the left by
// default.
- std::wstring elided_url(gfx::ElideUrl(url, tt_font, max_width, languages));
- elided_url = UTF16ToWide(base::i18n::GetDisplayStringInLTRDirectionality(
- WideToUTF16(elided_url)));
- result.append(elided_url);
+ string16 elided_url(gfx::ElideUrl(url, tt_font, max_width, languages));
+ elided_url = base::i18n::GetDisplayStringInLTRDirectionality(elided_url);
+ result.append(UTF16ToWideHack(elided_url));
}
return result;
}
diff --git a/chrome/browser/views/status_bubble_views.cc b/chrome/browser/views/status_bubble_views.cc
index 2f92daf..234b6f0 100644
--- a/chrome/browser/views/status_bubble_views.cc
+++ b/chrome/browser/views/status_bubble_views.cc
@@ -646,8 +646,8 @@ void StatusBubbleViews::SetURL(const GURL& url, const string16& languages) {
popup_->GetBounds(&popup_bounds, true);
int text_width = static_cast<int>(popup_bounds.width() -
(kShadowThickness * 2) - kTextPositionX - kTextHorizPadding - 1);
- url_text_ = WideToUTF16(gfx::ElideUrl(url, view_->Label::font(),
- text_width, UTF16ToWide(languages)));
+ url_text_ = gfx::ElideUrl(url, view_->Label::font(),
+ text_width, UTF16ToWideHack(languages));
std::wstring original_url_text =
UTF16ToWideHack(net::FormatUrl(url, UTF16ToUTF8(languages)));
@@ -801,8 +801,8 @@ void StatusBubbleViews::ExpandBubble() {
gfx::Rect popup_bounds;
popup_->GetBounds(&popup_bounds, true);
int max_status_bubble_width = GetMaxStatusBubbleWidth();
- url_text_ = WideToUTF16(gfx::ElideUrl(url_, view_->Label::font(),
- max_status_bubble_width, UTF16ToWideHack(languages_)));
+ url_text_ = gfx::ElideUrl(url_, view_->Label::font(),
+ max_status_bubble_width, UTF16ToWideHack(languages_));
int expanded_bubble_width =std::max(GetStandardStatusBubbleWidth(),
std::min(view_->Label::font().GetStringWidth(UTF16ToWide(url_text_)) +
(kShadowThickness * 2) + kTextPositionX +
diff --git a/printing/printed_document.cc b/printing/printed_document.cc
index 04d8d3d..75d4b95 100644
--- a/printing/printed_document.cc
+++ b/printing/printed_document.cc
@@ -232,7 +232,8 @@ void PrintedDocument::PrintHeaderFooter(gfx::NativeDrawingContext context,
if (string_size.width() > bounding.width()) {
if (line == PageOverlays::kUrl) {
- output = gfx::ElideUrl(url(), font, bounding.width(), std::wstring());
+ output = UTF16ToWideHack(gfx::ElideUrl(url(), font, bounding.width(),
+ std::wstring()));
} else {
output = UTF16ToWideHack(gfx::ElideText(WideToUTF16Hack(output),
font, bounding.width(), false));
diff --git a/views/controls/label.cc b/views/controls/label.cc
index dcff7c8..9421444 100644
--- a/views/controls/label.cc
+++ b/views/controls/label.cc
@@ -423,7 +423,8 @@ void Label::CalculateDrawStringParams(std::wstring* paint_text,
if (url_set_) {
// TODO(jungshik) : Figure out how to get 'intl.accept_languages'
// preference and use it when calling ElideUrl.
- *paint_text = gfx::ElideUrl(url_, font_, width(), std::wstring());
+ *paint_text = UTF16ToWideHack(gfx::ElideUrl(url_, font_, width(),
+ std::wstring()));
// An URLs is always treated as an LTR text and therefore we should
// explicitly mark it as such if the locale is RTL so that URLs containing