| 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_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 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 // contained within that directory. The output .crx file is always signed with a | 23 // contained within that directory. The output .crx file is always signed with a |
| 24 // private key that is either provided in |private_key_path| or is internal | 24 // private key that is either provided in |private_key_path| or is internal |
| 25 // generated randomly (and optionally written to |output_private_key_path|. | 25 // generated randomly (and optionally written to |output_private_key_path|. |
| 26 class ExtensionCreator { | 26 class ExtensionCreator { |
| 27 public: | 27 public: |
| 28 ExtensionCreator(); | 28 ExtensionCreator(); |
| 29 | 29 |
| 30 // Settings to specify treatment of special or ignorable error conditions. | 30 // Settings to specify treatment of special or ignorable error conditions. |
| 31 enum RunFlags { | 31 enum RunFlags { |
| 32 kNoRunFlags = 0x0, | 32 kNoRunFlags = 0x0, |
| 33 kOverwriteCRX = 0x1 | 33 kOverwriteCRX = 0x1, |
| 34 kRequireModernManifestVersion = 0x2, |
| 34 }; | 35 }; |
| 35 | 36 |
| 36 // Categories of error that may need special handling on the UI end. | 37 // Categories of error that may need special handling on the UI end. |
| 37 enum ErrorType { kOtherError, kCRXExists }; | 38 enum ErrorType { kOtherError, kCRXExists }; |
| 38 | 39 |
| 39 bool Run(const FilePath& extension_dir, | 40 bool Run(const FilePath& extension_dir, |
| 40 const FilePath& crx_path, | 41 const FilePath& crx_path, |
| 41 const FilePath& private_key_path, | 42 const FilePath& private_key_path, |
| 42 const FilePath& private_key_output_path, | 43 const FilePath& private_key_output_path, |
| 43 int run_flags); | 44 int run_flags); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 56 // it is written to |private_key_output_path| -- if provided). | 57 // it is written to |private_key_output_path| -- if provided). |
| 57 // |flags| is a bitset of RunFlags values. | 58 // |flags| is a bitset of RunFlags values. |
| 58 bool InitializeInput(const FilePath& extension_dir, | 59 bool InitializeInput(const FilePath& extension_dir, |
| 59 const FilePath& crx_path, | 60 const FilePath& crx_path, |
| 60 const FilePath& private_key_path, | 61 const FilePath& private_key_path, |
| 61 const FilePath& private_key_output_path, | 62 const FilePath& private_key_output_path, |
| 62 int run_flags); | 63 int run_flags); |
| 63 | 64 |
| 64 // Validates the manifest by trying to load the extension. | 65 // Validates the manifest by trying to load the extension. |
| 65 bool ValidateManifest(const FilePath& extension_dir, | 66 bool ValidateManifest(const FilePath& extension_dir, |
| 66 crypto::RSAPrivateKey* key_pair); | 67 crypto::RSAPrivateKey* key_pair, |
| 68 int run_flags); |
| 67 | 69 |
| 68 // Reads private key from |private_key_path|. | 70 // Reads private key from |private_key_path|. |
| 69 crypto::RSAPrivateKey* ReadInputKey(const FilePath& private_key_path); | 71 crypto::RSAPrivateKey* ReadInputKey(const FilePath& private_key_path); |
| 70 | 72 |
| 71 // Generates a key pair and writes the private key to |private_key_path| | 73 // Generates a key pair and writes the private key to |private_key_path| |
| 72 // if provided. | 74 // if provided. |
| 73 crypto::RSAPrivateKey* GenerateKey(const FilePath& private_key_path); | 75 crypto::RSAPrivateKey* GenerateKey(const FilePath& private_key_path); |
| 74 | 76 |
| 75 // Creates temporary zip file for the extension. | 77 // Creates temporary zip file for the extension. |
| 76 bool CreateZip(const FilePath& extension_dir, const FilePath& temp_path, | 78 bool CreateZip(const FilePath& extension_dir, const FilePath& temp_path, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 92 | 94 |
| 93 // Type of error that was raised, if any. | 95 // Type of error that was raised, if any. |
| 94 ErrorType error_type_; | 96 ErrorType error_type_; |
| 95 | 97 |
| 96 DISALLOW_COPY_AND_ASSIGN(ExtensionCreator); | 98 DISALLOW_COPY_AND_ASSIGN(ExtensionCreator); |
| 97 }; | 99 }; |
| 98 | 100 |
| 99 } // namespace extensions | 101 } // namespace extensions |
| 100 | 102 |
| 101 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_CREATOR_H_ | 103 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_CREATOR_H_ |
| OLD | NEW |