| 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 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 15 #include "base/version.h" | 15 #include "base/version.h" |
| 16 #include "chrome/browser/extensions/blacklist.h" | 16 #include "chrome/browser/extensions/blacklist.h" |
| 17 #include "chrome/browser/extensions/extension_install_checker.h" |
| 17 #include "chrome/browser/extensions/extension_install_prompt.h" | 18 #include "chrome/browser/extensions/extension_install_prompt.h" |
| 18 #include "chrome/browser/extensions/extension_installer.h" | |
| 19 #include "chrome/browser/extensions/extension_service.h" | 19 #include "chrome/browser/extensions/extension_service.h" |
| 20 #include "chrome/browser/extensions/sandboxed_unpacker.h" | 20 #include "chrome/browser/extensions/sandboxed_unpacker.h" |
| 21 #include "chrome/browser/extensions/webstore_installer.h" | 21 #include "chrome/browser/extensions/webstore_installer.h" |
| 22 #include "chrome/common/extensions/extension_constants.h" | 22 #include "chrome/common/extensions/extension_constants.h" |
| 23 #include "extensions/browser/install_flag.h" | 23 #include "extensions/browser/install_flag.h" |
| 24 #include "extensions/common/extension.h" | 24 #include "extensions/common/extension.h" |
| 25 #include "extensions/common/manifest.h" | 25 #include "extensions/common/manifest.h" |
| 26 #include "sync/api/string_ordinal.h" | 26 #include "sync/api/string_ordinal.h" |
| 27 | 27 |
| 28 class ExtensionService; | 28 class ExtensionService; |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 } | 188 } |
| 189 void set_is_ephemeral(bool val) { | 189 void set_is_ephemeral(bool val) { |
| 190 set_install_flag(kInstallFlagIsEphemeral, val); | 190 set_install_flag(kInstallFlagIsEphemeral, val); |
| 191 } | 191 } |
| 192 void set_do_not_sync(bool val) { | 192 void set_do_not_sync(bool val) { |
| 193 set_install_flag(kInstallFlagDoNotSync, val); | 193 set_install_flag(kInstallFlagDoNotSync, val); |
| 194 } | 194 } |
| 195 | 195 |
| 196 bool did_handle_successfully() const { return did_handle_successfully_; } | 196 bool did_handle_successfully() const { return did_handle_successfully_; } |
| 197 | 197 |
| 198 Profile* profile() { return installer_.profile(); } | 198 Profile* profile() { return install_checker_.profile(); } |
| 199 | 199 |
| 200 const Extension* extension() { return installer_.extension().get(); } | 200 const Extension* extension() { return install_checker_.extension().get(); } |
| 201 | 201 |
| 202 const std::string& current_version() const { return current_version_; } | 202 const std::string& current_version() const { return current_version_; } |
| 203 | 203 |
| 204 private: | 204 private: |
| 205 friend class ::ExtensionServiceTest; | 205 friend class ::ExtensionServiceTest; |
| 206 friend class ExtensionUpdaterTest; | 206 friend class ExtensionUpdaterTest; |
| 207 friend class ExtensionCrxInstallerTest; | 207 friend class ExtensionCrxInstallerTest; |
| 208 | 208 |
| 209 CrxInstaller(base::WeakPtr<ExtensionService> service_weak, | 209 CrxInstaller(base::WeakPtr<ExtensionService> service_weak, |
| 210 scoped_ptr<ExtensionInstallPrompt> client, | 210 scoped_ptr<ExtensionInstallPrompt> client, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 222 CrxInstallerError AllowInstall(const Extension* extension); | 222 CrxInstallerError AllowInstall(const Extension* extension); |
| 223 | 223 |
| 224 // SandboxedUnpackerClient | 224 // SandboxedUnpackerClient |
| 225 virtual void OnUnpackFailure(const base::string16& error_message) OVERRIDE; | 225 virtual void OnUnpackFailure(const base::string16& error_message) OVERRIDE; |
| 226 virtual void OnUnpackSuccess(const base::FilePath& temp_dir, | 226 virtual void OnUnpackSuccess(const base::FilePath& temp_dir, |
| 227 const base::FilePath& extension_dir, | 227 const base::FilePath& extension_dir, |
| 228 const base::DictionaryValue* original_manifest, | 228 const base::DictionaryValue* original_manifest, |
| 229 const Extension* extension, | 229 const Extension* extension, |
| 230 const SkBitmap& install_icon) OVERRIDE; | 230 const SkBitmap& install_icon) OVERRIDE; |
| 231 | 231 |
| 232 // Called on the UI thread to start the requirements check on the extension. | 232 // Called on the UI thread to start the requirements, policy and blacklist |
| 233 void CheckImportsAndRequirements(); | 233 // checks on the extension. |
| 234 void CheckInstall(); |
| 234 | 235 |
| 235 // Runs on the UI thread. Callback from RequirementsChecker. | 236 // Runs on the UI thread. Callback from ExtensionInstallChecker. |
| 236 void OnRequirementsChecked(std::vector<std::string> requirement_errors); | 237 void OnInstallChecksComplete(int failed_checks); |
| 237 | 238 |
| 238 // Runs on the UI thread. Callback from Blacklist. | 239 // Runs on the UI thread. Callback from Blacklist. |
| 239 void OnBlacklistChecked( | 240 void OnBlacklistChecked( |
| 240 extensions::BlacklistState blacklist_state); | 241 extensions::BlacklistState blacklist_state); |
| 241 | 242 |
| 242 // Runs on the UI thread. Confirms the installation to the ExtensionService. | 243 // Runs on the UI thread. Confirms the installation to the ExtensionService. |
| 243 void ConfirmInstall(); | 244 void ConfirmInstall(); |
| 244 | 245 |
| 245 // Runs on File thread. Install the unpacked extension into the profile and | 246 // Runs on File thread. Install the unpacked extension into the profile and |
| 246 // notify the frontend. | 247 // notify the frontend. |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 410 // Used to show the install dialog. | 411 // Used to show the install dialog. |
| 411 ExtensionInstallPrompt::ShowDialogCallback show_dialog_callback_; | 412 ExtensionInstallPrompt::ShowDialogCallback show_dialog_callback_; |
| 412 | 413 |
| 413 // Whether the update is initiated by the user from the extension settings | 414 // Whether the update is initiated by the user from the extension settings |
| 414 // page. | 415 // page. |
| 415 bool update_from_settings_page_; | 416 bool update_from_settings_page_; |
| 416 | 417 |
| 417 // The flags for ExtensionService::OnExtensionInstalled. | 418 // The flags for ExtensionService::OnExtensionInstalled. |
| 418 int install_flags_; | 419 int install_flags_; |
| 419 | 420 |
| 420 // Gives access to common methods and data of an extension installer. | 421 // Performs requirements, policy and blacklist checks on the extension. |
| 421 ExtensionInstaller installer_; | 422 ExtensionInstallChecker install_checker_; |
| 422 | 423 |
| 423 DISALLOW_COPY_AND_ASSIGN(CrxInstaller); | 424 DISALLOW_COPY_AND_ASSIGN(CrxInstaller); |
| 424 }; | 425 }; |
| 425 | 426 |
| 426 } // namespace extensions | 427 } // namespace extensions |
| 427 | 428 |
| 428 #endif // CHROME_BROWSER_EXTENSIONS_CRX_INSTALLER_H_ | 429 #endif // CHROME_BROWSER_EXTENSIONS_CRX_INSTALLER_H_ |
| OLD | NEW |