Commit 7f93717b authored by cira@chromium.org's avatar cira@chromium.org

Simple fix of extension_l10n_util that allows folders in form ".some_name" to...

Simple fix of extension_l10n_util that allows folders in form ".some_name" to exist in _locales folder.
It helps testing/loading extensions from svn tree (skips .svn folder, doesn't fail).

Review URL: http://codereview.chromium.org/196029

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25779 0039d316-1c4b-4281-b951-d872f2087c98
parent ef5ff1b4
......@@ -30,7 +30,6 @@ bool ValidateDefaultLocale(const Extension* extension) {
}
}
bool AddLocale(const std::set<std::string>& chrome_locales,
const FilePath& locale_folder,
Extension* extension,
......@@ -38,6 +37,10 @@ bool AddLocale(const std::set<std::string>& chrome_locales,
std::string* error) {
// Normalize underscores to hyphens because that's what our locale files use.
std::replace(locale_name->begin(), locale_name->end(), '_', '-');
// Accept name that starts with a . but don't add it to the list of supported
// 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.",
......
......@@ -24,6 +24,7 @@ bool ValidateDefaultLocale(const Extension* extension);
// 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.
// If file name starts with . return true (helps testing extensions under svn).
bool AddLocale(const std::set<std::string>& chrome_locales,
const FilePath& locale_folder,
Extension* extension,
......
......@@ -6,9 +6,11 @@
#include "base/file_path.h"
#include "base/file_util.h"
#include "base/path_service.h"
#include "base/scoped_ptr.h"
#include "base/scoped_temp_dir.h"
#include "base/values.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_constants.h"
#include "testing/gtest/include/gtest/gtest.h"
......@@ -17,7 +19,30 @@ namespace keys = extension_manifest_keys;
namespace {
Extension* CreateMinimalExtension(const std::string& default_locale) {
TEST(ExtensionL10nUtil, LoadGoodExtensionFromSVNTree) {
FilePath install_dir;
ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &install_dir));
install_dir = install_dir.AppendASCII("extensions")
.AppendASCII("good")
.AppendASCII("Extensions")
.AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj")
.AppendASCII("1.0.0.0");
FilePath locale_path = install_dir.AppendASCII(Extension::kLocaleFolder);
ASSERT_TRUE(file_util::PathExists(locale_path));
scoped_ptr<Extension> extension(new Extension(install_dir));
std::string error;
EXPECT_TRUE(extension_l10n_util::AddValidLocales(
locale_path, extension.get(), &error));
const std::set<std::string>& supported_locales =
extension->supported_locales();
EXPECT_EQ(2U, supported_locales.size());
EXPECT_TRUE(supported_locales.find("en-US") != supported_locales.end());
EXPECT_TRUE(supported_locales.find("sr") != supported_locales.end());
}
Extension* CreateMinimalExtension(const std::string& default_locale) {
#if defined(OS_WIN)
FilePath path(FILE_PATH_LITERAL("C:\\foo"));
#elif defined(OS_POSIX)
......
......@@ -68,7 +68,7 @@ int Extension::id_counter_ = 0;
const char Extension::kManifestFilename[] = "manifest.json";
const char Extension::kLocaleFolder[] = "_locales";
const char Extension::kMessagesFilename[] = "messages";
const char Extension::kMessagesFilename[] = "messages.json";
// A list of all the keys allowed by themes.
static const wchar_t* kValidThemeKeys[] = {
......
{
"name": {
"message": "Нека порука."
}
}
\ No newline at end of file
......@@ -6,6 +6,7 @@
"icons": {
"128": "icon_128.png"
},
"default_locale": "en_US",
"toolstrips": [
{
"path": "toolstrip1.html",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment