OLD | NEW |
1 // Copyright (c) 2009 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_BROWSER_EXTENSIONS_EXTENSION_CREATOR_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_CREATOR_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_CREATOR_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_CREATOR_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 | 13 |
14 namespace base { | 14 namespace crypto { |
15 class RSAPrivateKey; | 15 class RSAPrivateKey; |
16 } | 16 } |
17 | 17 |
18 class FilePath; | 18 class FilePath; |
19 | 19 |
20 // This class create an installable extension (.crx file) given an input | 20 // This class create an installable extension (.crx file) given an input |
21 // directory that contains a valid manifest.json and the extension's resources | 21 // directory that contains a valid manifest.json and the extension's resources |
22 // contained within that directory. The output .crx file is always signed with a | 22 // contained within that directory. The output .crx file is always signed with a |
23 // private key that is either provided in |private_key_path| or is internal | 23 // private key that is either provided in |private_key_path| or is internal |
24 // generated randomly (and optionally written to |output_private_key_path|. | 24 // generated randomly (and optionally written to |output_private_key_path|. |
(...skipping 13 matching lines...) Expand all Loading... |
38 // Verifies input directory's existence. |extension_dir| is the source | 38 // Verifies input directory's existence. |extension_dir| is the source |
39 // directory that should contain all the extension resources. | 39 // directory that should contain all the extension resources. |
40 // |private_key_path| is the optional path to an existing private key to sign | 40 // |private_key_path| is the optional path to an existing private key to sign |
41 // the extension. If not provided, a random key will be created (in which case | 41 // the extension. If not provided, a random key will be created (in which case |
42 // it is written to |private_key_output_path| -- if provided). | 42 // it is written to |private_key_output_path| -- if provided). |
43 bool InitializeInput(const FilePath& extension_dir, | 43 bool InitializeInput(const FilePath& extension_dir, |
44 const FilePath& private_key_path, | 44 const FilePath& private_key_path, |
45 const FilePath& private_key_output_path); | 45 const FilePath& private_key_output_path); |
46 | 46 |
47 // Reads private key from |private_key_path|. | 47 // Reads private key from |private_key_path|. |
48 base::RSAPrivateKey* ReadInputKey(const FilePath& private_key_path); | 48 crypto::RSAPrivateKey* ReadInputKey(const FilePath& private_key_path); |
49 | 49 |
50 // Generates a key pair and writes the private key to |private_key_path| | 50 // Generates a key pair and writes the private key to |private_key_path| |
51 // if provided. | 51 // if provided. |
52 base::RSAPrivateKey* GenerateKey(const FilePath& private_key_path); | 52 crypto::RSAPrivateKey* GenerateKey(const FilePath& private_key_path); |
53 | 53 |
54 // Creates temporary zip file for the extension. | 54 // Creates temporary zip file for the extension. |
55 bool CreateZip(const FilePath& extension_dir, const FilePath& temp_path, | 55 bool CreateZip(const FilePath& extension_dir, const FilePath& temp_path, |
56 FilePath* zip_path); | 56 FilePath* zip_path); |
57 | 57 |
58 // Signs the temporary zip and returns the signature. | 58 // Signs the temporary zip and returns the signature. |
59 bool SignZip(const FilePath& zip_path, | 59 bool SignZip(const FilePath& zip_path, |
60 base::RSAPrivateKey* private_key, | 60 crypto::RSAPrivateKey* private_key, |
61 std::vector<uint8>* signature); | 61 std::vector<uint8>* signature); |
62 | 62 |
63 // Export installable .crx to |crx_path|. | 63 // Export installable .crx to |crx_path|. |
64 bool WriteCRX(const FilePath& zip_path, | 64 bool WriteCRX(const FilePath& zip_path, |
65 base::RSAPrivateKey* private_key, | 65 crypto::RSAPrivateKey* private_key, |
66 const std::vector<uint8>& signature, | 66 const std::vector<uint8>& signature, |
67 const FilePath& crx_path); | 67 const FilePath& crx_path); |
68 | 68 |
69 // Holds a message for any error that is raised during Run(...). | 69 // Holds a message for any error that is raised during Run(...). |
70 std::string error_message_; | 70 std::string error_message_; |
71 | 71 |
72 DISALLOW_COPY_AND_ASSIGN(ExtensionCreator); | 72 DISALLOW_COPY_AND_ASSIGN(ExtensionCreator); |
73 }; | 73 }; |
74 | 74 |
75 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_CREATOR_H_ | 75 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_CREATOR_H_ |
OLD | NEW |