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