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

Unified Diff: chrome/browser/extensions/extension_install_prompt.cc

Issue 662073002: Fix crash when user closes window prior to the "Confirm Install" prompt showing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git/+/install_prompt_navigator
Patch Set: Created 6 years, 2 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/extension_install_prompt.cc
diff --git a/chrome/browser/extensions/extension_install_prompt.cc b/chrome/browser/extensions/extension_install_prompt.cc
index d692d9ee362f6e224627edc1c4c60ccd60201851..8a4929b34d9a71c434cefdfa64bcae92cf0d3a2c 100644
--- a/chrome/browser/extensions/extension_install_prompt.cc
+++ b/chrome/browser/extensions/extension_install_prompt.cc
@@ -14,6 +14,7 @@
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/extensions/bundle_installer.h"
+#include "chrome/browser/extensions/extension_install_prompt_show_params.h"
#include "chrome/browser/extensions/extension_util.h"
#include "chrome/browser/extensions/permissions_updater.h"
#include "chrome/browser/profiles/profile.h"
@@ -176,13 +177,6 @@ Profile* ProfileForWebContents(content::WebContents* web_contents) {
return Profile::FromBrowserContext(web_contents->GetBrowserContext());
}
-gfx::NativeWindow NativeWindowForWebContents(content::WebContents* contents) {
- if (!contents)
- return NULL;
-
- return contents->GetTopLevelNativeWindow();
-}
-
} // namespace
ExtensionInstallPrompt::Prompt::InstallPromptPermissions::
@@ -613,19 +607,6 @@ bool ExtensionInstallPrompt::Prompt::ShouldDisplayRevokeFilesButton() const {
return !retained_files_.empty();
}
-ExtensionInstallPrompt::ShowParams::ShowParams(content::WebContents* contents)
- : profile(ProfileForWebContents(contents)),
- parent_web_contents(contents),
- parent_window(NativeWindowForWebContents(contents)) {
-}
-
-ExtensionInstallPrompt::ShowParams::ShowParams(Profile* profile,
- gfx::NativeWindow window)
- : profile(profile),
- parent_web_contents(NULL),
- parent_window(window) {
-}
-
// static
scoped_refptr<Extension>
ExtensionInstallPrompt::GetLocalizedExtensionForDisplay(
@@ -664,7 +645,7 @@ ExtensionInstallPrompt::ExtensionInstallPrompt(content::WebContents* contents)
bundle_(NULL),
install_ui_(extensions::CreateExtensionInstallUI(
ProfileForWebContents(contents))),
- show_params_(contents),
+ show_params_(new ExtensionInstallPromptShowParams(contents)),
delegate_(NULL) {
}
@@ -675,7 +656,8 @@ ExtensionInstallPrompt::ExtensionInstallPrompt(Profile* profile,
extension_(NULL),
bundle_(NULL),
install_ui_(extensions::CreateExtensionInstallUI(profile)),
- show_params_(profile, native_window),
+ show_params_(
+ new ExtensionInstallPromptShowParams(profile, native_window)),
delegate_(NULL) {
}
@@ -945,8 +927,13 @@ void ExtensionInstallPrompt::ShowConfirmation() {
if (AutoConfirmPrompt(delegate_))
return;
+ if (show_params_->WasParentDestroyed()) {
+ delegate_->InstallUIAbort(false);
+ return;
+ }
+
if (show_dialog_callback_.is_null())
- GetDefaultShowDialogCallback().Run(show_params_, delegate_, prompt_);
+ GetDefaultShowDialogCallback().Run(show_params_.get(), delegate_, prompt_);
else
- show_dialog_callback_.Run(show_params_, delegate_, prompt_);
+ show_dialog_callback_.Run(show_params_.get(), delegate_, prompt_);
}

Powered by Google App Engine
This is Rietveld 408576698