| 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; | |
| 303 case DownloadItem::COMPLETE: | 299 case DownloadItem::COMPLETE: |
| 304 // Wait for other notifications if the download is really an extension. | 300 // Wait for other notifications if the download is really an extension. |
| 305 if (!download_crx_util::IsExtensionDownload(*download)) | 301 if (!download_crx_util::IsExtensionDownload(*download)) |
| 306 ReportFailure(kInvalidDownloadError); | 302 ReportFailure(kInvalidDownloadError); |
| 307 break; | 303 break; |
| 308 default: | 304 default: |
| 309 // Continue listening if the download is not in one of the above states. | 305 // Continue listening if the download is not in one of the above states. |
| 310 break; | 306 break; |
| 311 } | 307 } |
| 312 } | 308 } |
| 313 | 309 |
| 314 void WebstoreInstaller::OnDownloadOpened(DownloadItem* download) { | 310 void WebstoreInstaller::OnDownloadDestroyed(DownloadItem* download) { |
| 315 CHECK_EQ(download_item_, download); | 311 CHECK_EQ(download_item_, download); |
| 312 download_item_->RemoveObserver(this); |
| 313 download_item_ = NULL; |
| 316 } | 314 } |
| 317 | 315 |
| 318 void WebstoreInstaller::StartDownload(const FilePath& file) { | 316 void WebstoreInstaller::StartDownload(const FilePath& file) { |
| 319 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 317 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 320 | 318 |
| 321 if (file.empty() || !controller_->GetWebContents()) { | 319 if (file.empty() || !controller_->GetWebContents()) { |
| 322 ReportFailure(kDownloadDirectoryError); | 320 ReportFailure(kDownloadDirectoryError); |
| 323 return; | 321 return; |
| 324 } | 322 } |
| 325 | 323 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 354 void WebstoreInstaller::ReportSuccess() { | 352 void WebstoreInstaller::ReportSuccess() { |
| 355 if (delegate_) { | 353 if (delegate_) { |
| 356 delegate_->OnExtensionInstallSuccess(id_); | 354 delegate_->OnExtensionInstallSuccess(id_); |
| 357 delegate_ = NULL; | 355 delegate_ = NULL; |
| 358 } | 356 } |
| 359 | 357 |
| 360 Release(); // Balanced in Start(). | 358 Release(); // Balanced in Start(). |
| 361 } | 359 } |
| 362 | 360 |
| 363 } // namespace extensions | 361 } // namespace extensions |
| OLD | NEW |