[email protected] | d1f48ef5 | 2012-05-13 19:34:21 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | 6aeac834 | 2010-10-01 20:21:18 | [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 | |||||
[email protected] | d9ede58 | 2012-08-14 19:21:38 | [diff] [blame] | 5 | #ifndef CHROME_BROWSER_EXTENSIONS_STARTUP_HELPER_H_ |
6 | #define CHROME_BROWSER_EXTENSIONS_STARTUP_HELPER_H_ | ||||
[email protected] | 6aeac834 | 2010-10-01 20:21:18 | [diff] [blame] | 7 | |
avi | a2f4804a | 2015-12-24 23:11:13 | [diff] [blame] | 8 | #include "base/macros.h" |
[email protected] | 7856620 | 2012-05-14 20:46:51 | [diff] [blame] | 9 | #include "base/memory/ref_counted.h" |
[email protected] | ccd875e7 | 2010-12-13 23:49:02 | [diff] [blame] | 10 | #include "chrome/browser/extensions/pack_extension_job.h" |
11 | |||||
[email protected] | 2f3b1cc | 2014-03-17 23:07:15 | [diff] [blame] | 12 | namespace base { |
13 | class CommandLine; | ||||
14 | } | ||||
15 | |||||
[email protected] | d9ede58 | 2012-08-14 19:21:38 | [diff] [blame] | 16 | namespace extensions { |
17 | |||||
[email protected] | 6aeac834 | 2010-10-01 20:21:18 | [diff] [blame] | 18 | // Initialization helpers for various Extension startup actions. |
[email protected] | d9ede58 | 2012-08-14 19:21:38 | [diff] [blame] | 19 | class StartupHelper : public PackExtensionJob::Client { |
[email protected] | ccd875e7 | 2010-12-13 23:49:02 | [diff] [blame] | 20 | public: |
[email protected] | d9ede58 | 2012-08-14 19:21:38 | [diff] [blame] | 21 | StartupHelper(); |
dcheng | ae36a4a | 2014-10-21 12:36:36 | [diff] [blame] | 22 | ~StartupHelper() override; |
[email protected] | 6aeac834 | 2010-10-01 20:21:18 | [diff] [blame] | 23 | |
dcheng | ae36a4a | 2014-10-21 12:36:36 | [diff] [blame] | 24 | void OnPackSuccess(const base::FilePath& crx_path, |
25 | const base::FilePath& output_private_key_path) override; | ||||
26 | void OnPackFailure(const std::string& error_message, | ||||
27 | ExtensionCreator::ErrorType type) override; | ||||
[email protected] | ccd875e7 | 2010-12-13 23:49:02 | [diff] [blame] | 28 | |
29 | // Handle --pack-extension flag from the |cmd_line| by packing the specified | ||||
30 | // extension. Returns false if the pack job failed. | ||||
[email protected] | 2f3b1cc | 2014-03-17 23:07:15 | [diff] [blame] | 31 | bool PackExtension(const base::CommandLine& cmd_line); |
[email protected] | ccd875e7 | 2010-12-13 23:49:02 | [diff] [blame] | 32 | |
[email protected] | d37f4de | 2013-03-28 19:26:36 | [diff] [blame] | 33 | // Validates a crx at the path given by the --validate-extension flag - can |
34 | // it be installed? Returns true if the crx is valid, or false otherwise. | ||||
35 | // If the return value is false, a description of the problem may be written | ||||
36 | // into |error|. | ||||
[email protected] | 2f3b1cc | 2014-03-17 23:07:15 | [diff] [blame] | 37 | bool ValidateCrx(const base::CommandLine& cmd_line, std::string* error); |
[email protected] | d37f4de | 2013-03-28 19:26:36 | [diff] [blame] | 38 | |
[email protected] | ccd875e7 | 2010-12-13 23:49:02 | [diff] [blame] | 39 | private: |
[email protected] | ccd875e7 | 2010-12-13 23:49:02 | [diff] [blame] | 40 | bool pack_job_succeeded_; |
41 | |||||
[email protected] | d9ede58 | 2012-08-14 19:21:38 | [diff] [blame] | 42 | DISALLOW_COPY_AND_ASSIGN(StartupHelper); |
[email protected] | ccd875e7 | 2010-12-13 23:49:02 | [diff] [blame] | 43 | }; |
[email protected] | 6aeac834 | 2010-10-01 20:21:18 | [diff] [blame] | 44 | |
[email protected] | d9ede58 | 2012-08-14 19:21:38 | [diff] [blame] | 45 | } // namespace extensions |
46 | |||||
47 | #endif // CHROME_BROWSER_EXTENSIONS_STARTUP_HELPER_H_ |