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

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

Issue 13925019: fix GridLayout::CreatePanel for new style dialogs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: msw review Created 7 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
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/string_util.h" 9 #include "base/string_util.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 15 matching lines...) Expand all
26 #include "ash/shell.h" 26 #include "ash/shell.h"
27 #endif 27 #endif
28 28
29 namespace { 29 namespace {
30 30
31 const int kRightColumnWidth = 210; 31 const int kRightColumnWidth = 210;
32 const int kIconSize = 69; 32 const int kIconSize = 69;
33 33
34 class ExtensionUninstallDialogDelegateView; 34 class ExtensionUninstallDialogDelegateView;
35 35
36 // TODO(estade): remove this when UseNewStyle() is the default.
37 int HorizontalMargin() {
38 return views::DialogDelegate::UseNewStyle() ? views::kButtonHEdgeMarginNew :
39 views::kPanelHorizMargin;
40 }
41
36 // Returns parent window for extension uninstall dialog. 42 // Returns parent window for extension uninstall dialog.
37 // For ash, use app list window if it is visible. 43 // For ash, use app list window if it is visible.
38 // For other platforms or when app list is not visible on ash, 44 // For other platforms or when app list is not visible on ash,
39 // use the given browser window. 45 // use the given browser window.
40 // Note this function could return NULL if ash app list is not visible and 46 // Note this function could return NULL if ash app list is not visible and
41 // there is no browser window. 47 // there is no browser window.
42 gfx::NativeWindow GetParent(Browser* browser) { 48 gfx::NativeWindow GetParent(Browser* browser) {
43 #if defined(USE_ASH) 49 #if defined(USE_ASH)
44 if (ash::Shell::HasInstance()) { 50 if (ash::Shell::HasInstance()) {
45 gfx::NativeWindow app_list = ash::Shell::GetInstance()->GetAppListWindow(); 51 gfx::NativeWindow app_list = ash::Shell::GetInstance()->GetAppListWindow();
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 bool ExtensionUninstallDialogDelegateView::Cancel() { 201 bool ExtensionUninstallDialogDelegateView::Cancel() {
196 if (dialog_) 202 if (dialog_)
197 dialog_->ExtensionUninstallCanceled(); 203 dialog_->ExtensionUninstallCanceled();
198 return true; 204 return true;
199 } 205 }
200 206
201 string16 ExtensionUninstallDialogDelegateView::GetWindowTitle() const { 207 string16 ExtensionUninstallDialogDelegateView::GetWindowTitle() const {
202 return l10n_util::GetStringUTF16(IDS_EXTENSION_UNINSTALL_PROMPT_TITLE); 208 return l10n_util::GetStringUTF16(IDS_EXTENSION_UNINSTALL_PROMPT_TITLE);
203 } 209 }
204 210
205
206 gfx::Size ExtensionUninstallDialogDelegateView::GetPreferredSize() { 211 gfx::Size ExtensionUninstallDialogDelegateView::GetPreferredSize() {
207 int width = kRightColumnWidth; 212 int width = kRightColumnWidth;
208 width += kIconSize; 213 width += kIconSize;
209 width += views::kPanelHorizMargin * 3; 214 width += HorizontalMargin() * 2;
215 width += views::kRelatedControlHorizontalSpacing;
210 216
211 int height = views::kPanelVertMargin * 2; 217 int height = views::kPanelVertMargin * 2;
212 height += heading_->GetHeightForWidth(kRightColumnWidth); 218 height += heading_->GetHeightForWidth(kRightColumnWidth);
213 219
214 return gfx::Size(width, 220 return gfx::Size(width,
215 std::max(height, kIconSize + views::kPanelVertMargin * 2)); 221 std::max(height, kIconSize + views::kPanelVertMargin * 2));
216 } 222 }
217 223
218 void ExtensionUninstallDialogDelegateView::Layout() { 224 void ExtensionUninstallDialogDelegateView::Layout() {
219 int x = views::kPanelHorizMargin; 225 int x = HorizontalMargin();
220 int y = views::kPanelVertMargin; 226 int y = views::kPanelVertMargin;
221 227
222 heading_->SizeToFit(kRightColumnWidth); 228 heading_->SizeToFit(kRightColumnWidth);
223 229
224 if (heading_->height() <= kIconSize) { 230 if (heading_->height() <= kIconSize) {
225 icon_->SetBounds(x, y, kIconSize, kIconSize); 231 icon_->SetBounds(x, y, kIconSize, kIconSize);
226 x += kIconSize; 232 x += kIconSize;
227 x += views::kPanelHorizMargin; 233 x += views::kRelatedControlHorizontalSpacing;
228 234
229 heading_->SetX(x); 235 heading_->SetX(x);
230 heading_->SetY(y + (kIconSize - heading_->height()) / 2); 236 heading_->SetY(y + (kIconSize - heading_->height()) / 2);
231 } else { 237 } else {
232 icon_->SetBounds(x, 238 icon_->SetBounds(x,
233 y + (heading_->height() - kIconSize) / 2, 239 y + (heading_->height() - kIconSize) / 2,
234 kIconSize, 240 kIconSize,
235 kIconSize); 241 kIconSize);
236 x += kIconSize; 242 x += kIconSize;
237 x += views::kPanelHorizMargin; 243 x += views::kRelatedControlHorizontalSpacing;
238 244
239 heading_->SetX(x); 245 heading_->SetX(x);
240 heading_->SetY(y); 246 heading_->SetY(y);
241 } 247 }
242 } 248 }
243 249
244 } // namespace 250 } // namespace
245 251
246 // static 252 // static
247 ExtensionUninstallDialog* ExtensionUninstallDialog::Create( 253 ExtensionUninstallDialog* ExtensionUninstallDialog::Create(
248 Profile* profile, 254 Profile* profile,
249 Browser* browser, 255 Browser* browser,
250 Delegate* delegate) { 256 Delegate* delegate) {
251 return new ExtensionUninstallDialogViews(profile, browser, delegate); 257 return new ExtensionUninstallDialogViews(profile, browser, delegate);
252 } 258 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/confirm_bubble_views.cc ('k') | chrome/browser/ui/views/extensions/media_galleries_dialog_views.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698