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_PACK_EXTENSION_JOB_H_
6 #define CHROME_BROWSER_EXTENSIONS_PACK_EXTENSION_JOB_H_
10 #include "base/files/file_path.h"
11 #include "base/memory/ref_counted.h"
12 #include "base/strings/string16.h"
13 #include "chrome/browser/extensions/extension_creator.h"
14 #include "content/public/browser/browser_thread.h"
16 namespace extensions
{
18 // Manages packing an extension on the file thread and reporting the result
20 class PackExtensionJob
: public base::RefCountedThreadSafe
<PackExtensionJob
> {
22 // Interface for people who want to use PackExtensionJob to implement.
25 virtual void OnPackSuccess(const base::FilePath
& crx_file
,
26 const base::FilePath
& key_file
) = 0;
27 virtual void OnPackFailure(const std::string
& message
,
28 ExtensionCreator::ErrorType error_type
) = 0;
34 PackExtensionJob(Client
* client
,
35 const base::FilePath
& root_directory
,
36 const base::FilePath
& key_file
,
39 // Starts the packing job.
42 // The client should call this when it is destroyed to prevent
43 // PackExtensionJob from attempting to access it.
46 // The standard packing success message.
47 static base::string16
StandardSuccessMessage(const base::FilePath
& crx_file
,
48 const base::FilePath
& key_file
);
50 void set_asynchronous(bool async
) { asynchronous_
= async
; }
53 friend class base::RefCountedThreadSafe
<PackExtensionJob
>;
55 virtual ~PackExtensionJob();
57 // If |asynchronous_| is false, this is run on whichever thread calls it.
59 void ReportSuccessOnClientThread();
60 void ReportFailureOnClientThread(const std::string
& error
,
61 ExtensionCreator::ErrorType error_type
);
63 content::BrowserThread::ID client_thread_id_
;
65 base::FilePath root_directory_
;
66 base::FilePath key_file_
;
67 base::FilePath crx_file_out_
;
68 base::FilePath key_file_out_
;
70 int run_flags_
; // Bitset of ExtensionCreator::RunFlags values - we always
71 // assume kRequireModernManifestVersion, though.
73 DISALLOW_COPY_AND_ASSIGN(PackExtensionJob
);
76 } // namespace extensions
78 #endif // CHROME_BROWSER_EXTENSIONS_PACK_EXTENSION_JOB_H_