Avi Drissman | 8ba1bad | 2022-09-13 19:22:36 | [diff] [blame] | 1 | // Copyright 2017 The Chromium Authors |
Joshua Pawlicki | b8bc9f9 | 2017-10-16 17:23:52 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef COMPONENTS_CRX_FILE_CRX_CREATOR_H_ |
| 6 | #define COMPONENTS_CRX_FILE_CRX_CREATOR_H_ |
| 7 | |
Swapnil | e28f8ea7 | 2021-02-03 21:43:27 | [diff] [blame] | 8 | #include <string> |
| 9 | |
Joshua Pawlicki | b8bc9f9 | 2017-10-16 17:23:52 | [diff] [blame] | 10 | namespace base { |
| 11 | class FilePath; |
| 12 | } // namespace base |
| 13 | |
| 14 | namespace crypto { |
| 15 | class RSAPrivateKey; |
| 16 | } // namespace crypto |
| 17 | |
| 18 | namespace crx_file { |
| 19 | |
| 20 | enum class CreatorResult { |
| 21 | OK, // The CRX file was successfully created. |
| 22 | ERROR_SIGNING_FAILURE, |
| 23 | ERROR_FILE_NOT_READABLE, |
| 24 | ERROR_FILE_NOT_WRITABLE, |
| 25 | ERROR_FILE_WRITE_FAILURE, |
| 26 | }; |
| 27 | |
Swapnil | e28f8ea7 | 2021-02-03 21:43:27 | [diff] [blame] | 28 | // Similar to `Create` method but also injects `verified_contents` into the |
Swapnil | 79763c4 | 2021-04-01 09:54:10 | [diff] [blame] | 29 | // header. |
| 30 | CreatorResult CreateCrxWithVerifiedContentsInHeader( |
Swapnil | e28f8ea7 | 2021-02-03 21:43:27 | [diff] [blame] | 31 | const base::FilePath& output_path, |
| 32 | const base::FilePath& zip_path, |
| 33 | crypto::RSAPrivateKey* signing_key, |
| 34 | const std::string& verified_contents); |
| 35 | |
Joshua Pawlicki | b8bc9f9 | 2017-10-16 17:23:52 | [diff] [blame] | 36 | // Create a CRX3 file at |output_path|, using the contents of the ZIP archive |
| 37 | // located at |zip_path| and signing with (and deriving the CRX ID from) |
| 38 | // |signing_key|. |
| 39 | CreatorResult Create(const base::FilePath& output_path, |
| 40 | const base::FilePath& zip_path, |
| 41 | crypto::RSAPrivateKey* signing_key); |
| 42 | |
| 43 | } // namespace crx_file |
| 44 | |
| 45 | #endif // COMPONENTS_CRX_FILE_CRX_CREATOR_H_ |