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

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 5 years 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..aa64a2c4efb05ac26d5d455da285f8db4aa78800 100644
--- a/chrome/browser/extensions/api/webstore_private/webstore_private_api.cc
+++ b/chrome/browser/extensions/api/webstore_private/webstore_private_api.cc
@@ -291,7 +291,10 @@ 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.
asargent_no_longer_on_chrome 2015/12/31 00:45:56 nit: update to "...finishes up in OnInstallPromptD
Devlin 2016/01/04 22:59:23 Done.
}
@@ -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

Powered by Google App Engine
This is Rietveld 408576698