summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsail@chromium.org <sail@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-03 05:42:29 +0000
committersail@chromium.org <sail@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-03 05:42:29 +0000
commitbcd1eaf7295568d672bd856d6f6e4061bb3a5d2e (patch)
tree23c161c1f0bff0caf9db1ab9a9b9a476d3461025
parent0f6f446b9e6c6ac11b6359d205a88ae80716fa8e (diff)
downloadchromium_src-bcd1eaf7295568d672bd856d6f6e4061bb3a5d2e.zip
chromium_src-bcd1eaf7295568d672bd856d6f6e4061bb3a5d2e.tar.gz
chromium_src-bcd1eaf7295568d672bd856d6f6e4061bb3a5d2e.tar.bz2
Mac Web Intents Part 1: Show extension download progress
As per spec we want to show the extension download UI through the Web Intents Picker dialog. This CL also pipes download progress to the WebIntentPickerModel. I'll send out a separate CL to update the Mac UI to show the download progress. I also have a separate CL out for review to hide the download from the browser download shelf: https://codereview.chromium.org/11016022 BUG=152010 TEST=Go to http://webintents.org. Click share. Click "Add to Chrome". Verify that the download shelf is not shown. Review URL: https://chromiumcodereview.appspot.com/10980002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@159836 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/extensions/api/webstore_private/webstore_private_api.cc10
-rw-r--r--chrome/browser/extensions/api/webstore_private/webstore_private_api.h6
-rw-r--r--chrome/browser/extensions/api/webstore_private/webstore_private_apitest.cc6
-rw-r--r--chrome/browser/extensions/bundle_installer.cc6
-rw-r--r--chrome/browser/extensions/bundle_installer.h6
-rw-r--r--chrome/browser/extensions/webstore_inline_installer.cc4
-rw-r--r--chrome/browser/extensions/webstore_inline_installer.h6
-rw-r--r--chrome/browser/extensions/webstore_installer.cc39
-rw-r--r--chrome/browser/extensions/webstore_installer.h14
-rw-r--r--chrome/browser/ui/intents/web_intent_picker_controller.cc53
-rw-r--r--chrome/browser/ui/intents/web_intent_picker_controller.h17
-rw-r--r--chrome/browser/ui/intents/web_intent_picker_model.cc43
-rw-r--r--chrome/browser/ui/intents/web_intent_picker_model.h40
-rw-r--r--chrome/browser/ui/intents/web_intent_picker_model_unittest.cc4
14 files changed, 220 insertions, 34 deletions
diff --git a/chrome/browser/extensions/api/webstore_private/webstore_private_api.cc b/chrome/browser/extensions/api/webstore_private/webstore_private_api.cc
index 5e4883a..9959e34 100644
--- a/chrome/browser/extensions/api/webstore_private/webstore_private_api.cc
+++ b/chrome/browser/extensions/api/webstore_private/webstore_private_api.cc
@@ -445,9 +445,13 @@ void CompleteInstallFunction::OnExtensionInstallSuccess(
}
void CompleteInstallFunction::OnExtensionInstallFailure(
- const std::string& id, const std::string& error) {
- if (test_webstore_installer_delegate)
- test_webstore_installer_delegate->OnExtensionInstallFailure(id, error);
+ const std::string& id,
+ const std::string& error,
+ WebstoreInstaller::FailureReason reason) {
+ if (test_webstore_installer_delegate) {
+ test_webstore_installer_delegate->OnExtensionInstallFailure(
+ id, error, reason);
+ }
error_ = error;
SendResponse(false);
diff --git a/chrome/browser/extensions/api/webstore_private/webstore_private_api.h b/chrome/browser/extensions/api/webstore_private/webstore_private_api.h
index f77a135..cfb253a 100644
--- a/chrome/browser/extensions/api/webstore_private/webstore_private_api.h
+++ b/chrome/browser/extensions/api/webstore_private/webstore_private_api.h
@@ -153,8 +153,10 @@ class CompleteInstallFunction
// WebstoreInstaller::Delegate:
virtual void OnExtensionInstallSuccess(const std::string& id) OVERRIDE;
- virtual void OnExtensionInstallFailure(const std::string& id,
- const std::string& error) OVERRIDE;
+ virtual void OnExtensionInstallFailure(
+ const std::string& id,
+ const std::string& error,
+ WebstoreInstaller::FailureReason reason) OVERRIDE;
protected:
virtual ~CompleteInstallFunction() {}
diff --git a/chrome/browser/extensions/api/webstore_private/webstore_private_apitest.cc b/chrome/browser/extensions/api/webstore_private/webstore_private_apitest.cc
index fa6e759..449d1f3a 100644
--- a/chrome/browser/extensions/api/webstore_private/webstore_private_apitest.cc
+++ b/chrome/browser/extensions/api/webstore_private/webstore_private_apitest.cc
@@ -55,8 +55,10 @@ class WebstoreInstallListener : public WebstoreInstaller::Delegate {
}
}
- void OnExtensionInstallFailure(const std::string& id,
- const std::string& error) OVERRIDE {
+ void OnExtensionInstallFailure(
+ const std::string& id,
+ const std::string& error,
+ WebstoreInstaller::FailureReason reason) OVERRIDE {
received_failure_ = true;
id_ = id;
error_ = error;
diff --git a/chrome/browser/extensions/bundle_installer.cc b/chrome/browser/extensions/bundle_installer.cc
index c3ad798..eef78e9 100644
--- a/chrome/browser/extensions/bundle_installer.cc
+++ b/chrome/browser/extensions/bundle_installer.cc
@@ -327,8 +327,10 @@ void BundleInstaller::OnExtensionInstallSuccess(const std::string& id) {
ShowInstalledBubbleIfDone();
}
-void BundleInstaller::OnExtensionInstallFailure(const std::string& id,
- const std::string& error) {
+void BundleInstaller::OnExtensionInstallFailure(
+ const std::string& id,
+ const std::string& error,
+ WebstoreInstaller::FailureReason reason) {
items_[id].state = Item::STATE_FAILED;
ExtensionList::iterator i = std::find_if(
diff --git a/chrome/browser/extensions/bundle_installer.h b/chrome/browser/extensions/bundle_installer.h
index b1986d6..7498710 100644
--- a/chrome/browser/extensions/bundle_installer.h
+++ b/chrome/browser/extensions/bundle_installer.h
@@ -161,8 +161,10 @@ class BundleInstaller : public WebstoreInstallHelper::Delegate,
// WebstoreInstaller::Delegate implementation:
virtual void OnExtensionInstallSuccess(const std::string& id) OVERRIDE;
- virtual void OnExtensionInstallFailure(const std::string& id,
- const std::string& error) OVERRIDE;
+ virtual void OnExtensionInstallFailure(
+ const std::string& id,
+ const std::string& error,
+ WebstoreInstaller::FailureReason reason) OVERRIDE;
// chrome::BrowserListObserver implementation:
virtual void OnBrowserAdded(Browser* browser) OVERRIDE;
diff --git a/chrome/browser/extensions/webstore_inline_installer.cc b/chrome/browser/extensions/webstore_inline_installer.cc
index 6fe8c37..6800b75 100644
--- a/chrome/browser/extensions/webstore_inline_installer.cc
+++ b/chrome/browser/extensions/webstore_inline_installer.cc
@@ -423,7 +423,9 @@ void WebstoreInlineInstaller::OnExtensionInstallSuccess(const std::string& id) {
}
void WebstoreInlineInstaller::OnExtensionInstallFailure(
- const std::string& id, const std::string& error) {
+ const std::string& id,
+ const std::string& error,
+ WebstoreInstaller::FailureReason cancelled) {
CHECK_EQ(id_, id);
CompleteInstall(error);
}
diff --git a/chrome/browser/extensions/webstore_inline_installer.h b/chrome/browser/extensions/webstore_inline_installer.h
index 5525b69..6bc1b31 100644
--- a/chrome/browser/extensions/webstore_inline_installer.h
+++ b/chrome/browser/extensions/webstore_inline_installer.h
@@ -112,8 +112,10 @@ class WebstoreInlineInstaller
// WebstoreInstaller::Delegate interface implementation.
virtual void OnExtensionInstallSuccess(const std::string& id) OVERRIDE;
- virtual void OnExtensionInstallFailure(const std::string& id,
- const std::string& error) OVERRIDE;
+ virtual void OnExtensionInstallFailure(
+ const std::string& id,
+ const std::string& error,
+ WebstoreInstaller::FailureReason reason) OVERRIDE;
void CompleteInstall(const std::string& error);
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;
}
diff --git a/chrome/browser/extensions/webstore_installer.h b/chrome/browser/extensions/webstore_installer.h
index 1555234..2224305 100644
--- a/chrome/browser/extensions/webstore_installer.h
+++ b/chrome/browser/extensions/webstore_installer.h
@@ -44,11 +44,21 @@ class WebstoreInstaller :public content::NotificationObserver,
FLAG_INLINE_INSTALL = 1 << 0
};
+ enum FailureReason {
+ FAILURE_REASON_CANCELLED,
+ FAILURE_REASON_OTHER
+ };
+
class Delegate {
public:
+ virtual void OnExtensionDownloadStarted(const std::string& id,
+ content::DownloadItem* item);
+ virtual void OnExtensionDownloadProgress(const std::string& id,
+ content::DownloadItem* item);
virtual void OnExtensionInstallSuccess(const std::string& id) = 0;
virtual void OnExtensionInstallFailure(const std::string& id,
- const std::string& error) = 0;
+ const std::string& error,
+ FailureReason reason) = 0;
protected:
virtual ~Delegate() {}
@@ -145,7 +155,7 @@ class WebstoreInstaller :public content::NotificationObserver,
// Reports an install |error| to the delegate for the given extension if this
// managed its installation. This also removes the associated PendingInstall.
- void ReportFailure(const std::string& error);
+ void ReportFailure(const std::string& error, FailureReason reason);
// Reports a successful install to the delegate for the given extension if
// this managed its installation. This also removes the associated
diff --git a/chrome/browser/ui/intents/web_intent_picker_controller.cc b/chrome/browser/ui/intents/web_intent_picker_controller.cc
index a99d9a4..f8f1f16 100644
--- a/chrome/browser/ui/intents/web_intent_picker_controller.cc
+++ b/chrome/browser/ui/intents/web_intent_picker_controller.cc
@@ -39,6 +39,7 @@
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/url_constants.h"
#include "content/public/browser/browser_thread.h"
+#include "content/public/browser/download_manager.h"
#include "content/public/browser/navigation_controller.h"
#include "content/public/browser/notification_source.h"
#include "content/public/browser/web_contents.h"
@@ -472,6 +473,8 @@ void WebIntentPickerController::OnInlineDispositionWebContentsCreated(
void WebIntentPickerController::OnExtensionInstallRequested(
const std::string& id) {
+ picker_model_->SetPendingExtensionInstallId(id);
+
scoped_ptr<WebstoreInstaller::Approval> approval(
WebstoreInstaller::Approval::CreateWithInstallPrompt(profile_));
@@ -529,12 +532,27 @@ void WebIntentPickerController::OnChooseAnotherService() {
void WebIntentPickerController::OnClosing() {
SetDialogState(kPickerHidden);
picker_ = NULL;
+ picker_model_->ClearPendingExtensionInstall();
+ CancelDownload();
#if defined(TOOLKIT_VIEWS)
if (cancelled_)
OnUserCancelledPickerDialog();
#endif
}
+void WebIntentPickerController::OnExtensionDownloadStarted(
+ const std::string& id,
+ content::DownloadItem* item) {
+ download_id_ = item->GetGlobalId();
+ picker_model_->UpdateExtensionDownloadState(item);
+}
+
+void WebIntentPickerController::OnExtensionDownloadProgress(
+ const std::string& id,
+ content::DownloadItem* item) {
+ picker_model_->UpdateExtensionDownloadState(item);
+}
+
void WebIntentPickerController::OnExtensionInstallSuccess(
const std::string& extension_id) {
// OnExtensionInstallSuccess is called via NotificationService::Notify before
@@ -551,7 +569,12 @@ void WebIntentPickerController::OnExtensionInstallSuccess(
void WebIntentPickerController::DispatchToInstalledExtension(
const std::string& extension_id) {
web_intents::RecordCWSExtensionInstalled(uma_bucket_);
- picker_->OnExtensionInstallSuccess(extension_id);
+
+ download_id_ = content::DownloadId();
+ picker_model_->ClearPendingExtensionInstall();
+ if (picker_)
+ picker_->OnExtensionInstallSuccess(extension_id);
+
WebIntentsRegistry::IntentServiceList services;
GetWebIntentsRegistry(profile_)->GetIntentServicesForExtensionFilter(
picker_model_->action(), picker_model_->type(),
@@ -574,8 +597,16 @@ void WebIntentPickerController::DispatchToInstalledExtension(
void WebIntentPickerController::OnExtensionInstallFailure(
const std::string& id,
- const std::string& error) {
- picker_->OnExtensionInstallFailure(id);
+ const std::string& error,
+ WebstoreInstaller::FailureReason reason) {
+ // If the user cancelled the install then don't show an error message.
+ if (reason == WebstoreInstaller::FAILURE_REASON_CANCELLED)
+ picker_model_->ClearPendingExtensionInstall();
+ else
+ picker_model_->SetPendingExtensionInstallStatusString(UTF8ToUTF16(error));
+
+ if (picker_)
+ picker_->OnExtensionInstallFailure(id);
AsyncOperationFinished();
}
@@ -1075,3 +1106,19 @@ void WebIntentPickerController::ClosePicker() {
if (picker_)
picker_->Close();
}
+
+void WebIntentPickerController::CancelDownload() {
+ if (!download_id_.IsValid())
+ return;
+ Profile* profile =
+ Profile::FromBrowserContext(web_contents_->GetBrowserContext());
+ content::DownloadManager* download_manager =
+ content::BrowserContext::GetDownloadManager(profile);
+ if (!download_manager)
+ return;
+ content::DownloadItem* item =
+ download_manager->GetDownload(download_id_.local());
+ if (item)
+ item->Cancel(true);
+ download_id_ = content::DownloadId();
+}
diff --git a/chrome/browser/ui/intents/web_intent_picker_controller.h b/chrome/browser/ui/intents/web_intent_picker_controller.h
index 89397c0..7a5458b 100644
--- a/chrome/browser/ui/intents/web_intent_picker_controller.h
+++ b/chrome/browser/ui/intents/web_intent_picker_controller.h
@@ -124,9 +124,16 @@ class WebIntentPickerController
virtual void OnClosing() OVERRIDE;
// extensions::WebstoreInstaller::Delegate implementation.
+ virtual void OnExtensionDownloadStarted(const std::string& id,
+ content::DownloadItem* item) OVERRIDE;
+ virtual void OnExtensionDownloadProgress(
+ const std::string& id,
+ content::DownloadItem* item) OVERRIDE;
virtual void OnExtensionInstallSuccess(const std::string& id) OVERRIDE;
- virtual void OnExtensionInstallFailure(const std::string& id,
- const std::string& error) OVERRIDE;
+ virtual void OnExtensionInstallFailure(
+ const std::string& id,
+ const std::string& error,
+ extensions::WebstoreInstaller::FailureReason reason) OVERRIDE;
private:
explicit WebIntentPickerController(content::WebContents* web_contents);
@@ -258,6 +265,9 @@ class WebIntentPickerController
// loading the picker model and showing the dialog.
void ShowDialog(bool suppress_defaults);
+ // Cancel a pending download if any.
+ void CancelDownload();
+
WebIntentPickerState dialog_state_; // Current state of the dialog.
// A weak pointer to the web contents that the picker is displayed on.
@@ -345,6 +355,9 @@ class WebIntentPickerController
// |intents_dispatcher_| is set.
web_intents::UMABucket uma_bucket_;
+ // The ID of a pending extension download.
+ content::DownloadId download_id_;
+
DISALLOW_COPY_AND_ASSIGN(WebIntentPickerController);
};
diff --git a/chrome/browser/ui/intents/web_intent_picker_model.cc b/chrome/browser/ui/intents/web_intent_picker_model.cc
index 877cec9..a8a2ad3 100644
--- a/chrome/browser/ui/intents/web_intent_picker_model.cc
+++ b/chrome/browser/ui/intents/web_intent_picker_model.cc
@@ -8,7 +8,9 @@
#include "base/logging.h"
#include "base/stl_util.h"
+#include "chrome/browser/download/download_item_model.h"
#include "chrome/browser/ui/intents/web_intent_picker_model_observer.h"
+#include "content/public/browser/download_item.h"
#include "grit/generated_resources.h"
#include "grit/ui_resources.h"
#include "ui/base/l10n/l10n_util.h"
@@ -24,7 +26,8 @@ const size_t kMaxSuggestionCount = 5; // Maximum number of visible suggestions.
WebIntentPickerModel::WebIntentPickerModel()
: observer_(NULL),
waiting_for_suggestions_(true),
- default_service_hash_(0) {
+ default_service_hash_(0),
+ pending_extension_install_download_progress_(0) {
}
WebIntentPickerModel::~WebIntentPickerModel() {
@@ -62,6 +65,7 @@ void WebIntentPickerModel::Clear() {
type_.clear();
inline_disposition_url_ = GURL::EmptyGURL();
waiting_for_suggestions_ = true;
+ ClearPendingExtensionInstall();
if (observer_)
observer_->OnModelChanged(this);
}
@@ -160,6 +164,43 @@ void WebIntentPickerModel::SetWaitingForSuggestions(bool waiting) {
observer_->OnModelChanged(this);
}
+void WebIntentPickerModel::SetPendingExtensionInstallId(const std::string& id) {
+ pending_extension_install_id_ = id;
+ if (observer_)
+ observer_->OnModelChanged(this);
+}
+
+void WebIntentPickerModel::UpdateExtensionDownloadState(
+ content::DownloadItem* item) {
+ pending_extension_install_download_progress_ = item->PercentComplete();
+ DownloadItemModel download_model(item);
+ pending_extension_install_status_string_ = download_model.GetStatusText();
+ if (observer_)
+ observer_->OnModelChanged(this);
+}
+
+void WebIntentPickerModel::SetPendingExtensionInstallDownloadProgress(
+ int progress) {
+ pending_extension_install_download_progress_ = progress;
+ if (observer_)
+ observer_->OnModelChanged(this);
+}
+
+void WebIntentPickerModel::SetPendingExtensionInstallStatusString(
+ const string16& status) {
+ pending_extension_install_status_string_ = status;
+ if (observer_)
+ observer_->OnModelChanged(this);
+}
+
+void WebIntentPickerModel::ClearPendingExtensionInstall() {
+ pending_extension_install_id_.clear();
+ pending_extension_install_download_progress_ = 0;
+ pending_extension_install_status_string_.clear();
+ if (observer_)
+ observer_->OnModelChanged(this);
+}
+
void WebIntentPickerModel::DestroyAll() {
STLDeleteElements(&installed_services_);
}
diff --git a/chrome/browser/ui/intents/web_intent_picker_model.h b/chrome/browser/ui/intents/web_intent_picker_model.h
index 8683e9a..f2b4221 100644
--- a/chrome/browser/ui/intents/web_intent_picker_model.h
+++ b/chrome/browser/ui/intents/web_intent_picker_model.h
@@ -13,6 +13,10 @@
#include "ui/gfx/image/image.h"
#include "webkit/glue/web_intent_service_data.h"
+namespace content {
+class DownloadItem;
+}
+
class WebIntentPickerModelObserver;
// Model for the WebIntentPicker.
@@ -143,6 +147,37 @@ class WebIntentPickerModel {
// GURL::EmptyGURL() if none.
const GURL& inline_disposition_url() const { return inline_disposition_url_; }
+ // Sets the ID of the extension currently being installed.
+ void SetPendingExtensionInstallId(const std::string& id);
+
+ // Gets the ID of the extension currently being installed.
+ const std::string& pending_extension_install_id() const {
+ return pending_extension_install_id_;
+ }
+
+ // Updates the pending install download state.
+ void UpdateExtensionDownloadState(content::DownloadItem* item);
+
+ // Sets the download progress of the extension currently being downloaded.
+ void SetPendingExtensionInstallDownloadProgress(int progress);
+
+ // Gets the download progress of the extension currently being downloaded.
+ // Returns -1 if progress is indeterminate, otherwise a value from 0 to 100.
+ int pending_extension_install_download_progress() const {
+ return pending_extension_install_download_progress_;
+ }
+
+ // Sets the status of extension install process.
+ void SetPendingExtensionInstallStatusString(const string16& status);
+
+ // Gets the status of extension install process.
+ const string16& pending_extension_install_status_string() const {
+ return pending_extension_install_status_string_;
+ }
+
+ // Removes any pending extension install state.
+ void ClearPendingExtensionInstall();
+
private:
// Delete all elements in |installed_services_| and |suggested_extensions_|.
// Note that this method does not reset the observer.
@@ -178,6 +213,11 @@ class WebIntentPickerModel {
// The hash context for the default service, if there is one.
int64 default_service_hash_;
+ // Information about the pending extension install.
+ std::string pending_extension_install_id_;
+ int pending_extension_install_download_progress_;
+ string16 pending_extension_install_status_string_;
+
DISALLOW_COPY_AND_ASSIGN(WebIntentPickerModel);
};
diff --git a/chrome/browser/ui/intents/web_intent_picker_model_unittest.cc b/chrome/browser/ui/intents/web_intent_picker_model_unittest.cc
index d3bec3f..6e9e1b7 100644
--- a/chrome/browser/ui/intents/web_intent_picker_model_unittest.cc
+++ b/chrome/browser/ui/intents/web_intent_picker_model_unittest.cc
@@ -112,7 +112,7 @@ TEST_F(WebIntentPickerModelTest, RemoveInstalledServiceAt) {
}
TEST_F(WebIntentPickerModelTest, Clear) {
- EXPECT_CALL(observer_, OnModelChanged(&model_)).Times(3);
+ EXPECT_CALL(observer_, OnModelChanged(&model_)).Times(testing::AtLeast(3));
model_.AddInstalledService(kTitle1, kUrl1, kWindowDisposition);
model_.AddInstalledService(kTitle2, kUrl2, kWindowDisposition);
@@ -204,7 +204,7 @@ TEST_F(WebIntentPickerModelTest, SetSuggestedExtensionIconWithId) {
}
TEST_F(WebIntentPickerModelTest, SetInlineDisposition) {
- EXPECT_CALL(observer_, OnModelChanged(&model_)).Times(3);
+ EXPECT_CALL(observer_, OnModelChanged(&model_)).Times(testing::AtLeast(3));
EXPECT_CALL(observer_, OnInlineDisposition(kTitle2, testing::_)).Times(1);
EXPECT_FALSE(model_.IsInlineDisposition());