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_CRX_INSTALLER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_CRX_INSTALLER_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_CRX_INSTALLER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_CRX_INSTALLER_H_ |
7 | 7 |
8 #include <memory> | |
9 #include <string> | 8 #include <string> |
10 #include <vector> | 9 #include <vector> |
11 | 10 |
12 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
13 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
14 #include "base/macros.h" | 13 #include "base/macros.h" |
15 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
16 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
17 #include "base/version.h" | 16 #include "base/version.h" |
| 17 #include "chrome/browser/extensions/extension_install_checker.h" |
18 #include "chrome/browser/extensions/extension_install_prompt.h" | 18 #include "chrome/browser/extensions/extension_install_prompt.h" |
19 #include "chrome/browser/extensions/extension_service.h" | 19 #include "chrome/browser/extensions/extension_service.h" |
20 #include "chrome/browser/extensions/webstore_installer.h" | 20 #include "chrome/browser/extensions/webstore_installer.h" |
21 #include "chrome/common/extensions/extension_constants.h" | 21 #include "chrome/common/extensions/extension_constants.h" |
22 #include "components/sync/model/string_ordinal.h" | 22 #include "components/sync/model/string_ordinal.h" |
23 #include "extensions/browser/install_flag.h" | 23 #include "extensions/browser/install_flag.h" |
24 #include "extensions/browser/sandboxed_unpacker.h" | 24 #include "extensions/browser/sandboxed_unpacker.h" |
25 #include "extensions/common/extension.h" | 25 #include "extensions/common/extension.h" |
26 #include "extensions/common/manifest.h" | 26 #include "extensions/common/manifest.h" |
27 | 27 |
28 class ExtensionService; | 28 class ExtensionService; |
29 class ExtensionServiceTest; | 29 class ExtensionServiceTest; |
30 class SkBitmap; | 30 class SkBitmap; |
31 struct WebApplicationInfo; | 31 struct WebApplicationInfo; |
32 | 32 |
33 namespace base { | 33 namespace base { |
34 class SequencedTaskRunner; | 34 class SequencedTaskRunner; |
35 } | 35 } |
36 | 36 |
37 namespace extensions { | 37 namespace extensions { |
38 class CrxInstallError; | 38 class CrxInstallError; |
39 class ExtensionInstallChecker; | |
40 class ExtensionUpdaterTest; | 39 class ExtensionUpdaterTest; |
41 | 40 |
42 // This class installs a crx file into a profile. | 41 // This class installs a crx file into a profile. |
43 // | 42 // |
44 // Installing a CRX is a multi-step process, including unpacking the crx, | 43 // Installing a CRX is a multi-step process, including unpacking the crx, |
45 // validating it, prompting the user, and installing. Since many of these | 44 // validating it, prompting the user, and installing. Since many of these |
46 // steps must occur on the file thread, this class contains a copy of all data | 45 // steps must occur on the file thread, this class contains a copy of all data |
47 // necessary to do its job. (This also minimizes external dependencies for | 46 // necessary to do its job. (This also minimizes external dependencies for |
48 // easier testing). | 47 // easier testing). |
49 // | 48 // |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 | 193 |
195 void set_install_immediately(bool val) { | 194 void set_install_immediately(bool val) { |
196 set_install_flag(kInstallFlagInstallImmediately, val); | 195 set_install_flag(kInstallFlagInstallImmediately, val); |
197 } | 196 } |
198 void set_do_not_sync(bool val) { | 197 void set_do_not_sync(bool val) { |
199 set_install_flag(kInstallFlagDoNotSync, val); | 198 set_install_flag(kInstallFlagDoNotSync, val); |
200 } | 199 } |
201 | 200 |
202 bool did_handle_successfully() const { return did_handle_successfully_; } | 201 bool did_handle_successfully() const { return did_handle_successfully_; } |
203 | 202 |
204 Profile* profile() { return profile_; } | 203 Profile* profile() { return install_checker_.profile(); } |
205 | 204 |
206 const Extension* extension() { return extension_.get(); } | 205 const Extension* extension() { return install_checker_.extension().get(); } |
207 | 206 |
208 // The currently installed version of the extension, for updates. Will be | 207 // The currently installed version of the extension, for updates. Will be |
209 // invalid if this isn't an update. | 208 // invalid if this isn't an update. |
210 const base::Version& current_version() const { return current_version_; } | 209 const base::Version& current_version() const { return current_version_; } |
211 | 210 |
212 private: | 211 private: |
213 friend class ::ExtensionServiceTest; | 212 friend class ::ExtensionServiceTest; |
214 friend class ExtensionUpdaterTest; | 213 friend class ExtensionUpdaterTest; |
| 214 friend class ExtensionCrxInstallerTest; |
215 | 215 |
216 CrxInstaller(base::WeakPtr<ExtensionService> service_weak, | 216 CrxInstaller(base::WeakPtr<ExtensionService> service_weak, |
217 std::unique_ptr<ExtensionInstallPrompt> client, | 217 std::unique_ptr<ExtensionInstallPrompt> client, |
218 const WebstoreInstaller::Approval* approval); | 218 const WebstoreInstaller::Approval* approval); |
219 ~CrxInstaller() override; | 219 ~CrxInstaller() override; |
220 | 220 |
221 // Converts the source user script to an extension. | 221 // Converts the source user script to an extension. |
222 void ConvertUserScriptOnFileThread(); | 222 void ConvertUserScriptOnFileThread(); |
223 | 223 |
224 // Converts the source web app to an extension. | 224 // Converts the source web app to an extension. |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 // and needs additional permissions. | 281 // and needs additional permissions. |
282 void ConfirmReEnable(); | 282 void ConfirmReEnable(); |
283 | 283 |
284 void set_install_flag(int flag, bool val) { | 284 void set_install_flag(int flag, bool val) { |
285 if (val) | 285 if (val) |
286 install_flags_ |= flag; | 286 install_flags_ |= flag; |
287 else | 287 else |
288 install_flags_ &= ~flag; | 288 install_flags_ &= ~flag; |
289 } | 289 } |
290 | 290 |
291 // The Profile the extension is being installed in. | |
292 Profile* profile_; | |
293 | |
294 // The extension being installed. | |
295 scoped_refptr<const Extension> extension_; | |
296 | |
297 // The file we're installing. | 291 // The file we're installing. |
298 base::FilePath source_file_; | 292 base::FilePath source_file_; |
299 | 293 |
300 // The URL the file was downloaded from. | 294 // The URL the file was downloaded from. |
301 GURL download_url_; | 295 GURL download_url_; |
302 | 296 |
303 // The directory extensions are installed to. | 297 // The directory extensions are installed to. |
304 const base::FilePath install_directory_; | 298 const base::FilePath install_directory_; |
305 | 299 |
306 // The location the installation came from (bundled with Chromium, registry, | 300 // The location the installation came from (bundled with Chromium, registry, |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
437 ExtensionInstallPrompt::ShowDialogCallback show_dialog_callback_; | 431 ExtensionInstallPrompt::ShowDialogCallback show_dialog_callback_; |
438 | 432 |
439 // Whether the update is initiated by the user from the extension settings | 433 // Whether the update is initiated by the user from the extension settings |
440 // page. | 434 // page. |
441 bool update_from_settings_page_; | 435 bool update_from_settings_page_; |
442 | 436 |
443 // The flags for ExtensionService::OnExtensionInstalled. | 437 // The flags for ExtensionService::OnExtensionInstalled. |
444 int install_flags_; | 438 int install_flags_; |
445 | 439 |
446 // Performs requirements, policy and blacklist checks on the extension. | 440 // Performs requirements, policy and blacklist checks on the extension. |
447 std::unique_ptr<ExtensionInstallChecker> install_checker_; | 441 ExtensionInstallChecker install_checker_; |
448 | 442 |
449 DISALLOW_COPY_AND_ASSIGN(CrxInstaller); | 443 DISALLOW_COPY_AND_ASSIGN(CrxInstaller); |
450 }; | 444 }; |
451 | 445 |
452 } // namespace extensions | 446 } // namespace extensions |
453 | 447 |
454 #endif // CHROME_BROWSER_EXTENSIONS_CRX_INSTALLER_H_ | 448 #endif // CHROME_BROWSER_EXTENSIONS_CRX_INSTALLER_H_ |
OLD | NEW |