OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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_UNPACKED_INSTALLER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_UNPACKED_INSTALLER_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_UNPACKED_INSTALLER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_UNPACKED_INSTALLER_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
16 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
| 17 #include "chrome/browser/extensions/extension_install_checker.h" |
17 | 18 |
18 class ExtensionService; | 19 class ExtensionService; |
19 class Profile; | |
20 | 20 |
21 namespace extensions { | 21 namespace extensions { |
22 | 22 |
23 class Extension; | 23 class Extension; |
24 class ExtensionInstallChecker; | |
25 | 24 |
26 // Installs and loads an unpacked extension. Because internal state needs to be | 25 // Installs and loads an unpacked extension. Because internal state needs to be |
27 // held about the instalation process, only one call to Load*() should be made | 26 // held about the instalation process, only one call to Load*() should be made |
28 // per UnpackedInstaller. | 27 // per UnpackedInstaller. |
29 // TODO(erikkay): It might be useful to be able to load a packed extension | 28 // TODO(erikkay): It might be useful to be able to load a packed extension |
30 // (presumably into memory) without installing it. | 29 // (presumably into memory) without installing it. |
31 class UnpackedInstaller | 30 class UnpackedInstaller |
32 : public base::RefCountedThreadSafe<UnpackedInstaller> { | 31 : public base::RefCountedThreadSafe<UnpackedInstaller> { |
33 public: | 32 public: |
34 using CompletionCallback = base::Callback<void(const Extension* extension, | 33 using CompletionCallback = base::Callback<void(const Extension* extension, |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 | 110 |
112 // Notify the frontend that there was an error loading an extension. | 111 // Notify the frontend that there was an error loading an extension. |
113 void ReportExtensionLoadError(const std::string& error); | 112 void ReportExtensionLoadError(const std::string& error); |
114 | 113 |
115 // Passes the extension onto extension service. | 114 // Passes the extension onto extension service. |
116 void InstallExtension(); | 115 void InstallExtension(); |
117 | 116 |
118 // Helper to get the Extension::CreateFlags for the installing extension. | 117 // Helper to get the Extension::CreateFlags for the installing extension. |
119 int GetFlags(); | 118 int GetFlags(); |
120 | 119 |
121 const Extension* extension() { return extension_.get(); } | 120 const Extension* extension() { return install_checker_.extension().get(); } |
122 | 121 |
123 // The service we will report results back to. | 122 // The service we will report results back to. |
124 base::WeakPtr<ExtensionService> service_weak_; | 123 base::WeakPtr<ExtensionService> service_weak_; |
125 | 124 |
126 // The Profile the extension is being installed in. | |
127 Profile* profile_; | |
128 | |
129 // The pathname of the directory to load from, which is an absolute path | 125 // The pathname of the directory to load from, which is an absolute path |
130 // after GetAbsolutePath has been called. | 126 // after GetAbsolutePath has been called. |
131 base::FilePath extension_path_; | 127 base::FilePath extension_path_; |
132 | 128 |
133 // The extension being installed. | |
134 scoped_refptr<const Extension> extension_; | |
135 | |
136 // If true and the extension contains plugins, we prompt the user before | 129 // If true and the extension contains plugins, we prompt the user before |
137 // loading. | 130 // loading. |
138 bool prompt_for_plugins_; | 131 bool prompt_for_plugins_; |
139 | 132 |
140 // Whether to require the extension installed to have a modern manifest | 133 // Whether to require the extension installed to have a modern manifest |
141 // version. | 134 // version. |
142 bool require_modern_manifest_version_; | 135 bool require_modern_manifest_version_; |
143 | 136 |
144 // Whether or not to be noisy (show a dialog) on failure. Defaults to true. | 137 // Whether or not to be noisy (show a dialog) on failure. Defaults to true. |
145 bool be_noisy_on_failure_; | 138 bool be_noisy_on_failure_; |
146 | 139 |
147 // Checks management policies and requirements before the extension can be | 140 // Checks management policies and requirements before the extension can be |
148 // installed. | 141 // installed. |
149 std::unique_ptr<ExtensionInstallChecker> install_checker_; | 142 ExtensionInstallChecker install_checker_; |
150 | 143 |
151 CompletionCallback callback_; | 144 CompletionCallback callback_; |
152 | 145 |
153 DISALLOW_COPY_AND_ASSIGN(UnpackedInstaller); | 146 DISALLOW_COPY_AND_ASSIGN(UnpackedInstaller); |
154 }; | 147 }; |
155 | 148 |
156 } // namespace extensions | 149 } // namespace extensions |
157 | 150 |
158 #endif // CHROME_BROWSER_EXTENSIONS_UNPACKED_INSTALLER_H_ | 151 #endif // CHROME_BROWSER_EXTENSIONS_UNPACKED_INSTALLER_H_ |
OLD | NEW |