diff options
author | tony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-03 21:37:46 +0000 |
---|---|---|
committer | tony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-03 21:37:46 +0000 |
commit | 43d259d2f2653c30652d09856bcbfbcfdf639f2e (patch) | |
tree | 27ad2638eb5637a72834d25c1dd4615f791eb6c5 /chrome | |
parent | e6ce614c0c87180173566ee6438410ede82ae89e (diff) | |
download | chromium_src-43d259d2f2653c30652d09856bcbfbcfdf639f2e.zip chromium_src-43d259d2f2653c30652d09856bcbfbcfdf639f2e.tar.gz chromium_src-43d259d2f2653c30652d09856bcbfbcfdf639f2e.tar.bz2 |
Remove wstrings from status bubble code.
Use string16 instead.
BUG=23581
Review URL: http://codereview.chromium.org/3200010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@58545 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/browser.cc | 15 | ||||
-rw-r--r-- | chrome/browser/cocoa/status_bubble_mac.h | 7 | ||||
-rw-r--r-- | chrome/browser/cocoa/status_bubble_mac.mm | 12 | ||||
-rw-r--r-- | chrome/browser/cocoa/status_bubble_mac_unittest.mm | 111 | ||||
-rw-r--r-- | chrome/browser/gtk/status_bubble_gtk.cc | 8 | ||||
-rw-r--r-- | chrome/browser/gtk/status_bubble_gtk.h | 6 | ||||
-rw-r--r-- | chrome/browser/status_bubble.h | 6 | ||||
-rw-r--r-- | chrome/browser/views/status_bubble_views.cc | 55 | ||||
-rw-r--r-- | chrome/browser/views/status_bubble_views.h | 11 |
9 files changed, 120 insertions, 111 deletions
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc index 6c4385b..a5242c4 100644 --- a/chrome/browser/browser.cc +++ b/chrome/browser/browser.cc @@ -2479,7 +2479,8 @@ void Browser::TabSelectedAt(TabContents* old_contents, status_bubble->Hide(); // Show the loading state (if any). - status_bubble->SetStatus(GetSelectedTabContents()->GetStatusText()); + status_bubble->SetStatus(WideToUTF16Hack( + GetSelectedTabContents()->GetStatusText())); } if (HasFindBarController()) { @@ -2639,8 +2640,10 @@ void Browser::LoadingStateChanged(TabContents* source) { if (source == GetSelectedTabContents()) { UpdateReloadStopState(source->is_loading(), false); - if (GetStatusBubble()) - GetStatusBubble()->SetStatus(GetSelectedTabContents()->GetStatusText()); + if (GetStatusBubble()) { + GetStatusBubble()->SetStatus(WideToUTF16( + GetSelectedTabContents()->GetStatusText())); + } if (source->is_loading()) UpdateZoomCommandsForTabState(); @@ -2720,7 +2723,7 @@ void Browser::ContentsMouseEvent( if (source == GetSelectedTabContents()) { GetStatusBubble()->MouseMoved(location, !motion); if (!motion) - GetStatusBubble()->SetURL(GURL(), std::wstring()); + GetStatusBubble()->SetURL(GURL(), string16()); } } @@ -2731,7 +2734,7 @@ void Browser::UpdateTargetURL(TabContents* source, const GURL& url) { if (source == GetSelectedTabContents()) { PrefService* prefs = profile_->GetPrefs(); GetStatusBubble()->SetURL( - url, UTF8ToWide(prefs->GetString(prefs::kAcceptLanguages))); + url, UTF8ToUTF16(prefs->GetString(prefs::kAcceptLanguages))); } } @@ -3481,7 +3484,7 @@ void Browser::ProcessPendingUIUpdates() { // Updating the URL happens synchronously in ScheduleUIUpdate. if (flags & TabContents::INVALIDATE_LOAD && GetStatusBubble()) - GetStatusBubble()->SetStatus(contents->GetStatusText()); + GetStatusBubble()->SetStatus(WideToUTF16(contents->GetStatusText())); if (flags & (TabContents::INVALIDATE_TAB | TabContents::INVALIDATE_TITLE)) { diff --git a/chrome/browser/cocoa/status_bubble_mac.h b/chrome/browser/cocoa/status_bubble_mac.h index 34599ae..c1a722f 100644 --- a/chrome/browser/cocoa/status_bubble_mac.h +++ b/chrome/browser/cocoa/status_bubble_mac.h @@ -11,6 +11,7 @@ #import <Cocoa/Cocoa.h> #import <QuartzCore/QuartzCore.h> +#include "base/string16.h" #include "base/task.h" #include "chrome/browser/status_bubble.h" @@ -34,8 +35,8 @@ class StatusBubbleMac : public StatusBubble { virtual ~StatusBubbleMac(); // StatusBubble implementation. - virtual void SetStatus(const std::wstring& status); - virtual void SetURL(const GURL& url, const std::wstring& languages); + virtual void SetStatus(const string16& status); + virtual void SetURL(const GURL& url, const string16& languages); virtual void Hide(); virtual void MouseMoved(const gfx::Point& location, bool left_content); virtual void UpdateDownloadShelfVisibility(bool visible); @@ -62,7 +63,7 @@ class StatusBubbleMac : public StatusBubble { void SetState(StatusBubbleState state); // Sets the bubble text for SetStatus and SetURL. - void SetText(const std::wstring& text, bool is_url); + void SetText(const string16& text, bool is_url); // Construct the window/widget if it does not already exist. (Safe to call if // it does.) diff --git a/chrome/browser/cocoa/status_bubble_mac.mm b/chrome/browser/cocoa/status_bubble_mac.mm index 9b6e063d4..98d3e07 100644 --- a/chrome/browser/cocoa/status_bubble_mac.mm +++ b/chrome/browser/cocoa/status_bubble_mac.mm @@ -11,6 +11,7 @@ #include "base/message_loop.h" #include "base/string_util.h" #include "base/sys_string_conversions.h" +#include "base/utf_string_conversions.h" #import "chrome/browser/cocoa/bubble_view.h" #include "gfx/point.h" #include "googleurl/src/gurl.h" @@ -112,13 +113,13 @@ StatusBubbleMac::~StatusBubbleMac() { } } -void StatusBubbleMac::SetStatus(const std::wstring& status) { +void StatusBubbleMac::SetStatus(const string16& status) { Create(); SetText(status, false); } -void StatusBubbleMac::SetURL(const GURL& url, const std::wstring& languages) { +void StatusBubbleMac::SetURL(const GURL& url, const string16& languages) { Create(); NSRect frame = [window_ frame]; @@ -129,17 +130,18 @@ void StatusBubbleMac::SetURL(const GURL& url, const std::wstring& languages) { gfx::Font font_chr(base::SysNSStringToWide([font fontName]), [font pointSize]); - std::wstring status = gfx::ElideUrl(url, font_chr, text_width, languages); + string16 status = WideToUTF16(gfx::ElideUrl(url, font_chr, text_width, + UTF16ToWideHack(languages))); SetText(status, true); } -void StatusBubbleMac::SetText(const std::wstring& text, bool is_url) { +void StatusBubbleMac::SetText(const string16& text, bool is_url) { // The status bubble allows the status and URL strings to be set // independently. Whichever was set non-empty most recently will be the // value displayed. When both are empty, the status bubble hides. - NSString* text_ns = base::SysWideToNSString(text); + NSString* text_ns = base::SysUTF16ToNSString(text); NSString** main; NSString** backup; diff --git a/chrome/browser/cocoa/status_bubble_mac_unittest.mm b/chrome/browser/cocoa/status_bubble_mac_unittest.mm index 1da754d..d1e2b73 100644 --- a/chrome/browser/cocoa/status_bubble_mac_unittest.mm +++ b/chrome/browser/cocoa/status_bubble_mac_unittest.mm @@ -6,6 +6,7 @@ #include "base/scoped_nsobject.h" #include "base/scoped_ptr.h" +#include "base/utf_string_conversions.h" #import "chrome/browser/cocoa/bubble_view.h" #import "chrome/browser/cocoa/browser_test_helper.h" #import "chrome/browser/cocoa/cocoa_test_helper.h" @@ -112,42 +113,42 @@ class StatusBubbleMacTest : public CocoaTest { }; TEST_F(StatusBubbleMacTest, SetStatus) { - bubble_->SetStatus(L""); - bubble_->SetStatus(L"This is a test"); + bubble_->SetStatus(string16()); + bubble_->SetStatus(UTF8ToUTF16("This is a test")); EXPECT_NSEQ(@"This is a test", GetText()); EXPECT_TRUE(IsVisible()); // Set the status to the exact same thing again - bubble_->SetStatus(L"This is a test"); + bubble_->SetStatus(UTF8ToUTF16("This is a test")); EXPECT_NSEQ(@"This is a test", GetText()); // Hide it - bubble_->SetStatus(L""); + bubble_->SetStatus(string16()); EXPECT_FALSE(IsVisible()); } TEST_F(StatusBubbleMacTest, SetURL) { - bubble_->SetURL(GURL(), L""); + bubble_->SetURL(GURL(), string16()); EXPECT_FALSE(IsVisible()); - bubble_->SetURL(GURL("bad url"), L""); + bubble_->SetURL(GURL("bad url"), string16()); EXPECT_FALSE(IsVisible()); - bubble_->SetURL(GURL("http://"), L""); + bubble_->SetURL(GURL("http://"), string16()); EXPECT_TRUE(IsVisible()); EXPECT_NSEQ(@"http:", GetURLText()); - bubble_->SetURL(GURL("about:blank"), L""); + bubble_->SetURL(GURL("about:blank"), string16()); EXPECT_TRUE(IsVisible()); EXPECT_NSEQ(@"about:blank", GetURLText()); - bubble_->SetURL(GURL("foopy://"), L""); + bubble_->SetURL(GURL("foopy://"), string16()); EXPECT_TRUE(IsVisible()); EXPECT_NSEQ(@"foopy://", GetURLText()); - bubble_->SetURL(GURL("http://www.cnn.com"), L""); + bubble_->SetURL(GURL("http://www.cnn.com"), string16()); EXPECT_TRUE(IsVisible()); EXPECT_NSEQ(@"www.cnn.com", GetURLText()); } // Test hiding bubble that's already hidden. TEST_F(StatusBubbleMacTest, Hides) { - bubble_->SetStatus(L"Showing"); + bubble_->SetStatus(UTF8ToUTF16("Showing")); EXPECT_TRUE(IsVisible()); bubble_->Hide(); EXPECT_FALSE(IsVisible()); @@ -158,27 +159,27 @@ TEST_F(StatusBubbleMacTest, Hides) { // Test the "main"/"backup" behavior in StatusBubbleMac::SetText(). TEST_F(StatusBubbleMacTest, SetStatusAndURL) { EXPECT_FALSE(IsVisible()); - bubble_->SetStatus(L"Status"); + bubble_->SetStatus(UTF8ToUTF16("Status")); EXPECT_TRUE(IsVisible()); EXPECT_NSEQ(@"Status", GetBubbleViewText()); - bubble_->SetURL(GURL("http://www.nytimes.com"), L""); + bubble_->SetURL(GURL("http://www.nytimes.com"), string16()); EXPECT_TRUE(IsVisible()); EXPECT_NSEQ(@"www.nytimes.com", GetBubbleViewText()); - bubble_->SetURL(GURL(), L""); + bubble_->SetURL(GURL(), string16()); EXPECT_TRUE(IsVisible()); EXPECT_NSEQ(@"Status", GetBubbleViewText()); - bubble_->SetStatus(L""); + bubble_->SetStatus(string16()); EXPECT_FALSE(IsVisible()); - bubble_->SetURL(GURL("http://www.nytimes.com"), L""); + bubble_->SetURL(GURL("http://www.nytimes.com"), string16()); EXPECT_TRUE(IsVisible()); EXPECT_NSEQ(@"www.nytimes.com", GetBubbleViewText()); - bubble_->SetStatus(L"Status"); + bubble_->SetStatus(UTF8ToUTF16("Status")); EXPECT_TRUE(IsVisible()); EXPECT_NSEQ(@"Status", GetBubbleViewText()); - bubble_->SetStatus(L""); + bubble_->SetStatus(string16()); EXPECT_TRUE(IsVisible()); EXPECT_NSEQ(@"www.nytimes.com", GetBubbleViewText()); - bubble_->SetURL(GURL(), L""); + bubble_->SetURL(GURL(), string16()); EXPECT_FALSE(IsVisible()); } @@ -194,7 +195,7 @@ TEST_F(StatusBubbleMacTest, StateTransitions) { States()->clear(); EXPECT_TRUE(States()->empty()); - bubble_->SetStatus(L""); + bubble_->SetStatus(string16()); EXPECT_FALSE(IsVisible()); EXPECT_EQ(StatusBubbleMac::kBubbleHidden, GetState()); EXPECT_TRUE(States()->empty()); // no change from initial kBubbleHidden state @@ -202,7 +203,7 @@ TEST_F(StatusBubbleMacTest, StateTransitions) { // Next, a few ordinary cases // Test StartShowing from kBubbleHidden - bubble_->SetStatus(L"Status"); + bubble_->SetStatus(UTF8ToUTF16("Status")); EXPECT_TRUE(IsVisible()); // Check GetState before checking States to make sure that all state // transitions have been flushed to States. @@ -214,19 +215,19 @@ TEST_F(StatusBubbleMacTest, StateTransitions) { // Test StartShowing from kBubbleShown with the same message States()->clear(); - bubble_->SetStatus(L"Status"); + bubble_->SetStatus(UTF8ToUTF16("Status")); EXPECT_TRUE(IsVisible()); EXPECT_EQ(StatusBubbleMac::kBubbleShown, GetState()); EXPECT_TRUE(States()->empty()); // Test StartShowing from kBubbleShown with a different message - bubble_->SetStatus(L"New Status"); + bubble_->SetStatus(UTF8ToUTF16("New Status")); EXPECT_TRUE(IsVisible()); EXPECT_EQ(StatusBubbleMac::kBubbleShown, GetState()); EXPECT_TRUE(States()->empty()); // Test StartHiding from kBubbleShown - bubble_->SetStatus(L""); + bubble_->SetStatus(string16()); EXPECT_FALSE(IsVisible()); // Check GetState before checking States to make sure that all state // transitions have been flushed to States. @@ -238,7 +239,7 @@ TEST_F(StatusBubbleMacTest, StateTransitions) { // Test StartHiding from kBubbleHidden States()->clear(); - bubble_->SetStatus(L""); + bubble_->SetStatus(string16()); EXPECT_FALSE(IsVisible()); EXPECT_EQ(StatusBubbleMac::kBubbleHidden, GetState()); EXPECT_TRUE(States()->empty()); @@ -246,101 +247,103 @@ TEST_F(StatusBubbleMacTest, StateTransitions) { // Now, the edge cases // Test StartShowing from kBubbleShowingTimer - bubble_->SetStatus(L"Status"); + bubble_->SetStatus(UTF8ToUTF16("Status")); SetState(StatusBubbleMac::kBubbleShowingTimer); [GetWindow() setAlphaValue:0.0]; States()->clear(); EXPECT_TRUE(States()->empty()); - bubble_->SetStatus(L"Status"); + bubble_->SetStatus(UTF8ToUTF16("Status")); EXPECT_EQ(StatusBubbleMac::kBubbleShown, GetState()); EXPECT_EQ(2u, States()->size()); EXPECT_EQ(StatusBubbleMac::kBubbleShowingFadeIn, StateAt(0)); EXPECT_EQ(StatusBubbleMac::kBubbleShown, StateAt(1)); // Test StartShowing from kBubbleShowingFadeIn - bubble_->SetStatus(L"Status"); + bubble_->SetStatus(UTF8ToUTF16("Status")); SetState(StatusBubbleMac::kBubbleShowingFadeIn); [GetWindow() setAlphaValue:0.5]; States()->clear(); EXPECT_TRUE(States()->empty()); - bubble_->SetStatus(L"Status"); + bubble_->SetStatus(UTF8ToUTF16("Status")); // The actual state values can't be tested in immediate_ mode because // the window wasn't actually fading in. Without immediate_ mode, // expect kBubbleShown. - bubble_->SetStatus(L""); // Go back to a deterministic state. + bubble_->SetStatus(string16()); // Go back to a deterministic state. // Test StartShowing from kBubbleHidingTimer - bubble_->SetStatus(L""); + bubble_->SetStatus(string16()); SetState(StatusBubbleMac::kBubbleHidingTimer); [GetWindow() setAlphaValue:1.0]; States()->clear(); EXPECT_TRUE(States()->empty()); - bubble_->SetStatus(L"Status"); + bubble_->SetStatus(UTF8ToUTF16("Status")); EXPECT_EQ(StatusBubbleMac::kBubbleShown, GetState()); EXPECT_EQ(1u, States()->size()); EXPECT_EQ(StatusBubbleMac::kBubbleShown, StateAt(0)); // Test StartShowing from kBubbleHidingFadeOut - bubble_->SetStatus(L""); + bubble_->SetStatus(string16()); SetState(StatusBubbleMac::kBubbleHidingFadeOut); [GetWindow() setAlphaValue:0.5]; States()->clear(); EXPECT_TRUE(States()->empty()); - bubble_->SetStatus(L"Status"); + bubble_->SetStatus(UTF8ToUTF16("Status")); EXPECT_EQ(StatusBubbleMac::kBubbleShown, GetState()); EXPECT_EQ(2u, States()->size()); EXPECT_EQ(StatusBubbleMac::kBubbleShowingFadeIn, StateAt(0)); EXPECT_EQ(StatusBubbleMac::kBubbleShown, StateAt(1)); // Test StartHiding from kBubbleShowingTimer - bubble_->SetStatus(L"Status"); + bubble_->SetStatus(UTF8ToUTF16("Status")); SetState(StatusBubbleMac::kBubbleShowingTimer); [GetWindow() setAlphaValue:0.0]; States()->clear(); EXPECT_TRUE(States()->empty()); - bubble_->SetStatus(L""); + bubble_->SetStatus(string16()); EXPECT_EQ(StatusBubbleMac::kBubbleHidden, GetState()); EXPECT_EQ(1u, States()->size()); EXPECT_EQ(StatusBubbleMac::kBubbleHidden, StateAt(0)); // Test StartHiding from kBubbleShowingFadeIn - bubble_->SetStatus(L"Status"); + bubble_->SetStatus(UTF8ToUTF16("Status")); SetState(StatusBubbleMac::kBubbleShowingFadeIn); [GetWindow() setAlphaValue:0.5]; States()->clear(); EXPECT_TRUE(States()->empty()); - bubble_->SetStatus(L""); + bubble_->SetStatus(string16()); EXPECT_EQ(StatusBubbleMac::kBubbleHidden, GetState()); EXPECT_EQ(2u, States()->size()); EXPECT_EQ(StatusBubbleMac::kBubbleHidingFadeOut, StateAt(0)); EXPECT_EQ(StatusBubbleMac::kBubbleHidden, StateAt(1)); // Test StartHiding from kBubbleHidingTimer - bubble_->SetStatus(L""); + bubble_->SetStatus(string16()); SetState(StatusBubbleMac::kBubbleHidingTimer); [GetWindow() setAlphaValue:1.0]; States()->clear(); EXPECT_TRUE(States()->empty()); - bubble_->SetStatus(L""); + bubble_->SetStatus(string16()); // The actual state values can't be tested in immediate_ mode because // the timer wasn't actually running. Without immediate_ mode, expect // kBubbleHidingFadeOut and kBubbleHidden. - bubble_->SetStatus(L"Status"); // Go back to a deterministic state. + // Go back to a deterministic state. + bubble_->SetStatus(UTF8ToUTF16("Status")); // Test StartHiding from kBubbleHidingFadeOut - bubble_->SetStatus(L""); + bubble_->SetStatus(string16()); SetState(StatusBubbleMac::kBubbleHidingFadeOut); [GetWindow() setAlphaValue:0.5]; States()->clear(); EXPECT_TRUE(States()->empty()); - bubble_->SetStatus(L""); + bubble_->SetStatus(string16()); // The actual state values can't be tested in immediate_ mode because // the window wasn't actually fading out. Without immediate_ mode, expect // kBubbleHidden. - bubble_->SetStatus(L"Status"); // Go back to a deterministic state. + // Go back to a deterministic state. + bubble_->SetStatus(UTF8ToUTF16("Status")); // Test Hide from kBubbleHidden - bubble_->SetStatus(L""); + bubble_->SetStatus(string16()); EXPECT_EQ(StatusBubbleMac::kBubbleHidden, GetState()); States()->clear(); EXPECT_TRUE(States()->empty()); @@ -349,7 +352,7 @@ TEST_F(StatusBubbleMacTest, StateTransitions) { EXPECT_TRUE(States()->empty()); // Test Hide from kBubbleShowingTimer - bubble_->SetStatus(L"Status"); + bubble_->SetStatus(UTF8ToUTF16("Status")); SetState(StatusBubbleMac::kBubbleShowingTimer); [GetWindow() setAlphaValue:0.0]; States()->clear(); @@ -360,7 +363,7 @@ TEST_F(StatusBubbleMacTest, StateTransitions) { EXPECT_EQ(StatusBubbleMac::kBubbleHidden, StateAt(0)); // Test Hide from kBubbleShowingFadeIn - bubble_->SetStatus(L"Status"); + bubble_->SetStatus(UTF8ToUTF16("Status")); SetState(StatusBubbleMac::kBubbleShowingFadeIn); [GetWindow() setAlphaValue:0.5]; States()->clear(); @@ -372,7 +375,7 @@ TEST_F(StatusBubbleMacTest, StateTransitions) { EXPECT_EQ(StatusBubbleMac::kBubbleHidden, StateAt(1)); // Test Hide from kBubbleShown - bubble_->SetStatus(L"Status"); + bubble_->SetStatus(UTF8ToUTF16("Status")); States()->clear(); EXPECT_TRUE(States()->empty()); bubble_->Hide(); @@ -381,7 +384,7 @@ TEST_F(StatusBubbleMacTest, StateTransitions) { EXPECT_EQ(StatusBubbleMac::kBubbleHidden, StateAt(0)); // Test Hide from kBubbleHidingTimer - bubble_->SetStatus(L"Status"); + bubble_->SetStatus(UTF8ToUTF16("Status")); SetState(StatusBubbleMac::kBubbleHidingTimer); States()->clear(); EXPECT_TRUE(States()->empty()); @@ -391,7 +394,7 @@ TEST_F(StatusBubbleMacTest, StateTransitions) { EXPECT_EQ(StatusBubbleMac::kBubbleHidden, StateAt(0)); // Test Hide from kBubbleHidingFadeOut - bubble_->SetStatus(L"Status"); + bubble_->SetStatus(UTF8ToUTF16("Status")); SetState(StatusBubbleMac::kBubbleHidingFadeOut); [GetWindow() setAlphaValue:0.5]; States()->clear(); @@ -410,7 +413,7 @@ TEST_F(StatusBubbleMacTest, Delete) { // Create then delete while visible. bubble = new StatusBubbleMac(window, nil); - bubble->SetStatus(L"showing"); + bubble->SetStatus(UTF8ToUTF16("showing")); delete bubble; } @@ -423,7 +426,7 @@ TEST_F(StatusBubbleMacTest, UpdateSizeAndPosition) { // Create a status bubble (with contents) and call resize (without actually // resizing); the frame size shouldn't change. - bubble_->SetStatus(L"UpdateSizeAndPosition test"); + bubble_->SetStatus(UTF8ToUTF16("UpdateSizeAndPosition test")); ASSERT_TRUE(GetWindow()); NSRect rect_before = [GetWindow() frame]; bubble_->UpdateSizeAndPosition(); @@ -464,7 +467,7 @@ TEST_F(StatusBubbleMacTest, MovingWindowUpdatesPosition) { NSWindow* window = test_window(); // Show the bubble and make sure it has the same origin as |window|. - bubble_->SetStatus(L"Showing"); + bubble_->SetStatus(UTF8ToUTF16("Showing")); NSWindow* child = GetWindow(); EXPECT_TRUE(NSEqualPoints([window frame].origin, [child frame].origin)); @@ -473,7 +476,7 @@ TEST_F(StatusBubbleMacTest, MovingWindowUpdatesPosition) { NSRect frame = [window frame]; frame.origin.x += 50; [window setFrame:frame display:YES]; - bubble_->SetStatus(L"Reshowing"); + bubble_->SetStatus(UTF8ToUTF16("Reshowing")); // The bubble should reattach in the correct location. child = GetWindow(); diff --git a/chrome/browser/gtk/status_bubble_gtk.cc b/chrome/browser/gtk/status_bubble_gtk.cc index 99fbd32..bc6f9b3 100644 --- a/chrome/browser/gtk/status_bubble_gtk.cc +++ b/chrome/browser/gtk/status_bubble_gtk.cc @@ -57,8 +57,8 @@ StatusBubbleGtk::~StatusBubbleGtk() { container_.Destroy(); } -void StatusBubbleGtk::SetStatus(const std::wstring& status_text_wide) { - std::string status_text = WideToUTF8(status_text_wide); +void StatusBubbleGtk::SetStatus(const string16& status_text_wide) { + std::string status_text = UTF16ToUTF8(status_text_wide); if (status_text_ == status_text) return; @@ -72,7 +72,7 @@ void StatusBubbleGtk::SetStatus(const std::wstring& status_text_wide) { } } -void StatusBubbleGtk::SetURL(const GURL& url, const std::wstring& languages) { +void StatusBubbleGtk::SetURL(const GURL& url, const string16& languages) { url_ = url; languages_ = languages; @@ -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 gfx::ElideUrl to take some sort of pango font. url_text_ = WideToUTF8(gfx::ElideUrl(url_, gfx::Font(), desired_width, - languages_)); + UTF16ToWideHack(languages_))); SetStatusTextTo(url_text_); } diff --git a/chrome/browser/gtk/status_bubble_gtk.h b/chrome/browser/gtk/status_bubble_gtk.h index 18942ec..1706665 100644 --- a/chrome/browser/gtk/status_bubble_gtk.h +++ b/chrome/browser/gtk/status_bubble_gtk.h @@ -39,8 +39,8 @@ class StatusBubbleGtk : public StatusBubble, int y_offset() const { return y_offset_; } // StatusBubble implementation. - virtual void SetStatus(const std::wstring& status); - virtual void SetURL(const GURL& url, const std::wstring& languages); + virtual void SetStatus(const string16& status); + virtual void SetURL(const GURL& url, const string16& languages); virtual void Hide(); virtual void MouseMoved(const gfx::Point& location, bool left_content); @@ -129,7 +129,7 @@ class StatusBubbleGtk : public StatusBubble, // Used to determine the character set that the user can read (for eliding // the url text). - std::wstring languages_; + string16 languages_; // A timer that hides our window after a delay. base::OneShotTimer<StatusBubbleGtk> hide_timer_; diff --git a/chrome/browser/status_bubble.h b/chrome/browser/status_bubble.h index 86440fb..e7ddc15 100644 --- a/chrome/browser/status_bubble.h +++ b/chrome/browser/status_bubble.h @@ -6,7 +6,7 @@ #define CHROME_BROWSER_STATUS_BUBBLE_H_ #pragma once -#include <string> +#include "base/string16.h" class GURL; namespace gfx { @@ -30,13 +30,13 @@ class StatusBubble { // when the cursor exits a link) will set the status bubble back to its // status text. To hide the status bubble again, either call SetStatus // with an empty string, or call Hide(). - virtual void SetStatus(const std::wstring& status) = 0; + virtual void SetStatus(const string16& status) = 0; // Sets the bubble text to a URL - if given a non-empty URL, this will cause // 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. - virtual void SetURL(const GURL& url, const std::wstring& languages) = 0; + virtual void SetURL(const GURL& url, const string16& languages) = 0; // Skip the fade and instant-hide the bubble. virtual void Hide() = 0; diff --git a/chrome/browser/views/status_bubble_views.cc b/chrome/browser/views/status_bubble_views.cc index 1b21457..2f92daf 100644 --- a/chrome/browser/views/status_bubble_views.cc +++ b/chrome/browser/views/status_bubble_views.cc @@ -112,7 +112,7 @@ class StatusBubbleViews::StatusView : public views::Label, // Set the bubble text to a certain value, hides the bubble if text is // an empty string. Trigger animation sequence to display if // |should_animate_open|. - void SetText(const std::wstring& text, bool should_animate_open); + void SetText(const string16& text, bool should_animate_open); BubbleStage GetState() const { return stage_; } @@ -164,7 +164,7 @@ class StatusBubbleViews::StatusView : public views::Label, views::Widget* popup_; // The currently-displayed text. - std::wstring text_; + string16 text_; // Start and end opacities for the current transition - note that as a // fade-in can easily turn into a fade out, opacity_start_ is sometimes @@ -176,8 +176,8 @@ class StatusBubbleViews::StatusView : public views::Label, ThemeProvider* theme_provider_; }; -void StatusBubbleViews::StatusView::SetText( - const std::wstring& text, bool should_animate_open) { +void StatusBubbleViews::StatusView::SetText(const string16& text, + bool should_animate_open) { if (text.empty()) { // The string was empty. StartHiding(); @@ -428,7 +428,8 @@ void StatusBubbleViews::StatusView::Paint(gfx::Canvas* canvas) { // Draw highlight text and then the text body. In order to make sure the text // is aligned to the right on RTL UIs, we mirror the text bounds if the // locale is RTL. - int text_width = std::min(views::Label::font().GetStringWidth(text_), + int text_width = std::min( + views::Label::font().GetStringWidth(UTF16ToWide(text_)), width - (kShadowThickness * 2) - kTextPositionX - kTextHorizPadding); int text_height = height - (kShadowThickness * 2); gfx::Rect body_bounds(kShadowThickness + kTextPositionX, @@ -445,7 +446,7 @@ void StatusBubbleViews::StatusView::Paint(gfx::Canvas* canvas) { (SkColorGetR(text_color) + SkColorGetR(toolbar_color)) / 2, (SkColorGetG(text_color) + SkColorGetR(toolbar_color)) / 2, (SkColorGetB(text_color) + SkColorGetR(toolbar_color)) / 2); - canvas->DrawStringInt(text_, + canvas->DrawStringInt(UTF16ToWide(text_), views::Label::font(), text_color, body_bounds.x(), @@ -471,7 +472,7 @@ class StatusBubbleViews::StatusViewExpander : public LinearAnimation, } // Manage the expansion of the bubble. - void StartExpansion(std::wstring expanded_text, int current_width, + void StartExpansion(string16 expanded_text, int current_width, int expansion_end); // Set width of fully expanded bubble. @@ -491,7 +492,7 @@ class StatusBubbleViews::StatusViewExpander : public LinearAnimation, StatusView* status_view_; // Text elided (if needed) to fit maximum status bar width. - std::wstring expanded_text_; + string16 expanded_text_; // Widths at expansion start and end. int expansion_start_; @@ -509,7 +510,7 @@ void StatusBubbleViews::StatusViewExpander::AnimationEnded( } void StatusBubbleViews::StatusViewExpander::StartExpansion( - std::wstring expanded_text, int expansion_start, + string16 expanded_text, int expansion_start, int expansion_end) { expanded_text_ = expanded_text; expansion_start_ = expansion_start; @@ -595,7 +596,7 @@ void StatusBubbleViews::SetBounds(int x, int y, int w, int h) { Reposition(); } -void StatusBubbleViews::SetStatus(const std::wstring& status_text) { +void StatusBubbleViews::SetStatus(const string16& status_text) { if (size_.IsEmpty()) return; // We have no bounds, don't attempt to show the popup. @@ -613,11 +614,11 @@ void StatusBubbleViews::SetStatus(const std::wstring& status_text) { } else if (!url_text_.empty()) { view_->SetText(url_text_, true); } else { - view_->SetText(std::wstring(), true); + view_->SetText(string16(), true); } } -void StatusBubbleViews::SetURL(const GURL& url, const std::wstring& languages) { +void StatusBubbleViews::SetURL(const GURL& url, const string16& languages) { languages_ = languages; url_ = url; if (size_.IsEmpty()) @@ -628,7 +629,7 @@ void StatusBubbleViews::SetURL(const GURL& url, const std::wstring& languages) { // If we want to clear a displayed URL but there is a status still to // display, display that status instead. if (url.is_empty() && !status_text_.empty()) { - url_text_ = std::wstring(); + url_text_ = string16(); if (IsFrameVisible()) view_->SetText(status_text_, true); return; @@ -645,17 +646,16 @@ void StatusBubbleViews::SetURL(const GURL& url, const std::wstring& languages) { popup_->GetBounds(&popup_bounds, true); int text_width = static_cast<int>(popup_bounds.width() - (kShadowThickness * 2) - kTextPositionX - kTextHorizPadding - 1); - url_text_ = gfx::ElideUrl(url, view_->Label::font(), text_width, - languages); + url_text_ = WideToUTF16(gfx::ElideUrl(url, view_->Label::font(), + text_width, UTF16ToWide(languages))); std::wstring original_url_text = - UTF16ToWideHack(net::FormatUrl(url, WideToUTF8(languages))); + UTF16ToWideHack(net::FormatUrl(url, UTF16ToUTF8(languages))); // An URL is always treated as a left-to-right string. On right-to-left UIs // we need to explicitly mark the URL as LTR to make sure it is displayed // correctly. - url_text_ = UTF16ToWide(base::i18n::GetDisplayStringInLTRDirectionality( - WideToUTF16(url_text_))); + url_text_ = base::i18n::GetDisplayStringInLTRDirectionality(url_text_); if (IsFrameVisible()) { view_->SetText(url_text_, true); @@ -674,8 +674,8 @@ void StatusBubbleViews::SetURL(const GURL& url, const std::wstring& languages) { } void StatusBubbleViews::Hide() { - status_text_ = std::wstring(); - url_text_ = std::wstring(); + status_text_ = string16(); + url_text_ = string16(); if (view_) view_->Hide(); } @@ -801,14 +801,13 @@ void StatusBubbleViews::ExpandBubble() { gfx::Rect popup_bounds; popup_->GetBounds(&popup_bounds, true); int max_status_bubble_width = GetMaxStatusBubbleWidth(); - url_text_ = gfx::ElideUrl(url_, view_->Label::font(), - max_status_bubble_width, languages_); - int expanded_bubble_width = - std::max(GetStandardStatusBubbleWidth(), - std::min(view_->Label::font().GetStringWidth(url_text_) + - (kShadowThickness * 2) + kTextPositionX + - kTextHorizPadding + 1, - max_status_bubble_width)); + url_text_ = WideToUTF16(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 + + kTextHorizPadding + 1, + max_status_bubble_width)); is_expanded_ = true; expand_view_->StartExpansion(url_text_, popup_bounds.width(), expanded_bubble_width); diff --git a/chrome/browser/views/status_bubble_views.h b/chrome/browser/views/status_bubble_views.h index 9f7cd27..f5dbd12 100644 --- a/chrome/browser/views/status_bubble_views.h +++ b/chrome/browser/views/status_bubble_views.h @@ -8,6 +8,7 @@ #include "base/logging.h" #include "base/scoped_ptr.h" +#include "base/string16.h" #include "base/task.h" #include "chrome/browser/status_bubble.h" #include "googleurl/src/gurl.h" @@ -51,8 +52,8 @@ class StatusBubbleViews : public StatusBubble { void SetBubbleWidth(int width); // Overridden from StatusBubble: - virtual void SetStatus(const std::wstring& status); - virtual void SetURL(const GURL& url, const std::wstring& languages); + virtual void SetStatus(const string16& status); + virtual void SetURL(const GURL& url, const string16& languages); virtual void Hide(); virtual void MouseMoved(const gfx::Point& location, bool left_content); virtual void UpdateDownloadShelfVisibility(bool visible); @@ -85,16 +86,16 @@ class StatusBubbleViews : public StatusBubble { int GetMaxStatusBubbleWidth(); // The status text we want to display when there are no URLs to display. - std::wstring status_text_; + string16 status_text_; // The url we want to display when there is no status text to display. - std::wstring url_text_; + string16 url_text_; // The original, non-elided URL. GURL url_; // Used to elide the original URL again when we expand it. - std::wstring languages_; + string16 languages_; // Position relative to the base_view_. gfx::Point original_position_; |