OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
129 client_(client), | 129 client_(client), |
130 apps_require_extension_mime_type_(false), | 130 apps_require_extension_mime_type_(false), |
131 allow_silent_install_(false), | 131 allow_silent_install_(false), |
132 install_cause_(extension_misc::INSTALL_CAUSE_UNSET), | 132 install_cause_(extension_misc::INSTALL_CAUSE_UNSET), |
133 creation_flags_(Extension::NO_FLAGS) { | 133 creation_flags_(Extension::NO_FLAGS) { |
134 } | 134 } |
135 | 135 |
136 CrxInstaller::~CrxInstaller() { | 136 CrxInstaller::~CrxInstaller() { |
137 // Delete the temp directory and crx file as necessary. Note that the | 137 // Delete the temp directory and crx file as necessary. Note that the |
138 // destructor might be called on any thread, so we post a task to the file | 138 // destructor might be called on any thread, so we post a task to the file |
139 // thread to make sure the delete happens there. | 139 // thread to make sure the delete happens there. This is a best effort |
140 // operation since the browser can be shutting down so there might not | |
141 // be a file thread to post to. | |
asargent_no_longer_on_chrome
2011/11/01 22:15:01
would it make sense to do something like this?
i
| |
140 if (!temp_dir_.value().empty()) { | 142 if (!temp_dir_.value().empty()) { |
141 if (!BrowserThread::PostTask( | 143 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, |
142 BrowserThread::FILE, FROM_HERE, | 144 base::Bind(&extension_file_util::DeleteFile, temp_dir_, true)); |
143 base::Bind( | |
144 &extension_file_util::DeleteFile, temp_dir_, true))) | |
145 NOTREACHED(); | |
146 } | 145 } |
147 | |
148 if (delete_source_) { | 146 if (delete_source_) { |
149 if (!BrowserThread::PostTask( | 147 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, |
150 BrowserThread::FILE, FROM_HERE, | 148 base::Bind(&extension_file_util::DeleteFile, source_file_, false)); |
151 base::Bind( | |
152 &extension_file_util::DeleteFile, source_file_, false))) | |
153 NOTREACHED(); | |
154 } | 149 } |
155 | |
156 // Make sure the UI is deleted on the ui thread. | 150 // Make sure the UI is deleted on the ui thread. |
157 BrowserThread::DeleteSoon(BrowserThread::UI, FROM_HERE, client_); | 151 BrowserThread::DeleteSoon(BrowserThread::UI, FROM_HERE, client_); |
158 client_ = NULL; | 152 client_ = NULL; |
159 } | 153 } |
160 | 154 |
161 void CrxInstaller::InstallCrx(const FilePath& source_file) { | 155 void CrxInstaller::InstallCrx(const FilePath& source_file) { |
162 source_file_ = source_file; | 156 source_file_ = source_file; |
163 | 157 |
164 scoped_refptr<SandboxedExtensionUnpacker> unpacker( | 158 scoped_refptr<SandboxedExtensionUnpacker> unpacker( |
165 new SandboxedExtensionUnpacker( | 159 new SandboxedExtensionUnpacker( |
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
596 // Some users (such as the download shelf) need to know when a | 590 // Some users (such as the download shelf) need to know when a |
597 // CRXInstaller is done. Listening for the EXTENSION_* events | 591 // CRXInstaller is done. Listening for the EXTENSION_* events |
598 // is problematic because they don't know anything about the | 592 // is problematic because they don't know anything about the |
599 // extension before it is unpacked, so they can not filter based | 593 // extension before it is unpacked, so they can not filter based |
600 // on the extension. | 594 // on the extension. |
601 content::NotificationService::current()->Notify( | 595 content::NotificationService::current()->Notify( |
602 chrome::NOTIFICATION_CRX_INSTALLER_DONE, | 596 chrome::NOTIFICATION_CRX_INSTALLER_DONE, |
603 content::Source<CrxInstaller>(this), | 597 content::Source<CrxInstaller>(this), |
604 content::NotificationService::NoDetails()); | 598 content::NotificationService::NoDetails()); |
605 } | 599 } |
OLD | NEW |