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