summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/webstore_installer.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/extensions/webstore_installer.cc')
-rw-r--r--chrome/browser/extensions/webstore_installer.cc39
1 files changed, 29 insertions, 10 deletions
diff --git a/chrome/browser/extensions/webstore_installer.cc b/chrome/browser/extensions/webstore_installer.cc
index ffae640..8b80979 100644
--- a/chrome/browser/extensions/webstore_installer.cc
+++ b/chrome/browser/extensions/webstore_installer.cc
@@ -136,6 +136,16 @@ void GetDownloadFilePath(
namespace extensions {
+void WebstoreInstaller::Delegate::OnExtensionDownloadStarted(
+ const std::string& id,
+ content::DownloadItem* item) {
+}
+
+void WebstoreInstaller::Delegate::OnExtensionDownloadProgress(
+ const std::string& id,
+ content::DownloadItem* item) {
+}
+
WebstoreInstaller::Approval::Approval()
: profile(NULL),
use_app_installed_bubble(false),
@@ -201,7 +211,7 @@ void WebstoreInstaller::Start() {
AddRef(); // Balanced in ReportSuccess and ReportFailure.
if (!Extension::IdIsValid(id_)) {
- ReportFailure(kInvalidIdError);
+ ReportFailure(kInvalidIdError, FAILURE_REASON_OTHER);
return;
}
@@ -224,7 +234,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, FAILURE_REASON_CANCELLED);
}
break;
}
@@ -249,7 +259,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, FAILURE_REASON_OTHER);
break;
}
@@ -271,7 +281,7 @@ WebstoreInstaller::~WebstoreInstaller() {
void WebstoreInstaller::OnDownloadStarted(DownloadId id, net::Error error) {
if (error != net::OK) {
- ReportFailure(net::ErrorToString(error));
+ ReportFailure(net::ErrorToString(error), FAILURE_REASON_OTHER);
return;
}
@@ -288,6 +298,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_);
}
}
@@ -296,15 +308,21 @@ void WebstoreInstaller::OnDownloadUpdated(DownloadItem* download) {
switch (download->GetState()) {
case DownloadItem::CANCELLED:
- ReportFailure(kDownloadCanceledError);
+ ReportFailure(kDownloadCanceledError, FAILURE_REASON_CANCELLED);
break;
case DownloadItem::INTERRUPTED:
- ReportFailure(kDownloadInterruptedError);
+ ReportFailure(kDownloadInterruptedError, FAILURE_REASON_OTHER);
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, FAILURE_REASON_OTHER);
+ 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.
@@ -331,7 +349,7 @@ void WebstoreInstaller::StartDownload(const FilePath& file) {
!controller_->GetWebContents()->GetBrowserContext() ||
!controller_->GetWebContents()->GetBrowserContext()
->GetResourceContext()) {
- ReportFailure(kDownloadDirectoryError);
+ ReportFailure(kDownloadDirectoryError, FAILURE_REASON_OTHER);
return;
}
@@ -354,9 +372,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,
+ FailureReason reason) {
if (delegate_) {
- delegate_->OnExtensionInstallFailure(id_, error);
+ delegate_->OnExtensionInstallFailure(id_, error, reason);
delegate_ = NULL;
}