| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/file_path.h" | 10 #include "base/file_path.h" |
| 11 #include "base/message_loop.h" | |
| 12 #include "base/ref_counted.h" | 11 #include "base/ref_counted.h" |
| 13 #include "base/task.h" | 12 #include "base/task.h" |
| 14 #include "chrome/browser/extensions/extension_install_ui.h" | 13 #include "chrome/browser/extensions/extension_install_ui.h" |
| 15 #include "chrome/browser/extensions/extensions_service.h" | 14 #include "chrome/browser/extensions/extensions_service.h" |
| 16 #include "chrome/browser/extensions/sandboxed_extension_unpacker.h" | 15 #include "chrome/browser/extensions/sandboxed_extension_unpacker.h" |
| 17 #include "chrome/common/extensions/extension.h" | 16 #include "chrome/common/extensions/extension.h" |
| 18 | 17 |
| 19 class SkBitmap; | 18 class SkBitmap; |
| 20 | 19 |
| 21 // This class installs a crx file into a profile. | 20 // This class installs a crx file into a profile. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 41 public: | 40 public: |
| 42 // Starts the installation of the crx file in |crx_path| into | 41 // Starts the installation of the crx file in |crx_path| into |
| 43 // |install_directory|. | 42 // |install_directory|. |
| 44 // | 43 // |
| 45 // Other params: | 44 // Other params: |
| 46 // install_source: The source of the install (external, --load-extension, etc | 45 // install_source: The source of the install (external, --load-extension, etc |
| 47 // expected_id: Optional. If the caller knows what the ID of this extension | 46 // expected_id: Optional. If the caller knows what the ID of this extension |
| 48 // should be after unpacking, it can be specified here as a | 47 // should be after unpacking, it can be specified here as a |
| 49 // sanity check. | 48 // sanity check. |
| 50 // delete_crx: Whether the crx should be deleted on completion. | 49 // delete_crx: Whether the crx should be deleted on completion. |
| 51 // file_loop: The message loop to do file IO on. | |
| 52 // frontend: The ExtensionsService to report the successfully installed | 50 // frontend: The ExtensionsService to report the successfully installed |
| 53 // extension to. | 51 // extension to. |
| 54 // client: Optional. If specified, will be used to confirm installation and | 52 // client: Optional. If specified, will be used to confirm installation and |
| 55 // also notified of success/fail. Note that we hold a reference to | 53 // also notified of success/fail. Note that we hold a reference to |
| 56 // this, so it can outlive its creator (eg the UI). | 54 // this, so it can outlive its creator (eg the UI). |
| 57 static void Start(const FilePath& crx_path, | 55 static void Start(const FilePath& crx_path, |
| 58 const FilePath& install_directory, | 56 const FilePath& install_directory, |
| 59 Extension::Location install_source, | 57 Extension::Location install_source, |
| 60 const std::string& expected_id, | 58 const std::string& expected_id, |
| 61 bool delete_crx, | 59 bool delete_crx, |
| 62 bool allow_privilege_increase, | 60 bool allow_privilege_increase, |
| 63 MessageLoop* file_loop, | |
| 64 ExtensionsService* frontend, | 61 ExtensionsService* frontend, |
| 65 ExtensionInstallUI* client); | 62 ExtensionInstallUI* client); |
| 66 | 63 |
| 67 // Given the path to the large icon from an extension, read it if present and | 64 // Given the path to the large icon from an extension, read it if present and |
| 68 // decode it into result. | 65 // decode it into result. |
| 69 static void DecodeInstallIcon(const FilePath& large_icon_path, | 66 static void DecodeInstallIcon(const FilePath& large_icon_path, |
| 70 scoped_ptr<SkBitmap>* result); | 67 scoped_ptr<SkBitmap>* result); |
| 71 | 68 |
| 72 // ExtensionInstallUI::Delegate | 69 // ExtensionInstallUI::Delegate |
| 73 virtual void ContinueInstall(); | 70 virtual void ContinueInstall(); |
| 74 virtual void AbortInstall(); | 71 virtual void AbortInstall(); |
| 75 | 72 |
| 76 private: | 73 private: |
| 77 CrxInstaller(const FilePath& crx_path, | 74 CrxInstaller(const FilePath& crx_path, |
| 78 const FilePath& install_directory, | 75 const FilePath& install_directory, |
| 79 Extension::Location install_source, | 76 Extension::Location install_source, |
| 80 const std::string& expected_id, | 77 const std::string& expected_id, |
| 81 bool delete_crx, | 78 bool delete_crx, |
| 82 bool allow_privilege_increase, | 79 bool allow_privilege_increase, |
| 83 MessageLoop* file_loop, | |
| 84 ExtensionsService* frontend, | 80 ExtensionsService* frontend, |
| 85 ExtensionInstallUI* client); | 81 ExtensionInstallUI* client); |
| 86 ~CrxInstaller(); | 82 ~CrxInstaller(); |
| 87 | 83 |
| 88 // SandboxedExtensionUnpackerClient | 84 // SandboxedExtensionUnpackerClient |
| 89 virtual void OnUnpackFailure(const std::string& error_message); | 85 virtual void OnUnpackFailure(const std::string& error_message); |
| 90 virtual void OnUnpackSuccess(const FilePath& temp_dir, | 86 virtual void OnUnpackSuccess(const FilePath& temp_dir, |
| 91 const FilePath& extension_dir, | 87 const FilePath& extension_dir, |
| 92 Extension* extension); | 88 Extension* extension); |
| 93 | 89 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 // allowed. | 123 // allowed. |
| 128 bool extensions_enabled_; | 124 bool extensions_enabled_; |
| 129 | 125 |
| 130 // Whether we're supposed to delete the source crx file on destruction. | 126 // Whether we're supposed to delete the source crx file on destruction. |
| 131 bool delete_crx_; | 127 bool delete_crx_; |
| 132 | 128 |
| 133 // Whether privileges should be allowed to silently increaes from any | 129 // Whether privileges should be allowed to silently increaes from any |
| 134 // previously installed version of the extension. | 130 // previously installed version of the extension. |
| 135 bool allow_privilege_increase_; | 131 bool allow_privilege_increase_; |
| 136 | 132 |
| 137 // The message loop to use for file IO. | |
| 138 MessageLoop* file_loop_; | |
| 139 | |
| 140 // The message loop the UI is running on. | |
| 141 MessageLoop* ui_loop_; | |
| 142 | |
| 143 // The extension we're installing. We own this and either pass it off to | 133 // The extension we're installing. We own this and either pass it off to |
| 144 // ExtensionsService on success, or delete it on failure. | 134 // ExtensionsService on success, or delete it on failure. |
| 145 scoped_ptr<Extension> extension_; | 135 scoped_ptr<Extension> extension_; |
| 146 | 136 |
| 147 // If non-empty, contains the current version of the extension we're | 137 // If non-empty, contains the current version of the extension we're |
| 148 // installing (for upgrades). | 138 // installing (for upgrades). |
| 149 std::string current_version_; | 139 std::string current_version_; |
| 150 | 140 |
| 151 // The icon we will display in the installation UI, if any. | 141 // The icon we will display in the installation UI, if any. |
| 152 scoped_ptr<SkBitmap> install_icon_; | 142 scoped_ptr<SkBitmap> install_icon_; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 166 // temp_dir_, so we don't have to delete it explicitly. | 156 // temp_dir_, so we don't have to delete it explicitly. |
| 167 FilePath unpacked_extension_root_; | 157 FilePath unpacked_extension_root_; |
| 168 | 158 |
| 169 // The unpacker we will use to unpack the extension. | 159 // The unpacker we will use to unpack the extension. |
| 170 SandboxedExtensionUnpacker* unpacker_; | 160 SandboxedExtensionUnpacker* unpacker_; |
| 171 | 161 |
| 172 DISALLOW_COPY_AND_ASSIGN(CrxInstaller); | 162 DISALLOW_COPY_AND_ASSIGN(CrxInstaller); |
| 173 }; | 163 }; |
| 174 | 164 |
| 175 #endif // CHROME_BROWSER_EXTENSIONS_CRX_INSTALLER_H_ | 165 #endif // CHROME_BROWSER_EXTENSIONS_CRX_INSTALLER_H_ |
| OLD | NEW |