summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorjshin@chromium.org <jshin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-24 22:17:06 +0000
committerjshin@chromium.org <jshin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-24 22:17:06 +0000
commitd70539de3df8f214397881727229a7786da9be35 (patch)
treed10df8d461702c8de9b6df045955ee2226edc046 /chrome
parent16792a730c621ed32aa53b57d57e6c88e232ea02 (diff)
downloadchromium_src-d70539de3df8f214397881727229a7786da9be35.zip
chromium_src-d70539de3df8f214397881727229a7786da9be35.tar.gz
chromium_src-d70539de3df8f214397881727229a7786da9be35.tar.bz2
Replace std:;wstring with std::string and string16 in locale-name related APIs.
1. Change the locale param to be std::string because they're always ASCII and change call-sites accordingly. 2. Add GetStringFUTF16 to l10n_util. On Windows, they're inline helpers calling the correspondingGetStringF returning wstring while on Mac/Linux, they just return the result of |string16 GetStringF|without converting to wstring. This is part 1 of the fix for issue 8647. Some of newly introduced conversions are temporary and will be removed later (e.g. ASCIIToWide applied to the result of GetApplicationLocale in a few places). Note : this CL will be landed after http://codereview.chromium.org/147038 is landed. BUG=8647 (http://crbug.com/8647) TEST=Pass l10n_util_unittest and other unit tests Review URL: http://codereview.chromium.org/126223 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19183 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rwxr-xr-xchrome/browser/automation/automation_provider.cc2
-rw-r--r--chrome/browser/bookmarks/bookmark_model.cc2
-rw-r--r--chrome/browser/browser_process.h2
-rw-r--r--chrome/browser/browser_process_impl.cc6
-rw-r--r--chrome/browser/browser_process_impl.h4
-rw-r--r--chrome/browser/character_encoding.cc2
-rw-r--r--chrome/browser/character_encoding.h2
-rw-r--r--chrome/browser/first_run_win.cc2
-rw-r--r--chrome/browser/google_util.cc2
-rw-r--r--chrome/browser/plugin_service.cc3
-rw-r--r--chrome/browser/renderer_host/browser_render_process_host.cc4
-rw-r--r--chrome/browser/search_engines/template_url.cc3
-rw-r--r--chrome/browser/search_engines/template_url_unittest.cc2
-rw-r--r--chrome/browser/tab_contents/render_view_context_menu.cc36
-rw-r--r--chrome/browser/tab_contents/render_view_context_menu.h8
-rw-r--r--chrome/browser/tab_contents/render_view_context_menu_gtk.cc16
-rw-r--r--chrome/browser/tab_contents/render_view_context_menu_gtk.h10
-rw-r--r--chrome/browser/tab_contents/render_view_context_menu_mac.h10
-rw-r--r--chrome/browser/tab_contents/render_view_context_menu_mac.mm14
-rw-r--r--chrome/browser/views/options/fonts_page_view.cc2
-rw-r--r--chrome/browser/views/options/language_combobox_model.cc3
-rw-r--r--chrome/browser/views/options/languages_page_view.cc23
-rw-r--r--chrome/test/automated_ui_tests/automated_ui_tests.cc2
-rw-r--r--chrome/test/testing_browser_process.h6
-rw-r--r--chrome/test/unit/chrome_test_suite.h4
25 files changed, 89 insertions, 81 deletions
diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc
index ce26d28..0fe9706 100755
--- a/chrome/browser/automation/automation_provider.cc
+++ b/chrome/browser/automation/automation_provider.cc
@@ -1315,7 +1315,7 @@ void AutomationProvider::GetActiveTabIndex(int handle, int* active_tab_index) {
void AutomationProvider::GetBrowserLocale(string16* locale) {
DCHECK(g_browser_process);
- *locale = WideToUTF16(g_browser_process->GetApplicationLocale());
+ *locale = ASCIIToUTF16(g_browser_process->GetApplicationLocale());
}
void AutomationProvider::GetBrowserWindowCount(int* window_count) {
diff --git a/chrome/browser/bookmarks/bookmark_model.cc b/chrome/browser/bookmarks/bookmark_model.cc
index 1f75e0a..83bd08a 100644
--- a/chrome/browser/bookmarks/bookmark_model.cc
+++ b/chrome/browser/bookmarks/bookmark_model.cc
@@ -330,7 +330,7 @@ void BookmarkModel::SortChildren(BookmarkNode* parent) {
UErrorCode error = U_ZERO_ERROR;
scoped_ptr<Collator> collator(
Collator::createInstance(
- Locale(WideToUTF8(g_browser_process->GetApplicationLocale()).c_str()),
+ Locale(g_browser_process->GetApplicationLocale().c_str()),
error));
if (U_FAILURE(error))
collator.reset(NULL);
diff --git a/chrome/browser/browser_process.h b/chrome/browser/browser_process.h
index a329c6c..63a7412 100644
--- a/chrome/browser/browser_process.h
+++ b/chrome/browser/browser_process.h
@@ -129,7 +129,7 @@ class BrowserProcess {
virtual GoogleURLTracker* google_url_tracker() = 0;
// Returns the locale used by the application.
- virtual const std::wstring& GetApplicationLocale() = 0;
+ virtual const std::string& GetApplicationLocale() = 0;
virtual MemoryModel memory_model() = 0;
diff --git a/chrome/browser/browser_process_impl.cc b/chrome/browser/browser_process_impl.cc
index 844234ffb..46d86f1 100644
--- a/chrome/browser/browser_process_impl.cc
+++ b/chrome/browser/browser_process_impl.cc
@@ -262,11 +262,11 @@ printing::PrintJobManager* BrowserProcessImpl::print_job_manager() {
return print_job_manager_.get();
}
-const std::wstring& BrowserProcessImpl::GetApplicationLocale() {
+const std::string& BrowserProcessImpl::GetApplicationLocale() {
DCHECK(CalledOnValidThread());
if (locale_.empty()) {
- locale_ = l10n_util::GetApplicationLocale(local_state()->GetString(
- prefs::kApplicationLocale));
+ locale_ = l10n_util::GetApplicationLocale(
+ local_state()->GetString(prefs::kApplicationLocale));
}
return locale_;
}
diff --git a/chrome/browser/browser_process_impl.h b/chrome/browser/browser_process_impl.h
index 671f6b7..d33c493 100644
--- a/chrome/browser/browser_process_impl.h
+++ b/chrome/browser/browser_process_impl.h
@@ -185,7 +185,7 @@ class BrowserProcessImpl : public BrowserProcess, public NonThreadSafe {
return google_url_tracker_.get();
}
- virtual const std::wstring& GetApplicationLocale();
+ virtual const std::string& GetApplicationLocale();
virtual MemoryModel memory_model() {
DCHECK(CalledOnValidThread());
@@ -268,7 +268,7 @@ class BrowserProcessImpl : public BrowserProcess, public NonThreadSafe {
// Ensures that all the print jobs are finished before closing the browser.
scoped_ptr<printing::PrintJobManager> print_job_manager_;
- std::wstring locale_;
+ std::string locale_;
MemoryModel memory_model_;
diff --git a/chrome/browser/character_encoding.cc b/chrome/browser/character_encoding.cc
index da65159..841b48b 100644
--- a/chrome/browser/character_encoding.cc
+++ b/chrome/browser/character_encoding.cc
@@ -344,7 +344,7 @@ std::wstring CharacterEncoding::GetCanonicalEncodingNameByAliasName(
// At last, we put all rest encoding items.
const std::vector<CharacterEncoding::EncodingInfo>*
CharacterEncoding::GetCurrentDisplayEncodings(
- const std::wstring& locale,
+ const std::string& locale,
const std::wstring& locale_encodings,
const std::wstring& recently_select_encodings) {
std::vector<int>* const locale_dependent_encoding_list =
diff --git a/chrome/browser/character_encoding.h b/chrome/browser/character_encoding.h
index a676403..e1b6d9e 100644
--- a/chrome/browser/character_encoding.h
+++ b/chrome/browser/character_encoding.h
@@ -79,7 +79,7 @@ class CharacterEncoding {
// is from user recently selected. THIS FUNCTION IS NOT THREADSAFE. You must
// run this function only in UI thread.
static const std::vector<EncodingInfo>* GetCurrentDisplayEncodings(
- const std::wstring& locale,
+ const std::string& locale,
const std::wstring& locale_encodings,
const std::wstring& recently_select_encodings);
diff --git a/chrome/browser/first_run_win.cc b/chrome/browser/first_run_win.cc
index 136350c..165f10ee 100644
--- a/chrome/browser/first_run_win.cc
+++ b/chrome/browser/first_run_win.cc
@@ -523,7 +523,7 @@ bool FirstRun::ImportSettings(Profile* profile, int browser_type,
// current command line as fallback.
import_cmd.AppendSwitchWithValue(
switches::kLang,
- g_browser_process->GetApplicationLocale());
+ ASCIIToWide(g_browser_process->GetApplicationLocale()));
import_cmd.CommandLine::AppendSwitchWithValue(switches::kImport,
EncodeImportParams(browser_type, items_to_import, parent_window));
diff --git a/chrome/browser/google_util.cc b/chrome/browser/google_util.cc
index e33f6ca..0949d2f 100644
--- a/chrome/browser/google_util.cc
+++ b/chrome/browser/google_util.cc
@@ -33,7 +33,7 @@ namespace google_util {
GURL AppendGoogleLocaleParam(const GURL& url) {
return AppendParam(url, "hl",
- WideToUTF8(g_browser_process->GetApplicationLocale()));
+ g_browser_process->GetApplicationLocale());
}
GURL AppendGoogleTLDParam(const GURL& url) {
diff --git a/chrome/browser/plugin_service.cc b/chrome/browser/plugin_service.cc
index c49d56d..d9d3e65 100644
--- a/chrome/browser/plugin_service.cc
+++ b/chrome/browser/plugin_service.cc
@@ -7,6 +7,7 @@
#include "chrome/browser/plugin_service.h"
#include "base/command_line.h"
+#include "base/string_util.h"
#include "base/thread.h"
#include "base/waitable_event.h"
#include "chrome/browser/browser_process.h"
@@ -33,7 +34,7 @@ PluginService* PluginService::GetInstance() {
PluginService::PluginService()
: main_message_loop_(MessageLoop::current()),
resource_dispatcher_host_(NULL),
- ui_locale_(g_browser_process->GetApplicationLocale()) {
+ ui_locale_(ASCIIToWide(g_browser_process->GetApplicationLocale())) {
// Have the NPAPI plugin list search for Chrome plugins as well.
ChromePluginLib::RegisterPluginsWithNPAPI();
// Load the one specified on the command line as well.
diff --git a/chrome/browser/renderer_host/browser_render_process_host.cc b/chrome/browser/renderer_host/browser_render_process_host.cc
index 2fd6289..1c6fe9b 100644
--- a/chrome/browser/renderer_host/browser_render_process_host.cc
+++ b/chrome/browser/renderer_host/browser_render_process_host.cc
@@ -307,8 +307,8 @@ bool BrowserRenderProcessHost::Init() {
}
// Pass on the browser locale.
- const std::wstring locale = g_browser_process->GetApplicationLocale();
- cmd_line.AppendSwitchWithValue(switches::kLang, locale);
+ const std::string locale = g_browser_process->GetApplicationLocale();
+ cmd_line.AppendSwitchWithValue(switches::kLang, ASCIIToWide(locale));
// If we run a FieldTrial that we want to pass to the renderer, this is where
// the SINGULAR trial name and value should be specified. Note that only one
diff --git a/chrome/browser/search_engines/template_url.cc b/chrome/browser/search_engines/template_url.cc
index e749e89..0c98d48 100644
--- a/chrome/browser/search_engines/template_url.cc
+++ b/chrome/browser/search_engines/template_url.cc
@@ -317,7 +317,8 @@ std::wstring TemplateURLRef::ReplaceSearchTerms(
}
case LANGUAGE:
- url.insert(i->index, g_browser_process->GetApplicationLocale());
+ url.insert(i->index,
+ ASCIIToWide(g_browser_process->GetApplicationLocale()));
break;
case SEARCH_TERMS:
diff --git a/chrome/browser/search_engines/template_url_unittest.cc b/chrome/browser/search_engines/template_url_unittest.cc
index 5aa9ce5b..f6825d2 100644
--- a/chrome/browser/search_engines/template_url_unittest.cc
+++ b/chrome/browser/search_engines/template_url_unittest.cc
@@ -238,7 +238,7 @@ TEST_F(TemplateURLTest, ReplaceSearchTerms) {
EXPECT_TRUE(ref.SupportsReplacement());
std::string expected_result = data[i].expected_result;
ReplaceSubstringsAfterOffset(&expected_result, 0, "{language}",
- WideToASCII(g_browser_process->GetApplicationLocale()));
+ g_browser_process->GetApplicationLocale());
GURL result = GURL(WideToUTF8(ref.ReplaceSearchTerms(turl, L"X",
TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, std::wstring())));
EXPECT_TRUE(result.is_valid());
diff --git a/chrome/browser/tab_contents/render_view_context_menu.cc b/chrome/browser/tab_contents/render_view_context_menu.cc
index 94c789d..3fae586 100644
--- a/chrome/browser/tab_contents/render_view_context_menu.cc
+++ b/chrome/browser/tab_contents/render_view_context_menu.cc
@@ -84,7 +84,8 @@ void RenderViewContextMenu::AppendLinkItems() {
if (params_.link_url.SchemeIs(chrome::kMailToScheme)) {
AppendMenuItem(IDS_CONTENT_CONTEXT_COPYLINKLOCATION,
- l10n_util::GetString(IDS_CONTENT_CONTEXT_COPYEMAILADDRESS));
+ l10n_util::GetStringUTF16(
+ IDS_CONTENT_CONTEXT_COPYEMAILADDRESS));
} else {
AppendMenuItem(IDS_CONTENT_CONTEXT_COPYLINKLOCATION);
}
@@ -136,9 +137,10 @@ void RenderViewContextMenu::AppendSearchProvider() {
std::wstring selection_text =
l10n_util::TruncateString(params_.selection_text, 50);
if (!selection_text.empty()) {
- std::wstring label(l10n_util::GetStringF(IDS_CONTENT_CONTEXT_SEARCHWEBFOR,
- default_provider->short_name(),
- selection_text));
+ string16 label(WideToUTF16(
+ l10n_util::GetStringF(IDS_CONTENT_CONTEXT_SEARCHWEBFOR,
+ default_provider->short_name(),
+ selection_text)));
AppendMenuItem(IDS_CONTENT_CONTEXT_SEARCHWEBFOR, label);
}
}
@@ -150,7 +152,7 @@ void RenderViewContextMenu::AppendEditableItems() {
IDC_SPELLCHECK_SUGGESTION_0 + i <= IDC_SPELLCHECK_SUGGESTION_LAST;
++i) {
AppendMenuItem(IDC_SPELLCHECK_SUGGESTION_0 + static_cast<int>(i),
- params_.dictionary_suggestions[i]);
+ WideToUTF16(params_.dictionary_suggestions[i]));
}
if (params_.dictionary_suggestions.size() > 0)
AppendSeparator();
@@ -159,7 +161,8 @@ void RenderViewContextMenu::AppendEditableItems() {
if (!params_.misspelled_word.empty()) {
if (params_.dictionary_suggestions.size() == 0) {
AppendMenuItem(0,
- l10n_util::GetString(IDS_CONTENT_CONTEXT_NO_SPELLING_SUGGESTIONS));
+ l10n_util::GetStringUTF16(
+ IDS_CONTENT_CONTEXT_NO_SPELLING_SUGGESTIONS));
}
AppendMenuItem(IDS_CONTENT_CONTEXT_ADD_TO_DICTIONARY);
AppendSeparator();
@@ -176,19 +179,19 @@ void RenderViewContextMenu::AppendEditableItems() {
// Add Spell Check options sub menu.
StartSubMenu(IDC_SPELLCHECK_MENU,
- l10n_util::GetString(IDS_CONTENT_CONTEXT_SPELLCHECK_MENU));
+ l10n_util::GetStringUTF16(IDS_CONTENT_CONTEXT_SPELLCHECK_MENU));
// Add Spell Check languages to sub menu.
- SpellChecker::Languages display_languages;
+ SpellChecker::Languages spellcheck_languages;
SpellChecker::GetSpellCheckLanguages(profile_,
- &display_languages);
- DCHECK(display_languages.size() <
+ &spellcheck_languages);
+ DCHECK(spellcheck_languages.size() <
IDC_SPELLCHECK_LANGUAGES_LAST - IDC_SPELLCHECK_LANGUAGES_FIRST);
- const std::wstring app_locale = g_browser_process->GetApplicationLocale();
- for (size_t i = 0; i < display_languages.size(); ++i) {
- std::wstring local_language(l10n_util::GetLocalName(
- display_languages[i], app_locale, true));
- AppendRadioMenuItem(IDC_SPELLCHECK_LANGUAGES_FIRST + i, local_language);
+ const std::string app_locale = g_browser_process->GetApplicationLocale();
+ for (size_t i = 0; i < spellcheck_languages.size(); ++i) {
+ string16 display_name(l10n_util::GetDisplayNameForLocale(
+ spellcheck_languages[i], app_locale, true));
+ AppendRadioMenuItem(IDC_SPELLCHECK_LANGUAGES_FIRST + i, display_name);
}
// Add item in the sub menu to pop up the fonts and languages options menu.
@@ -198,7 +201,8 @@ void RenderViewContextMenu::AppendEditableItems() {
// Add 'Check the spelling of this field' item in the sub menu.
AppendCheckboxMenuItem(
IDC_CHECK_SPELLING_OF_THIS_FIELD,
- l10n_util::GetString(IDS_CONTENT_CONTEXT_CHECK_SPELLING_OF_THIS_FIELD));
+ l10n_util::GetStringUTF16(
+ IDS_CONTENT_CONTEXT_CHECK_SPELLING_OF_THIS_FIELD));
FinishSubMenu();
diff --git a/chrome/browser/tab_contents/render_view_context_menu.h b/chrome/browser/tab_contents/render_view_context_menu.h
index e586c49..95595c1 100644
--- a/chrome/browser/tab_contents/render_view_context_menu.h
+++ b/chrome/browser/tab_contents/render_view_context_menu.h
@@ -36,13 +36,13 @@ class RenderViewContextMenu {
virtual void AppendMenuItem(int id) = 0;
// Append a normal menu item, using |label| for the name.
- virtual void AppendMenuItem(int id, const std::wstring& label) = 0;
+ virtual void AppendMenuItem(int id, const string16& label) = 0;
// Append a radio menu item.
- virtual void AppendRadioMenuItem(int id, const std::wstring& label) = 0;
+ virtual void AppendRadioMenuItem(int id, const string16& label) = 0;
// Append a checkbox menu item.
- virtual void AppendCheckboxMenuItem(int id, const std::wstring& label) = 0;
+ virtual void AppendCheckboxMenuItem(int id, const string16& label) = 0;
// Append a separator.
virtual void AppendSeparator() = 0;
@@ -52,7 +52,7 @@ class RenderViewContextMenu {
// the main menu we are building. We only support at most single-depth
// submenus, so calls to StartSubMenu() while we are already building a
// submenu will be ignored.
- virtual void StartSubMenu(int id, const std::wstring& label) = 0;
+ virtual void StartSubMenu(int id, const string16& label) = 0;
// Finish creating the submenu and attach it to the main menu.
virtual void FinishSubMenu() = 0;
diff --git a/chrome/browser/tab_contents/render_view_context_menu_gtk.cc b/chrome/browser/tab_contents/render_view_context_menu_gtk.cc
index d1a17e1..dcfdb74 100644
--- a/chrome/browser/tab_contents/render_view_context_menu_gtk.cc
+++ b/chrome/browser/tab_contents/render_view_context_menu_gtk.cc
@@ -61,29 +61,29 @@ void RenderViewContextMenuGtk::StoppedShowing() {
}
void RenderViewContextMenuGtk::AppendMenuItem(int id) {
- AppendItem(id, std::wstring(), MENU_NORMAL);
+ AppendItem(id, string16(), MENU_NORMAL);
}
void RenderViewContextMenuGtk::AppendMenuItem(int id,
- const std::wstring& label) {
+ const string16& label) {
AppendItem(id, label, MENU_NORMAL);
}
void RenderViewContextMenuGtk::AppendRadioMenuItem(int id,
- const std::wstring& label) {
+ const string16& label) {
AppendItem(id, label, MENU_RADIO);
}
void RenderViewContextMenuGtk::AppendCheckboxMenuItem(int id,
- const std::wstring& label) {
+ const string16& label) {
AppendItem(id, label, MENU_CHECKBOX);
}
void RenderViewContextMenuGtk::AppendSeparator() {
- AppendItem(0, std::wstring(), MENU_SEPARATOR);
+ AppendItem(0, string16(), MENU_SEPARATOR);
}
-void RenderViewContextMenuGtk::StartSubMenu(int id, const std::wstring& label) {
+void RenderViewContextMenuGtk::StartSubMenu(int id, const string16& label) {
AppendItem(id, label, MENU_NORMAL);
making_submenu_ = true;
}
@@ -104,7 +104,7 @@ void RenderViewContextMenuGtk::DidWriteURLToClipboard(
}
void RenderViewContextMenuGtk::AppendItem(
- int id, const std::wstring& label, MenuItemType type) {
+ int id, const string16& label, MenuItemType type) {
MenuCreateMaterial menu_create_material = {
type, id, 0, 0, NULL
};
@@ -112,7 +112,7 @@ void RenderViewContextMenuGtk::AppendItem(
if (label.empty())
menu_create_material.label_id = id;
else
- label_map_[id] = WideToUTF8(label);
+ label_map_[id] = UTF16ToUTF8(label);
std::vector<MenuCreateMaterial>* menu =
making_submenu_ ? &submenu_ : &menu_;
diff --git a/chrome/browser/tab_contents/render_view_context_menu_gtk.h b/chrome/browser/tab_contents/render_view_context_menu_gtk.h
index dd6cc92..d4fca48 100644
--- a/chrome/browser/tab_contents/render_view_context_menu_gtk.h
+++ b/chrome/browser/tab_contents/render_view_context_menu_gtk.h
@@ -41,16 +41,16 @@ class RenderViewContextMenuGtk : public RenderViewContextMenu,
// RenderViewContextMenu implementation --------------------------------------
virtual void DoInit();
virtual void AppendMenuItem(int id);
- virtual void AppendMenuItem(int id, const std::wstring& label);
- virtual void AppendRadioMenuItem(int id, const std::wstring& label);
- virtual void AppendCheckboxMenuItem(int id, const std::wstring& label);
+ virtual void AppendMenuItem(int id, const string16& label);
+ virtual void AppendRadioMenuItem(int id, const string16& label);
+ virtual void AppendCheckboxMenuItem(int id, const string16& label);
virtual void AppendSeparator();
- virtual void StartSubMenu(int id, const std::wstring& label);
+ virtual void StartSubMenu(int id, const string16& label);
virtual void FinishSubMenu();
virtual void DidWriteURLToClipboard(const std::string& url);
private:
- void AppendItem(int id, const std::wstring& label, MenuItemType type);
+ void AppendItem(int id, const string16& label, MenuItemType type);
static void DoneMakingMenu(std::vector<MenuCreateMaterial>* menu);
scoped_ptr<MenuGtk> gtk_menu_;
diff --git a/chrome/browser/tab_contents/render_view_context_menu_mac.h b/chrome/browser/tab_contents/render_view_context_menu_mac.h
index 8ca5e3c..0703a18 100644
--- a/chrome/browser/tab_contents/render_view_context_menu_mac.h
+++ b/chrome/browser/tab_contents/render_view_context_menu_mac.h
@@ -29,15 +29,15 @@ class RenderViewContextMenuMac : public RenderViewContextMenu {
// RenderViewContextMenu implementation-
virtual void DoInit();
virtual void AppendMenuItem(int id);
- virtual void AppendMenuItem(int id, const std::wstring& label);
- virtual void AppendRadioMenuItem(int id, const std::wstring& label);
- virtual void AppendCheckboxMenuItem(int id, const std::wstring& label);
+ virtual void AppendMenuItem(int id, const string16& label);
+ virtual void AppendRadioMenuItem(int id, const string16& label);
+ virtual void AppendCheckboxMenuItem(int id, const string16& label);
virtual void AppendSeparator();
- virtual void StartSubMenu(int id, const std::wstring& label);
+ virtual void StartSubMenu(int id, const string16& label);
virtual void FinishSubMenu();
// Do things like remove the windows accelerators.
- static NSString* PrepareLabelForDisplay(const std::wstring& label);
+ static NSString* PrepareLabelForDisplay(const string16& label);
private:
NSMenu* menu_;
diff --git a/chrome/browser/tab_contents/render_view_context_menu_mac.mm b/chrome/browser/tab_contents/render_view_context_menu_mac.mm
index 4c0537f..34b49b3 100644
--- a/chrome/browser/tab_contents/render_view_context_menu_mac.mm
+++ b/chrome/browser/tab_contents/render_view_context_menu_mac.mm
@@ -68,10 +68,10 @@ void RenderViewContextMenuMac::DoInit() {
// TODO(pinkerton): Do we want to do anything like make a maximum string width
// and middle-truncate?
NSString* RenderViewContextMenuMac::PrepareLabelForDisplay(
- const std::wstring& label) {
+ const string16& label) {
// Strip out any "&"'s that are windows accelerators and we don't use.
NSMutableString* title =
- [NSMutableString stringWithString:base::SysWideToNSString(label)];
+ [NSMutableString stringWithString:base::SysUTF16ToNSString(label)];
DCHECK(title);
NSRange range = NSMakeRange(0, [title length]);
[title replaceOccurrencesOfString:@"&" withString:@"" options:0 range:range];
@@ -79,11 +79,11 @@ NSString* RenderViewContextMenuMac::PrepareLabelForDisplay(
}
void RenderViewContextMenuMac::AppendMenuItem(int command_id) {
- AppendMenuItem(command_id, l10n_util::GetString(command_id));
+ AppendMenuItem(command_id, l10n_util::GetStringUTF16(command_id));
}
void RenderViewContextMenuMac::AppendMenuItem(int command_id,
- const std::wstring& label) {
+ const string16& label) {
// Create the item and set its target/action to |target_| with the command
// as |command_id|. Then add it to the menu at the end.
NSMenuItem* item =
@@ -97,12 +97,12 @@ void RenderViewContextMenuMac::AppendMenuItem(int command_id,
}
void RenderViewContextMenuMac::AppendRadioMenuItem(int id,
- const std::wstring& label) {
+ const string16& label) {
NOTIMPLEMENTED();
}
void RenderViewContextMenuMac::AppendCheckboxMenuItem(int id,
- const std::wstring& label) {
+ const string16& label) {
NOTIMPLEMENTED();
}
@@ -112,7 +112,7 @@ void RenderViewContextMenuMac::AppendSeparator() {
}
void RenderViewContextMenuMac::StartSubMenu(int command_id,
- const std::wstring& label) {
+ const string16& label) {
// I'm not a fan of this kind of API, but the other platforms have similar
// guards so at least we know everyone will break together if someone
// tries to mis-use the API.
diff --git a/chrome/browser/views/options/fonts_page_view.cc b/chrome/browser/views/options/fonts_page_view.cc
index b22c557..7e99e9d 100644
--- a/chrome/browser/views/options/fonts_page_view.cc
+++ b/chrome/browser/views/options/fonts_page_view.cc
@@ -46,7 +46,7 @@ class DefaultEncodingComboboxModel : public views::Combobox::Model {
// Initialize the vector of all sorted encodings according to current
// UI locale.
if (!sorted_encoding_list.size()) {
- std::wstring locale = g_browser_process->GetApplicationLocale();
+ std::string locale = g_browser_process->GetApplicationLocale();
for (int i = 0; i < canonical_encoding_names_length_; i++) {
sorted_encoding_list.push_back(CharacterEncoding::EncodingInfo(
CharacterEncoding::GetEncodingCommandIdByIndex(i)));
diff --git a/chrome/browser/views/options/language_combobox_model.cc b/chrome/browser/views/options/language_combobox_model.cc
index 2503b6a..5e960e1 100644
--- a/chrome/browser/views/options/language_combobox_model.cc
+++ b/chrome/browser/views/options/language_combobox_model.cc
@@ -33,8 +33,7 @@ LanguageComboboxModel::LanguageComboboxModel(
void LanguageComboboxModel::InitNativeNames(
const std::vector<std::string>& locale_codes) {
- const std::string app_locale = WideToASCII(
- g_browser_process->GetApplicationLocale());
+ const std::string app_locale = g_browser_process->GetApplicationLocale();
for (size_t i = 0; i < locale_codes.size(); ++i) {
std::string locale_code_str = locale_codes[i];
const char* locale_code = locale_codes[i].c_str();
diff --git a/chrome/browser/views/options/languages_page_view.cc b/chrome/browser/views/options/languages_page_view.cc
index ac08680..5ed8587 100644
--- a/chrome/browser/views/options/languages_page_view.cc
+++ b/chrome/browser/views/options/languages_page_view.cc
@@ -291,17 +291,18 @@ void AddLanguageWindowView::ViewHierarchyChanged(bool is_add,
void AddLanguageWindowView::Init() {
// Determine Locale Codes.
std::vector<std::string> locale_codes;
- const std::wstring app_locale = g_browser_process->GetApplicationLocale();
+ const std::string app_locale = g_browser_process->GetApplicationLocale();
for (size_t i = 0; i < arraysize(accept_language_list); ++i) {
- std::wstring local_name =
- l10n_util::GetLocalName(accept_language_list[i], app_locale, false);
+ string16 display_name =
+ l10n_util::GetDisplayNameForLocale(accept_language_list[i],
+ app_locale, false);
// This is a hack. If ICU doesn't have a translated name for
- // this language, GetLocalName will just return the language code.
- // In that case, we skip it.
+ // this language, GetDisplayNameForLocale will just return the
+ // language code. In that case, we skip it.
// TODO(jungshik) : Put them at the of the list with language codes
// enclosed by brackets.
- if (IsStringASCII(local_name) &&
- WideToASCII(local_name) == accept_language_list[i])
+ if (IsStringASCII(display_name) &&
+ UTF16ToASCII(display_name) == accept_language_list[i])
continue;
locale_codes.push_back(accept_language_list[i]);
}
@@ -381,8 +382,10 @@ void LanguageOrderTableModel::SetObserver(TableModelObserver* observer) {
std::wstring LanguageOrderTableModel::GetText(int row, int column_id) {
DCHECK(row >= 0 && row < RowCount());
- const std::wstring app_locale = g_browser_process->GetApplicationLocale();
- return l10n_util::GetLocalName(languages_.at(row), app_locale, true);
+ const std::string app_locale = g_browser_process->GetApplicationLocale();
+ return l10n_util::GetDisplayNameForLocale(languages_.at(row),
+ app_locale,
+ true);
}
void LanguageOrderTableModel::Add(const std::string& language) {
@@ -702,7 +705,7 @@ void LanguagesPageView::NotifyPrefChanged(const std::wstring* pref_name) {
// The pref value for locale isn't valid. Use the current app locale
// (which is what we're currently using).
index = ui_language_model_->GetIndexFromLocale(
- WideToASCII(g_browser_process->GetApplicationLocale()));
+ g_browser_process->GetApplicationLocale());
}
DCHECK(-1 != index);
change_ui_language_combobox_->SetSelectedItem(index);
diff --git a/chrome/test/automated_ui_tests/automated_ui_tests.cc b/chrome/test/automated_ui_tests/automated_ui_tests.cc
index 4f3fce9..1a1df67 100644
--- a/chrome/test/automated_ui_tests/automated_ui_tests.cc
+++ b/chrome/test/automated_ui_tests/automated_ui_tests.cc
@@ -397,7 +397,7 @@ bool AutomatedUITest::DoAction(const std::string & action) {
bool AutomatedUITest::ChangeEncoding() {
// Get the encoding list that is used to populate the UI (encoding menu)
- std::wstring cur_locale = g_browser_process->GetApplicationLocale();
+ std::string cur_locale = g_browser_process->GetApplicationLocale();
const std::vector<CharacterEncoding::EncodingInfo>* encodings =
CharacterEncoding::GetCurrentDisplayEncodings(
cur_locale, L"ISO-8859-1,windows-1252", L"");
diff --git a/chrome/test/testing_browser_process.h b/chrome/test/testing_browser_process.h
index 7e97e73..cc0ef76 100644
--- a/chrome/test/testing_browser_process.h
+++ b/chrome/test/testing_browser_process.h
@@ -131,10 +131,10 @@ class TestingBrowserProcess : public BrowserProcess {
return NULL;
}
- virtual const std::wstring& GetApplicationLocale() {
- static std::wstring* value = NULL;
+ virtual const std::string& GetApplicationLocale() {
+ static std::string* value = NULL;
if (!value)
- value = new std::wstring(L"en");
+ value = new std::string("en");
return *value;
}
diff --git a/chrome/test/unit/chrome_test_suite.h b/chrome/test/unit/chrome_test_suite.h
index a8d98f3..7c49d72 100644
--- a/chrome/test/unit/chrome_test_suite.h
+++ b/chrome/test/unit/chrome_test_suite.h
@@ -101,9 +101,9 @@ class ChromeTestSuite : public TestSuite {
mac_util::SetOverrideAppBundlePath(path);
#endif
- // Force unittests to run using en-us so if we test against string
+ // Force unittests to run using en-US so if we test against string
// output, it'll pass regardless of the system language.
- ResourceBundle::InitSharedInstance(L"en-us");
+ ResourceBundle::InitSharedInstance(L"en-US");
ResourceBundle::GetSharedInstance().LoadThemeResources();
// initialize the global StatsTable for unit_tests