Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Side by Side Diff: chrome/browser/extensions/extension_creator.h

Issue 118328: chrome.exe --package-extension (Closed)
Patch Set: final Created 11 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/browser_init.cc ('k') | chrome/browser/extensions/extension_creator.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
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 CHROME_COMMON_EXTENSIONS_EXTENSION_CREATOR_H_
6 #define CHROME_COMMON_EXTENSIONS_EXTENSION_CREATOR_H_
7
8 #include "base/command_line.h"
9 #include "base/crypto/rsa_private_key.h"
10 #include "base/file_path.h"
11 #include "base/values.h"
12
13 // This class create an installable extension (.crx file) given an input
14 // directory that contains a valid manifest.json and the extension's resources
15 // contained within that directory. The output .crx file is always signed with a
16 // private key that is either provided in |private_key_path| or is internal
17 // generated randomly (and optionally written to |output_private_key_path|.
18 class ExtensionCreator {
19 public:
20 ExtensionCreator() {}
21
22 bool Run(const FilePath& extension_dir,
23 const FilePath& crx_path,
24 const FilePath& private_key_path,
25 const FilePath& private_key_output_path);
26
27 // Returns the error message that will be present if Run(...) returned false.
28 std::string error_message() { return error_message_; }
29
30 private:
31 // Verifies input directory's existance, and reads manifest. |extension_dir|
32 // Is the source directory that should contain all the extension resources.
33 // |private_key_path| is the optional path to an existing private key to sign
34 // the extension. If not provided, a random key will be created (in which case
35 // it is written to |private_key_output_path| -- if provided).
36 DictionaryValue* InitializeInput(const FilePath& extension_dir,
37 const FilePath& private_key_path,
38 const FilePath& private_key_output_path);
39
40 // Reads private key from |private_key_path|.
41 base::RSAPrivateKey* ReadInputKey(const FilePath& private_key_path);
42
43 // Generates a key pair and writes the private key to |private_key_path|
44 // if provided.
45 base::RSAPrivateKey* GenerateKey(const FilePath& private_key_path);
46
47 // Creates temporary zip file and generates a signature for it.
48 bool CreateAndSignZip(const FilePath& extension_dir,
49 base::RSAPrivateKey* key_pair,
50 FilePath* zip_path,
51 std::string* signature);
52
53 // Inserts generated keys (signature, public_key) into manifest.
54 bool PrepareManifestForExport(base::RSAPrivateKey* key_pair,
55 const std::string& signature,
56 DictionaryValue* manifest);
57
58 // Export installable .crx to |crx_path|.
59 bool WriteCRX(const FilePath& crx_path,
60 DictionaryValue *manifest,
61 const FilePath& zip_path);
62
63 // Holds a message for any error that is raised during Run(...).
64 std::string error_message_;
65
66 DISALLOW_COPY_AND_ASSIGN(ExtensionCreator);
67 };
68
69 #endif // CHROME_COMMON_EXTENSIONS_EXTENSION_CREATOR_H_
OLDNEW
« no previous file with comments | « chrome/browser/browser_init.cc ('k') | chrome/browser/extensions/extension_creator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698