| OLD | NEW |
| 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 17 matching lines...) Expand all Loading... |
| 28 #include "ash/shell.h" | 28 #include "ash/shell.h" |
| 29 #endif | 29 #endif |
| 30 | 30 |
| 31 namespace { | 31 namespace { |
| 32 | 32 |
| 33 const int kRightColumnWidth = 210; | 33 const int kRightColumnWidth = 210; |
| 34 const int kIconSize = 69; | 34 const int kIconSize = 69; |
| 35 | 35 |
| 36 class ExtensionUninstallDialogDelegateView; | 36 class ExtensionUninstallDialogDelegateView; |
| 37 | 37 |
| 38 // TODO(estade): remove this when UseNewStyle() is the default. | |
| 39 int HorizontalMargin() { | |
| 40 return views::DialogDelegate::UseNewStyle() ? views::kButtonHEdgeMarginNew : | |
| 41 views::kPanelHorizMargin; | |
| 42 } | |
| 43 | |
| 44 // Returns parent window for extension uninstall dialog. | 38 // Returns parent window for extension uninstall dialog. |
| 45 gfx::NativeWindow GetParent(Browser* browser) { | 39 gfx::NativeWindow GetParent(Browser* browser) { |
| 46 if (browser && browser->window()) | 40 if (browser && browser->window()) |
| 47 return browser->window()->GetNativeWindow(); | 41 return browser->window()->GetNativeWindow(); |
| 48 return NULL; | 42 return NULL; |
| 49 } | 43 } |
| 50 | 44 |
| 51 // Views implementation of the uninstall dialog. | 45 // Views implementation of the uninstall dialog. |
| 52 class ExtensionUninstallDialogViews : public ExtensionUninstallDialog { | 46 class ExtensionUninstallDialogViews : public ExtensionUninstallDialog { |
| 53 public: | 47 public: |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 return true; | 192 return true; |
| 199 } | 193 } |
| 200 | 194 |
| 201 string16 ExtensionUninstallDialogDelegateView::GetWindowTitle() const { | 195 string16 ExtensionUninstallDialogDelegateView::GetWindowTitle() const { |
| 202 return l10n_util::GetStringUTF16(IDS_EXTENSION_UNINSTALL_PROMPT_TITLE); | 196 return l10n_util::GetStringUTF16(IDS_EXTENSION_UNINSTALL_PROMPT_TITLE); |
| 203 } | 197 } |
| 204 | 198 |
| 205 gfx::Size ExtensionUninstallDialogDelegateView::GetPreferredSize() { | 199 gfx::Size ExtensionUninstallDialogDelegateView::GetPreferredSize() { |
| 206 int width = kRightColumnWidth; | 200 int width = kRightColumnWidth; |
| 207 width += kIconSize; | 201 width += kIconSize; |
| 208 width += HorizontalMargin() * 2; | 202 width += views::kButtonHEdgeMarginNew * 2; |
| 209 width += views::kRelatedControlHorizontalSpacing; | 203 width += views::kRelatedControlHorizontalSpacing; |
| 210 | 204 |
| 211 int height = views::kPanelVertMargin * 2; | 205 int height = views::kPanelVertMargin * 2; |
| 212 height += heading_->GetHeightForWidth(kRightColumnWidth); | 206 height += heading_->GetHeightForWidth(kRightColumnWidth); |
| 213 | 207 |
| 214 return gfx::Size(width, | 208 return gfx::Size(width, |
| 215 std::max(height, kIconSize + views::kPanelVertMargin * 2)); | 209 std::max(height, kIconSize + views::kPanelVertMargin * 2)); |
| 216 } | 210 } |
| 217 | 211 |
| 218 void ExtensionUninstallDialogDelegateView::Layout() { | 212 void ExtensionUninstallDialogDelegateView::Layout() { |
| 219 int x = HorizontalMargin(); | 213 int x = views::kButtonHEdgeMarginNew; |
| 220 int y = views::kPanelVertMargin; | 214 int y = views::kPanelVertMargin; |
| 221 | 215 |
| 222 heading_->SizeToFit(kRightColumnWidth); | 216 heading_->SizeToFit(kRightColumnWidth); |
| 223 | 217 |
| 224 if (heading_->height() <= kIconSize) { | 218 if (heading_->height() <= kIconSize) { |
| 225 icon_->SetBounds(x, y, kIconSize, kIconSize); | 219 icon_->SetBounds(x, y, kIconSize, kIconSize); |
| 226 x += kIconSize; | 220 x += kIconSize; |
| 227 x += views::kRelatedControlHorizontalSpacing; | 221 x += views::kRelatedControlHorizontalSpacing; |
| 228 | 222 |
| 229 heading_->SetX(x); | 223 heading_->SetX(x); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 243 | 237 |
| 244 } // namespace | 238 } // namespace |
| 245 | 239 |
| 246 // static | 240 // static |
| 247 ExtensionUninstallDialog* ExtensionUninstallDialog::Create( | 241 ExtensionUninstallDialog* ExtensionUninstallDialog::Create( |
| 248 Profile* profile, | 242 Profile* profile, |
| 249 Browser* browser, | 243 Browser* browser, |
| 250 Delegate* delegate) { | 244 Delegate* delegate) { |
| 251 return new ExtensionUninstallDialogViews(profile, browser, delegate); | 245 return new ExtensionUninstallDialogViews(profile, browser, delegate); |
| 252 } | 246 } |
| OLD | NEW |