summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions
diff options
context:
space:
mode:
authorcira@chromium.org <cira@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-09 20:05:45 +0000
committercira@chromium.org <cira@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-09 20:05:45 +0000
commit7f93717b442d05e12f90c69cd191fb6b7e9b7573 (patch)
treedcee846a22f2638e8ce569881428893f9ff63e22 /chrome/browser/extensions
parentef5ff1b40f1024d834620f5cede62dfd4aea6e0c (diff)
downloadchromium_src-7f93717b442d05e12f90c69cd191fb6b7e9b7573.zip
chromium_src-7f93717b442d05e12f90c69cd191fb6b7e9b7573.tar.gz
chromium_src-7f93717b442d05e12f90c69cd191fb6b7e9b7573.tar.bz2
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
Diffstat (limited to 'chrome/browser/extensions')
-rw-r--r--chrome/browser/extensions/extension_l10n_util.cc5
-rw-r--r--chrome/browser/extensions/extension_l10n_util.h1
-rw-r--r--chrome/browser/extensions/extension_l10n_util_unittest.cc27
3 files changed, 31 insertions, 2 deletions
diff --git a/chrome/browser/extensions/extension_l10n_util.cc b/chrome/browser/extensions/extension_l10n_util.cc
index 77fddba..5176b60 100644
--- a/chrome/browser/extensions/extension_l10n_util.cc
+++ b/chrome/browser/extensions/extension_l10n_util.cc
@@ -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.",
diff --git a/chrome/browser/extensions/extension_l10n_util.h b/chrome/browser/extensions/extension_l10n_util.h
index d964566..be73f99 100644
--- a/chrome/browser/extensions/extension_l10n_util.h
+++ b/chrome/browser/extensions/extension_l10n_util.h
@@ -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,
diff --git a/chrome/browser/extensions/extension_l10n_util_unittest.cc b/chrome/browser/extensions/extension_l10n_util_unittest.cc
index 04f1ac0..b3dc397 100644
--- a/chrome/browser/extensions/extension_l10n_util_unittest.cc
+++ b/chrome/browser/extensions/extension_l10n_util_unittest.cc
@@ -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)