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

Unified Diff: chrome/browser/ui/views/extensions/extension_uninstall_dialog_view.cc

Issue 382133003: Refactored ExtensionUninstallDialog to take a NativeWindow instead of a Browser (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Moved Browser out of ExtensionUninstallDialogViews Created 6 years, 5 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/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..f515e25933858b369a77ab1e3b86a156f1cbcaff 100644
--- a/chrome/browser/ui/views/extensions/extension_uninstall_dialog_view.cc
+++ b/chrome/browser/ui/views/extensions/extension_uninstall_dialog_view.cc
@@ -44,7 +44,7 @@ class ExtensionUninstallDialogViews
public:
ExtensionUninstallDialogViews(
Profile* profile,
- Browser* browser,
+ gfx::NativeWindow parent,
extensions::ExtensionUninstallDialog::Delegate* delegate);
virtual ~ExtensionUninstallDialogViews();
@@ -58,7 +58,6 @@ class ExtensionUninstallDialogViews
virtual void Show() OVERRIDE;
ExtensionUninstallDialogDelegateView* view_;
- bool show_in_app_list_;
DISALLOW_COPY_AND_ASSIGN(ExtensionUninstallDialogViews);
};
@@ -111,11 +110,10 @@ 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) {
+ : extensions::ExtensionUninstallDialog(profile, parent, delegate),
+ view_(NULL) {
}
ExtensionUninstallDialogViews::~ExtensionUninstallDialogViews() {
@@ -127,19 +125,9 @@ 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) {
- delegate_->ExtensionUninstallCanceled();
- return;
- }
-
view_ = new ExtensionUninstallDialogDelegateView(
this, extension_, triggering_extension_, &icon_);
- CreateBrowserModalDialogViews(view_, parent)->Show();
+ CreateBrowserModalDialogViews(view_, parent_)->Show();
}
void ExtensionUninstallDialogViews::ExtensionUninstallAccepted() {
@@ -247,5 +235,18 @@ extensions::ExtensionUninstallDialog*
extensions::ExtensionUninstallDialog::Create(Profile* profile,
Browser* browser,
Delegate* delegate) {
- return new ExtensionUninstallDialogViews(profile, browser, delegate);
+ // If no browser window can be found, GetParent(browser) will be NULL, which
+ // will display this dialog as a standalone window (rather than a modal).
+ ExtensionUninstallDialogViews* dialog =
+ new ExtensionUninstallDialogViews(profile, GetParent(browser), delegate);
+ dialog->RegisterObserver(browser);
+ return dialog;
+}
+
+// static
+extensions::ExtensionUninstallDialog*
+extensions::ExtensionUninstallDialog::CreateModal(Profile* profile,
+ gfx::NativeWindow parent,
+ Delegate* delegate) {
+ return new ExtensionUninstallDialogViews(profile, parent, delegate);
}

Powered by Google App Engine
This is Rietveld 408576698