Make the ChromeOS chromecast system tray integration use a private API.
[chromium-blink-merge.git] / chrome / browser / extensions / pack_extension_job.h
blob61a48cb7f26ed4f30e57d8b28e8c103d8ddfba1e
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_
8 #include <string>
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
19 // back to the UI.
20 class PackExtensionJob : public base::RefCountedThreadSafe<PackExtensionJob> {
21 public:
22 // Interface for people who want to use PackExtensionJob to implement.
23 class Client {
24 public:
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;
30 protected:
31 virtual ~Client() {}
34 PackExtensionJob(Client* client,
35 const base::FilePath& root_directory,
36 const base::FilePath& key_file,
37 int run_flags);
39 // Starts the packing job.
40 void Start();
42 // The client should call this when it is destroyed to prevent
43 // PackExtensionJob from attempting to access it.
44 void ClearClient();
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; }
52 private:
53 friend class base::RefCountedThreadSafe<PackExtensionJob>;
55 virtual ~PackExtensionJob();
57 // If |asynchronous_| is false, this is run on whichever thread calls it.
58 void Run();
59 void ReportSuccessOnClientThread();
60 void ReportFailureOnClientThread(const std::string& error,
61 ExtensionCreator::ErrorType error_type);
63 content::BrowserThread::ID client_thread_id_;
64 Client* client_;
65 base::FilePath root_directory_;
66 base::FilePath key_file_;
67 base::FilePath crx_file_out_;
68 base::FilePath key_file_out_;
69 bool asynchronous_;
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_