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> |
8 #include <string> | 9 #include <string> |
9 #include <vector> | 10 #include <vector> |
10 | 11 |
11 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
12 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
13 #include "base/macros.h" | 14 #include "base/macros.h" |
14 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
15 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
16 #include "base/version.h" | 17 #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; |
39 class ExtensionUpdaterTest; | 40 class ExtensionUpdaterTest; |
40 | 41 |
41 // This class installs a crx file into a profile. | 42 // This class installs a crx file into a profile. |
42 // | 43 // |
43 // Installing a CRX is a multi-step process, including unpacking the crx, | 44 // Installing a CRX is a multi-step process, including unpacking the crx, |
44 // validating it, prompting the user, and installing. Since many of these | 45 // validating it, prompting the user, and installing. Since many of these |
45 // steps must occur on the file thread, this class contains a copy of all data | 46 // steps must occur on the file thread, this class contains a copy of all data |
46 // necessary to do its job. (This also minimizes external dependencies for | 47 // necessary to do its job. (This also minimizes external dependencies for |
47 // easier testing). | 48 // easier testing). |
48 // | 49 // |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 | 194 |
194 void set_install_immediately(bool val) { | 195 void set_install_immediately(bool val) { |
195 set_install_flag(kInstallFlagInstallImmediately, val); | 196 set_install_flag(kInstallFlagInstallImmediately, val); |
196 } | 197 } |
197 void set_do_not_sync(bool val) { | 198 void set_do_not_sync(bool val) { |
198 set_install_flag(kInstallFlagDoNotSync, val); | 199 set_install_flag(kInstallFlagDoNotSync, val); |
199 } | 200 } |
200 | 201 |
201 bool did_handle_successfully() const { return did_handle_successfully_; } | 202 bool did_handle_successfully() const { return did_handle_successfully_; } |
202 | 203 |
203 Profile* profile() { return install_checker_.profile(); } | 204 Profile* profile() { return profile_; } |
204 | 205 |
205 const Extension* extension() { return install_checker_.extension().get(); } | 206 const Extension* extension() { return extension_.get(); } |
206 | 207 |
207 // The currently installed version of the extension, for updates. Will be | 208 // The currently installed version of the extension, for updates. Will be |
208 // invalid if this isn't an update. | 209 // invalid if this isn't an update. |
209 const base::Version& current_version() const { return current_version_; } | 210 const base::Version& current_version() const { return current_version_; } |
210 | 211 |
211 private: | 212 private: |
212 friend class ::ExtensionServiceTest; | 213 friend class ::ExtensionServiceTest; |
213 friend class ExtensionUpdaterTest; | 214 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 |
291 // The file we're installing. | 297 // The file we're installing. |
292 base::FilePath source_file_; | 298 base::FilePath source_file_; |
293 | 299 |
294 // The URL the file was downloaded from. | 300 // The URL the file was downloaded from. |
295 GURL download_url_; | 301 GURL download_url_; |
296 | 302 |
297 // The directory extensions are installed to. | 303 // The directory extensions are installed to. |
298 const base::FilePath install_directory_; | 304 const base::FilePath install_directory_; |
299 | 305 |
300 // The location the installation came from (bundled with Chromium, registry, | 306 // The location the installation came from (bundled with Chromium, registry, |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 ExtensionInstallPrompt::ShowDialogCallback show_dialog_callback_; | 437 ExtensionInstallPrompt::ShowDialogCallback show_dialog_callback_; |
432 | 438 |
433 // Whether the update is initiated by the user from the extension settings | 439 // Whether the update is initiated by the user from the extension settings |
434 // page. | 440 // page. |
435 bool update_from_settings_page_; | 441 bool update_from_settings_page_; |
436 | 442 |
437 // The flags for ExtensionService::OnExtensionInstalled. | 443 // The flags for ExtensionService::OnExtensionInstalled. |
438 int install_flags_; | 444 int install_flags_; |
439 | 445 |
440 // Performs requirements, policy and blacklist checks on the extension. | 446 // Performs requirements, policy and blacklist checks on the extension. |
441 ExtensionInstallChecker install_checker_; | 447 std::unique_ptr<ExtensionInstallChecker> install_checker_; |
442 | 448 |
443 DISALLOW_COPY_AND_ASSIGN(CrxInstaller); | 449 DISALLOW_COPY_AND_ASSIGN(CrxInstaller); |
444 }; | 450 }; |
445 | 451 |
446 } // namespace extensions | 452 } // namespace extensions |
447 | 453 |
448 #endif // CHROME_BROWSER_EXTENSIONS_CRX_INSTALLER_H_ | 454 #endif // CHROME_BROWSER_EXTENSIONS_CRX_INSTALLER_H_ |
OLD | NEW |