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 #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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <map> | 10 #include <map> |
11 | 11 |
12 #include "chrome/common/extensions/extension.h" | 12 #include "chrome/common/extensions/extension.h" |
13 #include "chrome/common/extensions/extension_message_bundle.h" | 13 #include "chrome/common/extensions/extension_message_bundle.h" |
14 | 14 |
15 class Extension; | 15 class Extension; |
16 class ExtensionMessageBundle; | 16 class ExtensionMessageBundle; |
17 class FilePath; | 17 class FilePath; |
18 class GURL; | 18 class GURL; |
19 namespace base { | 19 namespace base { |
20 class DictionaryValue; | 20 class DictionaryValue; |
21 } | 21 } |
22 | 22 |
23 // Utilties for manipulating the on-disk storage of extensions. | 23 // Utilties for manipulating the on-disk storage of extensions. |
24 namespace extension_file_util { | 24 namespace extension_file_util { |
25 | 25 |
| 26 enum DeleteSource { |
| 27 DELETE_SOURCE_NO, |
| 28 DELETE_SOURCE_YES, |
| 29 }; |
| 30 |
26 // The name of the directory inside the profile that we store installed | 31 // The name of the directory inside the profile that we store installed |
27 // extension in. | 32 // extension in. |
28 extern const char kInstallDirectoryName[]; | 33 extern const char kInstallDirectoryName[]; |
29 | 34 |
30 // Copies |unpacked_source_dir| into the right location under |extensions_dir|. | 35 // Copies |unpacked_source_dir| into the right location under |extensions_dir|. |
| 36 // Deletes the source directory if |should_delete_source| is true. |
31 // The destination directiory is returned on success, or empty path is returned | 37 // The destination directiory is returned on success, or empty path is returned |
32 // on failure. | 38 // on failure. |
33 FilePath InstallExtension(const FilePath& unpacked_source_dir, | 39 FilePath InstallExtension(const FilePath& unpacked_source_dir, |
34 const std::string& id, | 40 const std::string& id, |
35 const std::string& version, | 41 const std::string& version, |
36 const FilePath& extensions_dir); | 42 const FilePath& extensions_dir, |
| 43 DeleteSource should_delete_source); |
37 | 44 |
38 // Removes all versions of the extension with |id| from |extensions_dir|. | 45 // Removes all versions of the extension with |id| from |extensions_dir|. |
39 void UninstallExtension(const FilePath& extensions_dir, | 46 void UninstallExtension(const FilePath& extensions_dir, |
40 const std::string& id); | 47 const std::string& id); |
41 | 48 |
42 // Loads and validates an extension from the specified directory. Returns NULL | 49 // Loads and validates an extension from the specified directory. Returns NULL |
43 // on failure, with a description of the error in |error|. | 50 // on failure, with a description of the error in |error|. |
44 scoped_refptr<Extension> LoadExtension(const FilePath& extension_root, | 51 scoped_refptr<Extension> LoadExtension(const FilePath& extension_root, |
45 Extension::Location location, | 52 Extension::Location location, |
46 int flags, | 53 int flags, |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 FilePath GetUserDataTempDir(); | 107 FilePath GetUserDataTempDir(); |
101 | 108 |
102 // Helper function to delete files. This is used to avoid ugly casts which | 109 // Helper function to delete files. This is used to avoid ugly casts which |
103 // would be necessary with PostMessage since file_util::Delete is overloaded. | 110 // would be necessary with PostMessage since file_util::Delete is overloaded. |
104 // TODO(skerner): Make a version of Delete that is not overloaded in file_util. | 111 // TODO(skerner): Make a version of Delete that is not overloaded in file_util. |
105 void DeleteFile(const FilePath& path, bool recursive); | 112 void DeleteFile(const FilePath& path, bool recursive); |
106 | 113 |
107 } // namespace extension_file_util | 114 } // namespace extension_file_util |
108 | 115 |
109 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_FILE_UTIL_H_ | 116 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_FILE_UTIL_H_ |
OLD | NEW |