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

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

Issue 2758323002: Broke out layout metric information from ViewsDelegate to LayoutProvider (Closed)
Patch Set: Final feedback addressed Created 3 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
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/chrome_layout_provider.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"
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 OnDialogClosed(CLOSE_ACTION_CANCELED); 161 OnDialogClosed(CLOSE_ACTION_CANCELED);
162 } 162 }
163 163
164 ExtensionUninstallDialogDelegateView::ExtensionUninstallDialogDelegateView( 164 ExtensionUninstallDialogDelegateView::ExtensionUninstallDialogDelegateView(
165 ExtensionUninstallDialogViews* dialog_view, 165 ExtensionUninstallDialogViews* dialog_view,
166 bool triggered_by_extension, 166 bool triggered_by_extension,
167 const gfx::ImageSkia* image) 167 const gfx::ImageSkia* image)
168 : dialog_(dialog_view), 168 : dialog_(dialog_view),
169 triggered_by_extension_(triggered_by_extension), 169 triggered_by_extension_(triggered_by_extension),
170 report_abuse_checkbox_(nullptr) { 170 report_abuse_checkbox_(nullptr) {
171 LayoutDelegate* layout_delegate = LayoutDelegate::Get(); 171 ChromeLayoutProvider* provider = ChromeLayoutProvider::Get();
172 SetLayoutManager(new views::BoxLayout( 172 SetLayoutManager(new views::BoxLayout(
173 views::BoxLayout::kHorizontal, 173 views::BoxLayout::kHorizontal,
174 layout_delegate->GetMetric(LayoutDelegate::Metric::DIALOG_BUTTON_MARGIN), 174 provider->GetDistanceMetric(DISTANCE_DIALOG_BUTTON_MARGIN),
175 layout_delegate->GetMetric(LayoutDelegate::Metric::PANEL_CONTENT_MARGIN), 175 provider->GetDistanceMetric(DISTANCE_PANEL_CONTENT_MARGIN),
176 layout_delegate->GetMetric( 176 provider->GetDistanceMetric(views::DISTANCE_RELATED_CONTROL_HORIZONTAL)));
177 LayoutDelegate::Metric::RELATED_CONTROL_HORIZONTAL_SPACING)));
178 177
179 icon_ = new views::ImageView(); 178 icon_ = new views::ImageView();
180 DCHECK_GE(image->width(), kIconSize); 179 DCHECK_GE(image->width(), kIconSize);
181 DCHECK_GE(image->height(), kIconSize); 180 DCHECK_GE(image->height(), kIconSize);
182 icon_->SetImageSize(gfx::Size(kIconSize, kIconSize)); 181 icon_->SetImageSize(gfx::Size(kIconSize, kIconSize));
183 icon_->SetImage(*image); 182 icon_->SetImage(*image);
184 AddChildView(icon_); 183 AddChildView(icon_);
185 184
186 heading_ = new views::Label(base::UTF8ToUTF16(dialog_->GetHeadingText())); 185 heading_ = new views::Label(base::UTF8ToUTF16(dialog_->GetHeadingText()));
187 heading_->SetMultiLine(true); 186 heading_->SetMultiLine(true);
(...skipping 18 matching lines...) Expand all
206 if (dialog_->ShouldShowReportAbuseCheckbox()) { 205 if (dialog_->ShouldShowReportAbuseCheckbox()) {
207 report_abuse_checkbox_ = new views::Checkbox( 206 report_abuse_checkbox_ = new views::Checkbox(
208 l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_UNINSTALL_REPORT_ABUSE)); 207 l10n_util::GetStringUTF16(IDS_EXTENSION_PROMPT_UNINSTALL_REPORT_ABUSE));
209 } 208 }
210 return report_abuse_checkbox_; 209 return report_abuse_checkbox_;
211 } 210 }
212 211
213 bool ExtensionUninstallDialogDelegateView::GetExtraViewPadding(int* padding) { 212 bool ExtensionUninstallDialogDelegateView::GetExtraViewPadding(int* padding) {
214 // We want a little more padding between the "report abuse" checkbox and the 213 // We want a little more padding between the "report abuse" checkbox and the
215 // buttons. 214 // buttons.
216 *padding = LayoutDelegate::Get()->GetMetric( 215 *padding = ChromeLayoutProvider::Get()->GetDistanceMetric(
217 LayoutDelegate::Metric::UNRELATED_CONTROL_HORIZONTAL_SPACING_LARGE); 216 DISTANCE_UNRELATED_CONTROL_HORIZONTAL_LARGE);
218 return true; 217 return true;
219 } 218 }
220 219
221 base::string16 ExtensionUninstallDialogDelegateView::GetDialogButtonLabel( 220 base::string16 ExtensionUninstallDialogDelegateView::GetDialogButtonLabel(
222 ui::DialogButton button) const { 221 ui::DialogButton button) const {
223 return l10n_util::GetStringUTF16((button == ui::DIALOG_BUTTON_OK) ? 222 return l10n_util::GetStringUTF16((button == ui::DIALOG_BUTTON_OK) ?
224 IDS_EXTENSION_PROMPT_UNINSTALL_BUTTON : IDS_CANCEL); 223 IDS_EXTENSION_PROMPT_UNINSTALL_BUTTON : IDS_CANCEL);
225 } 224 }
226 225
227 bool ExtensionUninstallDialogDelegateView::Accept() { 226 bool ExtensionUninstallDialogDelegateView::Accept() {
(...skipping 16 matching lines...) Expand all
244 243
245 } // namespace 244 } // namespace
246 245
247 // static 246 // static
248 extensions::ExtensionUninstallDialog* 247 extensions::ExtensionUninstallDialog*
249 extensions::ExtensionUninstallDialog::Create(Profile* profile, 248 extensions::ExtensionUninstallDialog::Create(Profile* profile,
250 gfx::NativeWindow parent, 249 gfx::NativeWindow parent,
251 Delegate* delegate) { 250 Delegate* delegate) {
252 return new ExtensionUninstallDialogViews(profile, parent, delegate); 251 return new ExtensionUninstallDialogViews(profile, parent, delegate);
253 } 252 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698