| Index: chrome/browser/extensions/webstore_standalone_installer.cc
|
| diff --git a/chrome/browser/extensions/webstore_standalone_installer.cc b/chrome/browser/extensions/webstore_standalone_installer.cc
|
| index 4f42f01b221312bc01654531b520157d9c2244e0..9eba52f7de5edc7d77bd167f484c1d32f26e7066 100644
|
| --- a/chrome/browser/extensions/webstore_standalone_installer.cc
|
| +++ b/chrome/browser/extensions/webstore_standalone_installer.cc
|
| @@ -10,6 +10,7 @@
|
| #include "chrome/browser/extensions/extension_install_prompt.h"
|
| #include "chrome/browser/extensions/extension_install_ui.h"
|
| #include "chrome/browser/extensions/extension_service.h"
|
| +#include "chrome/browser/extensions/install_tracker.h"
|
| #include "chrome/browser/extensions/webstore_data_fetcher.h"
|
| #include "chrome/browser/profiles/profile.h"
|
| #include "content/public/browser/web_contents.h"
|
| @@ -31,6 +32,8 @@ const char kInvalidWebstoreResponseError[] = "Invalid Chrome Web Store reponse";
|
| const char kInvalidManifestError[] = "Invalid manifest";
|
| const char kUserCancelledError[] = "User cancelled install";
|
| const char kExtensionIsBlacklisted[] = "Extension is blacklisted";
|
| +const char kInstallInProgressError[] = "An install is already in progress";
|
| +const char kLaunchInProgressError[] = "A launch is already in progress";
|
|
|
| WebstoreStandaloneInstaller::WebstoreStandaloneInstaller(
|
| const std::string& webstore_item_id,
|
| @@ -56,6 +59,13 @@ void WebstoreStandaloneInstaller::BeginInstall() {
|
| return;
|
| }
|
|
|
| + webstore_install::Result result = webstore_install::UNKNOWN_ERROR;
|
| + std::string error;
|
| + if (!EnsureUniqueInstall(&result, &error)) {
|
| + CompleteInstall(result, error);
|
| + return;
|
| + }
|
| +
|
| // Use the requesting page as the referrer both since that is more correct
|
| // (it is the page that caused this request to happen) and so that we can
|
| // track top sites that trigger inline install requests.
|
| @@ -79,13 +89,40 @@ void WebstoreStandaloneInstaller::AbortInstall() {
|
| // Abort any in-progress fetches.
|
| if (webstore_data_fetcher_) {
|
| webstore_data_fetcher_.reset();
|
| + scoped_active_install_.reset();
|
| Release(); // Matches the AddRef in BeginInstall.
|
| }
|
| }
|
|
|
| +bool WebstoreStandaloneInstaller::EnsureUniqueInstall(
|
| + webstore_install::Result* reason,
|
| + std::string* error) {
|
| + InstallTracker* tracker = InstallTracker::Get(profile_);
|
| + DCHECK(tracker);
|
| +
|
| + const ActiveInstallData* existing_install_data =
|
| + tracker->GetActiveInstall(id_);
|
| + if (existing_install_data) {
|
| + if (existing_install_data->is_ephemeral) {
|
| + *reason = webstore_install::LAUNCH_IN_PROGRESS;
|
| + *error = kLaunchInProgressError;
|
| + } else {
|
| + *reason = webstore_install::INSTALL_IN_PROGRESS;
|
| + *error = kInstallInProgressError;
|
| + }
|
| + return false;
|
| + }
|
| +
|
| + ActiveInstallData install_data(id_);
|
| + InitInstallData(&install_data);
|
| + scoped_active_install_.reset(new ScopedActiveInstall(tracker, install_data));
|
| + return true;
|
| +}
|
| +
|
| void WebstoreStandaloneInstaller::CompleteInstall(
|
| webstore_install::Result result,
|
| const std::string& error) {
|
| + scoped_active_install_.reset();
|
| if (!callback_.is_null())
|
| callback_.Run(result == webstore_install::SUCCESS, error);
|
| Release(); // Matches the AddRef in BeginInstall.
|
| @@ -121,6 +158,11 @@ WebstoreStandaloneInstaller::GetLocalizedExtensionForDisplay() {
|
| return localized_extension_for_display_.get();
|
| }
|
|
|
| +void WebstoreStandaloneInstaller::InitInstallData(
|
| + ActiveInstallData* install_data) const {
|
| + // Default implementation sets no properties.
|
| +}
|
| +
|
| void WebstoreStandaloneInstaller::OnManifestParsed() {
|
| ProceedWithInstallPrompt();
|
| }
|
|
|