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

Unified Diff: chrome/browser/extensions/api/webstore_private/webstore_private_api.cc

Issue 1534123002: [Extensions] Migrate ExtensionInstallPrompt::Delegate to be a callback (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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/api/webstore_private/webstore_private_api.cc
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 ca0831ad41e2bc5563c26a73c7a48c1bcae527f4..c88e10e6a6df3763e58c6e6ddf81bb569b7e03f0 100644
--- a/chrome/browser/extensions/api/webstore_private/webstore_private_api.cc
+++ b/chrome/browser/extensions/api/webstore_private/webstore_private_api.cc
@@ -291,9 +291,12 @@ void WebstorePrivateBeginInstallWithManifest3Function::OnWebstoreParseSuccess(
}
install_prompt_.reset(new ExtensionInstallPrompt(web_contents));
install_prompt_->ShowDialog(
- this, dummy_extension_.get(), &icon_,
+ base::Bind(&WebstorePrivateBeginInstallWithManifest3Function::
+ OnInstallPromptDone,
+ this),
+ dummy_extension_.get(), &icon_,
ExtensionInstallPrompt::GetDefaultShowDialogCallback());
- // Control flow finishes up in InstallUIProceed or InstallUIAbort.
+ // Control flow finishes up in OnInstallPromptDone.
}
void WebstorePrivateBeginInstallWithManifest3Function::OnWebstoreParseFailure(
@@ -309,7 +312,19 @@ void WebstorePrivateBeginInstallWithManifest3Function::OnWebstoreParseFailure(
Release();
}
-void WebstorePrivateBeginInstallWithManifest3Function::InstallUIProceed() {
+void WebstorePrivateBeginInstallWithManifest3Function::OnInstallPromptDone(
+ ExtensionInstallPrompt::Result result) {
+ if (result == ExtensionInstallPrompt::Result::ACCEPTED) {
+ HandleInstallProceed();
+ } else {
+ HandleInstallAbort(result == ExtensionInstallPrompt::Result::USER_CANCELED);
+ }
+
+ // Matches the AddRef in Run().
+ Release();
+}
+
+void WebstorePrivateBeginInstallWithManifest3Function::HandleInstallProceed() {
// This gets cleared in CrxInstaller::ConfirmInstall(). TODO(asargent) - in
// the future we may also want to add time-based expiration, where a whitelist
// entry is only valid for some number of minutes.
@@ -338,12 +353,9 @@ void WebstorePrivateBeginInstallWithManifest3Function::InstallUIProceed() {
dummy_extension_.get(), "WebStoreInstall");
Respond(BuildResponse(api::webstore_private::RESULT_SUCCESS, std::string()));
-
- // Matches the AddRef in Run().
- Release();
}
-void WebstorePrivateBeginInstallWithManifest3Function::InstallUIAbort(
+void WebstorePrivateBeginInstallWithManifest3Function::HandleInstallAbort(
bool user_initiated) {
// The web store install histograms are a subset of the install histograms.
// We need to record both histograms here since CrxInstaller::InstallUIAbort
@@ -359,9 +371,6 @@ void WebstorePrivateBeginInstallWithManifest3Function::InstallUIAbort(
Respond(BuildResponse(api::webstore_private::RESULT_USER_CANCELLED,
kUserCancelledError));
-
- // Matches the AddRef in Run().
- Release();
}
ExtensionFunction::ResponseValue
« no previous file with comments | « chrome/browser/extensions/api/webstore_private/webstore_private_api.h ('k') | chrome/browser/extensions/bundle_installer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698