| 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_BROWSER_EXTENSIONS_SANDBOXED_UNPACKER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_SANDBOXED_UNPACKER_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_SANDBOXED_UNPACKER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_SANDBOXED_UNPACKER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 // | 73 // |
| 74 // | 74 // |
| 75 // NOTE: This class should only be used on the file thread. | 75 // NOTE: This class should only be used on the file thread. |
| 76 class SandboxedUnpacker : public content::UtilityProcessHostClient { | 76 class SandboxedUnpacker : public content::UtilityProcessHostClient { |
| 77 public: | 77 public: |
| 78 // Unpacks the extension in |crx_path| into a temporary directory and calls | 78 // Unpacks the extension in |crx_path| into a temporary directory and calls |
| 79 // |client| with the result. If |run_out_of_process| is provided, unpacking | 79 // |client| with the result. If |run_out_of_process| is provided, unpacking |
| 80 // is done in a sandboxed subprocess. Otherwise, it is done in-process. | 80 // is done in a sandboxed subprocess. Otherwise, it is done in-process. |
| 81 SandboxedUnpacker( | 81 SandboxedUnpacker( |
| 82 const base::FilePath& crx_path, | 82 const base::FilePath& crx_path, |
| 83 const std::string& package_hash, |
| 83 Manifest::Location location, | 84 Manifest::Location location, |
| 84 int creation_flags, | 85 int creation_flags, |
| 85 const base::FilePath& extensions_dir, | 86 const base::FilePath& extensions_dir, |
| 86 const scoped_refptr<base::SequencedTaskRunner>& unpacker_io_task_runner, | 87 const scoped_refptr<base::SequencedTaskRunner>& unpacker_io_task_runner, |
| 87 SandboxedUnpackerClient* client); | 88 SandboxedUnpackerClient* client); |
| 88 | 89 |
| 89 // Start unpacking the extension. The client is called with the results. | 90 // Start unpacking the extension. The client is called with the results. |
| 90 void Start(); | 91 void Start(); |
| 91 | 92 |
| 92 private: | 93 private: |
| (...skipping 26 matching lines...) Expand all Loading... |
| 119 CRX_HEADER_INVALID, | 120 CRX_HEADER_INVALID, |
| 120 CRX_MAGIC_NUMBER_INVALID, | 121 CRX_MAGIC_NUMBER_INVALID, |
| 121 CRX_VERSION_NUMBER_INVALID, | 122 CRX_VERSION_NUMBER_INVALID, |
| 122 CRX_EXCESSIVELY_LARGE_KEY_OR_SIGNATURE, | 123 CRX_EXCESSIVELY_LARGE_KEY_OR_SIGNATURE, |
| 123 CRX_ZERO_KEY_LENGTH, | 124 CRX_ZERO_KEY_LENGTH, |
| 124 CRX_ZERO_SIGNATURE_LENGTH, | 125 CRX_ZERO_SIGNATURE_LENGTH, |
| 125 CRX_PUBLIC_KEY_INVALID, | 126 CRX_PUBLIC_KEY_INVALID, |
| 126 CRX_SIGNATURE_INVALID, | 127 CRX_SIGNATURE_INVALID, |
| 127 CRX_SIGNATURE_VERIFICATION_INITIALIZATION_FAILED, | 128 CRX_SIGNATURE_VERIFICATION_INITIALIZATION_FAILED, |
| 128 CRX_SIGNATURE_VERIFICATION_FAILED, | 129 CRX_SIGNATURE_VERIFICATION_FAILED, |
| 130 CRX_HASH_VERIFICATION_FAILED, |
| 129 | 131 |
| 130 // SandboxedUnpacker::RewriteManifestFile() | 132 // SandboxedUnpacker::RewriteManifestFile() |
| 131 ERROR_SERIALIZING_MANIFEST_JSON, | 133 ERROR_SERIALIZING_MANIFEST_JSON, |
| 132 ERROR_SAVING_MANIFEST_JSON, | 134 ERROR_SAVING_MANIFEST_JSON, |
| 133 | 135 |
| 134 // SandboxedUnpacker::RewriteImageFiles() | 136 // SandboxedUnpacker::RewriteImageFiles() |
| 135 COULD_NOT_READ_IMAGE_DATA_FROM_DISK, | 137 COULD_NOT_READ_IMAGE_DATA_FROM_DISK, |
| 136 DECODED_IMAGES_DO_NOT_MATCH_THE_MANIFEST, | 138 DECODED_IMAGES_DO_NOT_MATCH_THE_MANIFEST, |
| 137 INVALID_PATH_FOR_BROWSER_IMAGE, | 139 INVALID_PATH_FOR_BROWSER_IMAGE, |
| 138 ERROR_REMOVING_OLD_IMAGE_FILE, | 140 ERROR_REMOVING_OLD_IMAGE_FILE, |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 // Reports error and returns false if it fails. | 197 // Reports error and returns false if it fails. |
| 196 bool RewriteImageFiles(SkBitmap* install_icon); | 198 bool RewriteImageFiles(SkBitmap* install_icon); |
| 197 bool RewriteCatalogFiles(); | 199 bool RewriteCatalogFiles(); |
| 198 | 200 |
| 199 // Cleans up temp directory artifacts. | 201 // Cleans up temp directory artifacts. |
| 200 void Cleanup(); | 202 void Cleanup(); |
| 201 | 203 |
| 202 // The path to the CRX to unpack. | 204 // The path to the CRX to unpack. |
| 203 base::FilePath crx_path_; | 205 base::FilePath crx_path_; |
| 204 | 206 |
| 207 // The package hash that was reported from the Web Store. |
| 208 std::string package_hash_; |
| 209 |
| 210 // Whether we need to check the .crx hash sum. |
| 211 bool check_crx_hash_; |
| 212 |
| 205 // Our client. | 213 // Our client. |
| 206 scoped_refptr<SandboxedUnpackerClient> client_; | 214 scoped_refptr<SandboxedUnpackerClient> client_; |
| 207 | 215 |
| 208 // The Extensions directory inside the profile. | 216 // The Extensions directory inside the profile. |
| 209 base::FilePath extensions_dir_; | 217 base::FilePath extensions_dir_; |
| 210 | 218 |
| 211 // A temporary directory to use for unpacking. | 219 // A temporary directory to use for unpacking. |
| 212 base::ScopedTempDir temp_dir_; | 220 base::ScopedTempDir temp_dir_; |
| 213 | 221 |
| 214 // The root directory of the unpacked extension. This is a child of temp_dir_. | 222 // The root directory of the unpacked extension. This is a child of temp_dir_. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 237 // when calling Extenion::Create() by the crx installer. | 245 // when calling Extenion::Create() by the crx installer. |
| 238 int creation_flags_; | 246 int creation_flags_; |
| 239 | 247 |
| 240 // Sequenced task runner where file I/O operations will be performed at. | 248 // Sequenced task runner where file I/O operations will be performed at. |
| 241 scoped_refptr<base::SequencedTaskRunner> unpacker_io_task_runner_; | 249 scoped_refptr<base::SequencedTaskRunner> unpacker_io_task_runner_; |
| 242 }; | 250 }; |
| 243 | 251 |
| 244 } // namespace extensions | 252 } // namespace extensions |
| 245 | 253 |
| 246 #endif // CHROME_BROWSER_EXTENSIONS_SANDBOXED_UNPACKER_H_ | 254 #endif // CHROME_BROWSER_EXTENSIONS_SANDBOXED_UNPACKER_H_ |
| OLD | NEW |