| 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 #include "chrome/browser/extensions/crx_installer.h" | 5 #include "chrome/browser/extensions/crx_installer.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/file_util.h" | 11 #include "base/file_util.h" |
| 12 #include "base/lazy_instance.h" | 12 #include "base/lazy_instance.h" |
| 13 #include "base/metrics/field_trial.h" | 13 #include "base/metrics/field_trial.h" |
| 14 #include "base/metrics/histogram.h" | 14 #include "base/metrics/histogram.h" |
| 15 #include "base/path_service.h" | 15 #include "base/path_service.h" |
| 16 #include "base/scoped_temp_dir.h" | 16 #include "base/scoped_temp_dir.h" |
| 17 #include "base/string_util.h" | 17 #include "base/string_util.h" |
| 18 #include "base/stringprintf.h" | 18 #include "base/stringprintf.h" |
| 19 #include "base/threading/thread_restrictions.h" | 19 #include "base/threading/thread_restrictions.h" |
| 20 #include "base/time.h" | 20 #include "base/time.h" |
| 21 #include "base/utf_string_conversions.h" | 21 #include "base/utf_string_conversions.h" |
| 22 #include "base/version.h" | 22 #include "base/version.h" |
| 23 #include "chrome/browser/browser_process.h" | 23 #include "chrome/browser/browser_process.h" |
| 24 #include "chrome/browser/extensions/convert_user_script.h" | 24 #include "chrome/browser/extensions/convert_user_script.h" |
| 25 #include "chrome/browser/extensions/convert_web_app.h" | 25 #include "chrome/browser/extensions/convert_web_app.h" |
| 26 #include "chrome/browser/extensions/default_apps_trial.h" | 26 #include "chrome/browser/extensions/default_apps_trial.h" |
| 27 #include "chrome/browser/extensions/extension_error_reporter.h" | 27 #include "chrome/browser/extensions/extension_error_reporter.h" |
| 28 #include "chrome/browser/extensions/extension_install_dialog.h" |
| 28 #include "chrome/browser/extensions/extension_install_ui.h" | 29 #include "chrome/browser/extensions/extension_install_ui.h" |
| 29 #include "chrome/browser/extensions/extension_service.h" | 30 #include "chrome/browser/extensions/extension_service.h" |
| 30 #include "chrome/browser/extensions/extension_system.h" | 31 #include "chrome/browser/extensions/extension_system.h" |
| 31 #include "chrome/browser/extensions/permissions_updater.h" | 32 #include "chrome/browser/extensions/permissions_updater.h" |
| 32 #include "chrome/browser/extensions/requirements_checker.h" | 33 #include "chrome/browser/extensions/requirements_checker.h" |
| 33 #include "chrome/browser/extensions/webstore_installer.h" | 34 #include "chrome/browser/extensions/webstore_installer.h" |
| 34 #include "chrome/browser/profiles/profile.h" | 35 #include "chrome/browser/profiles/profile.h" |
| 35 #include "chrome/browser/shell_integration.h" | 36 #include "chrome/browser/shell_integration.h" |
| 36 #include "chrome/browser/web_applications/web_app.h" | 37 #include "chrome/browser/web_applications/web_app.h" |
| 37 #include "chrome/common/chrome_notification_types.h" | 38 #include "chrome/common/chrome_notification_types.h" |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 } | 118 } |
| 118 | 119 |
| 119 if (approval->skip_install_dialog) { | 120 if (approval->skip_install_dialog) { |
| 120 // Mark the extension as approved, but save the expected manifest and ID | 121 // Mark the extension as approved, but save the expected manifest and ID |
| 121 // so we can check that they match the CRX's. | 122 // so we can check that they match the CRX's. |
| 122 approved_ = true; | 123 approved_ = true; |
| 123 expected_manifest_.reset(approval->parsed_manifest->DeepCopy()); | 124 expected_manifest_.reset(approval->parsed_manifest->DeepCopy()); |
| 124 expected_id_ = approval->extension_id; | 125 expected_id_ = approval->extension_id; |
| 125 record_oauth2_grant_ = approval->record_oauth2_grant; | 126 record_oauth2_grant_ = approval->record_oauth2_grant; |
| 126 } | 127 } |
| 128 |
| 129 dialog_ = approval->dialog_; |
| 127 } | 130 } |
| 128 | 131 |
| 129 CrxInstaller::~CrxInstaller() { | 132 CrxInstaller::~CrxInstaller() { |
| 130 // Delete the temp directory and crx file as necessary. Note that the | 133 // Delete the temp directory and crx file as necessary. Note that the |
| 131 // destructor might be called on any thread, so we post a task to the file | 134 // destructor might be called on any thread, so we post a task to the file |
| 132 // thread to make sure the delete happens there. This is a best effort | 135 // thread to make sure the delete happens there. This is a best effort |
| 133 // operation since the browser can be shutting down so there might not | 136 // operation since the browser can be shutting down so there might not |
| 134 // be a file thread to post to. | 137 // be a file thread to post to. |
| 135 if (!temp_dir_.value().empty()) { | 138 if (!temp_dir_.value().empty()) { |
| 136 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, | 139 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 446 IDS_EXTENSION_OVERLAPPING_WEB_EXTENT, | 449 IDS_EXTENSION_OVERLAPPING_WEB_EXTENT, |
| 447 UTF8ToUTF16(overlapping_extension->name())))); | 450 UTF8ToUTF16(overlapping_extension->name())))); |
| 448 return; | 451 return; |
| 449 } | 452 } |
| 450 | 453 |
| 451 current_version_ = | 454 current_version_ = |
| 452 frontend_weak_->extension_prefs()->GetVersionString(extension_->id()); | 455 frontend_weak_->extension_prefs()->GetVersionString(extension_->id()); |
| 453 | 456 |
| 454 if (client_ && (!allow_silent_install_ || !approved_)) { | 457 if (client_ && (!allow_silent_install_ || !approved_)) { |
| 455 AddRef(); // Balanced in Proceed() and Abort(). | 458 AddRef(); // Balanced in Proceed() and Abort(). |
| 456 client_->ConfirmInstall(this, extension_.get()); | 459 client_->ConfirmInstall(this, extension_.get(), dialog_); |
| 457 } else { | 460 } else { |
| 458 if (!BrowserThread::PostTask( | 461 if (!BrowserThread::PostTask( |
| 459 BrowserThread::FILE, FROM_HERE, | 462 BrowserThread::FILE, FROM_HERE, |
| 460 base::Bind(&CrxInstaller::CompleteInstall, this))) | 463 base::Bind(&CrxInstaller::CompleteInstall, this))) |
| 461 NOTREACHED(); | 464 NOTREACHED(); |
| 462 } | 465 } |
| 463 return; | 466 return; |
| 464 } | 467 } |
| 465 | 468 |
| 466 void CrxInstaller::InstallUIProceed() { | 469 void CrxInstaller::InstallUIProceed() { |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 650 // is problematic because they don't know anything about the | 653 // is problematic because they don't know anything about the |
| 651 // extension before it is unpacked, so they cannot filter based | 654 // extension before it is unpacked, so they cannot filter based |
| 652 // on the extension. | 655 // on the extension. |
| 653 content::NotificationService::current()->Notify( | 656 content::NotificationService::current()->Notify( |
| 654 chrome::NOTIFICATION_CRX_INSTALLER_DONE, | 657 chrome::NOTIFICATION_CRX_INSTALLER_DONE, |
| 655 content::Source<CrxInstaller>(this), | 658 content::Source<CrxInstaller>(this), |
| 656 content::Details<const Extension>(extension)); | 659 content::Details<const Extension>(extension)); |
| 657 } | 660 } |
| 658 | 661 |
| 659 } // namespace extensions | 662 } // namespace extensions |
| OLD | NEW |