diff options
author | cira@chromium.org <cira@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-19 20:45:14 +0000 |
---|---|---|
committer | cira@chromium.org <cira@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-19 20:45:14 +0000 |
commit | 300cc58db6bc8d78e279dc07c46f15d9702148c6 (patch) | |
tree | 01eb9d8585bc43b01850c226bc4d5f2a3ec00cea /chrome/browser/extensions/extension_l10n_util.h | |
parent | cceaf1fbf3f4963c59a49268217f1e3edfb372ef (diff) | |
download | chromium_src-300cc58db6bc8d78e279dc07c46f15d9702148c6.zip chromium_src-300cc58db6bc8d78e279dc07c46f15d9702148c6.tar.gz chromium_src-300cc58db6bc8d78e279dc07c46f15d9702148c6.tar.bz2 |
This change enables Chrome to load locale information for the extension. It detects default locale, and filters out all locales not supported
by Chrome or with invalid names/missing messages.
It also checks for folders that start with _ and are not in the reserved list.
We don't validate messages file with this CL.
Added support for loading supplied locale information to the extension_file_util, and detecting default locale.
Added new constants to extension class (_locales directory name, messages filename).
Added new error messages to _constants.
Added new unittests.
BUG=12131
TEST=There should be no visible changes, except in case of error when loading extension (e.g. create empty _locales folder and try loading).
Review URL: http://codereview.chromium.org/170015
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23739 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/extension_l10n_util.h')
-rw-r--r-- | chrome/browser/extensions/extension_l10n_util.h | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/chrome/browser/extensions/extension_l10n_util.h b/chrome/browser/extensions/extension_l10n_util.h new file mode 100644 index 0000000..d964566 --- /dev/null +++ b/chrome/browser/extensions/extension_l10n_util.h @@ -0,0 +1,46 @@ +// 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. +// +// This file declares extension specific l10n utils. + +#ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_L10N_UTIL_H_ +#define CHROME_BROWSER_EXTENSIONS_EXTENSION_L10N_UTIL_H_ + +#include <set> +#include <string> + +class DictionaryValue; +class Extension; +class FilePath; + +namespace extension_l10n_util { + +// Returns true if default_locale was set to valid locale +// (supported by the extension). +bool ValidateDefaultLocale(const Extension* extension); + +// Adds locale_name to the extension if it's in chrome_locales, and +// if messages file is present (we don't check content of messages file here). +// Returns false if locale_name was not found in chrome_locales, and sets +// error with locale_name. +bool AddLocale(const std::set<std::string>& chrome_locales, + const FilePath& locale_folder, + Extension* extension, + std::string* locale_name, + std::string* error); + +// Adds valid locales to the extension. +// 1. Do nothing if _locales directory is missing (not an error). +// 2. Get list of Chrome locales. +// 3. Enumerate all subdirectories of _locales directory. +// 4. Intersect both lists, and add intersection to the extension. +// Returns false if any of supplied locales don't match chrome list of locales. +// Fills out error with offending locale name. +bool AddValidLocales(const FilePath& locale_path, + Extension* extension, + std::string* error); + +} // namespace extension_l10n_util + +#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_L10N_UTIL_H_ |