diff options
-rw-r--r-- | chrome/browser/possible_url_model.cc | 5 | ||||
-rw-r--r-- | chrome/browser/ui/app_modal_dialogs/message_box_handler.cc | 3 | ||||
-rw-r--r-- | chrome/browser/ui/cocoa/status_bubble_mac.mm | 4 | ||||
-rw-r--r-- | chrome/browser/ui/gtk/status_bubble_gtk.cc | 2 | ||||
-rw-r--r-- | chrome/browser/ui/status_bubble.h | 2 | ||||
-rw-r--r-- | chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc | 4 | ||||
-rw-r--r-- | chrome/browser/ui/views/options/exceptions_page_view.cc | 4 | ||||
-rw-r--r-- | chrome/browser/ui/views/options/passwords_page_view.cc | 4 | ||||
-rw-r--r-- | chrome/browser/ui/views/status_bubble_views.cc | 4 | ||||
-rw-r--r-- | printing/printed_document.cc | 2 | ||||
-rw-r--r-- | ui/base/text/text_elider.cc | 13 | ||||
-rw-r--r-- | ui/base/text/text_elider.h | 4 | ||||
-rw-r--r-- | ui/base/text/text_elider_unittest.cc | 8 | ||||
-rw-r--r-- | views/controls/label.cc | 2 |
14 files changed, 30 insertions, 31 deletions
diff --git a/chrome/browser/possible_url_model.cc b/chrome/browser/possible_url_model.cc index c3e0815..73e9b46 100644 --- a/chrome/browser/possible_url_model.cc +++ b/chrome/browser/possible_url_model.cc @@ -80,9 +80,8 @@ void PossibleURLModel::Reload(Profile *profile) { void PossibleURLModel::OnHistoryQueryComplete(HistoryService::Handle h, history::QueryResults* result) { results_.resize(result->size()); - std::wstring languages = profile_ ? - UTF8ToWide(profile_->GetPrefs()->GetString(prefs::kAcceptLanguages)) : - std::wstring(); + std::string languages = profile_ ? + profile_->GetPrefs()->GetString(prefs::kAcceptLanguages) : std::string(); for (size_t i = 0; i < result->size(); ++i) { results_[i].url = (*result)[i].url(); results_[i].index = i; diff --git a/chrome/browser/ui/app_modal_dialogs/message_box_handler.cc b/chrome/browser/ui/app_modal_dialogs/message_box_handler.cc index 5124ac1..0de1b9a 100644 --- a/chrome/browser/ui/app_modal_dialogs/message_box_handler.cc +++ b/chrome/browser/ui/app_modal_dialogs/message_box_handler.cc @@ -47,8 +47,7 @@ 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 = ui::ElideUrl(frame_url.GetOrigin(), - gfx::Font(), 0, - UTF8ToWide(profile->GetPrefs()->GetString(prefs::kAcceptLanguages))); + gfx::Font(), 0, profile->GetPrefs()->GetString(prefs::kAcceptLanguages)); // Force URL to have LTR directionality. base_address = base::i18n::GetDisplayStringInLTRDirectionality( diff --git a/chrome/browser/ui/cocoa/status_bubble_mac.mm b/chrome/browser/ui/cocoa/status_bubble_mac.mm index f6fc627..aa77c16 100644 --- a/chrome/browser/ui/cocoa/status_bubble_mac.mm +++ b/chrome/browser/ui/cocoa/status_bubble_mac.mm @@ -151,7 +151,7 @@ void StatusBubbleMac::SetURL(const GURL& url, const string16& languages) { string16 original_url_text = net::FormatUrl(url, UTF16ToUTF8(languages)); string16 status = ui::ElideUrl(url, font_chr, text_width, - UTF16ToWideHack(languages)); + UTF16ToUTF8(languages)); SetText(status, true); @@ -591,7 +591,7 @@ void StatusBubbleMac::ExpandBubble() { gfx::Font font_chr(base::SysNSStringToUTF16([font fontName]), [font pointSize]); string16 expanded_url = ui::ElideUrl(url_, font_chr, - max_bubble_width, UTF16ToWideHack(languages_)); + max_bubble_width, UTF16ToUTF8(languages_)); // Scale width from gfx::Font in view coordinates to window coordinates. int required_width_for_string = diff --git a/chrome/browser/ui/gtk/status_bubble_gtk.cc b/chrome/browser/ui/gtk/status_bubble_gtk.cc index 98e08e2..de735bb 100644 --- a/chrome/browser/ui/gtk/status_bubble_gtk.cc +++ b/chrome/browser/ui/gtk/status_bubble_gtk.cc @@ -107,7 +107,7 @@ void StatusBubbleGtk::SetStatusTextToURL() { // TODO(tc): We don't actually use gfx::Font as the font in the status // bubble. We should extend ui::ElideUrl to take some sort of pango font. url_text_ = UTF16ToUTF8(ui::ElideUrl(url_, gfx::Font(), desired_width, - UTF16ToWideHack(languages_))); + UTF16ToUTF8(languages_))); SetStatusTextTo(url_text_); } diff --git a/chrome/browser/ui/status_bubble.h b/chrome/browser/ui/status_bubble.h index e7ddc15..43a30d2 100644 --- a/chrome/browser/ui/status_bubble.h +++ b/chrome/browser/ui/status_bubble.h @@ -36,6 +36,8 @@ class StatusBubble { // the bubble to fade in and remain open until given an empty URL or until // the Hide() method is called. languages is the value of Accept-Language // to determine what characters are understood by a user. + // TODO(tc): |languages| should be std::string (ascii)-- it's current + // usage is as bad as a WideToUTF8Hack. virtual void SetURL(const GURL& url, const string16& languages) = 0; // Skip the fade and instant-hide the bubble. diff --git a/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc b/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc index 6fd2f90..aee3bf8 100644 --- a/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc +++ b/chrome/browser/ui/views/bookmarks/bookmark_bar_view.cc @@ -1575,8 +1575,8 @@ std::wstring BookmarkBarView::CreateToolTipForURLAndTitle( // "/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 languages = - UTF8ToWide(profile->GetPrefs()->GetString(prefs::kAcceptLanguages)); + std::string languages = profile->GetPrefs()->GetString( + prefs::kAcceptLanguages); string16 elided_url(ui::ElideUrl(url, tt_font, max_width, languages)); elided_url = base::i18n::GetDisplayStringInLTRDirectionality(elided_url); result.append(UTF16ToWideHack(elided_url)); diff --git a/chrome/browser/ui/views/options/exceptions_page_view.cc b/chrome/browser/ui/views/options/exceptions_page_view.cc index ab96ed8..363c3e8 100644 --- a/chrome/browser/ui/views/options/exceptions_page_view.cc +++ b/chrome/browser/ui/views/options/exceptions_page_view.cc @@ -52,8 +52,8 @@ void ExceptionsTableModel::OnPasswordStoreRequestDone( pending_login_query_ = NULL; STLDeleteElements<PasswordRows>(&saved_signons_); - std::wstring languages = - UTF8ToWide(profile_->GetPrefs()->GetString(prefs::kAcceptLanguages)); + std::string languages = profile_->GetPrefs()->GetString( + prefs::kAcceptLanguages); for (size_t i = 0; i < result.size(); ++i) { saved_signons_.push_back(new PasswordRow( ui::SortedDisplayURL(result[i]->origin, languages), result[i])); diff --git a/chrome/browser/ui/views/options/passwords_page_view.cc b/chrome/browser/ui/views/options/passwords_page_view.cc index 705c4d1..9b714e0 100644 --- a/chrome/browser/ui/views/options/passwords_page_view.cc +++ b/chrome/browser/ui/views/options/passwords_page_view.cc @@ -115,8 +115,8 @@ void PasswordsTableModel::OnPasswordStoreRequestDone( STLDeleteElements<PasswordRows>(&saved_signons_); saved_signons_.resize(result.size(), NULL); - std::wstring languages = - UTF8ToWide(profile_->GetPrefs()->GetString(prefs::kAcceptLanguages)); + std::string languages = profile_->GetPrefs()->GetString( + prefs::kAcceptLanguages); for (size_t i = 0; i < result.size(); ++i) { saved_signons_[i] = new PasswordRow( ui::SortedDisplayURL(result[i]->origin, languages), result[i]); diff --git a/chrome/browser/ui/views/status_bubble_views.cc b/chrome/browser/ui/views/status_bubble_views.cc index 6fa60c1..f7d2f97 100644 --- a/chrome/browser/ui/views/status_bubble_views.cc +++ b/chrome/browser/ui/views/status_bubble_views.cc @@ -647,7 +647,7 @@ void StatusBubbleViews::SetURL(const GURL& url, const string16& languages) { int text_width = static_cast<int>(popup_bounds.width() - (kShadowThickness * 2) - kTextPositionX - kTextHorizPadding - 1); url_text_ = ui::ElideUrl(url, view_->Label::font(), - text_width, UTF16ToWideHack(languages)); + text_width, UTF16ToUTF8(languages)); std::wstring original_url_text = UTF16ToWideHack(net::FormatUrl(url, UTF16ToUTF8(languages))); @@ -801,7 +801,7 @@ void StatusBubbleViews::ExpandBubble() { gfx::Rect popup_bounds = popup_->GetWindowScreenBounds(); int max_status_bubble_width = GetMaxStatusBubbleWidth(); url_text_ = ui::ElideUrl(url_, view_->Label::font(), - max_status_bubble_width, UTF16ToWideHack(languages_)); + max_status_bubble_width, UTF16ToUTF8(languages_)); int expanded_bubble_width =std::max(GetStandardStatusBubbleWidth(), std::min(view_->Label::font().GetStringWidth(url_text_) + (kShadowThickness * 2) + kTextPositionX + diff --git a/printing/printed_document.cc b/printing/printed_document.cc index 1f2a939..45603b5 100644 --- a/printing/printed_document.cc +++ b/printing/printed_document.cc @@ -239,7 +239,7 @@ void PrintedDocument::PrintHeaderFooter(gfx::NativeDrawingContext context, if (string_size.width() > bounding.width()) { if (line == PageOverlays::kUrl) { output = UTF16ToWideHack(ui::ElideUrl(url(), font, bounding.width(), - std::wstring())); + std::string())); } else { output = UTF16ToWideHack(ui::ElideText(WideToUTF16Hack(output), font, bounding.width(), false)); diff --git a/ui/base/text/text_elider.cc b/ui/base/text/text_elider.cc index 590e464..9c42b2a 100644 --- a/ui/base/text/text_elider.cc +++ b/ui/base/text/text_elider.cc @@ -62,11 +62,11 @@ string16 CutString(const string16& text, string16 ElideUrl(const GURL& url, const gfx::Font& font, int available_pixel_width, - const std::wstring& languages) { + const std::string& languages) { // Get a formatted string and corresponding parsing of the url. url_parse::Parsed parsed; - string16 url_string = net::FormatUrl(url, WideToUTF8(languages), - net::kFormatUrlOmitAll, UnescapeRule::SPACES, &parsed, NULL, NULL); + string16 url_string = net::FormatUrl(url, languages, net::kFormatUrlOmitAll, + UnescapeRule::SPACES, &parsed, NULL, NULL); if (available_pixel_width <= 0) return url_string; @@ -388,15 +388,14 @@ string16 ElideText(const string16& text, return CutString(text, lo, elide_in_middle, true); } -// TODO(viettrungluu): convert |languages| to an |std::string|. SortedDisplayURL::SortedDisplayURL(const GURL& url, - const std::wstring& languages) { + const std::string& languages) { std::wstring host; - net::AppendFormattedHost(url, languages, &host, NULL, NULL); + net::AppendFormattedHost(url, UTF8ToWide(languages), &host, NULL, NULL); sort_host_ = WideToUTF16Hack(host); string16 host_minus_www = net::StripWWW(WideToUTF16Hack(host)); url_parse::Parsed parsed; - display_url_ = net::FormatUrl(url, WideToUTF8(languages), + display_url_ = net::FormatUrl(url, languages, net::kFormatUrlOmitAll, UnescapeRule::SPACES, &parsed, &prefix_end_, NULL); if (sort_host_.length() > host_minus_www.length()) { diff --git a/ui/base/text/text_elider.h b/ui/base/text/text_elider.h index 7c4a946..86424df 100644 --- a/ui/base/text/text_elider.h +++ b/ui/base/text/text_elider.h @@ -34,7 +34,7 @@ namespace ui { string16 ElideUrl(const GURL& url, const gfx::Font& font, int available_pixel_width, - const std::wstring& languages); + const std::string& 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 @@ -61,7 +61,7 @@ string16 ElideFilename(const FilePath& filename, // SortedDisplayURL is relatively cheap and supports value semantics. class SortedDisplayURL { public: - SortedDisplayURL(const GURL& url, const std::wstring& languages); + SortedDisplayURL(const GURL& url, const std::string& languages); SortedDisplayURL(); ~SortedDisplayURL(); diff --git a/ui/base/text/text_elider_unittest.cc b/ui/base/text/text_elider_unittest.cc index 57e0d40..933cc5f 100644 --- a/ui/base/text/text_elider_unittest.cc +++ b/ui/base/text/text_elider_unittest.cc @@ -49,7 +49,7 @@ void RunTest(Testcase* testcases, size_t num_testcases) { EXPECT_EQ(UTF8ToUTF16(testcases[i].output), ElideUrl(url, font, font.GetStringWidth(UTF8ToUTF16(testcases[i].output)), - std::wstring())); + std::string())); } } @@ -256,7 +256,7 @@ TEST(TextEliderTest, ElideTextLongStrings) { // Verifies display_url is set correctly. TEST(TextEliderTest, SortedDisplayURL) { - ui::SortedDisplayURL d_url(GURL("http://www.google.com"), std::wstring()); + ui::SortedDisplayURL d_url(GURL("http://www.google.com"), std::string()); EXPECT_EQ("www.google.com", UTF16ToASCII(d_url.display_url())); } @@ -291,8 +291,8 @@ TEST(TextEliderTest, SortedDisplayURLCompare) { }; for (size_t i = 0; i < arraysize(tests); ++i) { - ui::SortedDisplayURL url1(GURL(tests[i].a), std::wstring()); - ui::SortedDisplayURL url2(GURL(tests[i].b), std::wstring()); + ui::SortedDisplayURL url1(GURL(tests[i].a), std::string()); + ui::SortedDisplayURL url2(GURL(tests[i].b), std::string()); EXPECT_EQ(tests[i].compare_result, url1.Compare(url2, collator.get())); EXPECT_EQ(-tests[i].compare_result, url2.Compare(url1, collator.get())); } diff --git a/views/controls/label.cc b/views/controls/label.cc index 810769a..5bc1a2a 100644 --- a/views/controls/label.cc +++ b/views/controls/label.cc @@ -439,7 +439,7 @@ void Label::CalculateDrawStringParams(std::wstring* paint_text, // TODO(jungshik) : Figure out how to get 'intl.accept_languages' // preference and use it when calling ElideUrl. *paint_text = UTF16ToWideHack( - ui::ElideUrl(url_, font_, GetAvailableRect().width(), std::wstring())); + ui::ElideUrl(url_, font_, GetAvailableRect().width(), std::string())); // 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 |