Index: chrome/browser/ui/views/extensions/extension_uninstall_dialog_view.cc |
diff --git a/chrome/browser/ui/views/extensions/extension_uninstall_dialog_view.cc b/chrome/browser/ui/views/extensions/extension_uninstall_dialog_view.cc |
index d6d3a8c5964cfc01de4fcaa12927df3a1940c441..282e10dd80b13afcfa2335f1f2e17ff4d6df8ef0 100644 |
--- a/chrome/browser/ui/views/extensions/extension_uninstall_dialog_view.cc |
+++ b/chrome/browser/ui/views/extensions/extension_uninstall_dialog_view.cc |
@@ -42,9 +42,15 @@ gfx::NativeWindow GetParent(Browser* browser) { |
class ExtensionUninstallDialogViews |
: public extensions::ExtensionUninstallDialog { |
public: |
+ // If |browser| is set, it will be used as the browser window that this dialog |
+ // is launched from. If |parent| is set, it it used as the parent of the |
+ // dialog instead. If both |browser| and |parent| are NULL, this is launched |
+ // as a standalone window. Only at most one of |browser| and |parent| should |
+ // be set. |
ExtensionUninstallDialogViews( |
Profile* profile, |
Browser* browser, |
+ gfx::NativeWindow parent, |
extensions::ExtensionUninstallDialog::Delegate* delegate); |
virtual ~ExtensionUninstallDialogViews(); |
@@ -58,7 +64,7 @@ class ExtensionUninstallDialogViews |
virtual void Show() OVERRIDE; |
ExtensionUninstallDialogDelegateView* view_; |
- bool show_in_app_list_; |
+ gfx::NativeWindow parent_; |
DISALLOW_COPY_AND_ASSIGN(ExtensionUninstallDialogViews); |
}; |
@@ -112,10 +118,11 @@ class ExtensionUninstallDialogDelegateView : public views::DialogDelegateView { |
ExtensionUninstallDialogViews::ExtensionUninstallDialogViews( |
Profile* profile, |
Browser* browser, |
+ gfx::NativeWindow parent, |
extensions::ExtensionUninstallDialog::Delegate* delegate) |
: extensions::ExtensionUninstallDialog(profile, browser, delegate), |
view_(NULL), |
- show_in_app_list_(!browser) { |
+ parent_(parent) { |
} |
ExtensionUninstallDialogViews::~ExtensionUninstallDialogViews() { |
@@ -127,19 +134,18 @@ ExtensionUninstallDialogViews::~ExtensionUninstallDialogViews() { |
} |
void ExtensionUninstallDialogViews::Show() { |
- // TODO(tapted): A true |desktop_type| needs to be passed in at creation time |
- // to remove reliance on GetActiveDesktop(). http://crbug.com/308360 |
- gfx::NativeWindow parent = show_in_app_list_ ? |
- AppListService::Get(chrome::GetActiveDesktop())->GetAppListWindow() : |
- GetParent(browser_); |
- if (browser_ && !parent) { |
+ // Callers of ExtensionUninstallDialog::Create() expect a non-NULL result, but |
+ // it's possible that a browser window couldn't be found. In that case, |
+ // immediately cancel the dialog when shown. |
+ if (browser_ && !GetParent(browser_)) { |
delegate_->ExtensionUninstallCanceled(); |
return; |
} |
view_ = new ExtensionUninstallDialogDelegateView( |
this, extension_, triggering_extension_, &icon_); |
- CreateBrowserModalDialogViews(view_, parent)->Show(); |
+ CreateBrowserModalDialogViews(view_, parent_ ? parent_ : GetParent(browser_)) |
+ ->Show(); |
} |
void ExtensionUninstallDialogViews::ExtensionUninstallAccepted() { |
@@ -247,5 +253,21 @@ extensions::ExtensionUninstallDialog* |
extensions::ExtensionUninstallDialog::Create(Profile* profile, |
Browser* browser, |
Delegate* delegate) { |
- return new ExtensionUninstallDialogViews(profile, browser, delegate); |
+ return new ExtensionUninstallDialogViews(profile, browser, NULL, delegate); |
+} |
+ |
+// static |
+extensions::ExtensionUninstallDialog* |
+extensions::ExtensionUninstallDialog::CreateForAppList(Profile* profile, |
+ gfx::NativeWindow parent, |
+ Delegate* delegate) { |
+ return new ExtensionUninstallDialogViews(profile, NULL, parent, delegate); |
+} |
+ |
+// static |
+extensions::ExtensionUninstallDialog* |
+extensions::ExtensionUninstallDialog::CreateAsStandaloneDialog( |
+ Profile* profile, |
+ Delegate* delegate) { |
+ return new ExtensionUninstallDialogViews(profile, NULL, NULL, delegate); |
} |