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

Unified Diff: chrome/browser/apps/ephemeral_app_launcher.cc

Issue 389613006: Prevent duplicate concurrent installs of the same extension (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed update of webstore_result Created 6 years, 5 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/apps/ephemeral_app_launcher.cc
diff --git a/chrome/browser/apps/ephemeral_app_launcher.cc b/chrome/browser/apps/ephemeral_app_launcher.cc
index 92f7bd81ae5f87b73c53a8d4a7a21b2850661a49..37910c8a4421076c43cdc3e26e4cebe46229e2a2 100644
--- a/chrome/browser/apps/ephemeral_app_launcher.cc
+++ b/chrome/browser/apps/ephemeral_app_launcher.cc
@@ -224,17 +224,25 @@ bool EphemeralAppLauncher::CanLaunchInstalledApp(
}
void EphemeralAppLauncher::EnableInstalledApp(const Extension* extension) {
+ // Check whether an install is already in progress.
+ webstore_install::Result result = webstore_install::UNKNOWN_ERROR;
+ std::string error;
+ if (!EnsureUniqueInstall(&result, &error)) {
+ InvokeCallback(result, error);
+ return;
+ }
+
+ // Keep this object alive until the enable flow is complete. Either
+ // ExtensionEnableFlowFinished() or ExtensionEnableFlowAborted() will be
+ // called.
+ AddRef();
+
extension_enable_flow_.reset(
new ExtensionEnableFlow(profile(), extension->id(), this));
if (web_contents())
extension_enable_flow_->StartForWebContents(web_contents());
else
extension_enable_flow_->StartForNativeWindow(parent_window_);
-
- // Keep this object alive until the enable flow is complete. Either
- // ExtensionEnableFlowFinished() or ExtensionEnableFlowAborted() will be
- // called.
- AddRef();
}
void EphemeralAppLauncher::MaybeLaunchApp() {
@@ -292,8 +300,9 @@ bool EphemeralAppLauncher::LaunchHostedApp(const Extension* extension) const {
void EphemeralAppLauncher::InvokeCallback(webstore_install::Result result,
const std::string& error) {
if (!launch_callback_.is_null()) {
- launch_callback_.Run(result, error);
+ LaunchCallback callback = launch_callback_;
launch_callback_.Reset();
+ callback.Run(result, error);
}
}
@@ -339,6 +348,11 @@ void EphemeralAppLauncher::OnInstallChecked(int check_failures) {
ProceedWithInstallPrompt();
}
+void EphemeralAppLauncher::InitInstallData(
+ extensions::ActiveInstallData* install_data) const {
+ install_data->is_ephemeral = true;
+}
+
bool EphemeralAppLauncher::CheckRequestorAlive() const {
return dummy_web_contents_.get() != NULL || web_contents() != NULL;
}
@@ -439,10 +453,13 @@ void EphemeralAppLauncher::WebContentsDestroyed() {
void EphemeralAppLauncher::ExtensionEnableFlowFinished() {
MaybeLaunchApp();
- Release(); // Matches the AddRef in EnableInstalledApp().
+
+ // CompleteInstall will call Release.
+ WebstoreStandaloneInstaller::CompleteInstall(webstore_install::SUCCESS,
+ std::string());
}
void EphemeralAppLauncher::ExtensionEnableFlowAborted(bool user_initiated) {
- InvokeCallback(webstore_install::USER_CANCELLED, kUserCancelledError);
- Release(); // Matches the AddRef in EnableInstalledApp().
+ // CompleteInstall will call Release.
+ CompleteInstall(webstore_install::USER_CANCELLED, kUserCancelledError);
}
« no previous file with comments | « chrome/browser/apps/ephemeral_app_launcher.h ('k') | chrome/browser/apps/ephemeral_app_launcher_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698