diff options
author | cira@google.com <cira@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-09 17:52:29 +0000 |
---|---|---|
committer | cira@google.com <cira@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-09 17:52:29 +0000 |
commit | 1acbb4b66433d88c3ab43f85c209738d74cdb542 (patch) | |
tree | b4c86f0c938b382bbffcc63149e34857094747f3 /chrome/common/extensions/extension_l10n_util.cc | |
parent | 08c68eef4ab6438b967c1f50138df0be330024fe (diff) | |
download | chromium_src-1acbb4b66433d88c3ab43f85c209738d74cdb542.zip chromium_src-1acbb4b66433d88c3ab43f85c209738d74cdb542.tar.gz chromium_src-1acbb4b66433d88c3ab43f85c209738d74cdb542.tar.bz2 |
All platforms don't support same locales at the same time. Make locale check for extensions less strict (we log a warning now, but let extension load).
TEST=Create extension with _locales/xxx_yyy and see that it loads.
Review URL: http://codereview.chromium.org/671011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@41046 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/extensions/extension_l10n_util.cc')
-rw-r--r-- | chrome/common/extensions/extension_l10n_util.cc | 34 |
1 files changed, 26 insertions, 8 deletions
diff --git a/chrome/common/extensions/extension_l10n_util.cc b/chrome/common/extensions/extension_l10n_util.cc index 1de16fe..cd6ad60 100644 --- a/chrome/common/extensions/extension_l10n_util.cc +++ b/chrome/common/extensions/extension_l10n_util.cc @@ -11,6 +11,7 @@ #include "app/l10n_util.h" #include "base/file_util.h" #include "base/linked_ptr.h" +#include "base/logging.h" #include "base/string_util.h" #include "base/values.h" #include "chrome/common/extensions/extension.h" @@ -147,10 +148,11 @@ bool AddLocale(const std::set<std::string>& chrome_locales, if (locale_name.find(".") == 0) return true; if (chrome_locales.find(locale_name) == chrome_locales.end()) { - // Fail if there is an extension locale that's not in the Chrome list. - *error = StringPrintf("Supplied locale %s is not supported.", - locale_name.c_str()); - return false; + // Warn if there is an extension locale that's not in the Chrome list, + // but don't fail. + LOG(WARNING) << StringPrintf("Supplied locale %s is not supported.", + locale_name.c_str()); + return true; } // Check if messages file is actually present (but don't check content). if (file_util::PathExists( @@ -196,9 +198,7 @@ void GetParentLocales(const std::string& current_locale, } } -// Extends list of Chrome locales to them and their parents, so we can do -// proper fallback. -static void GetAllLocales(std::set<std::string>* all_locales) { +void GetAllLocales(std::set<std::string>* all_locales) { const std::vector<std::string>& available_locales = l10n_util::GetAvailableLocales(); // Add all parents of the current locale to the available locales set. @@ -240,7 +240,6 @@ bool GetValidLocales(const FilePath& locale_path, return true; } - // Loads contents of the messages file for given locale. If file is not found, // or there was parsing error we return NULL and set |error|. // Caller owns the returned object. @@ -293,4 +292,23 @@ ExtensionMessageBundle* LoadMessageCatalogs( return ExtensionMessageBundle::Create(catalogs, error); } +bool ShouldSkipValidation(const FilePath& locales_path, + const FilePath& locale_path, + const std::set<std::string>& all_locales) { + // Since we use this string as a key in a DictionaryValue, be paranoid about + // skipping any strings with '.'. This happens sometimes, for example with + // '.svn' directories. + FilePath relative_path; + if (!locales_path.AppendRelativePath(locale_path, &relative_path)) + NOTREACHED(); + std::wstring subdir(relative_path.ToWStringHack()); + if (std::find(subdir.begin(), subdir.end(), L'.') != subdir.end()) + return true; + + if (all_locales.find(WideToASCII(subdir)) == all_locales.end()) + return true; + + return false; +} + } // namespace extension_l10n_util |