| 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 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 void WebstoreInstaller::OnDownloadUpdated(DownloadItem* download) { | 278 void WebstoreInstaller::OnDownloadUpdated(DownloadItem* download) { |
| 279 CHECK_EQ(download_item_, download); | 279 CHECK_EQ(download_item_, download); |
| 280 | 280 |
| 281 switch (download->GetState()) { | 281 switch (download->GetState()) { |
| 282 case DownloadItem::CANCELLED: | 282 case DownloadItem::CANCELLED: |
| 283 ReportFailure(kDownloadCanceledError); | 283 ReportFailure(kDownloadCanceledError); |
| 284 break; | 284 break; |
| 285 case DownloadItem::INTERRUPTED: | 285 case DownloadItem::INTERRUPTED: |
| 286 ReportFailure(kDownloadInterruptedError); | 286 ReportFailure(kDownloadInterruptedError); |
| 287 break; | 287 break; |
| 288 case DownloadItem::REMOVING: | |
| 289 download_item_->RemoveObserver(this); | |
| 290 download_item_ = NULL; | |
| 291 break; | |
| 292 case DownloadItem::COMPLETE: | 288 case DownloadItem::COMPLETE: |
| 293 // Wait for other notifications if the download is really an extension. | 289 // Wait for other notifications if the download is really an extension. |
| 294 if (!download_crx_util::IsExtensionDownload(*download)) | 290 if (!download_crx_util::IsExtensionDownload(*download)) |
| 295 ReportFailure(kInvalidDownloadError); | 291 ReportFailure(kInvalidDownloadError); |
| 296 break; | 292 break; |
| 297 default: | 293 default: |
| 298 // Continue listening if the download is not in one of the above states. | 294 // Continue listening if the download is not in one of the above states. |
| 299 break; | 295 break; |
| 300 } | 296 } |
| 301 } | 297 } |
| 302 | 298 |
| 303 void WebstoreInstaller::OnDownloadOpened(DownloadItem* download) { | 299 void WebstoreInstaller::OnDownloadDestructed(DownloadItem* download) { |
| 304 CHECK_EQ(download_item_, download); | 300 CHECK_EQ(download_item_, download); |
| 301 download_item_->RemoveObserver(this); |
| 302 download_item_ = NULL; |
| 305 } | 303 } |
| 306 | 304 |
| 307 void WebstoreInstaller::StartDownload(const FilePath& file) { | 305 void WebstoreInstaller::StartDownload(const FilePath& file) { |
| 308 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 306 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 309 | 307 |
| 310 if (file.empty() || !controller_->GetWebContents()) { | 308 if (file.empty() || !controller_->GetWebContents()) { |
| 311 ReportFailure(kDownloadDirectoryError); | 309 ReportFailure(kDownloadDirectoryError); |
| 312 return; | 310 return; |
| 313 } | 311 } |
| 314 | 312 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 341 } | 339 } |
| 342 | 340 |
| 343 void WebstoreInstaller::ReportSuccess() { | 341 void WebstoreInstaller::ReportSuccess() { |
| 344 if (delegate_) { | 342 if (delegate_) { |
| 345 delegate_->OnExtensionInstallSuccess(id_); | 343 delegate_->OnExtensionInstallSuccess(id_); |
| 346 delegate_ = NULL; | 344 delegate_ = NULL; |
| 347 } | 345 } |
| 348 | 346 |
| 349 Release(); // Balanced in Start(). | 347 Release(); // Balanced in Start(). |
| 350 } | 348 } |
| OLD | NEW |