Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(92)

Side by Side Diff: chrome/browser/extensions/zipfile_installer.h

Issue 2697463002: Convert utility process extension Unpacker IPC to mojo (Closed)
Patch Set: Set the IPC enum traits limit to extensions::Manifest::NUM_LOCATIONS - 1. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/extensions/BUILD.gn ('k') | chrome/browser/extensions/zipfile_installer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_EXTENSIONS_ZIPFILE_INSTALLER_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_ZIPFILE_INSTALLER_H_
6 #define CHROME_BROWSER_EXTENSIONS_ZIPFILE_INSTALLER_H_ 6 #define CHROME_BROWSER_EXTENSIONS_ZIPFILE_INSTALLER_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 10
11 #include "base/callback.h"
12 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
13 #include "base/macros.h" 12 #include "base/macros.h"
14 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
15 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
16 #include "content/public/browser/utility_process_host_client.h" 15 #include "content/public/browser/utility_process_mojo_client.h"
17 16
18 class ExtensionService; 17 class ExtensionService;
19 18
20 namespace IPC { 19 namespace extensions {
21 class Message; 20
21 namespace mojom {
22 class ExtensionUnpacker;
22 } 23 }
23 24
24 namespace extensions { 25 // ZipFileInstaller unzips an extension in a utility process. On success, the
26 // extension content is loaded by an extensions::UnpackedInstaller. The class
27 // lives on the UI thread.
28 class ZipFileInstaller : public base::RefCountedThreadSafe<ZipFileInstaller> {
29 public:
30 static scoped_refptr<ZipFileInstaller> Create(ExtensionService* service);
25 31
26 // ZipFileInstaller unzips an extension that is zipped up via a utility process. 32 void LoadFromZipFile(const base::FilePath& zip_file);
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);
32
33 void LoadFromZipFile(const base::FilePath& path);
34 33
35 void set_be_noisy_on_failure(bool value) { be_noisy_on_failure_ = value; } 34 void set_be_noisy_on_failure(bool value) { be_noisy_on_failure_ = value; }
36 35
37 // UtilityProcessHostClient 36 private:
38 bool OnMessageReceived(const IPC::Message& message) override; 37 friend class base::RefCountedThreadSafe<ZipFileInstaller>;
39 38
40 private: 39 explicit ZipFileInstaller(ExtensionService* service);
41 explicit ZipFileInstaller(ExtensionService* extension_service); 40 ~ZipFileInstaller();
42 ~ZipFileInstaller() override;
43 41
44 void PrepareTempDir(); 42 // Unzip an extension into |unzip_dir| and load it with an UnpackedInstaller.
45 void StartWorkOnIOThread(const base::FilePath& temp_dir); 43 void PrepareUnzipDir(const base::FilePath& zip_file);
46 void ReportSuccessOnUIThread(const base::FilePath& unzipped_path); 44 void Unzip(const base::FilePath& unzip_dir);
47 void ReportErrorOnUIThread(const std::string& error); 45 void UnzipDone(const base::FilePath& unzip_dir, bool success);
48 46
49 void OnUnzipSucceeded(const base::FilePath& unzipped_path); 47 // On failure, report the |error| reason.
50 void OnUnzipFailed(const std::string& error); 48 void ReportFailure(const std::string& error);
51 49
50 // Passed to the ExtensionErrorReporter when reporting errors.
52 bool be_noisy_on_failure_; 51 bool be_noisy_on_failure_;
52
53 // Pointer to our controlling extension service.
53 base::WeakPtr<ExtensionService> extension_service_weak_; 54 base::WeakPtr<ExtensionService> extension_service_weak_;
54 base::FilePath zip_path_; 55
56 // File containing the extension to unzip.
57 base::FilePath zip_file_;
58
59 // Utility process used to perform the unzip.
60 std::unique_ptr<content::UtilityProcessMojoClient<mojom::ExtensionUnpacker>>
61 utility_process_mojo_client_;
55 62
56 DISALLOW_COPY_AND_ASSIGN(ZipFileInstaller); 63 DISALLOW_COPY_AND_ASSIGN(ZipFileInstaller);
57 }; 64 };
58 65
59 } // namespace extensions 66 } // namespace extensions
60 67
61 #endif // CHROME_BROWSER_EXTENSIONS_ZIPFILE_INSTALLER_H_ 68 #endif // CHROME_BROWSER_EXTENSIONS_ZIPFILE_INSTALLER_H_
OLDNEW
« no previous file with comments | « chrome/browser/extensions/BUILD.gn ('k') | chrome/browser/extensions/zipfile_installer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698