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

Unified Diff: chrome/browser/extensions/api/developer_private/show_permissions_dialog_helper.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/developer_private/show_permissions_dialog_helper.cc
diff --git a/chrome/browser/extensions/api/developer_private/show_permissions_dialog_helper.cc b/chrome/browser/extensions/api/developer_private/show_permissions_dialog_helper.cc
index d791ed1937685e110e6a89ca349f3d5af5261358..8019d38ca0743e0dd35f5e11ae4f1b7eca80e7d5 100644
--- a/chrome/browser/extensions/api/developer_private/show_permissions_dialog_helper.cc
+++ b/chrome/browser/extensions/api/developer_private/show_permissions_dialog_helper.cc
@@ -83,29 +83,30 @@ void ShowPermissionsDialogHelper::ShowPermissionsDialog(
ExtensionInstallPrompt::POST_INSTALL_PERMISSIONS_PROMPT));
prompt->set_retained_files(retained_file_paths);
prompt->set_retained_device_messages(retained_device_messages);
- prompt_->ShowDialog(this, extension, nullptr, std::move(prompt),
- ExtensionInstallPrompt::GetDefaultShowDialogCallback());
+ // Unretained() is safe because this class manages its own lifetime and
+ // deletes itself in OnInstallPromptDone().
asargent_no_longer_on_chrome 2015/12/31 00:45:56 also safe because it owns the prompt and so should
Devlin 2016/01/04 22:59:22 But that's part of the point in this change - it's
+ prompt_->ShowDialog(
+ base::Bind(&ShowPermissionsDialogHelper::OnInstallPromptDone,
+ base::Unretained(this)),
+ extension, nullptr, std::move(prompt),
+ ExtensionInstallPrompt::GetDefaultShowDialogCallback());
}
-// This is called when the user clicks "Revoke File Access."
-void ShowPermissionsDialogHelper::InstallUIProceed() {
- const Extension* extension =
- ExtensionRegistry::Get(profile_)->GetExtensionById(
- extension_id_, ExtensionRegistry::EVERYTHING);
-
- if (extension)
- apps::SavedFilesService::Get(profile_)->ClearQueue(extension);
- apps::AppLoadService::Get(profile_)
- ->RestartApplicationIfRunning(extension_id_);
-
- on_complete_.Run();
-
- delete this;
-}
+void ShowPermissionsDialogHelper::OnInstallPromptDone(
+ ExtensionInstallPrompt::Result result) {
+ if (result == ExtensionInstallPrompt::Result::ACCEPTED) {
+ // This is true when the user clicks "Revoke File Access."
+ const Extension* extension =
+ ExtensionRegistry::Get(profile_)
+ ->GetExtensionById(extension_id_, ExtensionRegistry::EVERYTHING);
+
+ if (extension)
+ apps::SavedFilesService::Get(profile_)->ClearQueue(extension);
+ apps::AppLoadService::Get(profile_)
+ ->RestartApplicationIfRunning(extension_id_);
+ }
-void ShowPermissionsDialogHelper::InstallUIAbort(bool user_initiated) {
on_complete_.Run();
-
delete this;
}

Powered by Google App Engine
This is Rietveld 408576698