Chromium Code Reviews| 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..cd9b53f184e56db2b7ea6d9ae0ca80bc3c1f5bde 100644 |
| --- a/chrome/browser/ui/views/extensions/extension_uninstall_dialog_view.cc |
| +++ b/chrome/browser/ui/views/extensions/extension_uninstall_dialog_view.cc |
| @@ -31,20 +31,13 @@ const int kIconSize = 64; |
| class ExtensionUninstallDialogDelegateView; |
| -// Returns parent window for extension uninstall dialog. |
| -gfx::NativeWindow GetParent(Browser* browser) { |
| - if (browser && browser->window()) |
| - return browser->window()->GetNativeWindow(); |
| - return NULL; |
| -} |
| - |
| // Views implementation of the uninstall dialog. |
| class ExtensionUninstallDialogViews |
| : public extensions::ExtensionUninstallDialog { |
| public: |
| ExtensionUninstallDialogViews( |
| Profile* profile, |
| - Browser* browser, |
| + gfx::NativeWindow parent, |
| extensions::ExtensionUninstallDialog::Delegate* delegate); |
| virtual ~ExtensionUninstallDialogViews(); |
| @@ -56,6 +49,7 @@ class ExtensionUninstallDialogViews |
| private: |
| virtual void Show() OVERRIDE; |
| + virtual void RefreshIcon() OVERRIDE; |
| ExtensionUninstallDialogDelegateView* view_; |
| bool show_in_app_list_; |
|
tapted
2014/07/24 00:35:36
unused?
sashab
2014/07/24 03:03:36
Done.
|
| @@ -73,11 +67,15 @@ class ExtensionUninstallDialogDelegateView : public views::DialogDelegateView { |
| gfx::ImageSkia* icon); |
| virtual ~ExtensionUninstallDialogDelegateView(); |
| + void SetIcon(gfx::ImageSkia* icon); |
| + |
| // Called when the ExtensionUninstallDialog has been destroyed to make sure |
| // we invalidate pointers. |
| void DialogDestroyed() { dialog_ = NULL; } |
| private: |
| + void SetIconInternal(gfx::ImageSkia* icon); |
| + |
| // views::DialogDelegate: |
| virtual base::string16 GetDialogButtonLabel( |
| ui::DialogButton button) const OVERRIDE; |
| @@ -111,11 +109,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 +124,13 @@ 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::RefreshIcon() { |
| + view_->SetIcon(&icon_); |
| } |
| void ExtensionUninstallDialogViews::ExtensionUninstallAccepted() { |
| @@ -161,13 +152,8 @@ ExtensionUninstallDialogDelegateView::ExtensionUninstallDialogDelegateView( |
| gfx::ImageSkia* icon) |
| : dialog_(dialog_view), |
| triggered_by_extension_(triggering_extension != NULL) { |
| - // Scale down to icon size, but allow smaller icons (don't scale up). |
| - gfx::Size size(icon->width(), icon->height()); |
| - if (size.width() > kIconSize || size.height() > kIconSize) |
| - size = gfx::Size(kIconSize, kIconSize); |
| icon_ = new views::ImageView(); |
| - icon_->SetImageSize(size); |
| - icon_->SetImage(*icon); |
| + SetIconInternal(icon); |
| AddChildView(icon_); |
| heading_ = new views::Label(base::UTF8ToUTF16(dialog_->GetHeadingText())); |
| @@ -179,6 +165,21 @@ ExtensionUninstallDialogDelegateView::ExtensionUninstallDialogDelegateView( |
| ExtensionUninstallDialogDelegateView::~ExtensionUninstallDialogDelegateView() { |
| } |
| +void ExtensionUninstallDialogDelegateView::SetIcon(gfx::ImageSkia* icon) { |
| + SetIconInternal(icon); |
| + Layout(); |
| +} |
| + |
| +void ExtensionUninstallDialogDelegateView::SetIconInternal( |
| + gfx::ImageSkia* icon) { |
| + // Scale down to icon size, but allow smaller icons (don't scale up). |
| + gfx::Size size(icon->width(), icon->height()); |
| + if (size.width() > kIconSize || size.height() > kIconSize) |
| + size = gfx::Size(kIconSize, kIconSize); |
| + icon_->SetImageSize(size); |
| + icon_->SetImage(*icon); |
| +} |
| + |
| base::string16 ExtensionUninstallDialogDelegateView::GetDialogButtonLabel( |
| ui::DialogButton button) const { |
| return l10n_util::GetStringUTF16((button == ui::DIALOG_BUTTON_OK) ? |
| @@ -245,7 +246,7 @@ void ExtensionUninstallDialogDelegateView::Layout() { |
| // static |
| extensions::ExtensionUninstallDialog* |
| extensions::ExtensionUninstallDialog::Create(Profile* profile, |
| - Browser* browser, |
| + gfx::NativeWindow parent, |
| Delegate* delegate) { |
| - return new ExtensionUninstallDialogViews(profile, browser, delegate); |
| + return new ExtensionUninstallDialogViews(profile, parent, delegate); |
| } |