diff options
author | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-13 19:39:58 +0000 |
---|---|---|
committer | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-13 19:39:58 +0000 |
commit | e23d3a394aed0b7f353edfeaac2fc2181085c8ff (patch) | |
tree | e5ae26a74ec8fa098aab0e9837ad8d4434ab6b08 /chrome | |
parent | 997e70b24b8041d402f759587b8ce01c56f55c0b (diff) | |
download | chromium_src-e23d3a394aed0b7f353edfeaac2fc2181085c8ff.zip chromium_src-e23d3a394aed0b7f353edfeaac2fc2181085c8ff.tar.gz chromium_src-e23d3a394aed0b7f353edfeaac2fc2181085c8ff.tar.bz2 |
Convert infobar APIs to UTF-16.
The critical change is the base class in infobar_delegate.h.
The remainder is just adapting all users to that change.
I grepped for all instances of the three base functions whose
types I changed to be more sure that I found all classes that
tried to overload these functions. I sure wish C++ had an
@Override annotation. :~(
TEST=compiles
BUG=23581
Review URL: http://codereview.chromium.org/3127009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@56066 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
36 files changed, 248 insertions, 234 deletions
diff --git a/chrome/browser/alternate_nav_url_fetcher.cc b/chrome/browser/alternate_nav_url_fetcher.cc index ebe136e..4e329cd 100644 --- a/chrome/browser/alternate_nav_url_fetcher.cc +++ b/chrome/browser/alternate_nav_url_fetcher.cc @@ -95,16 +95,16 @@ void AlternateNavURLFetcher::OnURLFetchComplete(const URLFetcher* source, ShowInfobarIfPossible(); } -std::wstring AlternateNavURLFetcher::GetMessageTextWithOffset( +string16 AlternateNavURLFetcher::GetMessageTextWithOffset( size_t* link_offset) const { - const std::wstring label = l10n_util::GetStringF( - IDS_ALTERNATE_NAV_URL_VIEW_LABEL, std::wstring(), link_offset); - DCHECK(*link_offset != std::wstring::npos); + const string16 label = l10n_util::GetStringFUTF16( + IDS_ALTERNATE_NAV_URL_VIEW_LABEL, string16(), link_offset); + DCHECK(*link_offset != string16::npos); return label; } -std::wstring AlternateNavURLFetcher::GetLinkText() const { - return UTF8ToWide(alternate_nav_url_.spec()); +string16 AlternateNavURLFetcher::GetLinkText() const { + return UTF8ToUTF16(alternate_nav_url_.spec()); } SkBitmap* AlternateNavURLFetcher::GetIcon() const { diff --git a/chrome/browser/alternate_nav_url_fetcher.h b/chrome/browser/alternate_nav_url_fetcher.h index 6b25350..e888d07 100644 --- a/chrome/browser/alternate_nav_url_fetcher.h +++ b/chrome/browser/alternate_nav_url_fetcher.h @@ -56,8 +56,8 @@ class AlternateNavURLFetcher : public NotificationObserver, const std::string& data); // LinkInfoBarDelegate - virtual std::wstring GetMessageTextWithOffset(size_t* link_offset) const; - virtual std::wstring GetLinkText() const; + virtual string16 GetMessageTextWithOffset(size_t* link_offset) const; + virtual string16 GetLinkText() const; virtual SkBitmap* GetIcon() const; virtual bool LinkClicked(WindowOpenDisposition disposition); virtual void InfoBarClosed(); diff --git a/chrome/browser/autofill/autofill_cc_infobar_delegate.cc b/chrome/browser/autofill/autofill_cc_infobar_delegate.cc index 7953d86..ec66b91 100644 --- a/chrome/browser/autofill/autofill_cc_infobar_delegate.cc +++ b/chrome/browser/autofill/autofill_cc_infobar_delegate.cc @@ -48,8 +48,8 @@ void AutoFillCCInfoBarDelegate::InfoBarClosed() { ConfirmInfoBarDelegate::InfoBarClosed(); } -std::wstring AutoFillCCInfoBarDelegate::GetMessageText() const { - return l10n_util::GetString(IDS_AUTOFILL_CC_INFOBAR_TEXT); +string16 AutoFillCCInfoBarDelegate::GetMessageText() const { + return l10n_util::GetStringUTF16(IDS_AUTOFILL_CC_INFOBAR_TEXT); } SkBitmap* AutoFillCCInfoBarDelegate::GetIcon() const { @@ -61,16 +61,16 @@ int AutoFillCCInfoBarDelegate::GetButtons() const { return BUTTON_OK | BUTTON_CANCEL; } -std::wstring AutoFillCCInfoBarDelegate::GetButtonLabel( +string16 AutoFillCCInfoBarDelegate::GetButtonLabel( ConfirmInfoBarDelegate::InfoBarButton button) const { if (button == BUTTON_OK) - return l10n_util::GetString(IDS_AUTOFILL_CC_INFOBAR_ACCEPT); + return l10n_util::GetStringUTF16(IDS_AUTOFILL_CC_INFOBAR_ACCEPT); else if (button == BUTTON_CANCEL) - return l10n_util::GetString(IDS_AUTOFILL_CC_INFOBAR_DENY); + return l10n_util::GetStringUTF16(IDS_AUTOFILL_CC_INFOBAR_DENY); else NOTREACHED(); - return std::wstring(); + return string16(); } bool AutoFillCCInfoBarDelegate::Accept() { @@ -91,8 +91,8 @@ bool AutoFillCCInfoBarDelegate::Cancel() { return true; } -std::wstring AutoFillCCInfoBarDelegate::GetLinkText() { - return l10n_util::GetString(IDS_AUTOFILL_CC_LEARN_MORE); +string16 AutoFillCCInfoBarDelegate::GetLinkText() { + return l10n_util::GetStringUTF16(IDS_AUTOFILL_CC_LEARN_MORE); } bool AutoFillCCInfoBarDelegate::LinkClicked(WindowOpenDisposition disposition) { diff --git a/chrome/browser/autofill/autofill_cc_infobar_delegate.h b/chrome/browser/autofill/autofill_cc_infobar_delegate.h index 6a8091e..b2dab99 100644 --- a/chrome/browser/autofill/autofill_cc_infobar_delegate.h +++ b/chrome/browser/autofill/autofill_cc_infobar_delegate.h @@ -25,14 +25,14 @@ class AutoFillCCInfoBarDelegate : public ConfirmInfoBarDelegate { virtual bool ShouldExpire( const NavigationController::LoadCommittedDetails& details) const; virtual void InfoBarClosed(); - virtual std::wstring GetMessageText() const; + virtual string16 GetMessageText() const; virtual SkBitmap* GetIcon() const; virtual int GetButtons() const; - virtual std::wstring GetButtonLabel( + virtual string16 GetButtonLabel( ConfirmInfoBarDelegate::InfoBarButton button) const; virtual bool Accept(); virtual bool Cancel(); - virtual std::wstring GetLinkText(); + virtual string16 GetLinkText(); virtual bool LinkClicked(WindowOpenDisposition disposition); #if defined(OS_WIN) diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc index 850d613..8cffdbf 100644 --- a/chrome/browser/automation/automation_provider.cc +++ b/chrome/browser/automation/automation_provider.cc @@ -1752,10 +1752,8 @@ ListValue* AutomationProvider::GetInfobarsInfo(TabContents* tc) { infobar_item->SetString("type", "confirm_infobar"); ConfirmInfoBarDelegate* confirm_infobar = infobar->AsConfirmInfoBarDelegate(); - infobar_item->SetString("text", - WideToUTF16Hack(confirm_infobar->GetMessageText())); - infobar_item->SetString("link_text", - WideToUTF16Hack(confirm_infobar->GetLinkText())); + infobar_item->SetString("text", confirm_infobar->GetMessageText()); + infobar_item->SetString("link_text", confirm_infobar->GetLinkText()); ListValue* buttons_list = new ListValue; int buttons = confirm_infobar->GetButtons(); if (ConfirmInfoBarDelegate::BUTTON_OK & buttons) { @@ -1775,13 +1773,11 @@ ListValue* AutomationProvider::GetInfobarsInfo(TabContents* tc) { infobar_item->SetString("type", "alert_infobar"); AlertInfoBarDelegate* alert_infobar = infobar->AsAlertInfoBarDelegate(); - infobar_item->SetString("text", - WideToUTF16Hack(alert_infobar->GetMessageText())); + infobar_item->SetString("text", alert_infobar->GetMessageText()); } else if (infobar->AsLinkInfoBarDelegate()) { infobar_item->SetString("type", "link_infobar"); LinkInfoBarDelegate* link_infobar = infobar->AsLinkInfoBarDelegate(); - infobar_item->SetString("link_text", - WideToUTF16Hack(link_infobar->GetLinkText())); + infobar_item->SetString("link_text", link_infobar->GetLinkText()); } else if (infobar->AsTranslateInfoBarDelegate()) { infobar_item->SetString("type", "translate_infobar"); TranslateInfoBarDelegate* translate_infobar = diff --git a/chrome/browser/blocked_plugin_manager.cc b/chrome/browser/blocked_plugin_manager.cc index 92b7c91..222ceee 100644 --- a/chrome/browser/blocked_plugin_manager.cc +++ b/chrome/browser/blocked_plugin_manager.cc @@ -29,19 +29,18 @@ int BlockedPluginManager::GetButtons() const { return BUTTON_OK; } -std::wstring BlockedPluginManager::GetButtonLabel(InfoBarButton button) const { +string16 BlockedPluginManager::GetButtonLabel(InfoBarButton button) const { if (button == BUTTON_OK) - return l10n_util::GetString(IDS_PLUGIN_LOAD_SHORT); + return l10n_util::GetStringUTF16(IDS_PLUGIN_LOAD_SHORT); return ConfirmInfoBarDelegate::GetButtonLabel(button); } -std::wstring BlockedPluginManager::GetMessageText() const { - return UTF16ToWide(l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED_PROMPT, - name_)); +string16 BlockedPluginManager::GetMessageText() const { + return l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED_PROMPT, name_); } -std::wstring BlockedPluginManager::GetLinkText() { - return l10n_util::GetString(IDS_LEARN_MORE); +string16 BlockedPluginManager::GetLinkText() { + return l10n_util::GetStringUTF16(IDS_LEARN_MORE); } SkBitmap* BlockedPluginManager::GetIcon() const { diff --git a/chrome/browser/blocked_plugin_manager.h b/chrome/browser/blocked_plugin_manager.h index e9f9506..b1e231a 100644 --- a/chrome/browser/blocked_plugin_manager.h +++ b/chrome/browser/blocked_plugin_manager.h @@ -20,9 +20,9 @@ class BlockedPluginManager : public RenderViewHostDelegate::BlockedPlugin, // ConfirmInfoBarDelegate methods virtual int GetButtons() const; - virtual std::wstring GetButtonLabel(InfoBarButton button) const; - virtual std::wstring GetMessageText() const; - virtual std::wstring GetLinkText(); + virtual string16 GetButtonLabel(InfoBarButton button) const; + virtual string16 GetMessageText() const; + virtual string16 GetLinkText(); virtual SkBitmap* GetIcon() const; virtual bool Accept(); virtual bool LinkClicked(WindowOpenDisposition disposition); diff --git a/chrome/browser/browser_init.cc b/chrome/browser/browser_init.cc index 87d7153..eaa83ae 100644 --- a/chrome/browser/browser_init.cc +++ b/chrome/browser/browser_init.cc @@ -132,8 +132,8 @@ class DefaultBrowserInfoBarDelegate : public ConfirmInfoBarDelegate { delete this; } - virtual std::wstring GetMessageText() const { - return l10n_util::GetString(IDS_DEFAULT_BROWSER_INFOBAR_SHORT_TEXT); + virtual string16 GetMessageText() const { + return l10n_util::GetStringUTF16(IDS_DEFAULT_BROWSER_INFOBAR_SHORT_TEXT); } virtual SkBitmap* GetIcon() const { @@ -145,10 +145,10 @@ class DefaultBrowserInfoBarDelegate : public ConfirmInfoBarDelegate { return BUTTON_OK | BUTTON_CANCEL | BUTTON_OK_DEFAULT; } - virtual std::wstring GetButtonLabel(InfoBarButton button) const { + virtual string16 GetButtonLabel(InfoBarButton button) const { return button == BUTTON_OK ? - l10n_util::GetString(IDS_SET_AS_DEFAULT_INFOBAR_BUTTON_LABEL) : - l10n_util::GetString(IDS_DONT_ASK_AGAIN_INFOBAR_BUTTON_LABEL); + l10n_util::GetStringUTF16(IDS_SET_AS_DEFAULT_INFOBAR_BUTTON_LABEL) : + l10n_util::GetStringUTF16(IDS_DONT_ASK_AGAIN_INFOBAR_BUTTON_LABEL); } virtual bool NeedElevation(InfoBarButton button) const { @@ -248,16 +248,16 @@ class SessionCrashedInfoBarDelegate : public ConfirmInfoBarDelegate { virtual void InfoBarClosed() { delete this; } - virtual std::wstring GetMessageText() const { - return l10n_util::GetString(IDS_SESSION_CRASHED_VIEW_MESSAGE); + virtual string16 GetMessageText() const { + return l10n_util::GetStringUTF16(IDS_SESSION_CRASHED_VIEW_MESSAGE); } virtual SkBitmap* GetIcon() const { return ResourceBundle::GetSharedInstance().GetBitmapNamed( IDR_INFOBAR_RESTORE_SESSION); } virtual int GetButtons() const { return BUTTON_OK; } - virtual std::wstring GetButtonLabel(InfoBarButton button) const { - return l10n_util::GetString(IDS_SESSION_CRASHED_VIEW_RESTORE_BUTTON); + virtual string16 GetButtonLabel(InfoBarButton button) const { + return l10n_util::GetStringUTF16(IDS_SESSION_CRASHED_VIEW_RESTORE_BUTTON); } virtual bool Accept() { // Restore the session. @@ -823,8 +823,8 @@ void BrowserInit::LaunchWithProfile::AddBadFlagsInfoBarIfNecessary( if (bad_flag) { tab->AddInfoBar(new SimpleAlertInfoBarDelegate(tab, - l10n_util::GetStringF(IDS_BAD_FLAGS_WARNING_MESSAGE, - L"--" + ASCIIToWide(bad_flag)), + l10n_util::GetStringFUTF16(IDS_BAD_FLAGS_WARNING_MESSAGE, + UTF8ToUTF16(std::string("--") + bad_flag)), NULL, false)); } } diff --git a/chrome/browser/cocoa/infobar_controller.mm b/chrome/browser/cocoa/infobar_controller.mm index cd7d14d..3997074 100644 --- a/chrome/browser/cocoa/infobar_controller.mm +++ b/chrome/browser/cocoa/infobar_controller.mm @@ -344,7 +344,7 @@ const float kAnimateCloseDuration = 0.12; // Insert the text. AlertInfoBarDelegate* delegate = delegate_->AsAlertInfoBarDelegate(); DCHECK(delegate); - [self setLabelToMessage:base::SysWideToNSString(delegate->GetMessageText())]; + [self setLabelToMessage:base::SysUTF16ToNSString(delegate->GetMessageText())]; } @end @@ -368,9 +368,9 @@ const float kAnimateCloseDuration = 0.12; LinkInfoBarDelegate* delegate = delegate_->AsLinkInfoBarDelegate(); DCHECK(delegate); size_t offset = std::wstring::npos; - std::wstring message = delegate->GetMessageTextWithOffset(&offset); - [self setLabelToMessage:base::SysWideToNSString(message) - withLink:base::SysWideToNSString(delegate->GetLinkText()) + string16 message = delegate->GetMessageTextWithOffset(&offset); + [self setLabelToMessage:base::SysUTF16ToNSString(message) + withLink:base::SysUTF16ToNSString(delegate->GetLinkText()) atOffset:offset]; } @@ -426,7 +426,7 @@ const float kAnimateCloseDuration = 0.12; // Update and position the Cancel button if needed. Otherwise, hide it. if (visibleButtons & ConfirmInfoBarDelegate::BUTTON_CANCEL) { - [cancelButton_ setTitle:base::SysWideToNSString( + [cancelButton_ setTitle:base::SysUTF16ToNSString( delegate->GetButtonLabel(ConfirmInfoBarDelegate::BUTTON_CANCEL))]; [GTMUILocalizerAndLayoutTweaker sizeToFitView:cancelButton_]; cancelButtonFrame = [cancelButton_ frame]; @@ -443,7 +443,7 @@ const float kAnimateCloseDuration = 0.12; // Update and position the OK button if needed. Otherwise, hide it. if (visibleButtons & ConfirmInfoBarDelegate::BUTTON_OK) { - [okButton_ setTitle:base::SysWideToNSString( + [okButton_ setTitle:base::SysUTF16ToNSString( delegate->GetButtonLabel(ConfirmInfoBarDelegate::BUTTON_OK))]; [GTMUILocalizerAndLayoutTweaker sizeToFitView:okButton_]; okButtonFrame = [okButton_ frame]; @@ -477,8 +477,8 @@ const float kAnimateCloseDuration = 0.12; [label_.get() setFrame:frame]; // Set the text and link. - NSString* message = base::SysWideToNSString(delegate->GetMessageText()); - std::wstring link = delegate->GetLinkText(); + NSString* message = base::SysUTF16ToNSString(delegate->GetMessageText()); + string16 link = delegate->GetLinkText(); if (link.empty()) { // Simple case: no link, so just set the message directly. [self setLabelToMessage:message]; @@ -490,7 +490,7 @@ const float kAnimateCloseDuration = 0.12; // Add spacing between the label and the link. message = [message stringByAppendingString:@" "]; [self setLabelToMessage:message - withLink:base::SysWideToNSString(link) + withLink:base::SysUTF16ToNSString(link) atOffset:[message length]]; } } diff --git a/chrome/browser/cocoa/infobar_controller_unittest.mm b/chrome/browser/cocoa/infobar_controller_unittest.mm index ec7bf1e..114a94c 100644 --- a/chrome/browser/cocoa/infobar_controller_unittest.mm +++ b/chrome/browser/cocoa/infobar_controller_unittest.mm @@ -134,8 +134,8 @@ TEST_F(AlertInfoBarControllerTest, ShowAndDismiss) { EXPECT_TRUE(delegate_.icon_accessed); // Check to make sure the infobar message was set properly. - EXPECT_EQ(std::wstring(kMockAlertInfoBarMessage), - base::SysNSStringToWide([controller_.get() labelString])); + EXPECT_EQ(kMockAlertInfoBarMessage, + base::SysNSStringToUTF8([controller_.get() labelString])); // Check that dismissing the infobar calls InfoBarClosed() on the delegate. [controller_ dismiss:nil]; @@ -204,8 +204,8 @@ TEST_F(ConfirmInfoBarControllerTest, ShowAndDismiss) { EXPECT_TRUE(delegate_.icon_accessed); // Check to make sure the infobar message was set properly. - EXPECT_EQ(std::wstring(kMockConfirmInfoBarMessage), - base::SysNSStringToWide([controller_.get() labelString])); + EXPECT_EQ(kMockConfirmInfoBarMessage, + base::SysNSStringToUTF8([controller_.get() labelString])); // Check that dismissing the infobar calls InfoBarClosed() on the delegate. [controller_ dismiss:nil]; diff --git a/chrome/browser/cocoa/infobar_test_helper.h b/chrome/browser/cocoa/infobar_test_helper.h index d83bdc1..e0247cd9 100644 --- a/chrome/browser/cocoa/infobar_test_helper.h +++ b/chrome/browser/cocoa/infobar_test_helper.h @@ -5,10 +5,10 @@ #include "chrome/browser/tab_contents/infobar_delegate.h" namespace { -const wchar_t* kMockAlertInfoBarMessage = L"MockAlertInfoBarMessage"; -const wchar_t* kMockLinkInfoBarMessage = L"MockLinkInfoBarMessage"; -const wchar_t* kMockLinkInfoBarLink = L"http://dev.chromium.org"; -const wchar_t* kMockConfirmInfoBarMessage = L"MockConfirmInfoBarMessage"; +const char kMockAlertInfoBarMessage[] = "MockAlertInfoBarMessage"; +const char kMockLinkInfoBarMessage[] = "MockLinkInfoBarMessage"; +const char kMockLinkInfoBarLink[] = "http://dev.chromium.org"; +const char kMockConfirmInfoBarMessage[] = "MockConfirmInfoBarMessage"; } ////////////////////////////////////////////////////////////////////////// @@ -23,9 +23,9 @@ class MockAlertInfoBarDelegate : public AlertInfoBarDelegate { closed(false) { } - virtual std::wstring GetMessageText() const { + virtual string16 GetMessageText() const { message_text_accessed = true; - return kMockAlertInfoBarMessage; + return ASCIIToUTF16(kMockAlertInfoBarMessage); } virtual SkBitmap* GetIcon() const { @@ -55,14 +55,14 @@ class MockLinkInfoBarDelegate : public LinkInfoBarDelegate { closes_on_action(true) { } - virtual std::wstring GetMessageTextWithOffset(size_t* link_offset) const { + virtual string16 GetMessageTextWithOffset(size_t* link_offset) const { message_text_accessed = true; - return kMockLinkInfoBarMessage; + return ASCIIToUTF16(kMockLinkInfoBarMessage); } - virtual std::wstring GetLinkText() const { + virtual string16 GetLinkText() const { link_text_accessed = true; - return kMockLinkInfoBarLink; + return ASCIIToUTF16(kMockLinkInfoBarLink); } virtual SkBitmap* GetIcon() const { @@ -108,11 +108,11 @@ class MockConfirmInfoBarDelegate : public ConfirmInfoBarDelegate { return (BUTTON_OK | BUTTON_CANCEL); } - virtual std::wstring GetButtonLabel(InfoBarButton button) const { + virtual string16 GetButtonLabel(InfoBarButton button) const { if (button == BUTTON_OK) - return L"OK"; + return ASCIIToUTF16("OK"); else - return L"Cancel"; + return ASCIIToUTF16("Cancel"); } virtual bool Accept() { @@ -125,9 +125,9 @@ class MockConfirmInfoBarDelegate : public ConfirmInfoBarDelegate { return closes_on_action; } - virtual std::wstring GetMessageText() const { + virtual string16 GetMessageText() const { message_text_accessed = true; - return kMockConfirmInfoBarMessage; + return ASCIIToUTF16(kMockConfirmInfoBarMessage); } virtual SkBitmap* GetIcon() const { @@ -139,9 +139,9 @@ class MockConfirmInfoBarDelegate : public ConfirmInfoBarDelegate { closed = true; } - virtual std::wstring GetLinkText() { + virtual string16 GetLinkText() { link_text_accessed = true; - return std::wstring(); + return string16(); } virtual bool LinkClicked(WindowOpenDisposition disposition) { diff --git a/chrome/browser/cocoa/keystone_infobar.mm b/chrome/browser/cocoa/keystone_infobar.mm index 377818a..7957605 100644 --- a/chrome/browser/cocoa/keystone_infobar.mm +++ b/chrome/browser/cocoa/keystone_infobar.mm @@ -62,9 +62,9 @@ class KeystonePromotionInfoBarDelegate : public ConfirmInfoBarDelegate { // Inherited from AlertInfoBarDelegate and overridden. - virtual std::wstring GetMessageText() const { - return l10n_util::GetStringF(IDS_PROMOTE_INFOBAR_TEXT, - l10n_util::GetString(IDS_PRODUCT_NAME)); + virtual string16 GetMessageText() const { + return l10n_util::GetStringFUTF16(IDS_PROMOTE_INFOBAR_TEXT, + l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); } virtual SkBitmap* GetIcon() const { @@ -78,10 +78,10 @@ class KeystonePromotionInfoBarDelegate : public ConfirmInfoBarDelegate { return BUTTON_OK | BUTTON_CANCEL | BUTTON_OK_DEFAULT; } - virtual std::wstring GetButtonLabel(InfoBarButton button) const { + virtual string16 GetButtonLabel(InfoBarButton button) const { return button == BUTTON_OK ? - l10n_util::GetString(IDS_PROMOTE_INFOBAR_PROMOTE_BUTTON) : - l10n_util::GetString(IDS_PROMOTE_INFOBAR_DONT_ASK_BUTTON); + l10n_util::GetStringUTF16(IDS_PROMOTE_INFOBAR_PROMOTE_BUTTON) : + l10n_util::GetStringUTF16(IDS_PROMOTE_INFOBAR_DONT_ASK_BUTTON); } virtual bool Accept() { diff --git a/chrome/browser/download/download_request_infobar_delegate.cc b/chrome/browser/download/download_request_infobar_delegate.cc index 4a401bb..ecbc108 100644 --- a/chrome/browser/download/download_request_infobar_delegate.cc +++ b/chrome/browser/download/download_request_infobar_delegate.cc @@ -27,8 +27,8 @@ void DownloadRequestInfoBarDelegate::InfoBarClosed() { ConfirmInfoBarDelegate::InfoBarClosed(); } -std::wstring DownloadRequestInfoBarDelegate::GetMessageText() const { - return l10n_util::GetString(IDS_MULTI_DOWNLOAD_WARNING); +string16 DownloadRequestInfoBarDelegate::GetMessageText() const { + return l10n_util::GetStringUTF16(IDS_MULTI_DOWNLOAD_WARNING); } SkBitmap* DownloadRequestInfoBarDelegate::GetIcon() const { @@ -40,12 +40,12 @@ int DownloadRequestInfoBarDelegate::GetButtons() const { return BUTTON_OK | BUTTON_CANCEL; } -std::wstring DownloadRequestInfoBarDelegate::GetButtonLabel( +string16 DownloadRequestInfoBarDelegate::GetButtonLabel( ConfirmInfoBarDelegate::InfoBarButton button) const { if (button == BUTTON_OK) - return l10n_util::GetString(IDS_MULTI_DOWNLOAD_WARNING_ALLOW); + return l10n_util::GetStringUTF16(IDS_MULTI_DOWNLOAD_WARNING_ALLOW); else - return l10n_util::GetString(IDS_MULTI_DOWNLOAD_WARNING_DENY); + return l10n_util::GetStringUTF16(IDS_MULTI_DOWNLOAD_WARNING_DENY); } bool DownloadRequestInfoBarDelegate::Accept() { diff --git a/chrome/browser/download/download_request_infobar_delegate.h b/chrome/browser/download/download_request_infobar_delegate.h index c33696c..c1280cf 100644 --- a/chrome/browser/download/download_request_infobar_delegate.h +++ b/chrome/browser/download/download_request_infobar_delegate.h @@ -29,13 +29,13 @@ class DownloadRequestInfoBarDelegate : public ConfirmInfoBarDelegate { virtual void InfoBarClosed(); - virtual std::wstring GetMessageText() const; + virtual string16 GetMessageText() const; virtual SkBitmap* GetIcon() const; virtual int GetButtons() const; - virtual std::wstring GetButtonLabel( + virtual string16 GetButtonLabel( ConfirmInfoBarDelegate::InfoBarButton button) const; virtual bool Accept(); diff --git a/chrome/browser/download/download_util.cc b/chrome/browser/download/download_util.cc index d6f8907..f61ac4c 100644 --- a/chrome/browser/download/download_util.cc +++ b/chrome/browser/download/download_util.cc @@ -305,7 +305,7 @@ void OpenChromeExtension(Profile* profile, if (contents) { contents->AddInfoBar( new SimpleAlertInfoBarDelegate(contents, - l10n_util::GetString( + l10n_util::GetStringUTF16( IDS_EXTENSION_INCOGNITO_INSTALL_INFOBAR_LABEL), ResourceBundle::GetSharedInstance().GetBitmapNamed( IDR_INFOBAR_PLUGIN_INSTALL), diff --git a/chrome/browser/extensions/crashed_extension_infobar.cc b/chrome/browser/extensions/crashed_extension_infobar.cc index 685c5f7..b43f11b 100644 --- a/chrome/browser/extensions/crashed_extension_infobar.cc +++ b/chrome/browser/extensions/crashed_extension_infobar.cc @@ -25,9 +25,9 @@ CrashedExtensionInfoBarDelegate::CrashedExtensionInfoBarDelegate( DCHECK(!extension_id_.empty()); } -std::wstring CrashedExtensionInfoBarDelegate::GetMessageText() const { - return l10n_util::GetStringF(IDS_EXTENSION_CRASHED_INFOBAR_MESSAGE, - UTF8ToWide(extension_name_)); +string16 CrashedExtensionInfoBarDelegate::GetMessageText() const { + return l10n_util::GetStringFUTF16(IDS_EXTENSION_CRASHED_INFOBAR_MESSAGE, + UTF8ToUTF16(extension_name_)); } void CrashedExtensionInfoBarDelegate::InfoBarClosed() { @@ -44,10 +44,12 @@ int CrashedExtensionInfoBarDelegate::GetButtons() const { return BUTTON_OK; } -std::wstring CrashedExtensionInfoBarDelegate::GetButtonLabel( +string16 CrashedExtensionInfoBarDelegate::GetButtonLabel( ConfirmInfoBarDelegate::InfoBarButton button) const { - if (button == BUTTON_OK) - return l10n_util::GetString(IDS_EXTENSION_CRASHED_INFOBAR_RESTART_BUTTON); + if (button == BUTTON_OK) { + return l10n_util::GetStringUTF16( + IDS_EXTENSION_CRASHED_INFOBAR_RESTART_BUTTON); + } return ConfirmInfoBarDelegate::GetButtonLabel(button); } diff --git a/chrome/browser/extensions/crashed_extension_infobar.h b/chrome/browser/extensions/crashed_extension_infobar.h index 2e3741a..5387a0a 100644 --- a/chrome/browser/extensions/crashed_extension_infobar.h +++ b/chrome/browser/extensions/crashed_extension_infobar.h @@ -34,11 +34,11 @@ class CrashedExtensionInfoBarDelegate : public ConfirmInfoBarDelegate { } // ConfirmInfoBarDelegate - virtual std::wstring GetMessageText() const; + virtual string16 GetMessageText() const; virtual void InfoBarClosed(); virtual SkBitmap* GetIcon() const; virtual int GetButtons() const; - virtual std::wstring GetButtonLabel( + virtual string16 GetButtonLabel( ConfirmInfoBarDelegate::InfoBarButton button) const; virtual bool Accept(); diff --git a/chrome/browser/extensions/extension_disabled_infobar_delegate.cc b/chrome/browser/extensions/extension_disabled_infobar_delegate.cc index f26c307..e8ed833 100644 --- a/chrome/browser/extensions/extension_disabled_infobar_delegate.cc +++ b/chrome/browser/extensions/extension_disabled_infobar_delegate.cc @@ -77,9 +77,9 @@ class ExtensionDisabledInfobarDelegate } virtual ~ExtensionDisabledInfobarDelegate() { } - virtual std::wstring GetMessageText() const { - return l10n_util::GetStringF(IDS_EXTENSION_DISABLED_INFOBAR_LABEL, - UTF8ToWide(extension_->name())); + virtual string16 GetMessageText() const { + return l10n_util::GetStringFUTF16(IDS_EXTENSION_DISABLED_INFOBAR_LABEL, + UTF8ToUTF16(extension_->name())); } virtual SkBitmap* GetIcon() const { return NULL; @@ -87,9 +87,10 @@ class ExtensionDisabledInfobarDelegate virtual int GetButtons() const { return BUTTON_OK; } - virtual std::wstring GetButtonLabel( + virtual string16 GetButtonLabel( ConfirmInfoBarDelegate::InfoBarButton button) const { - return l10n_util::GetString(IDS_EXTENSION_DISABLED_INFOBAR_ENABLE_BUTTON); + return l10n_util::GetStringUTF16( + IDS_EXTENSION_DISABLED_INFOBAR_ENABLE_BUTTON); } virtual bool Accept() { // This object manages its own lifetime. diff --git a/chrome/browser/extensions/extension_install_ui.cc b/chrome/browser/extensions/extension_install_ui.cc index bd59dd4..063b16d 100644 --- a/chrome/browser/extensions/extension_install_ui.cc +++ b/chrome/browser/extensions/extension_install_ui.cc @@ -352,9 +352,11 @@ void ExtensionInstallUI::ShowGenericExtensionInstalledInfoBar( if (!tab_contents) return; - std::wstring msg = l10n_util::GetStringF(IDS_EXTENSION_INSTALLED_HEADING, - UTF8ToWide(new_extension->name())) + - L" " + l10n_util::GetString(IDS_EXTENSION_INSTALLED_MANAGE_INFO_MAC); + string16 msg = + l10n_util::GetStringFUTF16(IDS_EXTENSION_INSTALLED_HEADING, + UTF8ToUTF16(new_extension->name())) + + UTF8ToUTF16(" ") + + l10n_util::GetStringUTF16(IDS_EXTENSION_INSTALLED_MANAGE_INFO_MAC); InfoBarDelegate* delegate = new SimpleAlertInfoBarDelegate( tab_contents, msg, new SkBitmap(icon_), true); tab_contents->AddInfoBar(delegate); diff --git a/chrome/browser/extensions/theme_installed_infobar_delegate.cc b/chrome/browser/extensions/theme_installed_infobar_delegate.cc index 4e9ac35..4fb501d 100644 --- a/chrome/browser/extensions/theme_installed_infobar_delegate.cc +++ b/chrome/browser/extensions/theme_installed_infobar_delegate.cc @@ -43,9 +43,9 @@ void ThemeInstalledInfoBarDelegate::InfoBarClosed() { delete this; } -std::wstring ThemeInstalledInfoBarDelegate::GetMessageText() const { - return l10n_util::GetStringF(IDS_THEME_INSTALL_INFOBAR_LABEL, - UTF8ToWide(name_)); +string16 ThemeInstalledInfoBarDelegate::GetMessageText() const { + return l10n_util::GetStringFUTF16(IDS_THEME_INSTALL_INFOBAR_LABEL, + UTF8ToUTF16(name_)); } SkBitmap* ThemeInstalledInfoBarDelegate::GetIcon() const { @@ -64,16 +64,16 @@ int ThemeInstalledInfoBarDelegate::GetButtons() const { return BUTTON_CANCEL; } -std::wstring ThemeInstalledInfoBarDelegate::GetButtonLabel( +string16 ThemeInstalledInfoBarDelegate::GetButtonLabel( ConfirmInfoBarDelegate::InfoBarButton button) const { switch (button) { case BUTTON_CANCEL: { - return l10n_util::GetString(IDS_THEME_INSTALL_INFOBAR_UNDO_BUTTON); + return l10n_util::GetStringUTF16(IDS_THEME_INSTALL_INFOBAR_UNDO_BUTTON); } default: // The InfoBar will create a default OK button and make it invisible. // TODO(mirandac): remove the default OK button from ConfirmInfoBar. - return L""; + return string16(); } } diff --git a/chrome/browser/extensions/theme_installed_infobar_delegate.h b/chrome/browser/extensions/theme_installed_infobar_delegate.h index 09139a1..2c54fa5 100644 --- a/chrome/browser/extensions/theme_installed_infobar_delegate.h +++ b/chrome/browser/extensions/theme_installed_infobar_delegate.h @@ -23,11 +23,11 @@ class ThemeInstalledInfoBarDelegate : public ConfirmInfoBarDelegate, const std::string& previous_theme_id); virtual ~ThemeInstalledInfoBarDelegate(); virtual void InfoBarClosed(); - virtual std::wstring GetMessageText() const; + virtual string16 GetMessageText() const; virtual SkBitmap* GetIcon() const; virtual ThemeInstalledInfoBarDelegate* AsThemePreviewInfobarDelegate(); virtual int GetButtons() const; - virtual std::wstring GetButtonLabel( + virtual string16 GetButtonLabel( ConfirmInfoBarDelegate::InfoBarButton button) const; virtual bool Cancel(); diff --git a/chrome/browser/geolocation/geolocation_permission_context.cc b/chrome/browser/geolocation/geolocation_permission_context.cc index 9b6733f..cb0a9a1 100644 --- a/chrome/browser/geolocation/geolocation_permission_context.cc +++ b/chrome/browser/geolocation/geolocation_permission_context.cc @@ -112,29 +112,30 @@ class GeolocationConfirmInfoBarDelegate : public ConfirmInfoBarDelegate { virtual bool Accept() { return OnPermissionSet(true); } virtual bool Cancel() { return OnPermissionSet(false); } virtual int GetButtons() const { return BUTTON_OK | BUTTON_CANCEL; } - virtual std::wstring GetButtonLabel(InfoBarButton button) const { + virtual string16 GetButtonLabel(InfoBarButton button) const { switch (button) { case BUTTON_OK: - return l10n_util::GetString(IDS_GEOLOCATION_ALLOW_BUTTON); + return l10n_util::GetStringUTF16(IDS_GEOLOCATION_ALLOW_BUTTON); case BUTTON_CANCEL: - return l10n_util::GetString(IDS_GEOLOCATION_DENY_BUTTON); + return l10n_util::GetStringUTF16(IDS_GEOLOCATION_DENY_BUTTON); default: // All buttons are labeled above. NOTREACHED() << "Bad button id " << button; - return L""; + return string16(); } } - virtual std::wstring GetMessageText() const { - return l10n_util::GetStringF( + virtual string16 GetMessageText() const { + return l10n_util::GetStringFUTF16( IDS_GEOLOCATION_INFOBAR_QUESTION, - net::FormatUrl(requesting_frame_url_.GetOrigin(), display_languages_)); + WideToUTF16Hack(net::FormatUrl(requesting_frame_url_.GetOrigin(), + display_languages_))); } virtual SkBitmap* GetIcon() const { return ResourceBundle::GetSharedInstance().GetBitmapNamed( IDR_GEOLOCATION_INFOBAR_ICON); } - virtual std::wstring GetLinkText() { - return l10n_util::GetString(IDS_LEARN_MORE); + virtual string16 GetLinkText() { + return l10n_util::GetStringUTF16(IDS_LEARN_MORE); } virtual bool LinkClicked(WindowOpenDisposition disposition) { // Ignore the click dispostion and always open in a new top level tab. diff --git a/chrome/browser/geolocation/geolocation_permission_context_unittest.cc b/chrome/browser/geolocation/geolocation_permission_context_unittest.cc index 59b070f..96cfd68 100644 --- a/chrome/browser/geolocation/geolocation_permission_context_unittest.cc +++ b/chrome/browser/geolocation/geolocation_permission_context_unittest.cc @@ -187,7 +187,7 @@ TEST_F(GeolocationPermissionContextTests, QueuedPermission) { ConfirmInfoBarDelegate* infobar_0 = contents()->GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); ASSERT_TRUE(infobar_0); - std::wstring text_0 = infobar_0->GetMessageText(); + string16 text_0 = infobar_0->GetMessageText(); // Accept the first frame. infobar_0->Accept(); @@ -204,7 +204,7 @@ TEST_F(GeolocationPermissionContextTests, QueuedPermission) { ConfirmInfoBarDelegate* infobar_1 = contents()->GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); ASSERT_TRUE(infobar_1); - std::wstring text_1 = infobar_1->GetMessageText(); + string16 text_1 = infobar_1->GetMessageText(); EXPECT_NE(text_0, text_1); // Cancel (block) this frame. @@ -251,7 +251,7 @@ TEST_F(GeolocationPermissionContextTests, CancelGeolocationPermissionRequest) { ConfirmInfoBarDelegate* infobar_0 = contents()->GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); ASSERT_TRUE(infobar_0); - std::wstring text_0 = infobar_0->GetMessageText(); + string16 text_0 = infobar_0->GetMessageText(); // Simulate the frame going away, ensure the infobar for this frame // is removed and the next pending infobar is created. @@ -265,7 +265,7 @@ TEST_F(GeolocationPermissionContextTests, CancelGeolocationPermissionRequest) { ConfirmInfoBarDelegate* infobar_1 = contents()->GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); ASSERT_TRUE(infobar_1); - std::wstring text_1 = infobar_1->GetMessageText(); + string16 text_1 = infobar_1->GetMessageText(); EXPECT_NE(text_0, text_1); // Allow this frame. diff --git a/chrome/browser/gtk/infobar_gtk.cc b/chrome/browser/gtk/infobar_gtk.cc index e06da07..46a1ac4 100644 --- a/chrome/browser/gtk/infobar_gtk.cc +++ b/chrome/browser/gtk/infobar_gtk.cc @@ -148,8 +148,8 @@ void InfoBar::Observe(NotificationType type, // TODO(joth): This method factors out some common functionality between the // various derived infobar classes, however the class hierarchy itself could // use refactoring to reduce this duplication. http://crbug.com/38924 -void InfoBar::AddLabelAndLink(const std::wstring& display_text, - const std::wstring& link_text, +void InfoBar::AddLabelAndLink(const string16& display_text, + const string16& link_text, size_t link_offset, guint link_padding, GCallback callback) { @@ -159,7 +159,7 @@ void InfoBar::AddLabelAndLink(const std::wstring& display_text, link_offset = std::wstring::npos; } else { // If we have some link text, create the link button. - link_button = gtk_chrome_link_button_new(WideToUTF8(link_text).c_str()); + link_button = gtk_chrome_link_button_new(UTF16ToUTF8(link_text).c_str()); gtk_chrome_link_button_set_use_gtk_theme( GTK_CHROME_LINK_BUTTON(link_button), FALSE); DCHECK(callback); @@ -178,7 +178,7 @@ void InfoBar::AddLabelAndLink(const std::wstring& display_text, if (link_offset == std::wstring::npos) { if (link_button) gtk_box_pack_end(GTK_BOX(hbox), link_button, FALSE, FALSE, 0); - GtkWidget* label = gtk_label_new(WideToUTF8(display_text).c_str()); + GtkWidget* label = gtk_label_new(UTF16ToUTF8(display_text).c_str()); // In order to avoid the link_button and the label overlapping with each // other, we make the label shrinkable. gtk_widget_set_size_request(label, 0, -1); @@ -190,9 +190,9 @@ void InfoBar::AddLabelAndLink(const std::wstring& display_text, DCHECK(link_button); // Need to insert the link inside the display text. GtkWidget* initial_label = gtk_label_new( - WideToUTF8(display_text.substr(0, link_offset)).c_str()); + UTF16ToUTF8(display_text.substr(0, link_offset)).c_str()); GtkWidget* trailing_label = gtk_label_new( - WideToUTF8(display_text.substr(link_offset)).c_str()); + UTF16ToUTF8(display_text.substr(link_offset)).c_str()); // TODO(joth): Unlike the right-align case above, none of the label widgets // are set as shrinkable here, meaning the text will run under the close @@ -289,7 +289,7 @@ class AlertInfoBar : public InfoBar { public: explicit AlertInfoBar(AlertInfoBarDelegate* delegate) : InfoBar(delegate) { - AddLabelAndLink(delegate->GetMessageText(), std::wstring(), 0, 0, NULL); + AddLabelAndLink(delegate->GetMessageText(), string16(), 0, 0, NULL); gtk_widget_show_all(border_bin_.get()); } }; @@ -301,9 +301,9 @@ class LinkInfoBar : public InfoBar { explicit LinkInfoBar(LinkInfoBarDelegate* delegate) : InfoBar(delegate) { size_t link_offset; - std::wstring display_text = + string16 display_text = delegate->GetMessageTextWithOffset(&link_offset); - std::wstring link_text = delegate->GetLinkText(); + string16 link_text = delegate->GetLinkText(); AddLabelAndLink(display_text, link_text, link_offset, 0, G_CALLBACK(OnLinkClick)); gtk_widget_show_all(border_bin_.get()); @@ -326,8 +326,8 @@ class ConfirmInfoBar : public InfoBar { : InfoBar(delegate) { AddConfirmButton(ConfirmInfoBarDelegate::BUTTON_CANCEL); AddConfirmButton(ConfirmInfoBarDelegate::BUTTON_OK); - std::wstring display_text = delegate->GetMessageText(); - std::wstring link_text = delegate->GetLinkText(); + string16 display_text = delegate->GetMessageText(); + string16 link_text = delegate->GetLinkText(); AddLabelAndLink(display_text, link_text, display_text.size(), kElementPadding, G_CALLBACK(OnLinkClick)); gtk_widget_show_all(border_bin_.get()); @@ -338,7 +338,7 @@ class ConfirmInfoBar : public InfoBar { // doesn't specify a button of the given type. void AddConfirmButton(ConfirmInfoBarDelegate::InfoBarButton type) { if (delegate_->AsConfirmInfoBarDelegate()->GetButtons() & type) { - GtkWidget* button = gtk_button_new_with_label(WideToUTF8( + GtkWidget* button = gtk_button_new_with_label(UTF16ToUTF8( delegate_->AsConfirmInfoBarDelegate()->GetButtonLabel(type)).c_str()); gtk_util::CenterWidgetInHBox(hbox_, button, true, 0); g_signal_connect(button, "clicked", diff --git a/chrome/browser/gtk/infobar_gtk.h b/chrome/browser/gtk/infobar_gtk.h index ce1762a..194c39b 100644 --- a/chrome/browser/gtk/infobar_gtk.h +++ b/chrome/browser/gtk/infobar_gtk.h @@ -73,8 +73,8 @@ class InfoBar : public SlideAnimatorGtk::Delegate, // or right aligned in the infobar if |link_offset| is |npos|. |link_padding| // pixels are inserted around the link (pass 0 for not padding). If a link // is supplied, |link_callback| must not be null. It will be invoked on click. - void AddLabelAndLink(const std::wstring& display_text, - const std::wstring& link, + void AddLabelAndLink(const string16& display_text, + const string16& link, size_t link_offset, guint link_padding, GCallback link_callback); diff --git a/chrome/browser/notifications/desktop_notification_service.cc b/chrome/browser/notifications/desktop_notification_service.cc index 0f86e26..8059e1e 100644 --- a/chrome/browser/notifications/desktop_notification_service.cc +++ b/chrome/browser/notifications/desktop_notification_service.cc @@ -117,7 +117,7 @@ class NotificationPermissionInfoBarDelegate : public ConfirmInfoBarDelegate { public: NotificationPermissionInfoBarDelegate(TabContents* contents, const GURL& origin, - const std::wstring& display_name, + const string16& display_name, int process_id, int route_id, int callback_context) @@ -144,8 +144,9 @@ class NotificationPermissionInfoBarDelegate : public ConfirmInfoBarDelegate { delete this; } - virtual std::wstring GetMessageText() const { - return l10n_util::GetStringF(IDS_NOTIFICATION_PERMISSIONS, display_name_); + virtual string16 GetMessageText() const { + return l10n_util::GetStringFUTF16(IDS_NOTIFICATION_PERMISSIONS, + display_name_); } virtual SkBitmap* GetIcon() const { @@ -157,10 +158,10 @@ class NotificationPermissionInfoBarDelegate : public ConfirmInfoBarDelegate { return BUTTON_OK | BUTTON_CANCEL | BUTTON_OK_DEFAULT; } - virtual std::wstring GetButtonLabel(InfoBarButton button) const { + virtual string16 GetButtonLabel(InfoBarButton button) const { return button == BUTTON_OK ? - l10n_util::GetString(IDS_NOTIFICATION_PERMISSION_YES) : - l10n_util::GetString(IDS_NOTIFICATION_PERMISSION_NO); + l10n_util::GetStringUTF16(IDS_NOTIFICATION_PERMISSION_YES) : + l10n_util::GetStringUTF16(IDS_NOTIFICATION_PERMISSION_NO); } virtual bool Accept() { @@ -186,7 +187,7 @@ class NotificationPermissionInfoBarDelegate : public ConfirmInfoBarDelegate { // The display name for the origin to be displayed. Will be different from // origin_ for extensions. - std::wstring display_name_; + string16 display_name_; // The Profile that we restore sessions from. Profile* profile_; @@ -517,10 +518,9 @@ void DesktopNotificationService::RequestPermission( ContentSetting setting = GetContentSetting(origin); if (setting == CONTENT_SETTING_ASK) { // Show an info bar requesting permission. - std::wstring display_name = UTF16ToWide(DisplayNameForOrigin(origin)); - tab->AddInfoBar(new NotificationPermissionInfoBarDelegate( - tab, origin, display_name, process_id, route_id, callback_context)); + tab, origin, DisplayNameForOrigin(origin), process_id, + route_id, callback_context)); } else { // Notify renderer immediately. ChromeThread::PostTask( diff --git a/chrome/browser/omnibox_search_hint.cc b/chrome/browser/omnibox_search_hint.cc index d0ac268..470532d 100644 --- a/chrome/browser/omnibox_search_hint.cc +++ b/chrome/browser/omnibox_search_hint.cc @@ -70,8 +70,8 @@ class HintInfoBar : public ConfirmInfoBarDelegate { omnibox_hint_->DisableHint(); } - virtual std::wstring GetMessageText() const { - return l10n_util::GetString(IDS_OMNIBOX_SEARCH_HINT_INFOBAR_TEXT); + virtual string16 GetMessageText() const { + return l10n_util::GetStringUTF16(IDS_OMNIBOX_SEARCH_HINT_INFOBAR_TEXT); } virtual SkBitmap* GetIcon() const { @@ -83,8 +83,9 @@ class HintInfoBar : public ConfirmInfoBarDelegate { return BUTTON_OK; } - virtual std::wstring GetButtonLabel(InfoBarButton button) const { - return l10n_util::GetString(IDS_OMNIBOX_SEARCH_HINT_INFOBAR_BUTTON_LABEL); + virtual string16 GetButtonLabel(InfoBarButton button) const { + return l10n_util::GetStringUTF16( + IDS_OMNIBOX_SEARCH_HINT_INFOBAR_BUTTON_LABEL); } virtual Type GetInfoBarType() { return PAGE_ACTION_TYPE; } diff --git a/chrome/browser/plugin_installer.cc b/chrome/browser/plugin_installer.cc index 2d0e0a3..1b1d0c5 100644 --- a/chrome/browser/plugin_installer.cc +++ b/chrome/browser/plugin_installer.cc @@ -43,8 +43,8 @@ void PluginInstaller::OnMissingPluginStatus(int status) { } } -std::wstring PluginInstaller::GetMessageText() const { - return l10n_util::GetString(IDS_PLUGININSTALLER_MISSINGPLUGIN_PROMPT); +string16 PluginInstaller::GetMessageText() const { + return l10n_util::GetStringUTF16(IDS_PLUGININSTALLER_MISSINGPLUGIN_PROMPT); } SkBitmap* PluginInstaller::GetIcon() const { @@ -56,9 +56,9 @@ int PluginInstaller::GetButtons() const { return BUTTON_OK; } -std::wstring PluginInstaller::GetButtonLabel(InfoBarButton button) const { +string16 PluginInstaller::GetButtonLabel(InfoBarButton button) const { if (button == BUTTON_OK) - return l10n_util::GetString(IDS_PLUGININSTALLER_INSTALLPLUGIN_BUTTON); + return l10n_util::GetStringUTF16(IDS_PLUGININSTALLER_INSTALLPLUGIN_BUTTON); return ConfirmInfoBarDelegate::GetButtonLabel(button); } @@ -67,8 +67,8 @@ bool PluginInstaller::Accept() { return true; } -std::wstring PluginInstaller::GetLinkText() { - return l10n_util::GetString(IDS_PLUGININSTALLER_PROBLEMSINSTALLING); +string16 PluginInstaller::GetLinkText() { + return l10n_util::GetStringUTF16(IDS_PLUGININSTALLER_PROBLEMSINSTALLING); } bool PluginInstaller::LinkClicked(WindowOpenDisposition disposition) { diff --git a/chrome/browser/plugin_installer.h b/chrome/browser/plugin_installer.h index c2ef2c4..b56034d 100644 --- a/chrome/browser/plugin_installer.h +++ b/chrome/browser/plugin_installer.h @@ -23,12 +23,12 @@ class PluginInstaller : public ConfirmInfoBarDelegate { private: // Overridden from ConfirmInfoBarDelegate: - virtual std::wstring GetMessageText() const; + virtual string16 GetMessageText() const; virtual SkBitmap* GetIcon() const; virtual int GetButtons() const; - virtual std::wstring GetButtonLabel(InfoBarButton button) const; + virtual string16 GetButtonLabel(InfoBarButton button) const; virtual bool Accept(); - virtual std::wstring GetLinkText(); + virtual string16 GetLinkText(); virtual bool LinkClicked(WindowOpenDisposition disposition); // The containing TabContents diff --git a/chrome/browser/printing/print_dialog_gtk.cc b/chrome/browser/printing/print_dialog_gtk.cc index 5cc203d..7bf9a39 100644 --- a/chrome/browser/printing/print_dialog_gtk.cc +++ b/chrome/browser/printing/print_dialog_gtk.cc @@ -12,6 +12,7 @@ #include "base/lazy_instance.h" #include "base/lock.h" #include "base/logging.h" +#include "base/utf_string_conversions.h" #include "chrome/browser/browser_list.h" #include "chrome/browser/browser_window.h" #include "chrome/browser/chrome_thread.h" @@ -39,15 +40,15 @@ class PdfUnsupportedInfoBarDelegate : public LinkInfoBarDelegate { virtual ~PdfUnsupportedInfoBarDelegate() {} - virtual std::wstring GetMessageTextWithOffset(size_t* link_offset) const { - std::wstring message(L"Oops! Your printer does not support PDF. Please " - L"report this to us ."); + virtual string16 GetMessageTextWithOffset(size_t* link_offset) const { + string16 message = UTF8ToUTF16("Oops! Your printer does not support PDF. " + "Please report this to us."); *link_offset = message.length() - 1; return message; } - virtual std::wstring GetLinkText() const { - return std::wstring(L"here"); + virtual string16 GetLinkText() const { + return UTF8ToUTF16("here"); } virtual Type GetInfoBarType() { diff --git a/chrome/browser/ssl/ssl_policy_backend.cc b/chrome/browser/ssl/ssl_policy_backend.cc index 42fef7a..16d12dc 100644 --- a/chrome/browser/ssl/ssl_policy_backend.cc +++ b/chrome/browser/ssl/ssl_policy_backend.cc @@ -5,6 +5,7 @@ #include "chrome/browser/ssl/ssl_policy_backend.h" #include "app/resource_bundle.h" +#include "base/utf_string_conversions.h" #include "chrome/browser/profile.h" #include "chrome/browser/ssl/ssl_host_state.h" #include "chrome/browser/tab_contents/infobar_delegate.h" @@ -17,8 +18,8 @@ class SSLInfoBarDelegate : public ConfirmInfoBarDelegate { public: SSLInfoBarDelegate(TabContents* contents, - const std::wstring message, - const std::wstring& button_label, + const string16& message, + const string16& button_label, Task* task) : ConfirmInfoBarDelegate(contents), message_(message), @@ -31,7 +32,7 @@ class SSLInfoBarDelegate : public ConfirmInfoBarDelegate { virtual void InfoBarClosed() { delete this; } - virtual std::wstring GetMessageText() const { + virtual string16 GetMessageText() const { return message_; } virtual SkBitmap* GetIcon() const { @@ -41,7 +42,7 @@ class SSLInfoBarDelegate : public ConfirmInfoBarDelegate { virtual int GetButtons() const { return !button_label_.empty() ? BUTTON_OK : BUTTON_NONE; } - virtual std::wstring GetButtonLabel(InfoBarButton button) const { + virtual string16 GetButtonLabel(InfoBarButton button) const { return button_label_; } virtual bool Accept() { @@ -54,8 +55,8 @@ class SSLInfoBarDelegate : public ConfirmInfoBarDelegate { private: // Labels for the InfoBar's message and button. - std::wstring message_; - std::wstring button_label_; + string16 message_; + string16 button_label_; // A task to run when the InfoBar is accepted. scoped_ptr<Task> task_; @@ -96,8 +97,12 @@ void SSLPolicyBackend::ShowMessageWithLink(const std::wstring& msg, return; if (controller_->tab_contents()) { + // TODO(evanm): remove base/utf_string_conversions.h include after fixing + // below conversions. controller_->tab_contents()->AddInfoBar( - new SSLInfoBarDelegate(controller_->tab_contents(), msg, link_text, + new SSLInfoBarDelegate(controller_->tab_contents(), + WideToUTF16Hack(msg), + WideToUTF16Hack(link_text), task)); } } diff --git a/chrome/browser/tab_contents/infobar_delegate.cc b/chrome/browser/tab_contents/infobar_delegate.cc index b703c7a..aae8553 100644 --- a/chrome/browser/tab_contents/infobar_delegate.cc +++ b/chrome/browser/tab_contents/infobar_delegate.cc @@ -55,14 +55,14 @@ LinkInfoBarDelegate::LinkInfoBarDelegate(TabContents* contents) // ConfirmInfoBarDelegate: ----------------------------------------------------- -std::wstring ConfirmInfoBarDelegate::GetButtonLabel( +string16 ConfirmInfoBarDelegate::GetButtonLabel( InfoBarButton button) const { if (button == BUTTON_OK) - return l10n_util::GetString(IDS_OK); + return l10n_util::GetStringUTF16(IDS_OK); if (button == BUTTON_CANCEL) - return l10n_util::GetString(IDS_CANCEL); + return l10n_util::GetStringUTF16(IDS_CANCEL); NOTREACHED(); - return std::wstring(); + return string16(); } ConfirmInfoBarDelegate::ConfirmInfoBarDelegate(TabContents* contents) @@ -73,7 +73,7 @@ ConfirmInfoBarDelegate::ConfirmInfoBarDelegate(TabContents* contents) SimpleAlertInfoBarDelegate::SimpleAlertInfoBarDelegate( TabContents* contents, - const std::wstring& message, + const string16& message, SkBitmap* icon, bool auto_expire) : AlertInfoBarDelegate(contents), @@ -90,7 +90,7 @@ bool SimpleAlertInfoBarDelegate::ShouldExpire( return false; } -std::wstring SimpleAlertInfoBarDelegate::GetMessageText() const { +string16 SimpleAlertInfoBarDelegate::GetMessageText() const { return message_; } diff --git a/chrome/browser/tab_contents/infobar_delegate.h b/chrome/browser/tab_contents/infobar_delegate.h index 7be7b1e..33336b8 100644 --- a/chrome/browser/tab_contents/infobar_delegate.h +++ b/chrome/browser/tab_contents/infobar_delegate.h @@ -156,7 +156,7 @@ class InfoBarDelegate { class AlertInfoBarDelegate : public InfoBarDelegate { public: // Returns the message string to be displayed for the InfoBar. - virtual std::wstring GetMessageText() const = 0; + virtual string16 GetMessageText() const = 0; // Overridden from InfoBarDelegate. virtual SkBitmap* GetIcon() const { return NULL; } @@ -178,15 +178,15 @@ class LinkInfoBarDelegate : public InfoBarDelegate { public: // Returns the message string to be displayed in the InfoBar. |link_offset| // is the position where the link should be inserted. If |link_offset| is set - // to std::wstring::npos (it is by default), the link is right aligned within + // to string16::npos (it is by default), the link is right aligned within // the InfoBar rather than being embedded in the message text. - virtual std::wstring GetMessageTextWithOffset(size_t* link_offset) const { - *link_offset = std::wstring::npos; - return std::wstring(); + virtual string16 GetMessageTextWithOffset(size_t* link_offset) const { + *link_offset = string16::npos; + return string16(); } // Returns the text of the link to be displayed. - virtual std::wstring GetLinkText() const = 0; + virtual string16 GetLinkText() const = 0; // Overridden from InfoBarDelegate. virtual SkBitmap* GetIcon() const { return NULL; } @@ -231,7 +231,7 @@ class ConfirmInfoBarDelegate : public AlertInfoBarDelegate { // Return the label for the specified button. The default implementation // returns "OK" for the OK button and "Cancel" for the Cancel button. - virtual std::wstring GetButtonLabel(InfoBarButton button) const; + virtual string16 GetButtonLabel(InfoBarButton button) const; // Return whether or not the specified button needs elevation. virtual bool NeedElevation(InfoBarButton button) const { return false; } @@ -246,8 +246,8 @@ class ConfirmInfoBarDelegate : public AlertInfoBarDelegate { // Returns the text of the link to be displayed, if any. Otherwise returns // and empty string. - virtual std::wstring GetLinkText() { - return std::wstring(); + virtual string16 GetLinkText() { + return string16(); } // Called when the Link is clicked. The |disposition| specifies how the @@ -278,19 +278,19 @@ class SimpleAlertInfoBarDelegate : public AlertInfoBarDelegate { public: // |icon| may be |NULL|. SimpleAlertInfoBarDelegate(TabContents* contents, - const std::wstring& message, + const string16& message, SkBitmap* icon, bool auto_expire); // Overridden from AlertInfoBarDelegate: virtual bool ShouldExpire( const NavigationController::LoadCommittedDetails& details) const; - virtual std::wstring GetMessageText() const; + virtual string16 GetMessageText() const; virtual SkBitmap* GetIcon() const; virtual void InfoBarClosed(); private: - std::wstring message_; + string16 message_; SkBitmap* icon_; bool auto_expire_; // Should it expire automatically on navigation? diff --git a/chrome/browser/tab_contents/tab_contents.cc b/chrome/browser/tab_contents/tab_contents.cc index c6b8876..9ab1020 100644 --- a/chrome/browser/tab_contents/tab_contents.cc +++ b/chrome/browser/tab_contents/tab_contents.cc @@ -252,21 +252,20 @@ class DisabledPluginInfoBar : public ConfirmInfoBarDelegate { return BUTTON_OK | BUTTON_CANCEL | BUTTON_OK_DEFAULT; } - virtual std::wstring GetButtonLabel(InfoBarButton button) const { + virtual string16 GetButtonLabel(InfoBarButton button) const { if (button == BUTTON_CANCEL) - return l10n_util::GetString(IDS_PLUGIN_ENABLE_TEMPORARILY); + return l10n_util::GetStringUTF16(IDS_PLUGIN_ENABLE_TEMPORARILY); if (button == BUTTON_OK) - return l10n_util::GetString(IDS_PLUGIN_UPDATE); + return l10n_util::GetStringUTF16(IDS_PLUGIN_UPDATE); return ConfirmInfoBarDelegate::GetButtonLabel(button); } - virtual std::wstring GetMessageText() const { - return UTF16ToWide(l10n_util::GetStringFUTF16(IDS_PLUGIN_OUTDATED_PROMPT, - name_)); + virtual string16 GetMessageText() const { + return l10n_util::GetStringFUTF16(IDS_PLUGIN_OUTDATED_PROMPT, name_); } - virtual std::wstring GetLinkText() { - return l10n_util::GetString(IDS_LEARN_MORE); + virtual string16 GetLinkText() { + return l10n_util::GetStringUTF16(IDS_LEARN_MORE); } virtual SkBitmap* GetIcon() const { @@ -1985,13 +1984,14 @@ void TabContents::OnCrashedPlugin(const FilePath& plugin_path) { SkBitmap* crash_icon = ResourceBundle::GetSharedInstance().GetBitmapNamed( IDR_INFOBAR_PLUGIN_CRASHED); AddInfoBar(new SimpleAlertInfoBarDelegate( - this, l10n_util::GetStringF(IDS_PLUGIN_CRASHED_PROMPT, plugin_name), + this, l10n_util::GetStringFUTF16(IDS_PLUGIN_CRASHED_PROMPT, + WideToUTF16Hack(plugin_name)), crash_icon, true)); } void TabContents::OnCrashedWorker() { AddInfoBar(new SimpleAlertInfoBarDelegate( - this, l10n_util::GetString(IDS_WEBWORKER_CRASHED_PROMPT), + this, l10n_util::GetStringUTF16(IDS_WEBWORKER_CRASHED_PROMPT), NULL, true)); } @@ -2860,7 +2860,8 @@ void TabContents::OnIgnoredUIEvent() { void TabContents::OnJSOutOfMemory() { AddInfoBar(new SimpleAlertInfoBarDelegate( - this, l10n_util::GetString(IDS_JS_OUT_OF_MEMORY_PROMPT), NULL, true)); + this, l10n_util::GetStringUTF16(IDS_JS_OUT_OF_MEMORY_PROMPT), + NULL, true)); } void TabContents::OnCrossSiteResponse(int new_render_process_host_id, @@ -3238,8 +3239,8 @@ class SavePasswordInfoBarDelegate : public ConfirmInfoBarDelegate { virtual Type GetInfoBarType() { return PAGE_ACTION_TYPE; } - virtual std::wstring GetMessageText() const { - return l10n_util::GetString(IDS_PASSWORD_MANAGER_SAVE_PASSWORD_PROMPT); + virtual string16 GetMessageText() const { + return l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_SAVE_PASSWORD_PROMPT); } virtual SkBitmap* GetIcon() const { @@ -3251,13 +3252,13 @@ class SavePasswordInfoBarDelegate : public ConfirmInfoBarDelegate { return BUTTON_OK | BUTTON_CANCEL; } - virtual std::wstring GetButtonLabel(InfoBarButton button) const { + virtual string16 GetButtonLabel(InfoBarButton button) const { if (button == BUTTON_OK) - return l10n_util::GetString(IDS_PASSWORD_MANAGER_SAVE_BUTTON); + return l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_SAVE_BUTTON); if (button == BUTTON_CANCEL) - return l10n_util::GetString(IDS_PASSWORD_MANAGER_BLACKLIST_BUTTON); + return l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_BLACKLIST_BUTTON); NOTREACHED(); - return std::wstring(); + return string16(); } virtual bool Accept() { diff --git a/chrome/browser/tab_contents/tab_contents_ssl_helper.cc b/chrome/browser/tab_contents/tab_contents_ssl_helper.cc index db6d960..2dde79e 100644 --- a/chrome/browser/tab_contents/tab_contents_ssl_helper.cc +++ b/chrome/browser/tab_contents/tab_contents_ssl_helper.cc @@ -41,9 +41,11 @@ class SSLCertAddedInfoBarDelegate : public ConfirmInfoBarDelegate { } // Overridden from ConfirmInfoBarDelegate: - virtual std::wstring GetMessageText() const { - return l10n_util::GetStringF(IDS_ADD_CERT_SUCCESS_INFOBAR_LABEL, - UTF8ToWide(cert_->issuer().GetDisplayName())); + virtual string16 GetMessageText() const { + // TODO(evanm): GetDisplayName should return UTF-16. + return l10n_util::GetStringFUTF16( + IDS_ADD_CERT_SUCCESS_INFOBAR_LABEL, + UTF8ToUTF16(cert_->issuer().GetDisplayName())); } virtual SkBitmap* GetIcon() const { @@ -54,12 +56,12 @@ class SSLCertAddedInfoBarDelegate : public ConfirmInfoBarDelegate { return BUTTON_OK; } - virtual std::wstring GetButtonLabel(InfoBarButton button) const { + virtual string16 GetButtonLabel(InfoBarButton button) const { switch (button) { case BUTTON_OK: - return l10n_util::GetString(IDS_ADD_CERT_SUCCESS_INFOBAR_BUTTON); + return l10n_util::GetStringUTF16(IDS_ADD_CERT_SUCCESS_INFOBAR_BUTTON); default: - return std::wstring(); + return string16(); } } @@ -114,7 +116,10 @@ class TabContentsSSLHelper::SSLAddCertData : public NotificationObserver { void ShowErrorInfoBar(const std::wstring& message) { ShowInfoBar( - new SimpleAlertInfoBarDelegate(tab_, message, GetCertIcon(), true)); + new SimpleAlertInfoBarDelegate(tab_, + WideToUTF16(message), + GetCertIcon(), + true)); } // NotificationObserver implementation. diff --git a/chrome/browser/views/infobars/infobars.cc b/chrome/browser/views/infobars/infobars.cc index 1d78058..a9e1688 100644 --- a/chrome/browser/views/infobars/infobars.cc +++ b/chrome/browser/views/infobars/infobars.cc @@ -11,6 +11,7 @@ #include "app/win_util.h" #endif // defined(OS_WIN) #include "base/message_loop.h" +#include "base/utf_string_conversions.h" #include "chrome/browser/views/event_utils.h" #include "chrome/browser/views/infobars/infobar_container.h" #include "gfx/canvas.h" @@ -33,9 +34,6 @@ const int InfoBar::kEndOfLabelSpacing = 16; const int InfoBar::kCloseButtonSpacing = 12; const int InfoBar::kButtonInLabelSpacing = 5; -static const SkColor kInfoBackgroundColorTop = SkColorSetRGB(170, 214, 112); -static const SkColor kInfoBackgroundColorBottom = SkColorSetRGB(146, 205, 114); - static const SkColor kWarningBackgroundColorTop = SkColorSetRGB(255, 242, 183); static const SkColor kWarningBackgroundColorBottom = SkColorSetRGB(250, 230, 145); @@ -295,7 +293,7 @@ void InfoBar::DeleteSelf() { AlertInfoBar::AlertInfoBar(AlertInfoBarDelegate* delegate) : InfoBar(delegate) { label_ = new views::Label( - delegate->GetMessageText(), + UTF16ToWideHack(delegate->GetMessageText()), ResourceBundle::GetSharedInstance().GetFont(ResourceBundle::MediumFont)); label_->SetColor(SK_ColorBLACK); label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); @@ -350,12 +348,12 @@ LinkInfoBar::LinkInfoBar(LinkInfoBarDelegate* delegate) // Set up the labels. size_t offset; - std::wstring message_text = delegate->GetMessageTextWithOffset(&offset); - if (offset != std::wstring::npos) { - label_1_->SetText(message_text.substr(0, offset)); - label_2_->SetText(message_text.substr(offset)); + string16 message_text = delegate->GetMessageTextWithOffset(&offset); + if (offset != string16::npos) { + label_1_->SetText(UTF16ToWideHack(message_text.substr(0, offset))); + label_2_->SetText(UTF16ToWideHack(message_text.substr(offset))); } else { - label_1_->SetText(message_text); + label_1_->SetText(UTF16ToWideHack(message_text)); } ResourceBundle& rb = ResourceBundle::GetSharedInstance(); label_1_->SetFont(rb.GetFont(ResourceBundle::MediumFont)); @@ -368,7 +366,7 @@ LinkInfoBar::LinkInfoBar(LinkInfoBarDelegate* delegate) AddChildView(label_2_); // Set up the link. - link_->SetText(delegate->GetLinkText()); + link_->SetText(UTF16ToWideHack(delegate->GetLinkText())); link_->SetFont(rb.GetFont(ResourceBundle::MediumFont)); link_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); link_->SetController(this); @@ -446,20 +444,22 @@ ConfirmInfoBar::ConfirmInfoBar(ConfirmInfoBarDelegate* delegate) cancel_button_(NULL), link_(NULL), initialized_(false) { - ok_button_ = new views::NativeButton( - this, delegate->GetButtonLabel(ConfirmInfoBarDelegate::BUTTON_OK)); + ok_button_ = new views::NativeButton(this, + UTF16ToWideHack(delegate->GetButtonLabel( + ConfirmInfoBarDelegate::BUTTON_OK))); ok_button_->SetAccessibleName(ok_button_->label()); if (delegate->GetButtons() & ConfirmInfoBarDelegate::BUTTON_OK_DEFAULT) ok_button_->SetAppearsAsDefault(true); if (delegate->NeedElevation(ConfirmInfoBarDelegate::BUTTON_OK)) ok_button_->SetNeedElevation(true); cancel_button_ = new views::NativeButton( - this, delegate->GetButtonLabel(ConfirmInfoBarDelegate::BUTTON_CANCEL)); + this, UTF16ToWideHack( + delegate->GetButtonLabel(ConfirmInfoBarDelegate::BUTTON_CANCEL))); cancel_button_->SetAccessibleName(cancel_button_->label()); // Set up the link. link_ = new views::Link; - link_->SetText(delegate->GetLinkText()); + link_->SetText(UTF16ToWideHack(delegate->GetLinkText())); ResourceBundle& rb = ResourceBundle::GetSharedInstance(); link_->SetFont(rb.GetFont(ResourceBundle::MediumFont)); link_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); |