| 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 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/file_path.h" | 11 #include "base/file_path.h" |
| 12 #include "base/ref_counted.h" | 12 #include "base/ref_counted.h" |
| 13 #include "chrome/browser/extensions/extension_install_ui.h" | 13 #include "chrome/browser/extensions/extension_install_ui.h" |
| 14 #include "chrome/browser/extensions/sandboxed_extension_unpacker.h" | 14 #include "chrome/browser/extensions/sandboxed_extension_unpacker.h" |
| 15 #include "chrome/common/extensions/extension.h" | 15 #include "chrome/common/extensions/extension.h" |
| 16 #include "chrome/common/web_apps.h" | 16 #include "chrome/common/web_apps.h" |
| 17 | 17 |
| 18 class ExtensionsService; | 18 class ExtensionService; |
| 19 class SkBitmap; | 19 class SkBitmap; |
| 20 | 20 |
| 21 // This class installs a crx file into a profile. | 21 // This class installs a crx file into a profile. |
| 22 // | 22 // |
| 23 // Installing a CRX is a multi-step process, including unpacking the crx, | 23 // Installing a CRX is a multi-step process, including unpacking the crx, |
| 24 // validating it, prompting the user, and installing. Since many of these | 24 // validating it, prompting the user, and installing. Since many of these |
| 25 // steps must occur on the file thread, this class contains a copy of all data | 25 // steps must occur on the file thread, this class contains a copy of all data |
| 26 // necessary to do its job. (This also minimizes external dependencies for | 26 // necessary to do its job. (This also minimizes external dependencies for |
| 27 // easier testing). | 27 // easier testing). |
| 28 // | 28 // |
| (...skipping 29 matching lines...) Expand all Loading... |
| 58 static bool IsIdWhitelisted(const std::string& id); | 58 static bool IsIdWhitelisted(const std::string& id); |
| 59 | 59 |
| 60 // Returns whether |id| was found and removed (was whitelisted). This should | 60 // Returns whether |id| was found and removed (was whitelisted). This should |
| 61 // only be called on the UI thread. | 61 // only be called on the UI thread. |
| 62 static bool ClearWhitelistedInstallId(const std::string& id); | 62 static bool ClearWhitelistedInstallId(const std::string& id); |
| 63 | 63 |
| 64 // Constructor. Extensions will be installed into | 64 // Constructor. Extensions will be installed into |
| 65 // frontend->install_directory() then registered with |frontend|. Any install | 65 // frontend->install_directory() then registered with |frontend|. Any install |
| 66 // UI will be displayed using |client|. Pass NULL for |client| for silent | 66 // UI will be displayed using |client|. Pass NULL for |client| for silent |
| 67 // install. | 67 // install. |
| 68 CrxInstaller(ExtensionsService* frontend, | 68 CrxInstaller(ExtensionService* frontend, |
| 69 ExtensionInstallUI* client); | 69 ExtensionInstallUI* client); |
| 70 | 70 |
| 71 // Install the crx in |source_file|. | 71 // Install the crx in |source_file|. |
| 72 void InstallCrx(const FilePath& source_file); | 72 void InstallCrx(const FilePath& source_file); |
| 73 | 73 |
| 74 // Convert the specified user script into an extension and install it. | 74 // Convert the specified user script into an extension and install it. |
| 75 void InstallUserScript(const FilePath& source_file, | 75 void InstallUserScript(const FilePath& source_file, |
| 76 const GURL& original_url); | 76 const GURL& original_url); |
| 77 | 77 |
| 78 // Convert the specified web app into an extension and install it. | 78 // Convert the specified web app into an extension and install it. |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 | 175 |
| 176 // Whether the install originated from the gallery. | 176 // Whether the install originated from the gallery. |
| 177 bool is_gallery_install_; | 177 bool is_gallery_install_; |
| 178 | 178 |
| 179 // Whether to create an app shortcut after successful installation. This is | 179 // Whether to create an app shortcut after successful installation. This is |
| 180 // set based on the user's selection in the UI and can only ever be true for | 180 // set based on the user's selection in the UI and can only ever be true for |
| 181 // apps. | 181 // apps. |
| 182 bool create_app_shortcut_; | 182 bool create_app_shortcut_; |
| 183 | 183 |
| 184 // The extension we're installing. We own this and either pass it off to | 184 // The extension we're installing. We own this and either pass it off to |
| 185 // ExtensionsService on success, or delete it on failure. | 185 // ExtensionService on success, or delete it on failure. |
| 186 scoped_refptr<const Extension> extension_; | 186 scoped_refptr<const Extension> extension_; |
| 187 | 187 |
| 188 // If non-empty, contains the current version of the extension we're | 188 // If non-empty, contains the current version of the extension we're |
| 189 // installing (for upgrades). | 189 // installing (for upgrades). |
| 190 std::string current_version_; | 190 std::string current_version_; |
| 191 | 191 |
| 192 // The icon we will display in the installation UI, if any. | 192 // The icon we will display in the installation UI, if any. |
| 193 scoped_ptr<SkBitmap> install_icon_; | 193 scoped_ptr<SkBitmap> install_icon_; |
| 194 | 194 |
| 195 // The temp directory extension resources were unpacked to. We own this and | 195 // The temp directory extension resources were unpacked to. We own this and |
| 196 // must delete it when we are done with it. | 196 // must delete it when we are done with it. |
| 197 FilePath temp_dir_; | 197 FilePath temp_dir_; |
| 198 | 198 |
| 199 // The frontend we will report results back to. | 199 // The frontend we will report results back to. |
| 200 scoped_refptr<ExtensionsService> frontend_; | 200 scoped_refptr<ExtensionService> frontend_; |
| 201 | 201 |
| 202 // The client we will work with to do the installation. This can be NULL, in | 202 // The client we will work with to do the installation. This can be NULL, in |
| 203 // which case the install is silent. | 203 // which case the install is silent. |
| 204 // NOTE: we may be deleted on the file thread. To ensure the UI is deleted on | 204 // NOTE: we may be deleted on the file thread. To ensure the UI is deleted on |
| 205 // the main thread we don't use a scoped_ptr here. | 205 // the main thread we don't use a scoped_ptr here. |
| 206 ExtensionInstallUI* client_; | 206 ExtensionInstallUI* client_; |
| 207 | 207 |
| 208 // The root of the unpacked extension directory. This is a subdirectory of | 208 // The root of the unpacked extension directory. This is a subdirectory of |
| 209 // temp_dir_, so we don't have to delete it explicitly. | 209 // temp_dir_, so we don't have to delete it explicitly. |
| 210 FilePath unpacked_extension_root_; | 210 FilePath unpacked_extension_root_; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 221 bool allow_silent_install_; | 221 bool allow_silent_install_; |
| 222 | 222 |
| 223 // The value of the content type header sent with the CRX. | 223 // The value of the content type header sent with the CRX. |
| 224 // Ignorred unless |require_extension_mime_type_| is true. | 224 // Ignorred unless |require_extension_mime_type_| is true. |
| 225 std::string original_mime_type_; | 225 std::string original_mime_type_; |
| 226 | 226 |
| 227 DISALLOW_COPY_AND_ASSIGN(CrxInstaller); | 227 DISALLOW_COPY_AND_ASSIGN(CrxInstaller); |
| 228 }; | 228 }; |
| 229 | 229 |
| 230 #endif // CHROME_BROWSER_EXTENSIONS_CRX_INSTALLER_H_ | 230 #endif // CHROME_BROWSER_EXTENSIONS_CRX_INSTALLER_H_ |
| OLD | NEW |