diff options
author | jungshik@google.com <jungshik@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-26 16:32:57 +0000 |
---|---|---|
committer | jungshik@google.com <jungshik@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-26 16:32:57 +0000 |
commit | 74dc7edef49b83d2f201c3127245cf77b1607949 (patch) | |
tree | fc4c16bb45525bcd1c3aa17389eab293d303f8c3 | |
parent | 4e55fc89525a3ad81f698ea83b8363ea1185f7b6 (diff) | |
download | chromium_src-74dc7edef49b83d2f201c3127245cf77b1607949.zip chromium_src-74dc7edef49b83d2f201c3127245cf77b1607949.tar.gz chromium_src-74dc7edef49b83d2f201c3127245cf77b1607949.tar.bz2 |
Block Oriya locale on Windows XP.
Add IsLocaleSupportedByOS to l10n_util_{win,posix}.cc. Posix version always returns true. Windows blocks Oriya on Windows XP.
BUG=7325
TEST=1. L10n*.GetAppLocale
2. On Win XP, Oriya should not be shown in the UI language switch menu while it should be shown elsewhere.
Review URL: http://codereview.chromium.org/45054
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@12557 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/chrome.gyp | 1 | ||||
-rw-r--r-- | chrome/common/common.scons | 2 | ||||
-rw-r--r-- | chrome/common/l10n_util.cc | 5 | ||||
-rw-r--r-- | chrome/common/l10n_util.h | 5 | ||||
-rw-r--r-- | chrome/common/l10n_util_posix.cc | 14 | ||||
-rw-r--r-- | chrome/common/l10n_util_unittest.cc | 19 | ||||
-rw-r--r-- | chrome/common/l10n_util_win.cc | 8 |
7 files changed, 54 insertions, 0 deletions
diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp index 0921376..d58c608 100644 --- a/chrome/chrome.gyp +++ b/chrome/chrome.gyp @@ -197,6 +197,7 @@ 'common/jstemplate_builder.h', 'common/l10n_util.cc', 'common/l10n_util.h', + 'common/l10n_util_posix.cc', 'common/l10n_util_win.cc', 'common/l10n_util_win.h', 'common/libxml_utils.cc', diff --git a/chrome/common/common.scons b/chrome/common/common.scons index a816ca1..66b9add 100644 --- a/chrome/common/common.scons +++ b/chrome/common/common.scons @@ -154,6 +154,7 @@ input_files = ChromeFileList([ 'jstemplate_builder.h', 'l10n_util.cc', 'l10n_util.h', + 'l10n_util_posix.cc', 'libxml_utils.cc', 'libxml_utils.h', 'logging_chrome.cc', @@ -292,6 +293,7 @@ if not env.Bit('mac'): if not env.Bit('posix'): input_files.Remove( 'ipc_channel_posix.cc', + 'l10n_util_posix.cc', ) if env.Bit('windows'): diff --git a/chrome/common/l10n_util.cc b/chrome/common/l10n_util.cc index 8615622..8d1a6f3 100644 --- a/chrome/common/l10n_util.cc +++ b/chrome/common/l10n_util.cc @@ -128,6 +128,9 @@ bool IsLocaleAvailable(const std::wstring& locale, if (test_locale != locale) return false; + if (!l10n_util::IsLocaleSupportedByOS(locale)) + return false; + FilePath test_path = FilePath::FromWStringHack(locale_path) .Append(FilePath::FromWStringHack(locale)) .ReplaceExtension(kLocaleFileExtension); @@ -641,6 +644,8 @@ const std::vector<std::string>& GetAvailableLocales() { // Filter out the names that have aliases. if (IsDuplicateName(locale_name)) continue; + if (!IsLocaleSupportedByOS(ASCIIToWide(locale_name))) + continue; // Normalize underscores to hyphens because that's what our locale files // use. std::replace(locale_name.begin(), locale_name.end(), '_', '-'); diff --git a/chrome/common/l10n_util.h b/chrome/common/l10n_util.h index e836a40..e26fe70 100644 --- a/chrome/common/l10n_util.h +++ b/chrome/common/l10n_util.h @@ -48,6 +48,11 @@ const char16 kPopDirectionalFormatting = 0x202C; // we fall back to en-us. std::wstring GetApplicationLocale(const std::wstring& pref_locale); +// Given a locale code, return true if the OS is capable of supporting it. +// For instance, Oriya is not well supported on Windows XP and we return +// false for "or". +bool IsLocaleSupportedByOS(const std::wstring& locale); + // This method returns the Local Name of the Locale Code. For example, for // |local_code_wstr| = "en-US", it returns "English (United States)". // |app_locale_wstr| can be obtained in the UI thread - for example: diff --git a/chrome/common/l10n_util_posix.cc b/chrome/common/l10n_util_posix.cc new file mode 100644 index 0000000..a0c8ae1 --- /dev/null +++ b/chrome/common/l10n_util_posix.cc @@ -0,0 +1,14 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/common/l10n_util.h" + +namespace l10n_util { + +// Return true blindly for now. +bool IsLocaleSupportedByOS(const std::wstring& locale) { + return true; +} + +} // namespace l10n_util diff --git a/chrome/common/l10n_util_unittest.cc b/chrome/common/l10n_util_unittest.cc index 122dc3d..c7ade0f 100644 --- a/chrome/common/l10n_util_unittest.cc +++ b/chrome/common/l10n_util_unittest.cc @@ -8,6 +8,9 @@ #include "base/file_util.h" #include "base/path_service.h" #include "base/string_util.h" +#if defined(OS_WIN) +#include "base/win_util.h" +#endif #include "chrome/common/chrome_paths.h" #include "chrome/common/l10n_util.h" #include "chrome/common/stl_util-inl.h" @@ -114,6 +117,7 @@ TEST_F(L10nUtilTest, GetAppLocale) { L"he", L"fil", L"nb", + L"or", }; #if defined(OS_WIN) @@ -184,6 +188,21 @@ TEST_F(L10nUtilTest, GetAppLocale) { SetICUDefaultLocale(L"he"); EXPECT_EQ(L"en-US", l10n_util::GetApplicationLocale(L"en")); +#if defined(OS_WIN) + // Oriya should be blocked unless OS is Vista or newer. + if (win_util::GetWinVersion() < win_util::WINVERSION_VISTA) { + SetICUDefaultLocale(L"or"); + EXPECT_EQ(L"en-US", l10n_util::GetApplicationLocale(L"")); + SetICUDefaultLocale(L"en-GB"); + EXPECT_EQ(L"en-GB", l10n_util::GetApplicationLocale(L"or")); + } else { + SetICUDefaultLocale(L"or"); + EXPECT_EQ(L"or", l10n_util::GetApplicationLocale(L"")); + SetICUDefaultLocale(L"en-GB"); + EXPECT_EQ(L"or", l10n_util::GetApplicationLocale(L"or")); + } +#endif + // Clean up. PathService::Override(chrome::DIR_LOCALES, orig_locale_dir); file_util::Delete(new_locale_dir, true); diff --git a/chrome/common/l10n_util_win.cc b/chrome/common/l10n_util_win.cc index 352d518..4c49bf6 100644 --- a/chrome/common/l10n_util_win.cc +++ b/chrome/common/l10n_util_win.cc @@ -5,6 +5,8 @@ #include "chrome/common/l10n_util.h" #include "chrome/common/l10n_util_win.h" +#include "base/win_util.h" + namespace l10n_util { int GetExtendedStyles() { @@ -31,4 +33,10 @@ void HWNDSetRTLLayout(HWND hwnd) { } } +bool IsLocaleSupportedByOS(const std::wstring& locale) { + // Block Oriya on Windows XP. + return !(LowerCaseEqualsASCII(locale, "or") && + win_util::GetWinVersion() < win_util::WINVERSION_VISTA); +} + } // namespace l10n_util |