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" |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 void set_expected_version(const Version& val) { | 123 void set_expected_version(const Version& val) { |
124 expected_version_.reset(new Version(val)); | 124 expected_version_.reset(new Version(val)); |
125 } | 125 } |
126 | 126 |
127 bool delete_source() const { return delete_source_; } | 127 bool delete_source() const { return delete_source_; } |
128 void set_delete_source(bool val) { delete_source_ = val; } | 128 void set_delete_source(bool val) { delete_source_ = val; } |
129 | 129 |
130 bool allow_silent_install() const { return allow_silent_install_; } | 130 bool allow_silent_install() const { return allow_silent_install_; } |
131 void set_allow_silent_install(bool val) { allow_silent_install_ = val; } | 131 void set_allow_silent_install(bool val) { allow_silent_install_ = val; } |
132 | 132 |
| 133 void set_bypass_blacklist_for_test(bool val) { |
| 134 bypass_blacklist_for_test_ = val; |
| 135 } |
| 136 |
133 bool is_gallery_install() const { | 137 bool is_gallery_install() const { |
134 return (creation_flags_ & Extension::FROM_WEBSTORE) > 0; | 138 return (creation_flags_ & Extension::FROM_WEBSTORE) > 0; |
135 } | 139 } |
136 void set_is_gallery_install(bool val) { | 140 void set_is_gallery_install(bool val) { |
137 if (val) | 141 if (val) |
138 creation_flags_ |= Extension::FROM_WEBSTORE; | 142 creation_flags_ |= Extension::FROM_WEBSTORE; |
139 else | 143 else |
140 creation_flags_ &= ~Extension::FROM_WEBSTORE; | 144 creation_flags_ &= ~Extension::FROM_WEBSTORE; |
141 } | 145 } |
142 | 146 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 // should complete. | 214 // should complete. |
211 CrxInstallerError AllowInstall(const Extension* extension); | 215 CrxInstallerError AllowInstall(const Extension* extension); |
212 | 216 |
213 // SandboxedUnpackerClient | 217 // SandboxedUnpackerClient |
214 virtual void OnUnpackFailure(const string16& error_message) OVERRIDE; | 218 virtual void OnUnpackFailure(const string16& error_message) OVERRIDE; |
215 virtual void OnUnpackSuccess(const base::FilePath& temp_dir, | 219 virtual void OnUnpackSuccess(const base::FilePath& temp_dir, |
216 const base::FilePath& extension_dir, | 220 const base::FilePath& extension_dir, |
217 const base::DictionaryValue* original_manifest, | 221 const base::DictionaryValue* original_manifest, |
218 const Extension* extension) OVERRIDE; | 222 const Extension* extension) OVERRIDE; |
219 | 223 |
220 // Returns true if we can skip confirmation because the install was | |
221 // whitelisted. | |
222 bool CanSkipConfirmation(); | |
223 | |
224 // Called on the UI thread to start the requirements check on the extension. | 224 // Called on the UI thread to start the requirements check on the extension. |
225 void CheckRequirements(); | 225 void CheckRequirements(); |
226 | 226 |
227 // Runs on the UI thread. Callback from RequirementsChecker. | 227 // Runs on the UI thread. Callback from RequirementsChecker. |
228 void OnRequirementsChecked(std::vector<std::string> requirement_errors); | 228 void OnRequirementsChecked(std::vector<std::string> requirement_errors); |
229 | 229 |
230 // Runs on the UI thread. Confirms with the user (via ExtensionInstallPrompt) | 230 // Runs on the UI thread. Confirms with the user (via ExtensionInstallPrompt) |
231 // that it is OK to install this extension. | 231 // that it is OK to install this extension. |
232 void ConfirmInstall(); | 232 void ConfirmInstall(); |
233 | 233 |
234 // Runs on File thread. Install the unpacked extension into the profile and | 234 // Runs on File thread. Install the unpacked extension into the profile and |
235 // notify the frontend. | 235 // notify the frontend. |
236 void CompleteInstall(); | 236 void CompleteInstall(); |
237 | 237 |
238 // Result reporting. | 238 // Result reporting. |
239 void ReportFailureFromFileThread(const CrxInstallerError& error); | 239 void ReportFailureFromFileThread(const CrxInstallerError& error); |
240 void ReportFailureFromUIThread(const CrxInstallerError& error); | 240 void ReportFailureFromUIThread(const CrxInstallerError& error); |
241 void ReportSuccessFromFileThread(); | 241 void ReportSuccessFromFileThread(); |
242 void ReportSuccessFromUIThread(); | 242 void ReportSuccessFromUIThread(); |
243 void NotifyCrxInstallComplete(const Extension* extension); | 243 void HandleIsBlacklistedResponse(const base::Closure& on_success, |
| 244 bool success); |
| 245 void NotifyCrxInstallComplete(bool success); |
244 | 246 |
245 // Deletes temporary directory and crx file if needed. | 247 // Deletes temporary directory and crx file if needed. |
246 void CleanupTempFiles(); | 248 void CleanupTempFiles(); |
247 | 249 |
248 // Creates sequenced task runner for extension install file I/O operations. | 250 // Creates sequenced task runner for extension install file I/O operations. |
249 scoped_refptr<base::SequencedTaskRunner> CreateSequencedTaskRunner(); | 251 scoped_refptr<base::SequencedTaskRunner> CreateSequencedTaskRunner(); |
250 | 252 |
251 // The file we're installing. | 253 // The file we're installing. |
252 base::FilePath source_file_; | 254 base::FilePath source_file_; |
253 | 255 |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 // The root of the unpacked extension directory. This is a subdirectory of | 338 // The root of the unpacked extension directory. This is a subdirectory of |
337 // temp_dir_, so we don't have to delete it explicitly. | 339 // temp_dir_, so we don't have to delete it explicitly. |
338 base::FilePath unpacked_extension_root_; | 340 base::FilePath unpacked_extension_root_; |
339 | 341 |
340 // True when the CRX being installed was just downloaded. | 342 // True when the CRX being installed was just downloaded. |
341 // Used to trigger extra checks before installing. | 343 // Used to trigger extra checks before installing. |
342 bool apps_require_extension_mime_type_; | 344 bool apps_require_extension_mime_type_; |
343 | 345 |
344 // Allows for the possibility of a normal install (one in which a |client| | 346 // Allows for the possibility of a normal install (one in which a |client| |
345 // is provided in the ctor) to procede without showing the permissions prompt | 347 // is provided in the ctor) to procede without showing the permissions prompt |
346 // dialog. Note that this will only take place if |allow_silent_install_| | 348 // dialog. |
347 // is true AND the unpacked id of the extension is whitelisted with | |
348 // SetWhitelistedInstallId(). | |
349 bool allow_silent_install_; | 349 bool allow_silent_install_; |
350 | 350 |
| 351 // Allows for bypassing the blacklist check. Only use for tests. |
| 352 bool bypass_blacklist_for_test_; |
| 353 |
351 // The value of the content type header sent with the CRX. | 354 // The value of the content type header sent with the CRX. |
352 // Ignorred unless |require_extension_mime_type_| is true. | 355 // Ignorred unless |require_extension_mime_type_| is true. |
353 std::string original_mime_type_; | 356 std::string original_mime_type_; |
354 | 357 |
355 // What caused this install? Used only for histograms that report | 358 // What caused this install? Used only for histograms that report |
356 // on failure rates, broken down by the cause of the install. | 359 // on failure rates, broken down by the cause of the install. |
357 extension_misc::CrxInstallCause install_cause_; | 360 extension_misc::CrxInstallCause install_cause_; |
358 | 361 |
359 // Creation flags to use for the extension. These flags will be used | 362 // Creation flags to use for the extension. These flags will be used |
360 // when calling Extenion::Create() by the crx installer. | 363 // when calling Extenion::Create() by the crx installer. |
(...skipping 28 matching lines...) Expand all Loading... |
389 | 392 |
390 // Used to show the install dialog. | 393 // Used to show the install dialog. |
391 ExtensionInstallPrompt::ShowDialogCallback show_dialog_callback_; | 394 ExtensionInstallPrompt::ShowDialogCallback show_dialog_callback_; |
392 | 395 |
393 DISALLOW_COPY_AND_ASSIGN(CrxInstaller); | 396 DISALLOW_COPY_AND_ASSIGN(CrxInstaller); |
394 }; | 397 }; |
395 | 398 |
396 } // namespace extensions | 399 } // namespace extensions |
397 | 400 |
398 #endif // CHROME_BROWSER_EXTENSIONS_CRX_INSTALLER_H_ | 401 #endif // CHROME_BROWSER_EXTENSIONS_CRX_INSTALLER_H_ |
OLD | NEW |