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_unsupported_requirements(bool val) { | |
170 error_on_unsupported_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 // Called on the UI thread to start the requirements check on the extension. | |
208 void CheckRequirements(); | |
209 | |
210 // Runs on the FILE thread. Callback from RequirementsChecker. | |
211 void RequirementsChecked(std::vector<std::string> errors); | |
Aaron Boodman
2012/08/21 23:04:21
OnRequirementsChecked
eaugusti
2012/08/24 19:30:52
Done.
| |
212 | |
202 // Runs on the UI thread. Confirms with the user (via ExtensionInstallPrompt) | 213 // Runs on the UI thread. Confirms with the user (via ExtensionInstallPrompt) |
203 // that it is OK to install this extension. | 214 // that it is OK to install this extension. |
204 void ConfirmInstall(); | 215 void ConfirmInstall(); |
205 | 216 |
206 // Runs on File thread. Install the unpacked extension into the profile and | 217 // Runs on File thread. Install the unpacked extension into the profile and |
207 // notify the frontend. | 218 // notify the frontend. |
208 void CompleteInstall(); | 219 void CompleteInstall(); |
209 | 220 |
210 // Result reporting. | 221 // Result reporting. |
211 void ReportFailureFromFileThread(const CrxInstallerError& error); | 222 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 | 343 // Whether the installation was handled successfully. This is used to |
333 // indicate to the client whether the file should be removed and any UI | 344 // 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 | 345 // 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 | 346 // there was an error; if there was an error that rejects installation we |
336 // still consider the installation 'handled'. | 347 // still consider the installation 'handled'. |
337 bool did_handle_successfully_; | 348 bool did_handle_successfully_; |
338 | 349 |
339 // Whether we should record an oauth2 grant upon successful install. | 350 // Whether we should record an oauth2 grant upon successful install. |
340 bool record_oauth2_grant_; | 351 bool record_oauth2_grant_; |
341 | 352 |
353 // 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 | |
355 // will continue but the extension will be distabled. | |
356 bool error_on_unsupported_requirements_; | |
357 | |
358 scoped_ptr<RequirementsChecker> requirements_checker_; | |
359 | |
360 bool has_requirement_errors_; | |
361 | |
342 DISALLOW_COPY_AND_ASSIGN(CrxInstaller); | 362 DISALLOW_COPY_AND_ASSIGN(CrxInstaller); |
343 }; | 363 }; |
344 | 364 |
345 } // namespace extensions | 365 } // namespace extensions |
346 | 366 |
347 #endif // CHROME_BROWSER_EXTENSIONS_CRX_INSTALLER_H_ | 367 #endif // CHROME_BROWSER_EXTENSIONS_CRX_INSTALLER_H_ |
OLD | NEW |