OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #ifndef EXTENSIONS_COMMON_FILE_UTIL_H_ | 5 #ifndef EXTENSIONS_COMMON_FILE_UTIL_H_ |
6 #define EXTENSIONS_COMMON_FILE_UTIL_H_ | 6 #define EXTENSIONS_COMMON_FILE_UTIL_H_ |
7 | 7 |
| 8 #include <map> |
8 #include <string> | 9 #include <string> |
9 | 10 |
10 #include "extensions/common/message_bundle.h" | 11 class ExtensionIconSet; |
11 | |
12 class GURL; | 12 class GURL; |
13 | 13 |
14 namespace base { | 14 namespace base { |
15 class FilePath; | 15 class FilePath; |
16 } | 16 } |
17 | 17 |
18 namespace extensions { | 18 namespace extensions { |
| 19 class Extension; |
| 20 class MessageBundle; |
| 21 |
19 namespace file_util { | 22 namespace file_util { |
20 | 23 |
21 // Get a relative file path from a chrome-extension:// URL. | 24 // Get a relative file path from a chrome-extension:// URL. |
22 base::FilePath ExtensionURLToRelativeFilePath(const GURL& url); | 25 base::FilePath ExtensionURLToRelativeFilePath(const GURL& url); |
23 | 26 |
24 // Get a full file path from a chrome-extension-resource:// URL, If the URL | 27 // Get a full file path from a chrome-extension-resource:// URL, If the URL |
25 // points a file outside of root, this function will return empty FilePath. | 28 // points a file outside of root, this function will return empty FilePath. |
26 base::FilePath ExtensionResourceURLToFilePath(const GURL& url, | 29 base::FilePath ExtensionResourceURLToFilePath(const GURL& url, |
27 const base::FilePath& root); | 30 const base::FilePath& root); |
28 | 31 |
| 32 // Returns true if the icons in the icon set exist. Oherwise, populates |
| 33 // |error| with the |error_message_id| for an invalid file. |
| 34 bool ValidateExtensionIconSet(const ExtensionIconSet& icon_set, |
| 35 const Extension* extension, |
| 36 int error_message_id, |
| 37 std::string* error); |
| 38 |
29 // Loads extension message catalogs and returns message bundle. | 39 // Loads extension message catalogs and returns message bundle. |
30 // Returns NULL on error or if the extension is not localized. | 40 // Returns NULL on error or if the extension is not localized. |
31 MessageBundle* LoadMessageBundle(const base::FilePath& extension_path, | 41 MessageBundle* LoadMessageBundle(const base::FilePath& extension_path, |
32 const std::string& default_locale, | 42 const std::string& default_locale, |
33 std::string* error); | 43 std::string* error); |
34 | 44 |
35 // Loads the extension message bundle substitution map. Contains at least | 45 // Loads the extension message bundle substitution map. Contains at least |
36 // the extension_id item. | 46 // the extension_id item. |
37 MessageBundle::SubstitutionMap* LoadMessageBundleSubstitutionMap( | 47 std::map<std::string, std::string>* LoadMessageBundleSubstitutionMap( |
38 const base::FilePath& extension_path, | 48 const base::FilePath& extension_path, |
39 const std::string& extension_id, | 49 const std::string& extension_id, |
40 const std::string& default_locale); | 50 const std::string& default_locale); |
41 | 51 |
42 } // namespace file_util | 52 } // namespace file_util |
43 } // namespace extensions | 53 } // namespace extensions |
44 | 54 |
45 #endif // EXTENSIONS_COMMON_FILE_UTIL_H_ | 55 #endif // EXTENSIONS_COMMON_FILE_UTIL_H_ |
OLD | NEW |