Chromium Code Reviews| Index: chrome/browser/extensions/webstore_installer.cc |
| diff --git a/chrome/browser/extensions/webstore_installer.cc b/chrome/browser/extensions/webstore_installer.cc |
| index 88e68ddf40ec39c9fccd62a4c2ebb5f5ed1fe2aa..7af3db7a2f95f1d10e01539ea4885d265213bfac 100644 |
| --- a/chrome/browser/extensions/webstore_installer.cc |
| +++ b/chrome/browser/extensions/webstore_installer.cc |
| @@ -201,7 +201,7 @@ void WebstoreInstaller::Start() { |
| AddRef(); // Balanced in ReportSuccess and ReportFailure. |
| if (!Extension::IdIsValid(id_)) { |
| - ReportFailure(kInvalidIdError); |
| + ReportFailure(kInvalidIdError, false); |
| return; |
| } |
| @@ -224,7 +224,7 @@ void WebstoreInstaller::Observe(int type, |
| if (extension == NULL && download_item_ != NULL && |
| installer->download_url() == download_item_->GetURL() && |
| installer->profile()->IsSameProfile(profile_)) { |
| - ReportFailure(kInstallCanceledError); |
| + ReportFailure(kInstallCanceledError, true); |
|
Steve McKay
2012/09/25 18:56:04
Add a method name ReportCancelled, call that inste
sail
2012/10/02 18:57:01
I changed ReportFailure to take a enum. Do you sti
Greg Billock
2012/10/02 19:20:38
This is fine.
On 2012/10/02 18:57:01, sail wrote:
|
| } |
| break; |
| } |
| @@ -249,7 +249,7 @@ void WebstoreInstaller::Observe(int type, |
| const string16* error = content::Details<const string16>(details).ptr(); |
| const std::string utf8_error = UTF16ToUTF8(*error); |
| if (download_url_ == crx_installer->original_download_url()) |
| - ReportFailure(utf8_error); |
| + ReportFailure(utf8_error, false); |
| break; |
| } |
| @@ -271,7 +271,7 @@ WebstoreInstaller::~WebstoreInstaller() { |
| void WebstoreInstaller::OnDownloadStarted(DownloadId id, net::Error error) { |
| if (error != net::OK) { |
| - ReportFailure(net::ErrorToString(error)); |
| + ReportFailure(net::ErrorToString(error), false); |
| return; |
| } |
| @@ -286,6 +286,8 @@ void WebstoreInstaller::OnDownloadStarted(DownloadId id, net::Error error) { |
| download_item_->AddObserver(this); |
| if (approval_.get()) |
| download_item_->SetUserData(kApprovalKey, approval_.release()); |
| + if (delegate_) |
| + delegate_->OnExtensionDownloadStarted(id_, download_item_); |
| } |
| } |
| @@ -294,15 +296,21 @@ void WebstoreInstaller::OnDownloadUpdated(DownloadItem* download) { |
| switch (download->GetState()) { |
| case DownloadItem::CANCELLED: |
| - ReportFailure(kDownloadCanceledError); |
| + ReportFailure(kDownloadCanceledError, true); |
| break; |
| case DownloadItem::INTERRUPTED: |
| - ReportFailure(kDownloadInterruptedError); |
| + ReportFailure(kDownloadInterruptedError, false); |
| break; |
| case DownloadItem::COMPLETE: |
| // Wait for other notifications if the download is really an extension. |
| if (!download_crx_util::IsExtensionDownload(*download)) |
| - ReportFailure(kInvalidDownloadError); |
| + ReportFailure(kInvalidDownloadError, false); |
| + else if (delegate_) |
| + delegate_->OnExtensionDownloadProgress(id_, download); |
| + break; |
| + case DownloadItem::IN_PROGRESS: |
| + if (delegate_) |
| + delegate_->OnExtensionDownloadProgress(id_, download); |
| break; |
| default: |
| // Continue listening if the download is not in one of the above states. |
| @@ -329,7 +337,7 @@ void WebstoreInstaller::StartDownload(const FilePath& file) { |
| !controller_->GetWebContents()->GetBrowserContext() || |
| !controller_->GetWebContents()->GetBrowserContext() |
| ->GetResourceContext()) { |
| - ReportFailure(kDownloadDirectoryError); |
| + ReportFailure(kDownloadDirectoryError, false); |
| return; |
| } |
| @@ -352,9 +360,10 @@ void WebstoreInstaller::StartDownload(const FilePath& file) { |
| download_manager->DownloadUrl(params.Pass()); |
| } |
| -void WebstoreInstaller::ReportFailure(const std::string& error) { |
| +void WebstoreInstaller::ReportFailure(const std::string& error, |
| + bool cancelled) { |
| if (delegate_) { |
| - delegate_->OnExtensionInstallFailure(id_, error); |
| + delegate_->OnExtensionInstallFailure(id_, error, cancelled); |
|
Nico
2012/09/25 03:07:18
nit: It looks like cancelled is true iff error ==
sail
2012/10/02 18:57:01
I changed this to take an enum.
error is a string
|
| delegate_ = NULL; |
| } |