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

Unified Diff: chrome/browser/extensions/bundle_installer.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
« no previous file with comments | « chrome/browser/extensions/bundle_installer.h ('k') | chrome/browser/extensions/crx_installer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/bundle_installer.cc
diff --git a/chrome/browser/extensions/bundle_installer.cc b/chrome/browser/extensions/bundle_installer.cc
index 7e6d269de893accc96f9311395152aff223dd9e3..c7105596c917eb2a4dcfedad2841dcac6470d6bb 100644
--- a/chrome/browser/extensions/bundle_installer.cc
+++ b/chrome/browser/extensions/bundle_installer.cc
@@ -113,7 +113,8 @@ BundleInstaller::BundleInstaller(Browser* browser,
authuser_(authuser),
delegated_username_(delegated_username),
host_desktop_type_(browser->host_desktop_type()),
- profile_(browser->profile()) {
+ profile_(browser->profile()),
+ weak_factory_(this) {
BrowserList::AddObserver(this);
for (size_t i = 0; i < items.size(); ++i) {
items_[items[i].id] = items[i];
@@ -270,9 +271,9 @@ void BundleInstaller::ShowPrompt() {
}
if (g_auto_approve_for_test == PROCEED) {
- InstallUIProceed();
+ OnInstallPromptDone(ExtensionInstallPrompt::Result::ACCEPTED);
} else if (g_auto_approve_for_test == ABORT) {
- InstallUIAbort(true);
+ OnInstallPromptDone(ExtensionInstallPrompt::Result::USER_CANCELED);
} else {
Browser* browser = browser_;
if (!browser) {
@@ -295,7 +296,9 @@ void BundleInstaller::ShowPrompt() {
}
prompt->set_bundle(this);
install_ui_->ShowDialog(
- this, nullptr, &icon_, std::move(prompt), std::move(permissions),
+ base::Bind(&BundleInstaller::OnInstallPromptDone,
+ weak_factory_.GetWeakPtr()),
+ nullptr, &icon_, std::move(prompt), std::move(permissions),
ExtensionInstallPrompt::GetDefaultShowDialogCallback());
}
}
@@ -332,16 +335,21 @@ void BundleInstaller::OnWebstoreParseFailure(
ShowPromptIfDoneParsing();
}
-void BundleInstaller::InstallUIProceed() {
- approved_ = true;
- approval_callback_.Run(APPROVED);
-}
-
-void BundleInstaller::InstallUIAbort(bool user_initiated) {
- for (std::pair<const std::string, Item>& entry : items_)
- entry.second.state = Item::STATE_FAILED;
+void BundleInstaller::OnInstallPromptDone(
+ ExtensionInstallPrompt::Result result) {
+ ApprovalState state = APPROVED;
+ if (result == ExtensionInstallPrompt::Result::ACCEPTED) {
+ approved_ = true;
+ state = APPROVED;
+ } else {
+ for (std::pair<const std::string, Item>& entry : items_)
+ entry.second.state = Item::STATE_FAILED;
- approval_callback_.Run(user_initiated ? USER_CANCELED : APPROVAL_ERROR);
+ state = result == ExtensionInstallPrompt::Result::USER_CANCELED
+ ? USER_CANCELED
+ : APPROVAL_ERROR;
+ }
+ approval_callback_.Run(state);
}
void BundleInstaller::OnExtensionInstallSuccess(const std::string& id) {
« no previous file with comments | « chrome/browser/extensions/bundle_installer.h ('k') | chrome/browser/extensions/crx_installer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698