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/webstore_installer.h" | 5 #include "chrome/browser/extensions/webstore_installer.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 void WebstoreInstaller::OnDownloadUpdated(DownloadItem* download) { | 289 void WebstoreInstaller::OnDownloadUpdated(DownloadItem* download) { |
290 CHECK_EQ(download_item_, download); | 290 CHECK_EQ(download_item_, download); |
291 | 291 |
292 switch (download->GetState()) { | 292 switch (download->GetState()) { |
293 case DownloadItem::CANCELLED: | 293 case DownloadItem::CANCELLED: |
294 ReportFailure(kDownloadCanceledError); | 294 ReportFailure(kDownloadCanceledError); |
295 break; | 295 break; |
296 case DownloadItem::INTERRUPTED: | 296 case DownloadItem::INTERRUPTED: |
297 ReportFailure(kDownloadInterruptedError); | 297 ReportFailure(kDownloadInterruptedError); |
298 break; | 298 break; |
| 299 case DownloadItem::REMOVING: |
| 300 download_item_->RemoveObserver(this); |
| 301 download_item_ = NULL; |
| 302 break; |
299 case DownloadItem::COMPLETE: | 303 case DownloadItem::COMPLETE: |
300 // Wait for other notifications if the download is really an extension. | 304 // Wait for other notifications if the download is really an extension. |
301 if (!download_crx_util::IsExtensionDownload(*download)) | 305 if (!download_crx_util::IsExtensionDownload(*download)) |
302 ReportFailure(kInvalidDownloadError); | 306 ReportFailure(kInvalidDownloadError); |
303 break; | 307 break; |
304 default: | 308 default: |
305 // Continue listening if the download is not in one of the above states. | 309 // Continue listening if the download is not in one of the above states. |
306 break; | 310 break; |
307 } | 311 } |
308 } | 312 } |
309 | 313 |
310 void WebstoreInstaller::OnDownloadDestroyed(DownloadItem* download) { | 314 void WebstoreInstaller::OnDownloadOpened(DownloadItem* download) { |
311 CHECK_EQ(download_item_, download); | 315 CHECK_EQ(download_item_, download); |
312 download_item_->RemoveObserver(this); | |
313 download_item_ = NULL; | |
314 } | 316 } |
315 | 317 |
316 void WebstoreInstaller::StartDownload(const FilePath& file) { | 318 void WebstoreInstaller::StartDownload(const FilePath& file) { |
317 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 319 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
318 | 320 |
319 if (file.empty() || !controller_->GetWebContents()) { | 321 if (file.empty() || !controller_->GetWebContents()) { |
320 ReportFailure(kDownloadDirectoryError); | 322 ReportFailure(kDownloadDirectoryError); |
321 return; | 323 return; |
322 } | 324 } |
323 | 325 |
(...skipping 28 matching lines...) Expand all Loading... |
352 void WebstoreInstaller::ReportSuccess() { | 354 void WebstoreInstaller::ReportSuccess() { |
353 if (delegate_) { | 355 if (delegate_) { |
354 delegate_->OnExtensionInstallSuccess(id_); | 356 delegate_->OnExtensionInstallSuccess(id_); |
355 delegate_ = NULL; | 357 delegate_ = NULL; |
356 } | 358 } |
357 | 359 |
358 Release(); // Balanced in Start(). | 360 Release(); // Balanced in Start(). |
359 } | 361 } |
360 | 362 |
361 } // namespace extensions | 363 } // namespace extensions |
OLD | NEW |