Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/extensions/extension_l10n_util.h" | 5 #include "chrome/browser/extensions/extension_l10n_util.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 23 std::string default_locale = extension->default_locale(); | 23 std::string default_locale = extension->default_locale(); |
| 24 | 24 |
| 25 if (extension->supported_locales().find(default_locale) != | 25 if (extension->supported_locales().find(default_locale) != |
| 26 extension->supported_locales().end()) { | 26 extension->supported_locales().end()) { |
| 27 return true; | 27 return true; |
| 28 } else { | 28 } else { |
| 29 return false; | 29 return false; |
| 30 } | 30 } |
| 31 } | 31 } |
| 32 | 32 |
| 33 | |
| 34 bool AddLocale(const std::set<std::string>& chrome_locales, | 33 bool AddLocale(const std::set<std::string>& chrome_locales, |
| 35 const FilePath& locale_folder, | 34 const FilePath& locale_folder, |
| 36 Extension* extension, | 35 Extension* extension, |
| 37 std::string* locale_name, | 36 std::string* locale_name, |
| 38 std::string* error) { | 37 std::string* error) { |
| 39 // Normalize underscores to hyphens because that's what our locale files use. | 38 // Normalize underscores to hyphens because that's what our locale files use. |
| 40 std::replace(locale_name->begin(), locale_name->end(), '_', '-'); | 39 std::replace(locale_name->begin(), locale_name->end(), '_', '-'); |
| 40 // Accept name that starts with . but don't add it to the list of supported | |
| 41 // locales. | |
| 42 if (locale_name->find(".", 0) == 0) { | |
|
Aaron Boodman
2009/09/09 01:42:56
Nit: braces not needed.
Aaron Boodman
2009/09/09 01:42:56
Nit: second parameter unnecessary as 0 is the defa
| |
| 43 return true; | |
| 44 } | |
| 41 if (chrome_locales.find(*locale_name) == chrome_locales.end()) { | 45 if (chrome_locales.find(*locale_name) == chrome_locales.end()) { |
| 42 // Fail if there is an extension locale that's not in the Chrome list. | 46 // Fail if there is an extension locale that's not in the Chrome list. |
| 43 *error = StringPrintf("Supplied locale %s is not supported.", | 47 *error = StringPrintf("Supplied locale %s is not supported.", |
| 44 locale_name->c_str()); | 48 locale_name->c_str()); |
| 45 return false; | 49 return false; |
| 46 } | 50 } |
| 47 // Check if messages file is actually present (but don't check content). | 51 // Check if messages file is actually present (but don't check content). |
| 48 if (file_util::PathExists( | 52 if (file_util::PathExists( |
| 49 locale_folder.AppendASCII(Extension::kMessagesFilename))) { | 53 locale_folder.AppendASCII(Extension::kMessagesFilename))) { |
| 50 extension->AddSupportedLocale(*locale_name); | 54 extension->AddSupportedLocale(*locale_name); |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 81 | 85 |
| 82 if (extension->supported_locales().empty()) { | 86 if (extension->supported_locales().empty()) { |
| 83 *error = extension_manifest_errors::kLocalesNoValidLocaleNamesListed; | 87 *error = extension_manifest_errors::kLocalesNoValidLocaleNamesListed; |
| 84 return false; | 88 return false; |
| 85 } | 89 } |
| 86 | 90 |
| 87 return true; | 91 return true; |
| 88 } | 92 } |
| 89 | 93 |
| 90 } // namespace extension_l10n_util | 94 } // namespace extension_l10n_util |
| OLD | NEW |