OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // This file declares extension specific l10n utils. | 5 // This file declares extension specific l10n utils. |
6 | 6 |
7 #ifndef CHROME_COMMON_EXTENSIONS_EXTENSION_L10N_UTIL_H_ | 7 #ifndef CHROME_COMMON_EXTENSIONS_EXTENSION_L10N_UTIL_H_ |
8 #define CHROME_COMMON_EXTENSIONS_EXTENSION_L10N_UTIL_H_ | 8 #define CHROME_COMMON_EXTENSIONS_EXTENSION_L10N_UTIL_H_ |
9 #pragma once | 9 #pragma once |
10 | 10 |
11 #include <set> | 11 #include <set> |
12 #include <string> | 12 #include <string> |
13 #include <vector> | 13 #include <vector> |
14 | 14 |
15 class Extension; | |
16 class ExtensionMessageBundle; | 15 class ExtensionMessageBundle; |
17 class FilePath; | 16 class FilePath; |
18 struct ExtensionInfo; | |
19 | 17 |
20 namespace base { | 18 namespace base { |
21 class DictionaryValue; | 19 class DictionaryValue; |
22 } | 20 } |
23 | 21 |
| 22 namespace extensions { |
| 23 struct ExtensionInfo; |
| 24 } |
| 25 |
24 namespace extension_l10n_util { | 26 namespace extension_l10n_util { |
25 | 27 |
26 // Set the locale for this process to a fixed value, rather than using the | 28 // Set the locale for this process to a fixed value, rather than using the |
27 // normal file-based lookup mechanisms. This is used to set the locale inside | 29 // normal file-based lookup mechanisms. This is used to set the locale inside |
28 // the sandboxed utility process, where file reading is not allowed. | 30 // the sandboxed utility process, where file reading is not allowed. |
29 void SetProcessLocale(const std::string& locale); | 31 void SetProcessLocale(const std::string& locale); |
30 | 32 |
31 // Returns default locale in form "en-US" or "sr" or empty string if | 33 // Returns default locale in form "en-US" or "sr" or empty string if |
32 // "default_locale" section was not defined in the manifest.json file. | 34 // "default_locale" section was not defined in the manifest.json file. |
33 std::string GetDefaultLocaleFromManifest(const base::DictionaryValue& manifest, | 35 std::string GetDefaultLocaleFromManifest(const base::DictionaryValue& manifest, |
34 std::string* error); | 36 std::string* error); |
35 | 37 |
36 // Returns true iff the extension was localized, and the current locale | 38 // Returns true iff the extension was localized, and the current locale |
37 // doesn't match the locale written into info.extension_manifest. | 39 // doesn't match the locale written into info.extension_manifest. |
38 bool ShouldRelocalizeManifest(const ExtensionInfo& info); | 40 bool ShouldRelocalizeManifest(const extensions::ExtensionInfo& info); |
39 | 41 |
40 // Localize extension name, description, browser_action and other fields | 42 // Localize extension name, description, browser_action and other fields |
41 // in the manifest. | 43 // in the manifest. |
42 bool LocalizeManifest(const ExtensionMessageBundle& messages, | 44 bool LocalizeManifest(const ExtensionMessageBundle& messages, |
43 base::DictionaryValue* manifest, | 45 base::DictionaryValue* manifest, |
44 std::string* error); | 46 std::string* error); |
45 | 47 |
46 // Load message catalogs, localize manifest and attach message bundle to the | 48 // Load message catalogs, localize manifest and attach message bundle to the |
47 // extension. | 49 // extension. |
48 bool LocalizeExtension(const FilePath& extension_path, | 50 bool LocalizeExtension(const FilePath& extension_path, |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 // |locales_path| is extension_id/_locales | 97 // |locales_path| is extension_id/_locales |
96 // |locale_path| is extension_id/_locales/xx | 98 // |locale_path| is extension_id/_locales/xx |
97 // |all_locales| is a set of all valid Chrome locales. | 99 // |all_locales| is a set of all valid Chrome locales. |
98 bool ShouldSkipValidation(const FilePath& locales_path, | 100 bool ShouldSkipValidation(const FilePath& locales_path, |
99 const FilePath& locale_path, | 101 const FilePath& locale_path, |
100 const std::set<std::string>& all_locales); | 102 const std::set<std::string>& all_locales); |
101 | 103 |
102 } // namespace extension_l10n_util | 104 } // namespace extension_l10n_util |
103 | 105 |
104 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_L10N_UTIL_H_ | 106 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_L10N_UTIL_H_ |
OLD | NEW |