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_COMPONENT_UPDATER_COMPONENT_UNPACKER_H_ | 5 #ifndef CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_UNPACKER_H_ |
6 #define CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_UNPACKER_H_ | 6 #define CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_UNPACKER_H_ |
7 | 7 |
| 8 #include <string> |
8 #include <vector> | 9 #include <vector> |
9 | 10 |
10 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
11 | 12 |
12 class ComponentInstaller; | 13 class ComponentInstaller; |
| 14 class ComponentPatcher; |
13 | 15 |
14 // In charge of unpacking the component CRX package and verifying that it is | 16 // In charge of unpacking the component CRX package and verifying that it is |
15 // well formed and the cryptographic signature is correct. If there is no | 17 // well formed and the cryptographic signature is correct. If there is no |
16 // error the component specific installer will be invoked to proceed with | 18 // error the component specific installer will be invoked to proceed with |
17 // the component installation or update. | 19 // the component installation or update. |
18 // | 20 // |
19 // This class should be used only by the component updater. It is inspired | 21 // This class should be used only by the component updater. It is inspired |
20 // and overlaps with code in the extension's SandboxedUnpacker. | 22 // and overlaps with code in the extension's SandboxedUnpacker. |
21 // The main differences are: | 23 // The main differences are: |
22 // - The public key hash is full SHA256. | 24 // - The public key hash is full SHA256. |
23 // - Does not use a sandboxed unpacker. A valid component is fully trusted. | 25 // - Does not use a sandboxed unpacker. A valid component is fully trusted. |
24 // - The manifest can have different attributes and resources are not | 26 // - The manifest can have different attributes and resources are not |
25 // transcoded. | 27 // transcoded. |
26 class ComponentUnpacker { | 28 class ComponentUnpacker { |
27 public: | 29 public: |
28 // Possible error conditions. | 30 // Possible error conditions. |
29 enum Error { | 31 enum Error { |
30 kNone, | 32 kNone, |
31 kInvalidParams, | 33 kInvalidParams, |
32 kInvalidFile, | 34 kInvalidFile, |
33 kUzipPathError, | 35 kUnzipPathError, |
34 kUnzipFailed, | 36 kUnzipFailed, |
35 kNoManifest, | 37 kNoManifest, |
36 kBadManifest, | 38 kBadManifest, |
37 kBadExtension, | 39 kBadExtension, |
38 kInvalidId, | 40 kInvalidId, |
39 kInstallerError, | 41 kInstallerError, |
| 42 kIoError, |
| 43 kDeltaVerificationFailure, |
| 44 kDeltaBadCommands, |
| 45 kDeltaUnsupportedCommand, |
| 46 kDeltaOperationFailure, |
| 47 kDeltaPatchProcessFailure, |
| 48 kFingerprintWriteFailed, |
40 }; | 49 }; |
41 // Unpacks, verifies and calls the installer. |pk_hash| is the expected | 50 // Unpacks, verifies and calls the installer. |pk_hash| is the expected |
42 // public key SHA256 hash. |path| is the current location of the CRX. | 51 // public key SHA256 hash. |path| is the current location of the CRX. |
43 ComponentUnpacker(const std::vector<uint8>& pk_hash, | 52 ComponentUnpacker(const std::vector<uint8>& pk_hash, |
44 const base::FilePath& path, | 53 const base::FilePath& path, |
| 54 const std::string& fingerprint, |
| 55 ComponentPatcher* patcher, |
45 ComponentInstaller* installer); | 56 ComponentInstaller* installer); |
46 | 57 |
47 // If something went wrong during unpacking or installer invocation, the | 58 // If something went wrong during unpacking or installer invocation, the |
48 // destructor will delete the unpacked CRX files. | 59 // destructor will delete the unpacked CRX files. |
49 ~ComponentUnpacker(); | 60 ~ComponentUnpacker(); |
50 | 61 |
51 Error error() const { return error_; } | 62 Error error() const { return error_; } |
52 | 63 |
| 64 int extended_error() const { return extended_error_; } |
| 65 |
53 private: | 66 private: |
54 base::FilePath unpack_path_; | 67 base::FilePath unpack_path_; |
55 Error error_; | 68 Error error_; |
| 69 int extended_error_; // Provides additional error information. |
56 }; | 70 }; |
57 | 71 |
58 #endif // CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_UNPACKER_H_ | 72 #endif // CHROME_BROWSER_COMPONENT_UPDATER_COMPONENT_UNPACKER_H_ |
OLD | NEW |