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

Side by Side Diff: chrome/browser/ui/views/extensions/extension_uninstall_dialog_view.cc

Issue 243643003: Improve extension uninstall flow (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use ctor initialization Created 6 years, 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/cocoa/extensions/extension_uninstall_dialog_cocoa.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/extensions/extension_uninstall_dialog.h" 5 #include "chrome/browser/extensions/extension_uninstall_dialog.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 77
78 // Called when the ExtensionUninstallDialog has been destroyed to make sure 78 // Called when the ExtensionUninstallDialog has been destroyed to make sure
79 // we invalidate pointers. 79 // we invalidate pointers.
80 void DialogDestroyed() { dialog_ = NULL; } 80 void DialogDestroyed() { dialog_ = NULL; }
81 81
82 private: 82 private:
83 // views::DialogDelegate: 83 // views::DialogDelegate:
84 virtual base::string16 GetDialogButtonLabel( 84 virtual base::string16 GetDialogButtonLabel(
85 ui::DialogButton button) const OVERRIDE; 85 ui::DialogButton button) const OVERRIDE;
86 virtual int GetDefaultDialogButton() const OVERRIDE { 86 virtual int GetDefaultDialogButton() const OVERRIDE {
87 return ui::DIALOG_BUTTON_CANCEL; 87 // Default to accept when triggered via chrome://extensions page.
88 return triggered_by_extension_ ?
89 ui::DIALOG_BUTTON_CANCEL : ui::DIALOG_BUTTON_OK;
88 } 90 }
89 virtual bool Accept() OVERRIDE; 91 virtual bool Accept() OVERRIDE;
90 virtual bool Cancel() OVERRIDE; 92 virtual bool Cancel() OVERRIDE;
91 93
92 // views::WidgetDelegate: 94 // views::WidgetDelegate:
93 virtual ui::ModalType GetModalType() const OVERRIDE { 95 virtual ui::ModalType GetModalType() const OVERRIDE {
94 return ui::MODAL_TYPE_WINDOW; 96 return ui::MODAL_TYPE_WINDOW;
95 } 97 }
96 virtual base::string16 GetWindowTitle() const OVERRIDE; 98 virtual base::string16 GetWindowTitle() const OVERRIDE;
97 99
98 // views::View: 100 // views::View:
99 virtual gfx::Size GetPreferredSize() OVERRIDE; 101 virtual gfx::Size GetPreferredSize() OVERRIDE;
100 102
101 virtual void Layout() OVERRIDE; 103 virtual void Layout() OVERRIDE;
102 104
103 ExtensionUninstallDialogViews* dialog_; 105 ExtensionUninstallDialogViews* dialog_;
104 106
105 views::ImageView* icon_; 107 views::ImageView* icon_;
106 views::Label* heading_; 108 views::Label* heading_;
109 bool triggered_by_extension_;
107 110
108 DISALLOW_COPY_AND_ASSIGN(ExtensionUninstallDialogDelegateView); 111 DISALLOW_COPY_AND_ASSIGN(ExtensionUninstallDialogDelegateView);
109 }; 112 };
110 113
111 ExtensionUninstallDialogViews::ExtensionUninstallDialogViews( 114 ExtensionUninstallDialogViews::ExtensionUninstallDialogViews(
112 Profile* profile, 115 Profile* profile,
113 Browser* browser, 116 Browser* browser,
114 ExtensionUninstallDialog::Delegate* delegate) 117 ExtensionUninstallDialog::Delegate* delegate)
115 : ExtensionUninstallDialog(profile, browser, delegate), 118 : ExtensionUninstallDialog(profile, browser, delegate),
116 view_(NULL), 119 view_(NULL),
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 // The widget gets destroyed when the dialog is canceled. 154 // The widget gets destroyed when the dialog is canceled.
152 view_ = NULL; 155 view_ = NULL;
153 delegate_->ExtensionUninstallCanceled(); 156 delegate_->ExtensionUninstallCanceled();
154 } 157 }
155 158
156 ExtensionUninstallDialogDelegateView::ExtensionUninstallDialogDelegateView( 159 ExtensionUninstallDialogDelegateView::ExtensionUninstallDialogDelegateView(
157 ExtensionUninstallDialogViews* dialog_view, 160 ExtensionUninstallDialogViews* dialog_view,
158 const extensions::Extension* extension, 161 const extensions::Extension* extension,
159 const extensions::Extension* triggering_extension, 162 const extensions::Extension* triggering_extension,
160 gfx::ImageSkia* icon) 163 gfx::ImageSkia* icon)
161 : dialog_(dialog_view) { 164 : dialog_(dialog_view),
165 triggered_by_extension_(triggering_extension != NULL) {
162 // Scale down to icon size, but allow smaller icons (don't scale up). 166 // Scale down to icon size, but allow smaller icons (don't scale up).
163 gfx::Size size(icon->width(), icon->height()); 167 gfx::Size size(icon->width(), icon->height());
164 if (size.width() > kIconSize || size.height() > kIconSize) 168 if (size.width() > kIconSize || size.height() > kIconSize)
165 size = gfx::Size(kIconSize, kIconSize); 169 size = gfx::Size(kIconSize, kIconSize);
166 icon_ = new views::ImageView(); 170 icon_ = new views::ImageView();
167 icon_->SetImageSize(size); 171 icon_->SetImageSize(size);
168 icon_->SetImage(*icon); 172 icon_->SetImage(*icon);
169 AddChildView(icon_); 173 AddChildView(icon_);
170 174
171 heading_ = new views::Label(base::UTF8ToUTF16(dialog_->GetHeadingText())); 175 heading_ = new views::Label(base::UTF8ToUTF16(dialog_->GetHeadingText()));
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 244
241 } // namespace 245 } // namespace
242 246
243 // static 247 // static
244 ExtensionUninstallDialog* ExtensionUninstallDialog::Create( 248 ExtensionUninstallDialog* ExtensionUninstallDialog::Create(
245 Profile* profile, 249 Profile* profile,
246 Browser* browser, 250 Browser* browser,
247 Delegate* delegate) { 251 Delegate* delegate) {
248 return new ExtensionUninstallDialogViews(profile, browser, delegate); 252 return new ExtensionUninstallDialogViews(profile, browser, delegate);
249 } 253 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/extensions/extension_uninstall_dialog_cocoa.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698