Chromium Code Reviews| 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/crx_installer_error.h" | 15 #include "chrome/browser/extensions/crx_installer_error.h" |
| 16 #include "chrome/browser/extensions/extension_install_prompt.h" | 16 #include "chrome/browser/extensions/extension_install_prompt.h" |
| 17 #include "chrome/browser/extensions/sandboxed_unpacker.h" | 17 #include "chrome/browser/extensions/sandboxed_unpacker.h" |
| 18 #include "chrome/browser/extensions/webstore_installer.h" | 18 #include "chrome/browser/extensions/webstore_installer.h" |
| 19 #include "chrome/common/extensions/extension.h" | 19 #include "chrome/common/extensions/extension.h" |
| 20 #include "chrome/common/string_ordinal.h" | 20 #include "chrome/common/string_ordinal.h" |
| 21 #include "chrome/common/web_apps.h" | 21 #include "chrome/common/web_apps.h" |
| 22 | 22 |
| 23 class ExtensionService; | 23 class ExtensionService; |
| 24 class SkBitmap; | 24 class SkBitmap; |
| 25 | 25 |
| 26 namespace extensions { | 26 namespace extensions { |
| 27 class ExtensionUpdaterTest; | 27 class ExtensionUpdaterTest; |
| 28 class RequirementsChecker; | |
| 28 | 29 |
| 29 // This class installs a crx file into a profile. | 30 // This class installs a crx file into a profile. |
| 30 // | 31 // |
| 31 // Installing a CRX is a multi-step process, including unpacking the crx, | 32 // Installing a CRX is a multi-step process, including unpacking the crx, |
| 32 // validating it, prompting the user, and installing. Since many of these | 33 // validating it, prompting the user, and installing. Since many of these |
| 33 // steps must occur on the file thread, this class contains a copy of all data | 34 // steps must occur on the file thread, this class contains a copy of all data |
| 34 // necessary to do its job. (This also minimizes external dependencies for | 35 // necessary to do its job. (This also minimizes external dependencies for |
| 35 // easier testing). | 36 // easier testing). |
| 36 // | 37 // |
| 37 // Lifetime management: | 38 // Lifetime management: |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 158 return off_store_install_allow_reason_; | 159 return off_store_install_allow_reason_; |
| 159 } | 160 } |
| 160 void set_off_store_install_allow_reason(OffStoreInstallAllowReason reason) { | 161 void set_off_store_install_allow_reason(OffStoreInstallAllowReason reason) { |
| 161 off_store_install_allow_reason_ = reason; | 162 off_store_install_allow_reason_ = reason; |
| 162 } | 163 } |
| 163 | 164 |
| 164 void set_page_ordinal(const StringOrdinal& page_ordinal) { | 165 void set_page_ordinal(const StringOrdinal& page_ordinal) { |
| 165 page_ordinal_ = page_ordinal; | 166 page_ordinal_ = page_ordinal; |
| 166 } | 167 } |
| 167 | 168 |
| 169 void set_error_on_unsported_requirements(bool val) { | |
| 170 error_on_unsported_requirements_ = val; | |
| 171 } | |
| 172 | |
| 168 bool did_handle_successfully() const { return did_handle_successfully_; } | 173 bool did_handle_successfully() const { return did_handle_successfully_; } |
| 169 | 174 |
| 170 Profile* profile() { return profile_; } | 175 Profile* profile() { return profile_; } |
| 171 | 176 |
| 172 private: | 177 private: |
| 173 friend class ExtensionUpdaterTest; | 178 friend class ExtensionUpdaterTest; |
| 174 friend class ExtensionCrxInstallerTest; | 179 friend class ExtensionCrxInstallerTest; |
| 175 | 180 |
| 176 CrxInstaller(base::WeakPtr<ExtensionService> frontend_weak, | 181 CrxInstaller(base::WeakPtr<ExtensionService> frontend_weak, |
| 177 ExtensionInstallPrompt* client, | 182 ExtensionInstallPrompt* client, |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 192 virtual void OnUnpackFailure(const string16& error_message) OVERRIDE; | 197 virtual void OnUnpackFailure(const string16& error_message) OVERRIDE; |
| 193 virtual void OnUnpackSuccess(const FilePath& temp_dir, | 198 virtual void OnUnpackSuccess(const FilePath& temp_dir, |
| 194 const FilePath& extension_dir, | 199 const FilePath& extension_dir, |
| 195 const base::DictionaryValue* original_manifest, | 200 const base::DictionaryValue* original_manifest, |
| 196 const Extension* extension) OVERRIDE; | 201 const Extension* extension) OVERRIDE; |
| 197 | 202 |
| 198 // Returns true if we can skip confirmation because the install was | 203 // Returns true if we can skip confirmation because the install was |
| 199 // whitelisted. | 204 // whitelisted. |
| 200 bool CanSkipConfirmation(); | 205 bool CanSkipConfirmation(); |
| 201 | 206 |
| 207 void RunRequirementsChecker(); | |
|
Aaron Boodman
2012/08/01 03:58:54
Needs comments.
Yoyo Zhou
2012/08/02 22:23:30
How about "Check Requirements"?
eaugusti
2012/08/03 01:06:26
Done.
| |
| 208 | |
| 209 // Runs on the FILE thread. Callback from RequirementsChecker. | |
| 210 void RequirementsChecked(std::vector<std::string> errors); | |
| 211 | |
| 202 // Runs on the UI thread. Confirms with the user (via ExtensionInstallPrompt) | 212 // Runs on the UI thread. Confirms with the user (via ExtensionInstallPrompt) |
| 203 // that it is OK to install this extension. | 213 // that it is OK to install this extension. |
| 204 void ConfirmInstall(); | 214 void ConfirmInstall(); |
| 205 | 215 |
| 206 // Runs on File thread. Install the unpacked extension into the profile and | 216 // Runs on File thread. Install the unpacked extension into the profile and |
| 207 // notify the frontend. | 217 // notify the frontend. |
| 208 void CompleteInstall(); | 218 void CompleteInstall(); |
| 209 | 219 |
| 210 // Result reporting. | 220 // Result reporting. |
| 211 void ReportFailureFromFileThread(const CrxInstallerError& error); | 221 void ReportFailureFromFileThread(const CrxInstallerError& error); |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 332 // Whether the installation was handled successfully. This is used to | 342 // Whether the installation was handled successfully. This is used to |
| 333 // indicate to the client whether the file should be removed and any UI | 343 // indicate to the client whether the file should be removed and any UI |
| 334 // initiating the installation can be removed. This is different than whether | 344 // initiating the installation can be removed. This is different than whether |
| 335 // there was an error; if there was an error that rejects installation we | 345 // there was an error; if there was an error that rejects installation we |
| 336 // still consider the installation 'handled'. | 346 // still consider the installation 'handled'. |
| 337 bool did_handle_successfully_; | 347 bool did_handle_successfully_; |
| 338 | 348 |
| 339 // Whether we should record an oauth2 grant upon successful install. | 349 // Whether we should record an oauth2 grant upon successful install. |
| 340 bool record_oauth2_grant_; | 350 bool record_oauth2_grant_; |
| 341 | 351 |
| 352 // Whether we should produce an error if the manifest declares requirements | |
| 353 // that are not met. If false and there is an unmet requirement, the install | |
| 354 // will continue but the extension will be distabled. | |
| 355 bool error_on_unsported_requirements_; | |
|
Yoyo Zhou
2012/08/02 22:23:30
Did you mean 'unsupported'?
eaugusti
2012/08/03 01:06:26
Done.
| |
| 356 | |
| 357 scoped_ptr<RequirementsChecker> requirements_checker_; | |
| 358 | |
| 359 std::vector<std::string> requirement_errors_; | |
| 360 | |
| 342 DISALLOW_COPY_AND_ASSIGN(CrxInstaller); | 361 DISALLOW_COPY_AND_ASSIGN(CrxInstaller); |
| 343 }; | 362 }; |
| 344 | 363 |
| 345 } // namespace extensions | 364 } // namespace extensions |
| 346 | 365 |
| 347 #endif // CHROME_BROWSER_EXTENSIONS_CRX_INSTALLER_H_ | 366 #endif // CHROME_BROWSER_EXTENSIONS_CRX_INSTALLER_H_ |
| OLD | NEW |