Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1152)

Unified Diff: chrome/browser/extensions/webstore_installer.cc

Issue 10980002: Mac Web Intents Part 1: Show extension download progress (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove downloads code Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/webstore_installer.cc
diff --git a/chrome/browser/extensions/webstore_installer.cc b/chrome/browser/extensions/webstore_installer.cc
index ffae6402dcf5fcb74cdc07ea4ac88cc8e8b47c12..8b80979f052812f50953ee08585abf267ec46be0 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;
}
« no previous file with comments | « chrome/browser/extensions/webstore_installer.h ('k') | chrome/browser/ui/intents/web_intent_picker_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698