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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_EXTENSIONS_STARTUP_HELPER_H_
6 #define CHROME_BROWSER_EXTENSIONS_STARTUP_HELPER_H_
8 #include "base/memory/ref_counted.h"
9 #include "chrome/browser/extensions/pack_extension_job.h"
17 namespace extensions
{
19 // Initialization helpers for various Extension startup actions.
20 class StartupHelper
: public PackExtensionJob::Client
{
23 ~StartupHelper() override
;
25 void OnPackSuccess(const base::FilePath
& crx_path
,
26 const base::FilePath
& output_private_key_path
) override
;
27 void OnPackFailure(const std::string
& error_message
,
28 ExtensionCreator::ErrorType type
) override
;
30 // Handle --pack-extension flag from the |cmd_line| by packing the specified
31 // extension. Returns false if the pack job failed.
32 bool PackExtension(const base::CommandLine
& cmd_line
);
34 // Validates a crx at the path given by the --validate-extension flag - can
35 // it be installed? Returns true if the crx is valid, or false otherwise.
36 // If the return value is false, a description of the problem may be written
38 bool ValidateCrx(const base::CommandLine
& cmd_line
, std::string
* error
);
41 scoped_refptr
<PackExtensionJob
> pack_job_
;
42 bool pack_job_succeeded_
;
44 DISALLOW_COPY_AND_ASSIGN(StartupHelper
);
47 } // namespace extensions
49 #endif // CHROME_BROWSER_EXTENSIONS_STARTUP_HELPER_H_