OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CHROME_COMMON_EXTENSIONS_EXTENSION_FILE_UTIL_H_ | 5 #ifndef CHROME_COMMON_EXTENSIONS_EXTENSION_FILE_UTIL_H_ |
6 #define CHROME_COMMON_EXTENSIONS_EXTENSION_FILE_UTIL_H_ | 6 #define CHROME_COMMON_EXTENSIONS_EXTENSION_FILE_UTIL_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "extensions/common/manifest.h" | 13 #include "extensions/common/manifest.h" |
14 | 14 |
15 class ExtensionIconSet; | |
16 | |
17 namespace base { | 15 namespace base { |
18 class DictionaryValue; | 16 class DictionaryValue; |
19 class FilePath; | 17 class FilePath; |
20 } | 18 } |
21 | 19 |
22 namespace extensions { | 20 namespace extensions { |
23 class Extension; | 21 class Extension; |
24 struct InstallWarning; | 22 struct InstallWarning; |
25 } | 23 } |
26 | 24 |
(...skipping 28 matching lines...) Expand all Loading... |
55 const std::string& extension_id, | 53 const std::string& extension_id, |
56 extensions::Manifest::Location location, | 54 extensions::Manifest::Location location, |
57 int flags, | 55 int flags, |
58 std::string* error); | 56 std::string* error); |
59 | 57 |
60 // Loads an extension manifest from the specified directory. Returns NULL | 58 // Loads an extension manifest from the specified directory. Returns NULL |
61 // on failure, with a description of the error in |error|. | 59 // on failure, with a description of the error in |error|. |
62 base::DictionaryValue* LoadManifest(const base::FilePath& extension_root, | 60 base::DictionaryValue* LoadManifest(const base::FilePath& extension_root, |
63 std::string* error); | 61 std::string* error); |
64 | 62 |
65 // Returns true if the given file path exists and is not zero-length. | |
66 bool ValidateFilePath(const base::FilePath& path); | |
67 | |
68 // Returns true if the icons in the icon set exist. Oherwise, populates | |
69 // |error| with the |error_message_id| for an invalid file. | |
70 bool ValidateExtensionIconSet(const ExtensionIconSet& icon_set, | |
71 const extensions::Extension* extension, | |
72 int error_message_id, | |
73 std::string* error); | |
74 | |
75 // Returns true if the given extension object is valid and consistent. | 63 // Returns true if the given extension object is valid and consistent. |
76 // May also append a series of warning messages to |warnings|, but they | 64 // May also append a series of warning messages to |warnings|, but they |
77 // should not prevent the extension from running. | 65 // should not prevent the extension from running. |
78 // | 66 // |
79 // Otherwise, returns false, and a description of the error is | 67 // Otherwise, returns false, and a description of the error is |
80 // returned in |error|. | 68 // returned in |error|. |
81 bool ValidateExtension(const extensions::Extension* extension, | 69 bool ValidateExtension(const extensions::Extension* extension, |
82 std::string* error, | 70 std::string* error, |
83 std::vector<extensions::InstallWarning>* warnings); | 71 std::vector<extensions::InstallWarning>* warnings); |
84 | 72 |
(...skipping 22 matching lines...) Expand all Loading... |
107 base::FilePath GetInstallTempDir(const base::FilePath& extensions_dir); | 95 base::FilePath GetInstallTempDir(const base::FilePath& extensions_dir); |
108 | 96 |
109 // Helper function to delete files. This is used to avoid ugly casts which | 97 // Helper function to delete files. This is used to avoid ugly casts which |
110 // would be necessary with PostMessage since base::Delete is overloaded. | 98 // would be necessary with PostMessage since base::Delete is overloaded. |
111 // TODO(skerner): Make a version of Delete that is not overloaded in file_util. | 99 // TODO(skerner): Make a version of Delete that is not overloaded in file_util. |
112 void DeleteFile(const base::FilePath& path, bool recursive); | 100 void DeleteFile(const base::FilePath& path, bool recursive); |
113 | 101 |
114 } // namespace extension_file_util | 102 } // namespace extension_file_util |
115 | 103 |
116 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_FILE_UTIL_H_ | 104 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_FILE_UTIL_H_ |
OLD | NEW |