Add a webstorePrivate API to show a permission prompt for delegated bundle installs
[chromium-blink-merge.git] / chrome / browser / extensions / zipfile_installer.h
blob7aa594c41f3ad8e20d55c35523e71b420e753754
1 // Copyright 2014 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_ZIPFILE_INSTALLER_H_
6 #define CHROME_BROWSER_EXTENSIONS_ZIPFILE_INSTALLER_H_
8 #include <string>
10 #include "base/basictypes.h"
11 #include "base/callback.h"
12 #include "base/files/file_path.h"
13 #include "base/memory/ref_counted.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "base/memory/weak_ptr.h"
16 #include "content/public/browser/utility_process_host_client.h"
18 class ExtensionService;
20 namespace IPC {
21 class Message;
24 namespace extensions {
26 // ZipFileInstaller unzips an extension that is zipped up via a utility process.
27 // The contents are then loaded via UnpackedInstaller.
28 class ZipFileInstaller : public content::UtilityProcessHostClient {
29 public:
30 static scoped_refptr<ZipFileInstaller> Create(
31 ExtensionService* extension_service);
33 void LoadFromZipFile(const base::FilePath& path);
35 void set_be_noisy_on_failure(bool value) { be_noisy_on_failure_ = value; }
37 // UtilityProcessHostClient
38 bool OnMessageReceived(const IPC::Message& message) override;
40 private:
41 explicit ZipFileInstaller(ExtensionService* extension_service);
42 ~ZipFileInstaller() override;
44 void PrepareTempDir();
45 void StartWorkOnIOThread(const base::FilePath& temp_dir);
46 void ReportSuccessOnUIThread(const base::FilePath& unzipped_path);
47 void ReportErrorOnUIThread(const std::string& error);
49 void OnUnzipSucceeded(const base::FilePath& unzipped_path);
50 void OnUnzipFailed(const std::string& error);
52 bool be_noisy_on_failure_;
53 base::WeakPtr<ExtensionService> extension_service_weak_;
54 base::FilePath zip_path_;
56 DISALLOW_COPY_AND_ASSIGN(ZipFileInstaller);
59 } // namespace extensions
61 #endif // CHROME_BROWSER_EXTENSIONS_ZIPFILE_INSTALLER_H_