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

Side by Side Diff: chrome/browser/ui/views/profiles/profile_chooser_view.cc

Issue 2904443006: Views/Harmony Remove references to ui/views/layout/layout_constants.h (Closed)
Patch Set: Add layout_constants.h back to dialog_example.cc as it refers to kUnrelatedControlVerticalSpacing. … Created 3 years, 6 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/ui/views/profiles/profile_chooser_view.h" 5 #include "chrome/browser/ui/views/profiles/profile_chooser_view.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/metrics/user_metrics.h" 8 #include "base/metrics/user_metrics.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/app/vector_icons/vector_icons.h" 10 #include "chrome/app/vector_icons/vector_icons.h"
(...skipping 16 matching lines...) Expand all
27 #include "chrome/browser/themes/theme_service.h" 27 #include "chrome/browser/themes/theme_service.h"
28 #include "chrome/browser/themes/theme_service_factory.h" 28 #include "chrome/browser/themes/theme_service_factory.h"
29 #include "chrome/browser/ui/browser.h" 29 #include "chrome/browser/ui/browser.h"
30 #include "chrome/browser/ui/browser_commands.h" 30 #include "chrome/browser/ui/browser_commands.h"
31 #include "chrome/browser/ui/browser_dialogs.h" 31 #include "chrome/browser/ui/browser_dialogs.h"
32 #include "chrome/browser/ui/browser_list.h" 32 #include "chrome/browser/ui/browser_list.h"
33 #include "chrome/browser/ui/chrome_pages.h" 33 #include "chrome/browser/ui/chrome_pages.h"
34 #include "chrome/browser/ui/profile_chooser_constants.h" 34 #include "chrome/browser/ui/profile_chooser_constants.h"
35 #include "chrome/browser/ui/singleton_tabs.h" 35 #include "chrome/browser/ui/singleton_tabs.h"
36 #include "chrome/browser/ui/user_manager.h" 36 #include "chrome/browser/ui/user_manager.h"
37 #include "chrome/browser/ui/views/harmony/chrome_layout_provider.h"
37 #include "chrome/browser/ui/views/profiles/signin_view_controller_delegate_views .h" 38 #include "chrome/browser/ui/views/profiles/signin_view_controller_delegate_views .h"
38 #include "chrome/browser/ui/views/profiles/user_manager_view.h" 39 #include "chrome/browser/ui/views/profiles/user_manager_view.h"
39 #include "chrome/browser/ui/webui/signin/login_ui_service.h" 40 #include "chrome/browser/ui/webui/signin/login_ui_service.h"
40 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" 41 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h"
41 #include "chrome/common/pref_names.h" 42 #include "chrome/common/pref_names.h"
42 #include "chrome/common/url_constants.h" 43 #include "chrome/common/url_constants.h"
43 #include "chrome/grit/chromium_strings.h" 44 #include "chrome/grit/chromium_strings.h"
44 #include "chrome/grit/generated_resources.h" 45 #include "chrome/grit/generated_resources.h"
45 #include "chrome/grit/theme_resources.h" 46 #include "chrome/grit/theme_resources.h"
46 #include "components/browser_sync/profile_sync_service.h" 47 #include "components/browser_sync/profile_sync_service.h"
(...skipping 30 matching lines...) Expand all
77 #include "ui/views/controls/button/md_text_button.h" 78 #include "ui/views/controls/button/md_text_button.h"
78 #include "ui/views/controls/button/menu_button.h" 79 #include "ui/views/controls/button/menu_button.h"
79 #include "ui/views/controls/label.h" 80 #include "ui/views/controls/label.h"
80 #include "ui/views/controls/link.h" 81 #include "ui/views/controls/link.h"
81 #include "ui/views/controls/separator.h" 82 #include "ui/views/controls/separator.h"
82 #include "ui/views/controls/styled_label.h" 83 #include "ui/views/controls/styled_label.h"
83 #include "ui/views/controls/webview/webview.h" 84 #include "ui/views/controls/webview/webview.h"
84 #include "ui/views/layout/box_layout.h" 85 #include "ui/views/layout/box_layout.h"
85 #include "ui/views/layout/fill_layout.h" 86 #include "ui/views/layout/fill_layout.h"
86 #include "ui/views/layout/grid_layout.h" 87 #include "ui/views/layout/grid_layout.h"
87 #include "ui/views/layout/layout_constants.h"
88 #include "ui/views/widget/widget.h" 88 #include "ui/views/widget/widget.h"
89 89
90 namespace { 90 namespace {
91 91
92 // Helpers -------------------------------------------------------------------- 92 // Helpers --------------------------------------------------------------------
93 93
94 const int kButtonHeight = 32; 94 const int kButtonHeight = 32;
95 const int kFixedAccountRemovalViewWidth = 280; 95 const int kFixedAccountRemovalViewWidth = 280;
96 const int kFixedSwitchUserViewWidth = 320; 96 const int kFixedSwitchUserViewWidth = 320;
97 const int kImageSide = 40; 97 const int kImageSide = 40;
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 SetFocusPainter(nullptr); 186 SetFocusPainter(nullptr);
187 187
188 label()->SetHandlesTooltips(false); 188 label()->SetHandlesTooltips(false);
189 } 189 }
190 190
191 BackgroundColorHoverButton(ProfileChooserView* profile_chooser_view, 191 BackgroundColorHoverButton(ProfileChooserView* profile_chooser_view,
192 const base::string16& text, 192 const base::string16& text,
193 const gfx::ImageSkia& icon) 193 const gfx::ImageSkia& icon)
194 : BackgroundColorHoverButton(profile_chooser_view, text) { 194 : BackgroundColorHoverButton(profile_chooser_view, text) {
195 SetMinSize(gfx::Size( 195 SetMinSize(gfx::Size(
196 icon.width(), kButtonHeight + views::kRelatedControlVerticalSpacing)); 196 icon.width(),
197 kButtonHeight + ChromeLayoutProvider::Get()->GetDistanceMetric(
198 views::DISTANCE_RELATED_CONTROL_VERTICAL)));
197 SetImage(STATE_NORMAL, icon); 199 SetImage(STATE_NORMAL, icon);
198 } 200 }
199 201
200 // Overrides the main label associated with this button. If unset, 202 // Overrides the main label associated with this button. If unset,
201 // label() will be used instead. |label| should be drawn over this 203 // label() will be used instead. |label| should be drawn over this
202 // button, but it is not necessary that it be a child view. 204 // button, but it is not necessary that it be a child view.
203 void set_title(views::Label* label) { title_ = label; } 205 void set_title(views::Label* label) { title_ = label; }
204 206
205 // Sets a secondary label associated with this button. |label| 207 // Sets a secondary label associated with this button. |label|
206 // should be drawn over this button, but it is not necessary that it 208 // should be drawn over this button, but it is not necessary that it
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 : views::LabelButton(listener, base::string16()), 330 : views::LabelButton(listener, base::string16()),
329 photo_overlay_(nullptr), 331 photo_overlay_(nullptr),
330 profile_(profile) { 332 profile_(profile) {
331 set_can_process_events_within_subtree(false); 333 set_can_process_events_within_subtree(false);
332 gfx::Image image = 334 gfx::Image image =
333 profiles::GetSizedAvatarIcon(icon, true, kImageSide, kImageSide); 335 profiles::GetSizedAvatarIcon(icon, true, kImageSide, kImageSide);
334 SetImage(views::LabelButton::STATE_NORMAL, *image.ToImageSkia()); 336 SetImage(views::LabelButton::STATE_NORMAL, *image.ToImageSkia());
335 SetBorder(views::NullBorder()); 337 SetBorder(views::NullBorder());
336 SetMinSize(gfx::Size(GetPreferredSize().width() + kBadgeSpacing, 338 SetMinSize(gfx::Size(GetPreferredSize().width() + kBadgeSpacing,
337 GetPreferredSize().height() + kBadgeSpacing + 339 GetPreferredSize().height() + kBadgeSpacing +
338 views::kRelatedControlSmallVerticalSpacing)); 340 ChromeLayoutProvider::Get()->GetDistanceMetric(
341 DISTANCE_RELATED_CONTROL_VERTICAL_SMALL)));
339 342
340 SetEnabled(false); 343 SetEnabled(false);
341 } 344 }
342 345
343 void PaintChildren(const ui::PaintContext& context) override { 346 void PaintChildren(const ui::PaintContext& context) override {
344 { 347 {
345 // Display any children (the "change photo" overlay) as a circle. 348 // Display any children (the "change photo" overlay) as a circle.
346 ui::ClipRecorder clip_recorder(context); 349 ui::ClipRecorder clip_recorder(context);
347 gfx::Rect clip_bounds = image()->GetMirroredBounds(); 350 gfx::Rect clip_bounds = image()->GetMirroredBounds();
348 gfx::Path clip_mask; 351 gfx::Path clip_mask;
349 clip_mask.addCircle( 352 clip_mask.addCircle(
350 clip_bounds.x() + clip_bounds.width() / 2, 353 clip_bounds.x() + clip_bounds.width() / 2,
351 clip_bounds.y() + clip_bounds.height() / 2, 354 clip_bounds.y() + clip_bounds.height() / 2,
352 clip_bounds.width() / 2); 355 clip_bounds.width() / 2);
353 clip_recorder.ClipPathWithAntiAliasing(clip_mask); 356 clip_recorder.ClipPathWithAntiAliasing(clip_mask);
354 View::PaintChildren(context); 357 View::PaintChildren(context);
355 } 358 }
356 359
357 ui::PaintRecorder paint_recorder( 360 ui::PaintRecorder paint_recorder(
358 context, gfx::Size(kProfileBadgeSize, kProfileBadgeSize)); 361 context, gfx::Size(kProfileBadgeSize, kProfileBadgeSize));
359 gfx::Canvas* canvas = paint_recorder.canvas(); 362 gfx::Canvas* canvas = paint_recorder.canvas();
360 if (profile_->IsSupervised()) { 363 if (profile_->IsSupervised()) {
361 gfx::Rect bounds(0, 0, kProfileBadgeSize, kProfileBadgeSize); 364 gfx::Rect bounds(0, 0, kProfileBadgeSize, kProfileBadgeSize);
362 int badge_offset = kImageSide + kBadgeSpacing - kProfileBadgeSize; 365 int badge_offset = kImageSide + kBadgeSpacing - kProfileBadgeSize;
363 gfx::Vector2d badge_offset_vector = gfx::Vector2d( 366 gfx::Vector2d badge_offset_vector = gfx::Vector2d(
364 GetMirroredXWithWidthInView(badge_offset, kProfileBadgeSize), 367 GetMirroredXWithWidthInView(badge_offset, kProfileBadgeSize),
365 badge_offset + views::kRelatedControlSmallVerticalSpacing); 368 badge_offset + ChromeLayoutProvider::Get()->GetDistanceMetric(
369 DISTANCE_RELATED_CONTROL_VERTICAL_SMALL));
366 370
367 gfx::Point center_point = bounds.CenterPoint() + badge_offset_vector; 371 gfx::Point center_point = bounds.CenterPoint() + badge_offset_vector;
368 372
369 // Paint the circular background. 373 // Paint the circular background.
370 cc::PaintFlags flags; 374 cc::PaintFlags flags;
371 flags.setAntiAlias(true); 375 flags.setAntiAlias(true);
372 flags.setColor(GetNativeTheme()->GetSystemColor( 376 flags.setColor(GetNativeTheme()->GetSystemColor(
373 ui::NativeTheme::kColorId_BubbleBackground)); 377 ui::NativeTheme::kColorId_BubbleBackground));
374 canvas->DrawCircle(center_point, kProfileBadgeSize / 2, flags); 378 canvas->DrawCircle(center_point, kProfileBadgeSize / 2, flags);
375 379
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 // Creates a new view that has the |title_card| with horizontal padding at the 442 // Creates a new view that has the |title_card| with horizontal padding at the
439 // top, an edge-to-edge separator below, and the specified |view| at the 443 // top, an edge-to-edge separator below, and the specified |view| at the
440 // bottom. 444 // bottom.
441 static views::View* AddPaddedTitleCard(views::View* view, 445 static views::View* AddPaddedTitleCard(views::View* view,
442 TitleCard* title_card, 446 TitleCard* title_card,
443 int width) { 447 int width) {
444 views::View* titled_view = new views::View(); 448 views::View* titled_view = new views::View();
445 views::GridLayout* layout = new views::GridLayout(titled_view); 449 views::GridLayout* layout = new views::GridLayout(titled_view);
446 titled_view->SetLayoutManager(layout); 450 titled_view->SetLayoutManager(layout);
447 451
452 ChromeLayoutProvider* provider = ChromeLayoutProvider::Get();
453 gfx::Insets dialog_insets =
454 provider->GetInsetsMetric(views::INSETS_DIALOG_CONTENTS);
448 // Column set 0 is a single column layout with horizontal padding at left 455 // Column set 0 is a single column layout with horizontal padding at left
449 // and right, and column set 1 is a single column layout with no padding. 456 // and right, and column set 1 is a single column layout with no padding.
450 views::ColumnSet* columns = layout->AddColumnSet(0); 457 views::ColumnSet* columns = layout->AddColumnSet(0);
451 columns->AddPaddingColumn(1, views::kButtonHEdgeMarginNew); 458 columns->AddPaddingColumn(1, dialog_insets.left());
452 int available_width = width - 2 * views::kButtonHEdgeMarginNew; 459 int available_width = width - dialog_insets.width();
453 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 0, 460 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 0,
454 views::GridLayout::FIXED, available_width, available_width); 461 views::GridLayout::FIXED, available_width, available_width);
455 columns->AddPaddingColumn(1, views::kButtonHEdgeMarginNew); 462 columns->AddPaddingColumn(1, dialog_insets.right());
456 layout->AddColumnSet(1)->AddColumn(views::GridLayout::FILL, 463 layout->AddColumnSet(1)->AddColumn(views::GridLayout::FILL,
457 views::GridLayout::FILL, 0,views::GridLayout::FIXED, width, width); 464 views::GridLayout::FILL, 0,views::GridLayout::FIXED, width, width);
458 465
459 layout->StartRowWithPadding(1, 0, 0, kVerticalSpacing); 466 layout->StartRowWithPadding(1, 0, 0, kVerticalSpacing);
460 layout->AddView(title_card); 467 layout->AddView(title_card);
461 layout->StartRowWithPadding(1, 1, 0, kVerticalSpacing); 468 layout->StartRowWithPadding(1, 1, 0, kVerticalSpacing);
462 layout->AddView(new views::Separator()); 469 layout->AddView(new views::Separator());
463 470
464 layout->StartRow(1, 1); 471 layout->StartRow(1, 1);
465 layout->AddView(view); 472 layout->AddView(view);
466 473
467 return titled_view; 474 return titled_view;
468 } 475 }
469 476
470 private: 477 private:
471 void Layout() override { 478 void Layout() override {
472 int back_button_width = back_button_->GetPreferredSize().width(); 479 int back_button_width = back_button_->GetPreferredSize().width();
473 back_button_->SetBounds(0, 0, back_button_width, height()); 480 back_button_->SetBounds(0, 0, back_button_width, height());
474 int label_padding = back_button_width + views::kButtonHEdgeMarginNew; 481 int label_padding =
482 back_button_width +
483 ChromeLayoutProvider::Get()->GetDistanceMetric(
484 views::DISTANCE_DIALOG_CONTENTS_HORIZONTAL_MARGIN);
475 int label_width = width() - 2 * label_padding; 485 int label_width = width() - 2 * label_padding;
476 DCHECK_GT(label_width, 0); 486 DCHECK_GT(label_width, 0);
477 title_label_->SetBounds(label_padding, 0, label_width, height()); 487 title_label_->SetBounds(label_padding, 0, label_width, height());
478 } 488 }
479 489
480 gfx::Size GetPreferredSize() const override { 490 gfx::Size GetPreferredSize() const override {
481 int height = std::max(title_label_->GetPreferredSize().height(), 491 int height = std::max(title_label_->GetPreferredSize().height(),
482 back_button_->GetPreferredSize().height()); 492 back_button_->GetPreferredSize().height());
483 return gfx::Size(width(), height); 493 return gfx::Size(width(), height);
484 } 494 }
(...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after
1083 const base::string16& title_text, 1093 const base::string16& title_text,
1084 const base::string16& content_text, 1094 const base::string16& content_text,
1085 const base::string16& link_text, 1095 const base::string16& link_text,
1086 const base::string16& button_text, 1096 const base::string16& button_text,
1087 bool stack_button, 1097 bool stack_button,
1088 views::Link** link, 1098 views::Link** link,
1089 views::LabelButton** button, 1099 views::LabelButton** button,
1090 views::ImageButton** close_button) { 1100 views::ImageButton** close_button) {
1091 tutorial_mode_ = tutorial_mode; 1101 tutorial_mode_ = tutorial_mode;
1092 1102
1103 // TODO(ananta)
1104 // Use the dialog framework to create a dialog here instead of manually
1105 // creating one.
1106 ChromeLayoutProvider* provider = ChromeLayoutProvider::Get();
1107
1093 views::View* view = new views::View(); 1108 views::View* view = new views::View();
1094 view->set_background(views::Background::CreateSolidBackground( 1109 view->set_background(views::Background::CreateSolidBackground(
1095 profiles::kAvatarTutorialBackgroundColor)); 1110 profiles::kAvatarTutorialBackgroundColor));
1096 view->SetBorder(views::CreateEmptyBorder( 1111
1097 views::kButtonVEdgeMarginNew, views::kButtonHEdgeMarginNew, 1112 gfx::Insets dialog_insets = provider->GetInsetsMetric(
1098 views::kButtonVEdgeMarginNew, views::kButtonHEdgeMarginNew)); 1113 views::INSETS_DIALOG_CONTENTS);
1114
1115 view->SetBorder(views::CreateEmptyBorder(dialog_insets));
1116
1117 // TODO(ananta)
1118 // This seems to add a double margin at the side. Investigate and remove if
1119 // so.
1099 views::GridLayout* layout = CreateSingleColumnLayout( 1120 views::GridLayout* layout = CreateSingleColumnLayout(
1100 view, kFixedMenuWidth - 2 * views::kButtonHEdgeMarginNew); 1121 view, kFixedMenuWidth - dialog_insets.width());
1122
1101 // Creates a second column set for buttons and links. 1123 // Creates a second column set for buttons and links.
1102 views::ColumnSet* button_columns = layout->AddColumnSet(1); 1124 views::ColumnSet* button_columns = layout->AddColumnSet(1);
1103 button_columns->AddColumn(views::GridLayout::LEADING, 1125 button_columns->AddColumn(views::GridLayout::LEADING,
1104 views::GridLayout::CENTER, 0, views::GridLayout::USE_PREF, 0, 0); 1126 views::GridLayout::CENTER, 0, views::GridLayout::USE_PREF, 0, 0);
1105 button_columns->AddPaddingColumn( 1127 button_columns->AddPaddingColumn(1,
1106 1, views::kUnrelatedControlHorizontalSpacing); 1128 provider->GetDistanceMetric(DISTANCE_UNRELATED_CONTROL_HORIZONTAL));
1107 button_columns->AddColumn(views::GridLayout::TRAILING, 1129 button_columns->AddColumn(views::GridLayout::TRAILING,
1108 views::GridLayout::CENTER, 0, views::GridLayout::USE_PREF, 0, 0); 1130 views::GridLayout::CENTER, 0, views::GridLayout::USE_PREF, 0, 0);
1109 1131
1110 // Adds title and close button if needed. 1132 // Adds title and close button if needed.
1111 const SkColor kTitleAndButtonTextColor = SK_ColorWHITE; 1133 const SkColor kTitleAndButtonTextColor = SK_ColorWHITE;
1112 views::Label* title_label = new views::Label(title_text); 1134 views::Label* title_label = new views::Label(title_text);
1113 title_label->SetMultiLine(true); 1135 title_label->SetMultiLine(true);
1114 title_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); 1136 title_label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
1115 title_label->SetAutoColorReadabilityEnabled(false); 1137 title_label->SetAutoColorReadabilityEnabled(false);
1116 title_label->SetEnabledColor(kTitleAndButtonTextColor); 1138 title_label->SetEnabledColor(kTitleAndButtonTextColor);
(...skipping 18 matching lines...) Expand all
1135 layout->StartRow(1, 0); 1157 layout->StartRow(1, 0);
1136 layout->AddView(title_label); 1158 layout->AddView(title_label);
1137 } 1159 }
1138 1160
1139 // Adds body content. 1161 // Adds body content.
1140 views::Label* content_label = new views::Label(content_text); 1162 views::Label* content_label = new views::Label(content_text);
1141 content_label->SetMultiLine(true); 1163 content_label->SetMultiLine(true);
1142 content_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); 1164 content_label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
1143 content_label->SetAutoColorReadabilityEnabled(false); 1165 content_label->SetAutoColorReadabilityEnabled(false);
1144 content_label->SetEnabledColor(profiles::kAvatarTutorialContentTextColor); 1166 content_label->SetEnabledColor(profiles::kAvatarTutorialContentTextColor);
1145 layout->StartRowWithPadding(1, 0, 0, views::kRelatedControlVerticalSpacing); 1167
1168 const int related_control_vertical =
1169 provider->GetDistanceMetric(DISTANCE_UNRELATED_CONTROL_VERTICAL);
1170
1171 layout->StartRowWithPadding(1, 0, 0, related_control_vertical);
1146 layout->AddView(content_label); 1172 layout->AddView(content_label);
1147 1173
1148 // Adds links and buttons. 1174 // Adds links and buttons.
1149 bool has_button = !button_text.empty(); 1175 bool has_button = !button_text.empty();
1150 if (has_button) { 1176 if (has_button) {
1151 *button = views::MdTextButton::CreateSecondaryUiButton(this, button_text); 1177 *button = views::MdTextButton::CreateSecondaryUiButton(this, button_text);
1152 if (ui::MaterialDesignController::IsSecondaryUiMaterial()) 1178 if (ui::MaterialDesignController::IsSecondaryUiMaterial())
1153 (*button)->SetEnabledTextColors(kTitleAndButtonTextColor); 1179 (*button)->SetEnabledTextColors(kTitleAndButtonTextColor);
1154 else 1180 else
1155 (*button)->SetHorizontalAlignment(gfx::ALIGN_CENTER); 1181 (*button)->SetHorizontalAlignment(gfx::ALIGN_CENTER);
1156 } 1182 }
1157 1183
1158 bool has_link = !link_text.empty(); 1184 bool has_link = !link_text.empty();
1159 if (has_link) { 1185 if (has_link) {
1160 *link = CreateLink(link_text, this); 1186 *link = CreateLink(link_text, this);
1161 (*link)->SetHorizontalAlignment(gfx::ALIGN_LEFT); 1187 (*link)->SetHorizontalAlignment(gfx::ALIGN_LEFT);
1162 (*link)->SetAutoColorReadabilityEnabled(false); 1188 (*link)->SetAutoColorReadabilityEnabled(false);
1163 (*link)->SetEnabledColor(kTitleAndButtonTextColor); 1189 (*link)->SetEnabledColor(kTitleAndButtonTextColor);
1164 } 1190 }
1165 1191
1192 const int unrelated_control_vertical =
1193 provider->GetDistanceMetric(DISTANCE_UNRELATED_CONTROL_VERTICAL);
1194
1166 if (stack_button) { 1195 if (stack_button) {
1167 DCHECK(has_button); 1196 DCHECK(has_button);
1168 layout->StartRowWithPadding( 1197 layout->StartRowWithPadding(1, 0, 0, unrelated_control_vertical);
1169 1, 0, 0, views::kUnrelatedControlVerticalSpacing);
1170 layout->AddView(*button); 1198 layout->AddView(*button);
1171 if (has_link) { 1199 if (has_link) {
1172 layout->StartRowWithPadding( 1200 layout->StartRowWithPadding(1, 0, 0, related_control_vertical);
1173 1, 0, 0, views::kRelatedControlVerticalSpacing);
1174 (*link)->SetHorizontalAlignment(gfx::ALIGN_CENTER); 1201 (*link)->SetHorizontalAlignment(gfx::ALIGN_CENTER);
1175 layout->AddView(*link); 1202 layout->AddView(*link);
1176 } 1203 }
1177 } else { 1204 } else {
1178 DCHECK(has_link || has_button); 1205 DCHECK(has_link || has_button);
1179 layout->StartRowWithPadding( 1206 layout->StartRowWithPadding(1, 1, 0, unrelated_control_vertical);
1180 1, 1, 0, views::kUnrelatedControlVerticalSpacing);
1181 if (has_link) 1207 if (has_link)
1182 layout->AddView(*link); 1208 layout->AddView(*link);
1183 else 1209 else
1184 layout->SkipColumns(1); 1210 layout->SkipColumns(1);
1185 if (has_button) 1211 if (has_button)
1186 layout->AddView(*button); 1212 layout->AddView(*button);
1187 else 1213 else
1188 layout->SkipColumns(1); 1214 layout->SkipColumns(1);
1189 } 1215 }
1190 1216
(...skipping 24 matching lines...) Expand all
1215 break; 1241 break;
1216 case sync_ui_util::PASSPHRASE_ERROR: 1242 case sync_ui_util::PASSPHRASE_ERROR:
1217 button_out = &sync_error_passphrase_button_; 1243 button_out = &sync_error_passphrase_button_;
1218 break; 1244 break;
1219 case sync_ui_util::NO_SYNC_ERROR: 1245 case sync_ui_util::NO_SYNC_ERROR:
1220 return nullptr; 1246 return nullptr;
1221 default: 1247 default:
1222 NOTREACHED(); 1248 NOTREACHED();
1223 } 1249 }
1224 1250
1251 ChromeLayoutProvider* provider = ChromeLayoutProvider::Get();
1252
1225 // Sets an overall horizontal layout. 1253 // Sets an overall horizontal layout.
1226 views::View* view = new views::View(); 1254 views::View* view = new views::View();
1227 views::BoxLayout* layout = new views::BoxLayout( 1255 views::BoxLayout* layout = new views::BoxLayout(
1228 views::BoxLayout::kHorizontal, kMenuEdgeMargin, kMenuEdgeMargin, 1256 views::BoxLayout::kHorizontal, kMenuEdgeMargin, kMenuEdgeMargin,
1229 views::kUnrelatedControlHorizontalSpacing); 1257 provider->GetDistanceMetric(DISTANCE_UNRELATED_CONTROL_HORIZONTAL));
1230 layout->set_cross_axis_alignment( 1258 layout->set_cross_axis_alignment(
1231 views::BoxLayout::CROSS_AXIS_ALIGNMENT_START); 1259 views::BoxLayout::CROSS_AXIS_ALIGNMENT_START);
1232 view->SetLayoutManager(layout); 1260 view->SetLayoutManager(layout);
1233 1261
1234 // Adds the sync problem icon. 1262 // Adds the sync problem icon.
1235 views::ImageView* sync_problem_icon = new views::ImageView(); 1263 views::ImageView* sync_problem_icon = new views::ImageView();
1236 sync_problem_icon->SetImage( 1264 sync_problem_icon->SetImage(
1237 gfx::CreateVectorIcon(kSyncProblemIcon, 20, gfx::kGoogleRed700)); 1265 gfx::CreateVectorIcon(kSyncProblemIcon, 20, gfx::kGoogleRed700));
1238 view->AddChildView(sync_problem_icon); 1266 view->AddChildView(sync_problem_icon);
1239 1267
1240 // Adds a vertical view to organize the error title, message, and button. 1268 // Adds a vertical view to organize the error title, message, and button.
1241 views::View* vertical_view = new views::View(); 1269 views::View* vertical_view = new views::View();
1242 views::BoxLayout* vertical_layout = 1270 const int small_vertical_spacing = provider->GetDistanceMetric(
1243 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 1271 DISTANCE_RELATED_CONTROL_VERTICAL_SMALL);
1244 views::kRelatedControlSmallVerticalSpacing); 1272 views::BoxLayout* vertical_layout = new views::BoxLayout(
1273 views::BoxLayout::kVertical, 0, 0, small_vertical_spacing);
1245 vertical_layout->set_cross_axis_alignment( 1274 vertical_layout->set_cross_axis_alignment(
1246 views::BoxLayout::CROSS_AXIS_ALIGNMENT_START); 1275 views::BoxLayout::CROSS_AXIS_ALIGNMENT_START);
1247 vertical_view->SetLayoutManager(vertical_layout); 1276 vertical_view->SetLayoutManager(vertical_layout);
1248 1277
1249 // Adds the title. 1278 // Adds the title.
1250 views::Label* title_label = new views::Label( 1279 views::Label* title_label = new views::Label(
1251 l10n_util::GetStringUTF16(IDS_SYNC_ERROR_USER_MENU_TITLE)); 1280 l10n_util::GetStringUTF16(IDS_SYNC_ERROR_USER_MENU_TITLE));
1252 title_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); 1281 title_label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
1253 title_label->SetEnabledColor(gfx::kGoogleRed700); 1282 title_label->SetEnabledColor(gfx::kGoogleRed700);
1254 vertical_view->AddChildView(title_label); 1283 vertical_view->AddChildView(title_label);
1255 1284
1256 // Adds body content. 1285 // Adds body content.
1257 views::Label* content_label = 1286 views::Label* content_label =
1258 new views::Label(l10n_util::GetStringUTF16(content_string_id)); 1287 new views::Label(l10n_util::GetStringUTF16(content_string_id));
1259 content_label->SetMultiLine(true); 1288 content_label->SetMultiLine(true);
1260 content_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); 1289 content_label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
1261 vertical_view->AddChildView(content_label); 1290 vertical_view->AddChildView(content_label);
1262 1291
1263 // Adds an action button if an action exists. 1292 // Adds an action button if an action exists.
1264 if (button_string_id) { 1293 if (button_string_id) {
1265 // If the button string is specified, then the button itself needs to be 1294 // If the button string is specified, then the button itself needs to be
1266 // already initialized. 1295 // already initialized.
1267 DCHECK(button_out); 1296 DCHECK(button_out);
1268 // Adds a padding row between error title/content and the button. 1297 // Adds a padding row between error title/content and the button.
1269 auto* padding = new views::View; 1298 auto* padding = new views::View;
1270 padding->SetPreferredSize( 1299 padding->SetPreferredSize(gfx::Size(
1271 gfx::Size(0, views::kRelatedControlVerticalSpacing)); 1300 0,
1301 provider->GetDistanceMetric(views::DISTANCE_RELATED_CONTROL_VERTICAL)));
1272 vertical_view->AddChildView(padding); 1302 vertical_view->AddChildView(padding);
1273 1303
1274 *button_out = views::MdTextButton::CreateSecondaryUiBlueButton( 1304 *button_out = views::MdTextButton::CreateSecondaryUiBlueButton(
1275 this, l10n_util::GetStringUTF16(button_string_id)); 1305 this, l10n_util::GetStringUTF16(button_string_id));
1276 vertical_view->AddChildView(*button_out); 1306 vertical_view->AddChildView(*button_out);
1277 view->SetBorder(views::CreateEmptyBorder( 1307 view->SetBorder(views::CreateEmptyBorder(0, 0, small_vertical_spacing, 0));
1278 0, 0, views::kRelatedControlSmallVerticalSpacing, 0));
1279 } 1308 }
1280 1309
1281 view->AddChildView(vertical_view); 1310 view->AddChildView(vertical_view);
1282 return view; 1311 return view;
1283 } 1312 }
1284 1313
1285 views::View* ProfileChooserView::CreateCurrentProfileView( 1314 views::View* ProfileChooserView::CreateCurrentProfileView(
1286 const AvatarMenu::Item& avatar_item, 1315 const AvatarMenu::Item& avatar_item,
1287 bool is_guest) { 1316 bool is_guest) {
1317 ChromeLayoutProvider* provider = ChromeLayoutProvider::Get();
1318
1288 views::View* view = new views::View(); 1319 views::View* view = new views::View();
1289 view->SetLayoutManager( 1320 const int vertical_spacing_small =
1290 new views::BoxLayout(views::BoxLayout::kVertical, 0, 1321 provider->GetDistanceMetric(DISTANCE_RELATED_CONTROL_VERTICAL_SMALL);
1291 views::kRelatedControlVerticalSpacing, 0)); 1322 view->SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0,
1323 vertical_spacing_small, 0));
1292 1324
1293 // Container for the profile photo and avatar/user name. 1325 // Container for the profile photo and avatar/user name.
1294 BackgroundColorHoverButton* current_profile_card = 1326 BackgroundColorHoverButton* current_profile_card =
1295 new BackgroundColorHoverButton(this, base::string16()); 1327 new BackgroundColorHoverButton(this, base::string16());
1296 views::GridLayout* grid_layout = new views::GridLayout(current_profile_card); 1328 views::GridLayout* grid_layout = new views::GridLayout(current_profile_card);
1297 current_profile_card->SetLayoutManager(grid_layout); 1329 current_profile_card->SetLayoutManager(grid_layout);
1298 views::ColumnSet* columns = grid_layout->AddColumnSet(0); 1330 views::ColumnSet* columns = grid_layout->AddColumnSet(0);
1299 // BackgroundColorHoverButton has already accounted for the left and right 1331 // BackgroundColorHoverButton has already accounted for the left and right
1300 // margins. 1332 // margins.
1301 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 0, 1333 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 0,
1302 views::GridLayout::USE_PREF, 0, 0); 1334 views::GridLayout::USE_PREF, 0, 0);
1303 columns->AddPaddingColumn(0, kMenuEdgeMargin - kBadgeSpacing); 1335 columns->AddPaddingColumn(0, kMenuEdgeMargin - kBadgeSpacing);
1304 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 1, 1336 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 1,
1305 views::GridLayout::USE_PREF, 0, 0); 1337 views::GridLayout::USE_PREF, 0, 0);
1306 grid_layout->AddPaddingRow(0, 0); 1338 grid_layout->AddPaddingRow(0, 0);
1307 const int num_labels = 1339 const int num_labels =
1308 (avatar_item.signed_in && !switches::IsEnableAccountConsistency()) ? 2 1340 (avatar_item.signed_in && !switches::IsEnableAccountConsistency()) ? 2
1309 : 1; 1341 : 1;
1310 int profile_card_height = 1342 int profile_card_height =
1311 kImageSide + 1343 kImageSide + 2 * (kBadgeSpacing + vertical_spacing_small);
1312 2 * (kBadgeSpacing + views::kRelatedControlSmallVerticalSpacing);
1313 const int line_height = profile_card_height / num_labels; 1344 const int line_height = profile_card_height / num_labels;
1314 grid_layout->StartRow(0, 0, line_height); 1345 grid_layout->StartRow(0, 0, line_height);
1315 current_profile_card_ = current_profile_card; 1346 current_profile_card_ = current_profile_card;
1316 1347
1317 // Profile picture, left-aligned. 1348 // Profile picture, left-aligned.
1318 EditableProfilePhoto* current_profile_photo = new EditableProfilePhoto( 1349 EditableProfilePhoto* current_profile_photo = new EditableProfilePhoto(
1319 this, avatar_item.icon, !is_guest, browser_->profile()); 1350 this, avatar_item.icon, !is_guest, browser_->profile());
1320 1351
1321 // Profile name, left-aligned to the right of profile icon. 1352 // Profile name, left-aligned to the right of profile icon.
1322 views::Label* current_profile_name = new views::Label( 1353 views::Label* current_profile_name = new views::Label(
1323 profiles::GetAvatarNameForProfile(browser_->profile()->GetPath())); 1354 profiles::GetAvatarNameForProfile(browser_->profile()->GetPath()));
1324 current_profile_card->set_title(current_profile_name); 1355 current_profile_card->set_title(current_profile_name);
1325 current_profile_name->SetAutoColorReadabilityEnabled(false); 1356 current_profile_name->SetAutoColorReadabilityEnabled(false);
1326 current_profile_name->SetFontList( 1357 current_profile_name->SetFontList(
1327 ui::ResourceBundle::GetSharedInstance().GetFontListWithDelta( 1358 ui::ResourceBundle::GetSharedInstance().GetFontListWithDelta(
1328 1, gfx::Font::FontStyle::NORMAL, gfx::Font::Weight::MEDIUM)); 1359 1, gfx::Font::FontStyle::NORMAL, gfx::Font::Weight::MEDIUM));
1329 current_profile_name->SetHorizontalAlignment(gfx::ALIGN_LEFT); 1360 current_profile_name->SetHorizontalAlignment(gfx::ALIGN_LEFT);
1330 1361
1331 // The grid layout contains one row if not signed in or account consistency is 1362 // The grid layout contains one row if not signed in or account consistency is
1332 // enabled. It contains 2 rows if signed in and account consistency is 1363 // enabled. It contains 2 rows if signed in and account consistency is
1333 // disabled (the second row is for the email label). For the second case the 1364 // disabled (the second row is for the email label). For the second case the
1334 // profile photo has to be over 2 rows. 1365 // profile photo has to be over 2 rows.
1335 grid_layout->AddView(current_profile_photo, 1, num_labels); 1366 grid_layout->AddView(current_profile_photo, 1, num_labels);
1336 grid_layout->AddView(current_profile_name, 1, 1, views::GridLayout::LEADING, 1367 grid_layout->AddView(current_profile_name, 1, 1, views::GridLayout::LEADING,
1337 (num_labels == 2) ? views::GridLayout::TRAILING 1368 (num_labels == 2) ? views::GridLayout::TRAILING
1338 : views::GridLayout::CENTER); 1369 : views::GridLayout::CENTER);
1339 current_profile_card_->SetMinSize(gfx::Size( 1370 current_profile_card_->SetMinSize(gfx::Size(
1340 kFixedMenuWidth, current_profile_photo->GetPreferredSize().height() + 1371 kFixedMenuWidth, current_profile_photo->GetPreferredSize().height() +
1341 2 * views::kRelatedControlSmallVerticalSpacing)); 1372 2 * vertical_spacing_small));
1342 view->AddChildView(current_profile_card_); 1373 view->AddChildView(current_profile_card_);
1343 1374
1344 if (is_guest) { 1375 if (is_guest) {
1345 current_profile_card_->SetEnabled(false); 1376 current_profile_card_->SetEnabled(false);
1346 return view; 1377 return view;
1347 } 1378 }
1348 1379
1349 const base::string16 profile_name = 1380 const base::string16 profile_name =
1350 profiles::GetAvatarNameForProfile(browser_->profile()->GetPath()); 1381 profiles::GetAvatarNameForProfile(browser_->profile()->GetPath());
1351 1382
(...skipping 29 matching lines...) Expand all
1381 IDS_PROFILES_EDIT_SIGNED_IN_PROFILE_ACCESSIBLE_NAME, 1412 IDS_PROFILES_EDIT_SIGNED_IN_PROFILE_ACCESSIBLE_NAME,
1382 profile_name, 1413 profile_name,
1383 avatar_item.username)); 1414 avatar_item.username));
1384 return view; 1415 return view;
1385 } 1416 }
1386 1417
1387 SigninManagerBase* signin_manager = SigninManagerFactory::GetForProfile( 1418 SigninManagerBase* signin_manager = SigninManagerFactory::GetForProfile(
1388 browser_->profile()->GetOriginalProfile()); 1419 browser_->profile()->GetOriginalProfile());
1389 if (signin_manager->IsSigninAllowed()) { 1420 if (signin_manager->IsSigninAllowed()) {
1390 views::View* extra_links_view = new views::View(); 1421 views::View* extra_links_view = new views::View();
1391 views::BoxLayout* extra_links_layout = new views::BoxLayout( 1422 views::BoxLayout* extra_links_layout =
1392 views::BoxLayout::kVertical, kMenuEdgeMargin, 1423 new views::BoxLayout(
1393 views::kRelatedControlVerticalSpacing, kMenuEdgeMargin); 1424 views::BoxLayout::kVertical, kMenuEdgeMargin,
1425 provider->GetDistanceMetric(
1426 views::DISTANCE_RELATED_CONTROL_VERTICAL),
1427 kMenuEdgeMargin);
1394 extra_links_layout->set_cross_axis_alignment( 1428 extra_links_layout->set_cross_axis_alignment(
1395 views::BoxLayout::CROSS_AXIS_ALIGNMENT_START); 1429 views::BoxLayout::CROSS_AXIS_ALIGNMENT_START);
1396 extra_links_view->SetLayoutManager(extra_links_layout); 1430 extra_links_view->SetLayoutManager(extra_links_layout);
1397 views::Label* promo = 1431 views::Label* promo =
1398 new views::Label(l10n_util::GetStringUTF16(IDS_PROFILES_SIGNIN_PROMO)); 1432 new views::Label(l10n_util::GetStringUTF16(IDS_PROFILES_SIGNIN_PROMO));
1399 promo->SetMultiLine(true); 1433 promo->SetMultiLine(true);
1400 promo->SetHorizontalAlignment(gfx::ALIGN_LEFT); 1434 promo->SetHorizontalAlignment(gfx::ALIGN_LEFT);
1401 extra_links_view->AddChildView(promo); 1435 extra_links_view->AddChildView(promo);
1402 1436
1403 signin_current_profile_button_ = 1437 signin_current_profile_button_ =
1404 views::MdTextButton::CreateSecondaryUiBlueButton( 1438 views::MdTextButton::CreateSecondaryUiBlueButton(
1405 this, l10n_util::GetStringFUTF16( 1439 this, l10n_util::GetStringFUTF16(
1406 IDS_SYNC_START_SYNC_BUTTON_LABEL, 1440 IDS_SYNC_START_SYNC_BUTTON_LABEL,
1407 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME))); 1441 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME)));
1408 extra_links_view->AddChildView(signin_current_profile_button_); 1442 extra_links_view->AddChildView(signin_current_profile_button_);
1409 base::RecordAction( 1443 base::RecordAction(
1410 base::UserMetricsAction("Signin_Impression_FromAvatarBubbleSignin")); 1444 base::UserMetricsAction("Signin_Impression_FromAvatarBubbleSignin"));
1411 extra_links_view->SetBorder(views::CreateEmptyBorder( 1445 extra_links_view->SetBorder(
1412 0, 0, views::kRelatedControlSmallVerticalSpacing, 0)); 1446 views::CreateEmptyBorder(0, 0, vertical_spacing_small, 0));
1413 view->AddChildView(extra_links_view); 1447 view->AddChildView(extra_links_view);
1414 } 1448 }
1415 1449
1416 current_profile_card_->SetAccessibleName( 1450 current_profile_card_->SetAccessibleName(
1417 l10n_util::GetStringFUTF16( 1451 l10n_util::GetStringFUTF16(
1418 IDS_PROFILES_EDIT_PROFILE_ACCESSIBLE_NAME, profile_name)); 1452 IDS_PROFILES_EDIT_PROFILE_ACCESSIBLE_NAME, profile_name));
1419 return view; 1453 return view;
1420 } 1454 }
1421 1455
1422 views::View* ProfileChooserView::CreateGuestProfileView() { 1456 views::View* ProfileChooserView::CreateGuestProfileView() {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1459 layout->AddView(new views::Separator()); 1493 layout->AddView(new views::Separator());
1460 layout->StartRow(1, 0); 1494 layout->StartRow(1, 0);
1461 layout->AddView(button); 1495 layout->AddView(button);
1462 } 1496 }
1463 1497
1464 return view; 1498 return view;
1465 } 1499 }
1466 1500
1467 views::View* ProfileChooserView::CreateOptionsView(bool display_lock, 1501 views::View* ProfileChooserView::CreateOptionsView(bool display_lock,
1468 AvatarMenu* avatar_menu) { 1502 AvatarMenu* avatar_menu) {
1503 ChromeLayoutProvider* provider = ChromeLayoutProvider::Get();
1504 const int vertical_spacing =
1505 provider->GetDistanceMetric(views::DISTANCE_RELATED_CONTROL_VERTICAL);
1469 views::View* view = new views::View(); 1506 views::View* view = new views::View();
1470 views::GridLayout* layout = CreateSingleColumnLayout(view, kFixedMenuWidth); 1507 views::GridLayout* layout = CreateSingleColumnLayout(view, kFixedMenuWidth);
1471 1508
1472 const bool is_guest = browser_->profile()->IsGuestSession(); 1509 const bool is_guest = browser_->profile()->IsGuestSession();
1473 const int kIconSize = 20; 1510 const int kIconSize = 20;
1474 // Add the user switching buttons 1511 // Add the user switching buttons
1475 const int kProfileIconSize = 18; 1512 const int kProfileIconSize = 18;
1476 layout->StartRowWithPadding(1, 0, 0, views::kRelatedControlVerticalSpacing); 1513 layout->StartRowWithPadding(1, 0, 0, vertical_spacing);
1477 for (size_t i = 0; i < avatar_menu->GetNumberOfItems(); ++i) { 1514 for (size_t i = 0; i < avatar_menu->GetNumberOfItems(); ++i) {
1478 const AvatarMenu::Item& item = avatar_menu->GetItemAt(i); 1515 const AvatarMenu::Item& item = avatar_menu->GetItemAt(i);
1479 if (!item.active) { 1516 if (!item.active) {
1480 gfx::Image image = profiles::GetSizedAvatarIcon( 1517 gfx::Image image = profiles::GetSizedAvatarIcon(
1481 item.icon, true, kProfileIconSize, kProfileIconSize, 1518 item.icon, true, kProfileIconSize, kProfileIconSize,
1482 profiles::SHAPE_CIRCLE); 1519 profiles::SHAPE_CIRCLE);
1483 views::LabelButton* button = new BackgroundColorHoverButton( 1520 views::LabelButton* button = new BackgroundColorHoverButton(
1484 this, profiles::GetProfileSwitcherTextForItem(item), 1521 this, profiles::GetProfileSwitcherTextForItem(item),
1485 *image.ToImageSkia()); 1522 *image.ToImageSkia());
1486 button->SetImageLabelSpacing(kMenuEdgeMargin); 1523 button->SetImageLabelSpacing(kMenuEdgeMargin);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1535 close_all_windows_button_ = new BackgroundColorHoverButton( 1572 close_all_windows_button_ = new BackgroundColorHoverButton(
1536 this, 1573 this,
1537 l10n_util::GetStringUTF16(IDS_PROFILES_CLOSE_ALL_WINDOWS_BUTTON), 1574 l10n_util::GetStringUTF16(IDS_PROFILES_CLOSE_ALL_WINDOWS_BUTTON),
1538 gfx::CreateVectorIcon(kCloseAllIcon, kIconSize, 1575 gfx::CreateVectorIcon(kCloseAllIcon, kIconSize,
1539 gfx::kChromeIconGrey)); 1576 gfx::kChromeIconGrey));
1540 layout->StartRow(1, 0); 1577 layout->StartRow(1, 0);
1541 layout->AddView(close_all_windows_button_); 1578 layout->AddView(close_all_windows_button_);
1542 } 1579 }
1543 } 1580 }
1544 1581
1545 layout->StartRowWithPadding(1, 0, 0, views::kRelatedControlVerticalSpacing); 1582 layout->StartRowWithPadding(1, 0, 0, vertical_spacing);
1546 return view; 1583 return view;
1547 } 1584 }
1548 1585
1549 views::View* ProfileChooserView::CreateSupervisedUserDisclaimerView() { 1586 views::View* ProfileChooserView::CreateSupervisedUserDisclaimerView() {
1550 views::View* view = new views::View(); 1587 views::View* view = new views::View();
1551 int horizontal_margin = kMenuEdgeMargin; 1588 int horizontal_margin = kMenuEdgeMargin;
1552 views::GridLayout* layout = 1589 views::GridLayout* layout =
1553 CreateSingleColumnLayout(view, kFixedMenuWidth - 2 * horizontal_margin); 1590 CreateSingleColumnLayout(view, kFixedMenuWidth - 2 * horizontal_margin);
1554 view->SetBorder(views::CreateEmptyBorder(0, horizontal_margin, 1591 view->SetBorder(views::CreateEmptyBorder(0, horizontal_margin,
1555 kMenuEdgeMargin, horizontal_margin)); 1592 kMenuEdgeMargin, horizontal_margin));
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1588 // The primary account should always be listed first. 1625 // The primary account should always be listed first.
1589 // TODO(rogerta): we still need to further differentiate the primary account 1626 // TODO(rogerta): we still need to further differentiate the primary account
1590 // from the others in the UI, so more work is likely required here: 1627 // from the others in the UI, so more work is likely required here:
1591 // crbug.com/311124. 1628 // crbug.com/311124.
1592 CreateAccountButton(layout, primary_account, true, 1629 CreateAccountButton(layout, primary_account, true,
1593 error_account_id == primary_account, kFixedMenuWidth); 1630 error_account_id == primary_account, kFixedMenuWidth);
1594 for (size_t i = 0; i < accounts.size(); ++i) 1631 for (size_t i = 0; i < accounts.size(); ++i)
1595 CreateAccountButton(layout, accounts[i], false, 1632 CreateAccountButton(layout, accounts[i], false,
1596 error_account_id == accounts[i], kFixedMenuWidth); 1633 error_account_id == accounts[i], kFixedMenuWidth);
1597 1634
1635 ChromeLayoutProvider* provider = ChromeLayoutProvider::Get();
1636 const int vertical_spacing =
1637 provider->GetDistanceMetric(views::DISTANCE_RELATED_CONTROL_VERTICAL);
1598 if (!profile->IsSupervised()) { 1638 if (!profile->IsSupervised()) {
1599 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); 1639 layout->AddPaddingRow(0, vertical_spacing);
1600 1640
1601 add_account_link_ = CreateLink(l10n_util::GetStringFUTF16( 1641 add_account_link_ = CreateLink(l10n_util::GetStringFUTF16(
1602 IDS_PROFILES_PROFILE_ADD_ACCOUNT_BUTTON, avatar_item.name), this); 1642 IDS_PROFILES_PROFILE_ADD_ACCOUNT_BUTTON, avatar_item.name), this);
1603 add_account_link_->SetBorder( 1643 add_account_link_->SetBorder(views::CreateEmptyBorder(
1604 views::CreateEmptyBorder(0, views::kButtonVEdgeMarginNew, 1644 0,
1605 views::kRelatedControlVerticalSpacing, 0)); 1645 provider->GetInsetsMetric(views::INSETS_DIALOG_CONTENTS).left(),
1646 vertical_spacing, 0));
1606 layout->StartRow(1, 0); 1647 layout->StartRow(1, 0);
1607 layout->AddView(add_account_link_); 1648 layout->AddView(add_account_link_);
1608 } 1649 }
1609 1650
1610 return view; 1651 return view;
1611 } 1652 }
1612 1653
1613 void ProfileChooserView::CreateAccountButton(views::GridLayout* layout, 1654 void ProfileChooserView::CreateAccountButton(views::GridLayout* layout,
1614 const std::string& account_id, 1655 const std::string& account_id,
1615 bool is_primary_account, 1656 bool is_primary_account,
1616 bool reauth_required, 1657 bool reauth_required,
1617 int width) { 1658 int width) {
1659 ChromeLayoutProvider* provider = ChromeLayoutProvider::Get();
1618 std::string email = signin_ui_util::GetDisplayEmail(browser_->profile(), 1660 std::string email = signin_ui_util::GetDisplayEmail(browser_->profile(),
1619 account_id); 1661 account_id);
1620 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); 1662 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance();
1621 const gfx::ImageSkia* delete_default_image = 1663 const gfx::ImageSkia* delete_default_image =
1622 rb->GetImageNamed(IDR_CLOSE_1).ToImageSkia(); 1664 rb->GetImageNamed(IDR_CLOSE_1).ToImageSkia();
1623 const int kDeleteButtonWidth = delete_default_image->width(); 1665 const int kDeleteButtonWidth = delete_default_image->width();
1624 gfx::ImageSkia warning_default_image; 1666 gfx::ImageSkia warning_default_image;
1625 int warning_button_width = 0; 1667 int warning_button_width = 0;
1626 if (reauth_required) { 1668 if (reauth_required) {
1627 const int kIconSize = 18; 1669 const int kIconSize = 18;
1628 warning_default_image = gfx::CreateVectorIcon(ui::kWarningIcon, kIconSize, 1670 warning_default_image = gfx::CreateVectorIcon(ui::kWarningIcon, kIconSize,
1629 gfx::kChromeIconGrey); 1671 gfx::kChromeIconGrey);
1630 warning_button_width = kIconSize + views::kRelatedButtonHSpacing; 1672 warning_button_width =
1673 kIconSize +
1674 provider->GetDistanceMetric(views::DISTANCE_RELATED_BUTTON_HORIZONTAL);
1631 } 1675 }
1632 int available_width = width - 2 * views::kButtonHEdgeMarginNew - 1676
1633 kDeleteButtonWidth - warning_button_width; 1677 gfx::Insets dialog_insets =
1678 provider->GetInsetsMetric(views::INSETS_DIALOG_CONTENTS);
1679
1680 int available_width = width - dialog_insets.width() -
1681 kDeleteButtonWidth - warning_button_width;
1634 views::LabelButton* email_button = new BackgroundColorHoverButton( 1682 views::LabelButton* email_button = new BackgroundColorHoverButton(
1635 this, base::UTF8ToUTF16(email), warning_default_image); 1683 this, base::UTF8ToUTF16(email), warning_default_image);
1636 email_button->SetEnabled(reauth_required); 1684 email_button->SetEnabled(reauth_required);
1637 email_button->SetElideBehavior(gfx::ELIDE_EMAIL); 1685 email_button->SetElideBehavior(gfx::ELIDE_EMAIL);
1638 email_button->SetMinSize(gfx::Size(0, kButtonHeight)); 1686 email_button->SetMinSize(gfx::Size(0, kButtonHeight));
1639 email_button->SetMaxSize(gfx::Size(available_width, kButtonHeight)); 1687 email_button->SetMaxSize(gfx::Size(available_width, kButtonHeight));
1640 layout->StartRow(1, 0); 1688 layout->StartRow(1, 0);
1641 layout->AddView(email_button); 1689 layout->AddView(email_button);
1642 1690
1643 if (reauth_required) 1691 if (reauth_required)
1644 reauth_account_button_map_[email_button] = account_id; 1692 reauth_account_button_map_[email_button] = account_id;
1645 1693
1646 // Delete button. 1694 // Delete button.
1647 if (!browser_->profile()->IsSupervised()) { 1695 if (!browser_->profile()->IsSupervised()) {
1648 views::ImageButton* delete_button = new views::ImageButton(this); 1696 views::ImageButton* delete_button = new views::ImageButton(this);
1649 delete_button->SetImageAlignment(views::ImageButton::ALIGN_RIGHT, 1697 delete_button->SetImageAlignment(views::ImageButton::ALIGN_RIGHT,
1650 views::ImageButton::ALIGN_MIDDLE); 1698 views::ImageButton::ALIGN_MIDDLE);
1651 delete_button->SetImage(views::ImageButton::STATE_NORMAL, 1699 delete_button->SetImage(views::ImageButton::STATE_NORMAL,
1652 delete_default_image); 1700 delete_default_image);
1653 delete_button->SetImage(views::ImageButton::STATE_HOVERED, 1701 delete_button->SetImage(views::ImageButton::STATE_HOVERED,
1654 rb->GetImageSkiaNamed(IDR_CLOSE_1_H)); 1702 rb->GetImageSkiaNamed(IDR_CLOSE_1_H));
1655 delete_button->SetImage(views::ImageButton::STATE_PRESSED, 1703 delete_button->SetImage(views::ImageButton::STATE_PRESSED,
1656 rb->GetImageSkiaNamed(IDR_CLOSE_1_P)); 1704 rb->GetImageSkiaNamed(IDR_CLOSE_1_P));
1657 delete_button->SetBounds( 1705 delete_button->SetBounds(
1658 width - views::kButtonHEdgeMarginNew - kDeleteButtonWidth, 1706 width -
1707 provider->GetInsetsMetric(views::INSETS_DIALOG_CONTENTS).right() -
1708 kDeleteButtonWidth,
1659 0, kDeleteButtonWidth, kButtonHeight); 1709 0, kDeleteButtonWidth, kButtonHeight);
1660 1710
1661 email_button->set_notify_enter_exit_on_child(true); 1711 email_button->set_notify_enter_exit_on_child(true);
1662 email_button->AddChildView(delete_button); 1712 email_button->AddChildView(delete_button);
1663 1713
1664 // Save the original email address, as the button text could be elided. 1714 // Save the original email address, as the button text could be elided.
1665 delete_account_button_map_[delete_button] = account_id; 1715 delete_account_button_map_[delete_button] = account_id;
1666 } 1716 }
1667 } 1717 }
1668 1718
1669 views::View* ProfileChooserView::CreateAccountRemovalView() { 1719 views::View* ProfileChooserView::CreateAccountRemovalView() {
1720 ChromeLayoutProvider* provider = ChromeLayoutProvider::Get();
1721
1722 gfx::Insets dialog_insets = provider->GetInsetsMetric(
1723 views::INSETS_DIALOG_CONTENTS);
1724
1670 views::View* view = new views::View(); 1725 views::View* view = new views::View();
1671 views::GridLayout* layout = CreateSingleColumnLayout( 1726 views::GridLayout* layout = CreateSingleColumnLayout(
1672 view, kFixedAccountRemovalViewWidth - 2 * views::kButtonHEdgeMarginNew); 1727 view, kFixedAccountRemovalViewWidth - dialog_insets.width());
1673 view->SetBorder(views::CreateEmptyBorder(0, views::kButtonHEdgeMarginNew, 1728
1674 views::kButtonVEdgeMarginNew, 1729 view->SetBorder(
1675 views::kButtonHEdgeMarginNew)); 1730 views::CreateEmptyBorder(0, dialog_insets.left(),
1731 dialog_insets.bottom(), dialog_insets.right()));
1676 1732
1677 const std::string& primary_account = SigninManagerFactory::GetForProfile( 1733 const std::string& primary_account = SigninManagerFactory::GetForProfile(
1678 browser_->profile())->GetAuthenticatedAccountId(); 1734 browser_->profile())->GetAuthenticatedAccountId();
1679 bool is_primary_account = primary_account == account_id_to_remove_; 1735 bool is_primary_account = primary_account == account_id_to_remove_;
1680 1736
1737 const int unrelated_vertical_spacing =
1738 provider->GetDistanceMetric(DISTANCE_UNRELATED_CONTROL_VERTICAL);
1739
1681 // Adds main text. 1740 // Adds main text.
1682 layout->StartRowWithPadding(1, 0, 0, views::kUnrelatedControlVerticalSpacing); 1741 layout->StartRowWithPadding(1, 0, 0, unrelated_vertical_spacing);
1683 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); 1742 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance();
1684 const gfx::FontList& small_font_list = 1743 const gfx::FontList& small_font_list =
1685 rb->GetFontList(ui::ResourceBundle::SmallFont); 1744 rb->GetFontList(ui::ResourceBundle::SmallFont);
1686 1745
1687 if (is_primary_account) { 1746 if (is_primary_account) {
1688 std::string email = signin_ui_util::GetDisplayEmail(browser_->profile(), 1747 std::string email = signin_ui_util::GetDisplayEmail(browser_->profile(),
1689 account_id_to_remove_); 1748 account_id_to_remove_);
1690 std::vector<size_t> offsets; 1749 std::vector<size_t> offsets;
1691 const base::string16 settings_text = 1750 const base::string16 settings_text =
1692 l10n_util::GetStringUTF16(IDS_PROFILES_SETTINGS_LINK); 1751 l10n_util::GetStringUTF16(IDS_PROFILES_SETTINGS_LINK);
(...skipping 15 matching lines...) Expand all
1708 content_label->SetFontList(small_font_list); 1767 content_label->SetFontList(small_font_list);
1709 layout->AddView(content_label); 1768 layout->AddView(content_label);
1710 } 1769 }
1711 1770
1712 // Adds button. 1771 // Adds button.
1713 if (!is_primary_account) { 1772 if (!is_primary_account) {
1714 remove_account_button_ = views::MdTextButton::CreateSecondaryUiBlueButton( 1773 remove_account_button_ = views::MdTextButton::CreateSecondaryUiBlueButton(
1715 this, l10n_util::GetStringUTF16(IDS_PROFILES_ACCOUNT_REMOVAL_BUTTON)); 1774 this, l10n_util::GetStringUTF16(IDS_PROFILES_ACCOUNT_REMOVAL_BUTTON));
1716 remove_account_button_->SetHorizontalAlignment( 1775 remove_account_button_->SetHorizontalAlignment(
1717 gfx::ALIGN_CENTER); 1776 gfx::ALIGN_CENTER);
1718 layout->StartRowWithPadding( 1777 layout->StartRowWithPadding(1, 0, 0, unrelated_vertical_spacing);
1719 1, 0, 0, views::kUnrelatedControlVerticalSpacing);
1720 layout->AddView(remove_account_button_); 1778 layout->AddView(remove_account_button_);
1721 } else { 1779 } else {
1722 layout->AddPaddingRow(0, views::kUnrelatedControlVerticalSpacing); 1780 layout->AddPaddingRow(0, unrelated_vertical_spacing);
1723 } 1781 }
1724 1782
1725 TitleCard* title_card = new TitleCard( 1783 TitleCard* title_card = new TitleCard(
1726 l10n_util::GetStringUTF16(IDS_PROFILES_ACCOUNT_REMOVAL_TITLE), 1784 l10n_util::GetStringUTF16(IDS_PROFILES_ACCOUNT_REMOVAL_TITLE),
1727 this, &account_removal_cancel_button_); 1785 this, &account_removal_cancel_button_);
1728 return TitleCard::AddPaddedTitleCard(view, title_card, 1786 return TitleCard::AddPaddedTitleCard(view, title_card,
1729 kFixedAccountRemovalViewWidth); 1787 kFixedAccountRemovalViewWidth);
1730 } 1788 }
1731 1789
1732 views::View* ProfileChooserView::CreateWelcomeUpgradeTutorialView( 1790 views::View* ProfileChooserView::CreateWelcomeUpgradeTutorialView(
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1780 last_login_result, 1838 last_login_result,
1781 l10n_util::GetStringUTF16(IDS_PROFILES_PROFILE_TUTORIAL_LEARN_MORE), 1839 l10n_util::GetStringUTF16(IDS_PROFILES_PROFILE_TUTORIAL_LEARN_MORE),
1782 base::string16(), 1840 base::string16(),
1783 false /* stack_button */, 1841 false /* stack_button */,
1784 &tutorial_learn_more_link_, 1842 &tutorial_learn_more_link_,
1785 NULL, 1843 NULL,
1786 &tutorial_close_button_); 1844 &tutorial_close_button_);
1787 } 1845 }
1788 1846
1789 views::View* ProfileChooserView::CreateSwitchUserView() { 1847 views::View* ProfileChooserView::CreateSwitchUserView() {
1848 ChromeLayoutProvider* provider = ChromeLayoutProvider::Get();
1790 views::View* view = new views::View(); 1849 views::View* view = new views::View();
1791 views::GridLayout* layout = CreateSingleColumnLayout( 1850 views::GridLayout* layout = CreateSingleColumnLayout(
1792 view, kFixedSwitchUserViewWidth); 1851 view, kFixedSwitchUserViewWidth);
1793 views::ColumnSet* columns = layout->AddColumnSet(1); 1852 views::ColumnSet* columns = layout->AddColumnSet(1);
1794 columns->AddPaddingColumn(0, views::kButtonHEdgeMarginNew); 1853 gfx::Insets dialog_insets = provider->GetInsetsMetric(
1795 int label_width = 1854 views::INSETS_DIALOG_CONTENTS);
1796 kFixedSwitchUserViewWidth - 2 * views::kButtonHEdgeMarginNew; 1855 columns->AddPaddingColumn(0, dialog_insets.left());
1856 int label_width = kFixedSwitchUserViewWidth - dialog_insets.width();
1797 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 0, 1857 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 0,
1798 views::GridLayout::FIXED, label_width, label_width); 1858 views::GridLayout::FIXED, label_width, label_width);
1799 columns->AddPaddingColumn(0, views::kButtonHEdgeMarginNew); 1859 columns->AddPaddingColumn(0, dialog_insets.right());
1860
1861 const int unrelated_vertical_spacing =
1862 provider->GetDistanceMetric(DISTANCE_UNRELATED_CONTROL_VERTICAL);
1800 1863
1801 // Adds main text. 1864 // Adds main text.
1802 layout->StartRowWithPadding(1, 1, 0, views::kUnrelatedControlVerticalSpacing); 1865 layout->StartRowWithPadding(1, 1, 0, unrelated_vertical_spacing);
1803 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); 1866 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance();
1804 const gfx::FontList& small_font_list = 1867 const gfx::FontList& small_font_list =
1805 rb->GetFontList(ui::ResourceBundle::SmallFont); 1868 rb->GetFontList(ui::ResourceBundle::SmallFont);
1806 const AvatarMenu::Item& avatar_item = 1869 const AvatarMenu::Item& avatar_item =
1807 avatar_menu_->GetItemAt(avatar_menu_->GetActiveProfileIndex()); 1870 avatar_menu_->GetItemAt(avatar_menu_->GetActiveProfileIndex());
1808 views::Label* content_label = new views::Label( 1871 views::Label* content_label = new views::Label(
1809 l10n_util::GetStringFUTF16( 1872 l10n_util::GetStringFUTF16(
1810 IDS_PROFILES_NOT_YOU_CONTENT_TEXT, avatar_item.name)); 1873 IDS_PROFILES_NOT_YOU_CONTENT_TEXT, avatar_item.name));
1811 content_label->SetMultiLine(true); 1874 content_label->SetMultiLine(true);
1812 content_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); 1875 content_label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
1813 content_label->SetFontList(small_font_list); 1876 content_label->SetFontList(small_font_list);
1814 layout->AddView(content_label); 1877 layout->AddView(content_label);
1815 1878
1816 // Adds "Add person" button. 1879 // Adds "Add person" button.
1817 layout->StartRowWithPadding(1, 0, 0, views::kUnrelatedControlVerticalSpacing); 1880 layout->StartRowWithPadding(1, 0, 0, unrelated_vertical_spacing);
1818 layout->AddView(new views::Separator()); 1881 layout->AddView(new views::Separator());
1819 1882
1820 const int kIconSize = 24; 1883 const int kIconSize = 24;
1821 add_person_button_ = new BackgroundColorHoverButton( 1884 add_person_button_ = new BackgroundColorHoverButton(
1822 this, l10n_util::GetStringUTF16(IDS_PROFILES_ADD_PERSON_BUTTON), 1885 this, l10n_util::GetStringUTF16(IDS_PROFILES_ADD_PERSON_BUTTON),
1823 gfx::CreateVectorIcon(kAccountBoxIcon, kIconSize, gfx::kChromeIconGrey)); 1886 gfx::CreateVectorIcon(kAccountBoxIcon, kIconSize, gfx::kChromeIconGrey));
1824 layout->StartRow(1, 0); 1887 layout->StartRow(1, 0);
1825 layout->AddView(add_person_button_); 1888 layout->AddView(add_person_button_);
1826 1889
1827 // Adds "Disconnect your Google Account" button. 1890 // Adds "Disconnect your Google Account" button.
(...skipping 18 matching lines...) Expand all
1846 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != 1909 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) !=
1847 IncognitoModePrefs::DISABLED; 1910 IncognitoModePrefs::DISABLED;
1848 return incognito_available && !browser_->profile()->IsGuestSession(); 1911 return incognito_available && !browser_->profile()->IsGuestSession();
1849 } 1912 }
1850 1913
1851 void ProfileChooserView::PostActionPerformed( 1914 void ProfileChooserView::PostActionPerformed(
1852 ProfileMetrics::ProfileDesktopMenu action_performed) { 1915 ProfileMetrics::ProfileDesktopMenu action_performed) {
1853 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); 1916 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_);
1854 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; 1917 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE;
1855 } 1918 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698