From 70dff4fc82ac26c9beecc54644ab7ee055596862 Mon Sep 17 00:00:00 2001 From: tfarina Date: Thu, 15 Jan 2015 16:37:08 -0800 Subject: Move l10n_util's GetCanonicalLocal() function into base/i18n module. This removes the base version that takes const char*, and replace it by the one that takes const std::string&. Consolidating this code in one place and having a single function, instead of two with the same name in two different places. This is a redo of a patch that started in https://codereview.chromium.org/269943004/ and of another try that was made in https://codereview.chromium.org/834183005/. BUG=None TEST=base_unittests, ui_base_unittests and chrome. R=sky@chromium.org,thakis@chromium.org Review URL: https://codereview.chromium.org/846373002 Cr-Commit-Position: refs/heads/master@{#311781} --- ui/base/l10n/l10n_util.cc | 9 +++------ ui/base/l10n/l10n_util.h | 4 ---- 2 files changed, 3 insertions(+), 10 deletions(-) (limited to 'ui') diff --git a/ui/base/l10n/l10n_util.cc b/ui/base/l10n/l10n_util.cc index 7515f3f..eb49b14 100644 --- a/ui/base/l10n/l10n_util.cc +++ b/ui/base/l10n/l10n_util.cc @@ -310,10 +310,6 @@ base::LazyInstance, AvailableLocalesTraits> namespace l10n_util { -std::string GetCanonicalLocale(const std::string& locale) { - return base::i18n::GetCanonicalLocale(locale.c_str()); -} - std::string GetLanguage(const std::string& locale) { const std::string::size_type hyphen_pos = locale.find('-'); return std::string(locale, 0, hyphen_pos); @@ -434,14 +430,15 @@ std::string GetApplicationLocaleInternal(const std::string& pref_locale) { // First, try the preference value. if (!pref_locale.empty()) - candidates.push_back(GetCanonicalLocale(pref_locale)); + candidates.push_back(base::i18n::GetCanonicalLocale(pref_locale)); // Next, try the overridden locale. const std::vector& languages = l10n_util::GetLocaleOverrides(); if (!languages.empty()) { candidates.reserve(candidates.size() + languages.size()); std::transform(languages.begin(), languages.end(), - std::back_inserter(candidates), &GetCanonicalLocale); + std::back_inserter(candidates), + &base::i18n::GetCanonicalLocale); } else { // If no override was set, defer to ICU candidates.push_back(base::i18n::GetConfiguredLocale()); diff --git a/ui/base/l10n/l10n_util.h b/ui/base/l10n/l10n_util.h index e2cb27d..c957c3e 100644 --- a/ui/base/l10n/l10n_util.h +++ b/ui/base/l10n/l10n_util.h @@ -20,10 +20,6 @@ namespace l10n_util { -// The same as base::i18n::GetCanonicalLocale(const char*), but takes -// std::string as an argument. -UI_BASE_EXPORT std::string GetCanonicalLocale(const std::string& locale); - // Takes normalized locale as |locale|. Returns language part (before '-'). UI_BASE_EXPORT std::string GetLanguage(const std::string& locale); -- cgit v1.1