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

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

Issue 2753243002: Views/Harmony: Replace layout constants in chrome/browser/ui/views/extensions. (Closed)
Patch Set: Review comments. Created 3 years, 9 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
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 <memory> 5 #include <memory>
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/macros.h" 8 #include "base/macros.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"
11 #include "chrome/browser/extensions/extension_uninstall_dialog.h" 11 #include "chrome/browser/extensions/extension_uninstall_dialog.h"
12 #include "chrome/browser/ui/app_list/app_list_service.h" 12 #include "chrome/browser/ui/app_list/app_list_service.h"
13 #include "chrome/browser/ui/native_window_tracker.h" 13 #include "chrome/browser/ui/native_window_tracker.h"
14 #include "chrome/browser/ui/views/harmony/layout_delegate.h" 14 #include "chrome/browser/ui/views/harmony/layout_delegate.h"
15 #include "chrome/grit/generated_resources.h" 15 #include "chrome/grit/generated_resources.h"
16 #include "components/constrained_window/constrained_window_views.h" 16 #include "components/constrained_window/constrained_window_views.h"
17 #include "components/strings/grit/components_strings.h" 17 #include "components/strings/grit/components_strings.h"
18 #include "extensions/common/extension.h" 18 #include "extensions/common/extension.h"
19 #include "ui/base/l10n/l10n_util.h" 19 #include "ui/base/l10n/l10n_util.h"
20 #include "ui/compositor/compositor.h" 20 #include "ui/compositor/compositor.h"
21 #include "ui/compositor/layer.h" 21 #include "ui/compositor/layer.h"
22 #include "ui/views/controls/button/checkbox.h" 22 #include "ui/views/controls/button/checkbox.h"
23 #include "ui/views/controls/image_view.h" 23 #include "ui/views/controls/image_view.h"
24 #include "ui/views/controls/label.h" 24 #include "ui/views/controls/label.h"
25 #include "ui/views/layout/box_layout.h" 25 #include "ui/views/layout/box_layout.h"
26 #include "ui/views/layout/layout_constants.h"
27 #include "ui/views/view.h" 26 #include "ui/views/view.h"
28 #include "ui/views/widget/widget.h" 27 #include "ui/views/widget/widget.h"
29 #include "ui/views/window/dialog_delegate.h" 28 #include "ui/views/window/dialog_delegate.h"
30 29
31 namespace { 30 namespace {
32 31
33 const int kRightColumnWidth = 210; 32 const int kRightColumnWidth = 210;
34 const int kIconSize = 64; 33 const int kIconSize = 64;
35 34
36 class ExtensionUninstallDialogDelegateView; 35 class ExtensionUninstallDialogDelegateView;
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 OnDialogClosed(CLOSE_ACTION_CANCELED); 161 OnDialogClosed(CLOSE_ACTION_CANCELED);
163 } 162 }
164 163
165 ExtensionUninstallDialogDelegateView::ExtensionUninstallDialogDelegateView( 164 ExtensionUninstallDialogDelegateView::ExtensionUninstallDialogDelegateView(
166 ExtensionUninstallDialogViews* dialog_view, 165 ExtensionUninstallDialogViews* dialog_view,
167 bool triggered_by_extension, 166 bool triggered_by_extension,
168 const gfx::ImageSkia* image) 167 const gfx::ImageSkia* image)
169 : dialog_(dialog_view), 168 : dialog_(dialog_view),
170 triggered_by_extension_(triggered_by_extension), 169 triggered_by_extension_(triggered_by_extension),
171 report_abuse_checkbox_(nullptr) { 170 report_abuse_checkbox_(nullptr) {
171 LayoutDelegate* layout_delegate = LayoutDelegate::Get();
172 SetLayoutManager(new views::BoxLayout( 172 SetLayoutManager(new views::BoxLayout(
173 views::BoxLayout::kHorizontal, views::kButtonHEdgeMarginNew, 173 views::BoxLayout::kHorizontal,
174 LayoutDelegate::Get()->GetMetric( 174 layout_delegate->GetMetric(LayoutDelegate::Metric::DIALOG_BUTTON_MARGIN),
175 LayoutDelegate::Metric::PANEL_CONTENT_MARGIN), 175 layout_delegate->GetMetric(LayoutDelegate::Metric::PANEL_CONTENT_MARGIN),
176 views::kRelatedControlHorizontalSpacing)); 176 layout_delegate->GetMetric(
177 LayoutDelegate::Metric::RELATED_CONTROL_HORIZONTAL_SPACING)));
177 178
178 icon_ = new views::ImageView(); 179 icon_ = new views::ImageView();
179 DCHECK_GE(image->width(), kIconSize); 180 DCHECK_GE(image->width(), kIconSize);
180 DCHECK_GE(image->height(), kIconSize); 181 DCHECK_GE(image->height(), kIconSize);
181 icon_->SetImageSize(gfx::Size(kIconSize, kIconSize)); 182 icon_->SetImageSize(gfx::Size(kIconSize, kIconSize));
182 icon_->SetImage(*image); 183 icon_->SetImage(*image);
183 AddChildView(icon_); 184 AddChildView(icon_);
184 185
185 heading_ = new views::Label(base::UTF8ToUTF16(dialog_->GetHeadingText())); 186 heading_ = new views::Label(base::UTF8ToUTF16(dialog_->GetHeadingText()));
186 heading_->SetMultiLine(true); 187 heading_->SetMultiLine(true);
(...skipping 18 matching lines...) Expand all
205 if (dialog_->ShouldShowReportAbuseCheckbox()) { 206 if (dialog_->ShouldShowReportAbuseCheckbox()) {
206 report_abuse_checkbox_ = new views::Checkbox( 207 report_abuse_checkbox_ = new views::Checkbox(
207 l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_UNINSTALL_REPORT_ABUSE)); 208 l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_UNINSTALL_REPORT_ABUSE));
208 } 209 }
209 return report_abuse_checkbox_; 210 return report_abuse_checkbox_;
210 } 211 }
211 212
212 bool ExtensionUninstallDialogDelegateView::GetExtraViewPadding(int* padding) { 213 bool ExtensionUninstallDialogDelegateView::GetExtraViewPadding(int* padding) {
213 // We want a little more padding between the "report abuse" checkbox and the 214 // We want a little more padding between the "report abuse" checkbox and the
214 // buttons. 215 // buttons.
215 *padding = views::kUnrelatedControlLargeHorizontalSpacing; 216 *padding = LayoutDelegate::Get()->GetMetric(
217 LayoutDelegate::Metric::UNRELATED_CONTROL_HORIZONTAL_SPACING_LARGE);
216 return true; 218 return true;
217 } 219 }
218 220
219 base::string16 ExtensionUninstallDialogDelegateView::GetDialogButtonLabel( 221 base::string16 ExtensionUninstallDialogDelegateView::GetDialogButtonLabel(
220 ui::DialogButton button) const { 222 ui::DialogButton button) const {
221 return l10n_util::GetStringUTF16((button == ui::DIALOG_BUTTON_OK) ? 223 return l10n_util::GetStringUTF16((button == ui::DIALOG_BUTTON_OK) ?
222 IDS_EXTENSION_PROMPT_UNINSTALL_BUTTON : IDS_CANCEL); 224 IDS_EXTENSION_PROMPT_UNINSTALL_BUTTON : IDS_CANCEL);
223 } 225 }
224 226
225 bool ExtensionUninstallDialogDelegateView::Accept() { 227 bool ExtensionUninstallDialogDelegateView::Accept() {
(...skipping 16 matching lines...) Expand all
242 244
243 } // namespace 245 } // namespace
244 246
245 // static 247 // static
246 extensions::ExtensionUninstallDialog* 248 extensions::ExtensionUninstallDialog*
247 extensions::ExtensionUninstallDialog::Create(Profile* profile, 249 extensions::ExtensionUninstallDialog::Create(Profile* profile,
248 gfx::NativeWindow parent, 250 gfx::NativeWindow parent,
249 Delegate* delegate) { 251 Delegate* delegate) {
250 return new ExtensionUninstallDialogViews(profile, parent, delegate); 252 return new ExtensionUninstallDialogViews(profile, parent, delegate);
251 } 253 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698