OLD | NEW |
(Empty) | |
| 1 // Copyright 2013 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. |
| 4 |
| 5 #ifndef CHROME_BROWSER_EXTENSIONS_ZIPFILE_INSTALLER_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_ZIPFILE_INSTALLER_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 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" |
| 17 |
| 18 class ExtensionService; |
| 19 |
| 20 namespace IPC { |
| 21 class Message; |
| 22 } |
| 23 |
| 24 namespace extensions { |
| 25 |
| 26 class ZipFileInstallerClient |
| 27 : public base::RefCountedThreadSafe<ZipFileInstallerClient> { |
| 28 public: |
| 29 // temp_dir - A temporary directory containing the unzipped contents. |
| 30 virtual void OnUnzipSuccess(const base::FilePath& temp_dir) = 0; |
| 31 virtual void OnUnzipFailure(const std::string& error) = 0; |
| 32 |
| 33 protected: |
| 34 friend class base::RefCountedThreadSafe<ZipFileInstallerClient>; |
| 35 |
| 36 virtual ~ZipFileInstallerClient() {} |
| 37 }; |
| 38 |
| 39 // ZipFileInstaller unzips an extension that is zipped up via a utility process. |
| 40 // The contents are then loaded via UnpackedInstaller. |
| 41 class ZipFileInstaller : public content::UtilityProcessHostClient { |
| 42 public: |
| 43 static scoped_refptr<ZipFileInstaller> Create( |
| 44 ExtensionService* extension_service, |
| 45 ZipFileInstallerClient* client); |
| 46 |
| 47 void LoadFromZipFile(const base::FilePath& path); |
| 48 |
| 49 void set_be_noisy_on_failure(bool value) { be_noisy_on_failure_ = value; } |
| 50 |
| 51 // UtilityProcessHostClient |
| 52 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 53 |
| 54 private: |
| 55 explicit ZipFileInstaller(ExtensionService* extension_service, |
| 56 ZipFileInstallerClient* client); |
| 57 virtual ~ZipFileInstaller(); |
| 58 |
| 59 void PrepareTempDir(); |
| 60 void StartWorkOnIOThread(const base::FilePath& temp_dir); |
| 61 void ReportSuccessOnUIThread(const base::FilePath& unzipped_path); |
| 62 void ReportErrorOnUIThread(const std::string& error); |
| 63 |
| 64 void OnUnzipSucceeded(const base::FilePath& unzipped_path); |
| 65 void OnUnzipFailed(const std::string& error); |
| 66 |
| 67 bool be_noisy_on_failure_; |
| 68 base::WeakPtr<ExtensionService> extension_service_; |
| 69 base::FilePath zip_path_; |
| 70 |
| 71 scoped_refptr<ZipFileInstallerClient> client_; |
| 72 |
| 73 DISALLOW_COPY_AND_ASSIGN(ZipFileInstaller); |
| 74 }; |
| 75 |
| 76 } // namespace extensions |
| 77 |
| 78 #endif // CHROME_BROWSER_EXTENSIONS_ZIPFILE_INSTALLER_H_ |
OLD | NEW |