Chromium Code Reviews| Index: chrome/browser/extensions/extension_uninstall_dialog.cc |
| diff --git a/chrome/browser/extensions/extension_uninstall_dialog.cc b/chrome/browser/extensions/extension_uninstall_dialog.cc |
| index 467a3527b11b99d384404b7a171afa0ac6acecfd..4a16486d6867f389f0ffad7668a5dc2a855aca02 100644 |
| --- a/chrome/browser/extensions/extension_uninstall_dialog.cc |
| +++ b/chrome/browser/extensions/extension_uninstall_dialog.cc |
| @@ -12,6 +12,7 @@ |
| #include "chrome/browser/extensions/extension_util.h" |
| #include "chrome/browser/profiles/profile.h" |
| #include "chrome/browser/ui/browser.h" |
| +#include "chrome/browser/ui/browser_window.h" |
| #include "content/public/browser/notification_service.h" |
| #include "content/public/browser/notification_source.h" |
| #include "extensions/browser/extension_registry.h" |
| @@ -41,23 +42,38 @@ SkBitmap GetDefaultIconBitmapForMaxScaleFactor(bool is_app) { |
| gfx::ImageSkia::GetMaxSupportedScale()).sk_bitmap(); |
| } |
| +// Returns parent window for extension uninstall dialog. |
| +gfx::NativeWindow GetParent(Browser* browser) { |
| + if (browser && browser->window()) |
| + return browser->window()->GetNativeWindow(); |
| + return NULL; |
| +} |
| + |
| } // namespace |
| ExtensionUninstallDialog::ExtensionUninstallDialog( |
| Profile* profile, |
| Browser* browser, |
| + gfx::NativeWindow parent, |
| ExtensionUninstallDialog::Delegate* delegate) |
| : profile_(profile), |
| browser_(browser), |
| + parent_(parent), |
| delegate_(delegate), |
| extension_(NULL), |
| triggering_extension_(NULL), |
| state_(kImageIsLoading), |
| ui_loop_(base::MessageLoop::current()) { |
| if (browser) { |
| + // Close the dialog if the browser is closed while the dialog is open. |
| registrar_.Add(this, |
| chrome::NOTIFICATION_BROWSER_CLOSED, |
| content::Source<Browser>(browser)); |
| + |
| + // If there are no open browser windows, close the dialog immediately. |
|
not at google - send to devlin
2014/07/23 01:49:21
is this logic that you actually need?
...
I ask
|
| + parent_ = GetParent(browser); |
| + if (!parent_) |
| + delegate_->ExtensionUninstallCanceled(); |
| } |
| } |
| @@ -139,7 +155,6 @@ void ExtensionUninstallDialog::Observe( |
| const content::NotificationDetails& details) { |
| DCHECK(type == chrome::NOTIFICATION_BROWSER_CLOSED); |
| - browser_ = NULL; |
| // If the browser is closed while waiting for the image, we need to send a |
| // "cancel" event here, because there will not be another opportunity to |
| // notify the delegate of the cancellation as we won't open the dialog. |