| 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" |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 off_store_install_allow_reason_(OffStoreInstallDisallowed), | 103 off_store_install_allow_reason_(OffStoreInstallDisallowed), |
| 104 did_handle_successfully_(true), | 104 did_handle_successfully_(true), |
| 105 record_oauth2_grant_(false), | 105 record_oauth2_grant_(false), |
| 106 error_on_unsupported_requirements_(false), | 106 error_on_unsupported_requirements_(false), |
| 107 requirements_checker_(new extensions::RequirementsChecker()), | 107 requirements_checker_(new extensions::RequirementsChecker()), |
| 108 has_requirement_errors_(false) { | 108 has_requirement_errors_(false) { |
| 109 if (!approval) | 109 if (!approval) |
| 110 return; | 110 return; |
| 111 | 111 |
| 112 CHECK(profile_->IsSameProfile(approval->profile)); | 112 CHECK(profile_->IsSameProfile(approval->profile)); |
| 113 client_->install_ui()->SetUseAppInstalledBubble( | 113 if (client_) { |
| 114 approval->use_app_installed_bubble); | 114 client_->install_ui()->SetUseAppInstalledBubble( |
| 115 client_->install_ui()->SetSkipPostInstallUI(approval->skip_post_install_ui); | 115 approval->use_app_installed_bubble); |
| 116 client_->install_ui()->SetSkipPostInstallUI(approval->skip_post_install_ui); |
| 117 } |
| 116 | 118 |
| 117 if (approval->skip_install_dialog) { | 119 if (approval->skip_install_dialog) { |
| 118 // Mark the extension as approved, but save the expected manifest and ID | 120 // Mark the extension as approved, but save the expected manifest and ID |
| 119 // so we can check that they match the CRX's. | 121 // so we can check that they match the CRX's. |
| 120 approved_ = true; | 122 approved_ = true; |
| 121 expected_manifest_.reset(approval->parsed_manifest->DeepCopy()); | 123 expected_manifest_.reset(approval->parsed_manifest->DeepCopy()); |
| 122 expected_id_ = approval->extension_id; | 124 expected_id_ = approval->extension_id; |
| 123 record_oauth2_grant_ = approval->record_oauth2_grant; | 125 record_oauth2_grant_ = approval->record_oauth2_grant; |
| 124 } | 126 } |
| 125 } | 127 } |
| 126 | 128 |
| 127 CrxInstaller::~CrxInstaller() { | 129 CrxInstaller::~CrxInstaller() { |
| 128 // Delete the temp directory and crx file as necessary. Note that the | 130 // Delete the temp directory and crx file as necessary. Note that the |
| 129 // destructor might be called on any thread, so we post a task to the file | 131 // destructor might be called on any thread, so we post a task to the file |
| 130 // thread to make sure the delete happens there. This is a best effort | 132 // thread to make sure the delete happens there. This is a best effort |
| 131 // operation since the browser can be shutting down so there might not | 133 // operation since the browser can be shutting down so there might not |
| 132 // be a file thread to post to. | 134 // be a file thread to post to. |
| 133 if (!temp_dir_.value().empty()) { | 135 if (!temp_dir_.value().empty()) { |
| 134 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, | 136 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, |
| 135 base::Bind(&extension_file_util::DeleteFile, temp_dir_, true)); | 137 base::Bind(&extension_file_util::DeleteFile, temp_dir_, true)); |
| 136 } | 138 } |
| 137 if (delete_source_) { | 139 if (delete_source_) { |
| 138 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, | 140 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, |
| 139 base::Bind(&extension_file_util::DeleteFile, source_file_, false)); | 141 base::Bind(&extension_file_util::DeleteFile, source_file_, false)); |
| 140 } | 142 } |
| 141 // Make sure the UI is deleted on the ui thread. | 143 // Make sure the UI is deleted on the ui thread. |
| 142 BrowserThread::DeleteSoon(BrowserThread::UI, FROM_HERE, client_); | 144 if (client_) { |
| 143 client_ = NULL; | 145 BrowserThread::DeleteSoon(BrowserThread::UI, FROM_HERE, client_); |
| 146 client_ = NULL; |
| 147 } |
| 144 } | 148 } |
| 145 | 149 |
| 146 void CrxInstaller::InstallCrx(const FilePath& source_file) { | 150 void CrxInstaller::InstallCrx(const FilePath& source_file) { |
| 147 source_file_ = source_file; | 151 source_file_ = source_file; |
| 148 | 152 |
| 149 scoped_refptr<SandboxedUnpacker> unpacker( | 153 scoped_refptr<SandboxedUnpacker> unpacker( |
| 150 new SandboxedUnpacker( | 154 new SandboxedUnpacker( |
| 151 source_file, | 155 source_file, |
| 152 content::ResourceDispatcherHost::Get() != NULL, | 156 content::ResourceDispatcherHost::Get() != NULL, |
| 153 install_source_, | 157 install_source_, |
| (...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 647 // is problematic because they don't know anything about the | 651 // is problematic because they don't know anything about the |
| 648 // extension before it is unpacked, so they cannot filter based | 652 // extension before it is unpacked, so they cannot filter based |
| 649 // on the extension. | 653 // on the extension. |
| 650 content::NotificationService::current()->Notify( | 654 content::NotificationService::current()->Notify( |
| 651 chrome::NOTIFICATION_CRX_INSTALLER_DONE, | 655 chrome::NOTIFICATION_CRX_INSTALLER_DONE, |
| 652 content::Source<CrxInstaller>(this), | 656 content::Source<CrxInstaller>(this), |
| 653 content::Details<const Extension>(extension)); | 657 content::Details<const Extension>(extension)); |
| 654 } | 658 } |
| 655 | 659 |
| 656 } // namespace extensions | 660 } // namespace extensions |
| OLD | NEW |