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