Commit 90367644 authored by rdevlin.cronin's avatar rdevlin.cronin Committed by Commit bot

[Extensions] Fix crash in extension uninstall dialog

Refcount an extension so that it if it happens to be reloaded while the dialog
is showing, we don't crash.

BUG=487161
TBR=sky@chromium.org (small extension_uninstall_dialog_view.cc changes, reviewed by kalman)

Review URL: https://codereview.chromium.org/1140053004

Cr-Commit-Position: refs/heads/master@{#330143}
parent 95517b89
...@@ -48,8 +48,6 @@ ExtensionUninstallDialog::ExtensionUninstallDialog( ...@@ -48,8 +48,6 @@ ExtensionUninstallDialog::ExtensionUninstallDialog(
ExtensionUninstallDialog::Delegate* delegate) ExtensionUninstallDialog::Delegate* delegate)
: profile_(profile), : profile_(profile),
delegate_(delegate), delegate_(delegate),
extension_(NULL),
triggering_extension_(NULL),
ui_loop_(base::MessageLoop::current()) { ui_loop_(base::MessageLoop::current()) {
} }
...@@ -71,7 +69,7 @@ void ExtensionUninstallDialog::ConfirmUninstall(const Extension* extension) { ...@@ -71,7 +69,7 @@ void ExtensionUninstallDialog::ConfirmUninstall(const Extension* extension) {
? extension_misc::EXTENSION_ICON_SMALL * 2 ? extension_misc::EXTENSION_ICON_SMALL * 2
: extension_misc::EXTENSION_ICON_LARGE; : extension_misc::EXTENSION_ICON_LARGE;
ExtensionResource image = IconsInfo::GetIconResource( ExtensionResource image = IconsInfo::GetIconResource(
extension_, icon_size, ExtensionIconSet::MATCH_BIGGER); extension_.get(), icon_size, ExtensionIconSet::MATCH_BIGGER);
// Load the image asynchronously. The response will be sent to OnImageLoaded. // Load the image asynchronously. The response will be sent to OnImageLoaded.
ImageLoader* loader = ImageLoader::Get(profile_); ImageLoader* loader = ImageLoader::Get(profile_);
...@@ -83,7 +81,7 @@ void ExtensionUninstallDialog::ConfirmUninstall(const Extension* extension) { ...@@ -83,7 +81,7 @@ void ExtensionUninstallDialog::ConfirmUninstall(const Extension* extension) {
ImageLoader::ImageRepresentation::NEVER_RESIZE, ImageLoader::ImageRepresentation::NEVER_RESIZE,
gfx::Size(), gfx::Size(),
ui::SCALE_FACTOR_100P)); ui::SCALE_FACTOR_100P));
loader->LoadImagesAsync(extension_, loader->LoadImagesAsync(extension_.get(),
images_list, images_list,
base::Bind(&ExtensionUninstallDialog::OnImageLoaded, base::Bind(&ExtensionUninstallDialog::OnImageLoaded,
AsWeakPtr(), AsWeakPtr(),
...@@ -130,7 +128,7 @@ std::string ExtensionUninstallDialog::GetHeadingText() { ...@@ -130,7 +128,7 @@ std::string ExtensionUninstallDialog::GetHeadingText() {
} }
bool ExtensionUninstallDialog::ShouldShowReportAbuseCheckbox() const { bool ExtensionUninstallDialog::ShouldShowReportAbuseCheckbox() const {
return ManifestURL::UpdatesFromGallery(extension_); return ManifestURL::UpdatesFromGallery(extension_.get());
} }
void ExtensionUninstallDialog::OnDialogClosed(CloseAction action) { void ExtensionUninstallDialog::OnDialogClosed(CloseAction action) {
......
...@@ -91,11 +91,11 @@ class ExtensionUninstallDialog ...@@ -91,11 +91,11 @@ class ExtensionUninstallDialog
Delegate* delegate_; Delegate* delegate_;
// The extension we are showing the dialog for. // The extension we are showing the dialog for.
const Extension* extension_; scoped_refptr<const Extension> extension_;
// The extension triggering the dialog if the dialog was shown by // The extension triggering the dialog if the dialog was shown by
// chrome.management.uninstall. // chrome.management.uninstall.
const Extension* triggering_extension_; scoped_refptr<const Extension> triggering_extension_;
// The extensions icon. // The extensions icon.
gfx::ImageSkia icon_; gfx::ImageSkia icon_;
......
...@@ -69,8 +69,7 @@ class ExtensionUninstallDialogDelegateView : public views::DialogDelegateView { ...@@ -69,8 +69,7 @@ class ExtensionUninstallDialogDelegateView : public views::DialogDelegateView {
public: public:
ExtensionUninstallDialogDelegateView( ExtensionUninstallDialogDelegateView(
ExtensionUninstallDialogViews* dialog_view, ExtensionUninstallDialogViews* dialog_view,
const extensions::Extension* extension, bool triggered_by_extension,
const extensions::Extension* triggering_extension,
gfx::ImageSkia* image); gfx::ImageSkia* image);
~ExtensionUninstallDialogDelegateView() override; ~ExtensionUninstallDialogDelegateView() override;
...@@ -135,7 +134,7 @@ void ExtensionUninstallDialogViews::Show() { ...@@ -135,7 +134,7 @@ void ExtensionUninstallDialogViews::Show() {
} }
view_ = new ExtensionUninstallDialogDelegateView( view_ = new ExtensionUninstallDialogDelegateView(
this, extension_, triggering_extension_, &icon_); this, triggering_extension_.get() != nullptr, &icon_);
constrained_window::CreateBrowserModalDialogViews(view_, parent_)->Show(); constrained_window::CreateBrowserModalDialogViews(view_, parent_)->Show();
} }
...@@ -162,11 +161,10 @@ void ExtensionUninstallDialogViews::ExtensionUninstallCanceled() { ...@@ -162,11 +161,10 @@ void ExtensionUninstallDialogViews::ExtensionUninstallCanceled() {
ExtensionUninstallDialogDelegateView::ExtensionUninstallDialogDelegateView( ExtensionUninstallDialogDelegateView::ExtensionUninstallDialogDelegateView(
ExtensionUninstallDialogViews* dialog_view, ExtensionUninstallDialogViews* dialog_view,
const extensions::Extension* extension, bool triggered_by_extension,
const extensions::Extension* triggering_extension,
gfx::ImageSkia* image) gfx::ImageSkia* image)
: dialog_(dialog_view), : dialog_(dialog_view),
triggered_by_extension_(triggering_extension != NULL), triggered_by_extension_(triggered_by_extension),
report_abuse_checkbox_(nullptr) { report_abuse_checkbox_(nullptr) {
// Scale down to icon size, but allow smaller icons (don't scale up). // Scale down to icon size, but allow smaller icons (don't scale up).
gfx::Size size(image->width(), image->height()); gfx::Size size(image->width(), image->height());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment