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 <string> | 8 #include <string> |
9 | 9 |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "base/file_path.h" | 11 #include "base/file_path.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
14 #include "base/version.h" | 14 #include "base/version.h" |
| 15 #include "chrome/browser/extensions/app_host_installer.h" |
15 #include "chrome/browser/extensions/crx_installer_error.h" | 16 #include "chrome/browser/extensions/crx_installer_error.h" |
16 #include "chrome/browser/extensions/extension_install_prompt.h" | 17 #include "chrome/browser/extensions/extension_install_prompt.h" |
17 #include "chrome/browser/extensions/sandboxed_unpacker.h" | 18 #include "chrome/browser/extensions/sandboxed_unpacker.h" |
18 #include "chrome/browser/extensions/webstore_installer.h" | 19 #include "chrome/browser/extensions/webstore_installer.h" |
19 #include "chrome/common/extensions/extension.h" | 20 #include "chrome/common/extensions/extension.h" |
20 #include "chrome/common/web_apps.h" | 21 #include "chrome/common/web_apps.h" |
21 #include "sync/api/string_ordinal.h" | 22 #include "sync/api/string_ordinal.h" |
22 | 23 |
23 class ExtensionService; | 24 class ExtensionService; |
24 class SkBitmap; | 25 class SkBitmap; |
25 | 26 |
26 namespace extensions { | 27 namespace extensions { |
27 class ExtensionUpdaterTest; | 28 class ExtensionUpdaterTest; |
28 class RequirementsChecker; | 29 class RequirementsChecker; |
29 | 30 |
30 // This class installs a crx file into a profile. | 31 // This class installs a crx file into a profile. |
31 // | 32 // |
32 // Installing a CRX is a multi-step process, including unpacking the crx, | 33 // Installing a CRX is a multi-step process, including unpacking the crx, |
33 // validating it, prompting the user, and installing. Since many of these | 34 // validating it, prompting the user, and installing. Since many of these |
34 // steps must occur on the file thread, this class contains a copy of all data | 35 // steps must occur on the FILE thread, this class contains a copy of all data |
35 // necessary to do its job. (This also minimizes external dependencies for | 36 // necessary to do its job. (This also minimizes external dependencies for |
36 // easier testing). | 37 // easier testing). |
37 // | 38 // |
38 // Lifetime management: | 39 // Lifetime management: |
39 // | 40 // |
40 // This class is ref-counted by each call it makes to itself on another thread, | 41 // This class is ref-counted by each call it makes to itself on another thread, |
41 // and by UtilityProcessHost. | 42 // and by UtilityProcessHost. |
42 // | 43 // |
43 // Additionally, we hold a reference to our own client so that it lives at least | 44 // Additionally, we hold a reference to our own client so that it lives at least |
44 // long enough to receive the result of unpacking. | 45 // long enough to receive the result of unpacking. |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 // Called on the UI thread to start the requirements check on the extension. | 208 // Called on the UI thread to start the requirements check on the extension. |
208 void CheckRequirements(); | 209 void CheckRequirements(); |
209 | 210 |
210 // Runs on the UI thread. Callback from RequirementsChecker. | 211 // Runs on the UI thread. Callback from RequirementsChecker. |
211 void OnRequirementsChecked(std::vector<std::string> requirement_errors); | 212 void OnRequirementsChecked(std::vector<std::string> requirement_errors); |
212 | 213 |
213 // Runs on the UI thread. Confirms with the user (via ExtensionInstallPrompt) | 214 // Runs on the UI thread. Confirms with the user (via ExtensionInstallPrompt) |
214 // that it is OK to install this extension. | 215 // that it is OK to install this extension. |
215 void ConfirmInstall(); | 216 void ConfirmInstall(); |
216 | 217 |
217 // Runs on File thread. Install the unpacked extension into the profile and | 218 // Runs on FILE thread. Ensures that app is not downgraded. If App Host is |
218 // notify the frontend. | 219 // not installed, calls installer and posts OnAppHostInstallationComplete() |
| 220 // as call back. Else proceeds to CompleteInstall(). |
| 221 void BeginInstall(); |
| 222 |
| 223 // Runs on FILE thread. Callback function for AppHostInstaller. |
| 224 // If not |success|, shows error message. Else proceeds to CompleteInstall(). |
| 225 void OnAppHostInstallationComplete(bool success); |
| 226 |
| 227 // Runs on FILE thread. Installs the unpacked extension into the profile and |
| 228 // notifies the frontend. |
219 void CompleteInstall(); | 229 void CompleteInstall(); |
220 | 230 |
221 // Result reporting. | 231 // Result reporting. |
222 void ReportFailureFromFileThread(const CrxInstallerError& error); | 232 void ReportFailureFromFileThread(const CrxInstallerError& error); |
223 void ReportFailureFromUIThread(const CrxInstallerError& error); | 233 void ReportFailureFromUIThread(const CrxInstallerError& error); |
224 void ReportSuccessFromFileThread(); | 234 void ReportSuccessFromFileThread(); |
225 void ReportSuccessFromUIThread(); | 235 void ReportSuccessFromUIThread(); |
226 void NotifyCrxInstallComplete(const Extension* extension); | 236 void NotifyCrxInstallComplete(const Extension* extension); |
227 | 237 |
228 // The file we're installing. | 238 // The file we're installing. |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 FilePath temp_dir_; | 309 FilePath temp_dir_; |
300 | 310 |
301 // The frontend we will report results back to. | 311 // The frontend we will report results back to. |
302 base::WeakPtr<ExtensionService> frontend_weak_; | 312 base::WeakPtr<ExtensionService> frontend_weak_; |
303 | 313 |
304 // The Profile where the extension is being installed in. | 314 // The Profile where the extension is being installed in. |
305 Profile* profile_; | 315 Profile* profile_; |
306 | 316 |
307 // The client we will work with to do the installation. This can be NULL, in | 317 // The client we will work with to do the installation. This can be NULL, in |
308 // which case the install is silent. | 318 // which case the install is silent. |
309 // NOTE: we may be deleted on the file thread. To ensure the UI is deleted on | 319 // NOTE: we may be deleted on the FILE thread. To ensure the UI is deleted on |
310 // the main thread we don't use a scoped_ptr here. | 320 // the main thread we don't use a scoped_ptr here. |
311 ExtensionInstallPrompt* client_; | 321 ExtensionInstallPrompt* client_; |
312 | 322 |
313 // The root of the unpacked extension directory. This is a subdirectory of | 323 // The root of the unpacked extension directory. This is a subdirectory of |
314 // temp_dir_, so we don't have to delete it explicitly. | 324 // temp_dir_, so we don't have to delete it explicitly. |
315 FilePath unpacked_extension_root_; | 325 FilePath unpacked_extension_root_; |
316 | 326 |
317 // True when the CRX being installed was just downloaded. | 327 // True when the CRX being installed was just downloaded. |
318 // Used to trigger extra checks before installing. | 328 // Used to trigger extra checks before installing. |
319 bool apps_require_extension_mime_type_; | 329 bool apps_require_extension_mime_type_; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 | 362 |
353 // Whether we should produce an error if the manifest declares requirements | 363 // Whether we should produce an error if the manifest declares requirements |
354 // that are not met. If false and there is an unmet requirement, the install | 364 // that are not met. If false and there is an unmet requirement, the install |
355 // will continue but the extension will be distabled. | 365 // will continue but the extension will be distabled. |
356 bool error_on_unsupported_requirements_; | 366 bool error_on_unsupported_requirements_; |
357 | 367 |
358 scoped_ptr<RequirementsChecker> requirements_checker_; | 368 scoped_ptr<RequirementsChecker> requirements_checker_; |
359 | 369 |
360 bool has_requirement_errors_; | 370 bool has_requirement_errors_; |
361 | 371 |
| 372 // Helper to install App Host. |
| 373 AppHostInstaller app_host_installer_; |
| 374 |
362 DISALLOW_COPY_AND_ASSIGN(CrxInstaller); | 375 DISALLOW_COPY_AND_ASSIGN(CrxInstaller); |
363 }; | 376 }; |
364 | 377 |
365 } // namespace extensions | 378 } // namespace extensions |
366 | 379 |
367 #endif // CHROME_BROWSER_EXTENSIONS_CRX_INSTALLER_H_ | 380 #endif // CHROME_BROWSER_EXTENSIONS_CRX_INSTALLER_H_ |
OLD | NEW |