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

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

Issue 2902873002: Views/Harmony Remove references to ui/views/layout/layout_constants.h (Closed)
Patch Set: Fix patch failures. Created 3 years, 7 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 const int button_margin =
454 provider->GetDistanceMetric(DISTANCE_DIALOG_BUTTON_MARGIN);
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, button_margin);
452 int available_width = width - 2 * views::kButtonHEdgeMarginNew; 459 int available_width = width - 2 * button_margin;
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, button_margin);
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 + ChromeLayoutProvider::Get()->GetDistanceMetric(
483 DISTANCE_DIALOG_BUTTON_MARGIN);
475 int label_width = width() - 2 * label_padding; 484 int label_width = width() - 2 * label_padding;
476 DCHECK_GT(label_width, 0); 485 DCHECK_GT(label_width, 0);
477 title_label_->SetBounds(label_padding, 0, label_width, height()); 486 title_label_->SetBounds(label_padding, 0, label_width, height());
478 } 487 }
479 488
480 gfx::Size GetPreferredSize() const override { 489 gfx::Size GetPreferredSize() const override {
481 int height = std::max(title_label_->GetPreferredSize().height(), 490 int height = std::max(title_label_->GetPreferredSize().height(),
482 back_button_->GetPreferredSize().height()); 491 back_button_->GetPreferredSize().height());
483 return gfx::Size(width(), height); 492 return gfx::Size(width(), height);
484 } 493 }
(...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after
1083 const base::string16& title_text, 1092 const base::string16& title_text,
1084 const base::string16& content_text, 1093 const base::string16& content_text,
1085 const base::string16& link_text, 1094 const base::string16& link_text,
1086 const base::string16& button_text, 1095 const base::string16& button_text,
1087 bool stack_button, 1096 bool stack_button,
1088 views::Link** link, 1097 views::Link** link,
1089 views::LabelButton** button, 1098 views::LabelButton** button,
1090 views::ImageButton** close_button) { 1099 views::ImageButton** close_button) {
1091 tutorial_mode_ = tutorial_mode; 1100 tutorial_mode_ = tutorial_mode;
1092 1101
1102 // TODO(ananta)
1103 // Use the dialog framework to create a dialog here instead of manually
1104 // creating one.
1105 ChromeLayoutProvider* provider = ChromeLayoutProvider::Get();
1106 const int border_top =
1107 provider->GetInsetsMetric(views::INSETS_DIALOG_TITLE).top();
1108 const int border_bottom =
1109 provider->GetInsetsMetric(views::INSETS_DIALOG_BUTTON).bottom();
1110 const int button_margin =
1111 provider->GetDistanceMetric(DISTANCE_DIALOG_BUTTON_MARGIN);
1112 const int unrelated_control_horizontal =
1113 provider->GetDistanceMetric(DISTANCE_UNRELATED_CONTROL_HORIZONTAL);
1114 const int unrelated_control_vertical =
1115 provider->GetDistanceMetric(DISTANCE_UNRELATED_CONTROL_VERTICAL);
1116 const int related_control_vertical =
1117 provider->GetDistanceMetric(DISTANCE_UNRELATED_CONTROL_VERTICAL);
1118
1093 views::View* view = new views::View(); 1119 views::View* view = new views::View();
1094 view->set_background(views::Background::CreateSolidBackground( 1120 view->set_background(views::Background::CreateSolidBackground(
1095 profiles::kAvatarTutorialBackgroundColor)); 1121 profiles::kAvatarTutorialBackgroundColor));
1096 view->SetBorder(views::CreateEmptyBorder( 1122 view->SetBorder(views::CreateEmptyBorder(border_top, button_margin,
1097 views::kButtonVEdgeMarginNew, views::kButtonHEdgeMarginNew, 1123 border_bottom, button_margin));
1098 views::kButtonVEdgeMarginNew, views::kButtonHEdgeMarginNew)); 1124 views::GridLayout* layout =
1099 views::GridLayout* layout = CreateSingleColumnLayout( 1125 CreateSingleColumnLayout(view, kFixedMenuWidth - 2 * button_margin);
1100 view, kFixedMenuWidth - 2 * views::kButtonHEdgeMarginNew);
1101 // Creates a second column set for buttons and links. 1126 // Creates a second column set for buttons and links.
1102 views::ColumnSet* button_columns = layout->AddColumnSet(1); 1127 views::ColumnSet* button_columns = layout->AddColumnSet(1);
1103 button_columns->AddColumn(views::GridLayout::LEADING, 1128 button_columns->AddColumn(views::GridLayout::LEADING,
1104 views::GridLayout::CENTER, 0, views::GridLayout::USE_PREF, 0, 0); 1129 views::GridLayout::CENTER, 0, views::GridLayout::USE_PREF, 0, 0);
1105 button_columns->AddPaddingColumn( 1130 button_columns->AddPaddingColumn(1, unrelated_control_horizontal);
1106 1, views::kUnrelatedControlHorizontalSpacing);
1107 button_columns->AddColumn(views::GridLayout::TRAILING, 1131 button_columns->AddColumn(views::GridLayout::TRAILING,
1108 views::GridLayout::CENTER, 0, views::GridLayout::USE_PREF, 0, 0); 1132 views::GridLayout::CENTER, 0, views::GridLayout::USE_PREF, 0, 0);
1109 1133
1110 // Adds title and close button if needed. 1134 // Adds title and close button if needed.
1111 const SkColor kTitleAndButtonTextColor = SK_ColorWHITE; 1135 const SkColor kTitleAndButtonTextColor = SK_ColorWHITE;
1112 views::Label* title_label = new views::Label(title_text); 1136 views::Label* title_label = new views::Label(title_text);
1113 title_label->SetMultiLine(true); 1137 title_label->SetMultiLine(true);
1114 title_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); 1138 title_label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
1115 title_label->SetAutoColorReadabilityEnabled(false); 1139 title_label->SetAutoColorReadabilityEnabled(false);
1116 title_label->SetEnabledColor(kTitleAndButtonTextColor); 1140 title_label->SetEnabledColor(kTitleAndButtonTextColor);
(...skipping 18 matching lines...) Expand all
1135 layout->StartRow(1, 0); 1159 layout->StartRow(1, 0);
1136 layout->AddView(title_label); 1160 layout->AddView(title_label);
1137 } 1161 }
1138 1162
1139 // Adds body content. 1163 // Adds body content.
1140 views::Label* content_label = new views::Label(content_text); 1164 views::Label* content_label = new views::Label(content_text);
1141 content_label->SetMultiLine(true); 1165 content_label->SetMultiLine(true);
1142 content_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); 1166 content_label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
1143 content_label->SetAutoColorReadabilityEnabled(false); 1167 content_label->SetAutoColorReadabilityEnabled(false);
1144 content_label->SetEnabledColor(profiles::kAvatarTutorialContentTextColor); 1168 content_label->SetEnabledColor(profiles::kAvatarTutorialContentTextColor);
1145 layout->StartRowWithPadding(1, 0, 0, views::kRelatedControlVerticalSpacing); 1169 layout->StartRowWithPadding(1, 0, 0, related_control_vertical);
1146 layout->AddView(content_label); 1170 layout->AddView(content_label);
1147 1171
1148 // Adds links and buttons. 1172 // Adds links and buttons.
1149 bool has_button = !button_text.empty(); 1173 bool has_button = !button_text.empty();
1150 if (has_button) { 1174 if (has_button) {
1151 *button = views::MdTextButton::CreateSecondaryUiButton(this, button_text); 1175 *button = views::MdTextButton::CreateSecondaryUiButton(this, button_text);
1152 if (ui::MaterialDesignController::IsSecondaryUiMaterial()) 1176 if (ui::MaterialDesignController::IsSecondaryUiMaterial())
1153 (*button)->SetEnabledTextColors(kTitleAndButtonTextColor); 1177 (*button)->SetEnabledTextColors(kTitleAndButtonTextColor);
1154 else 1178 else
1155 (*button)->SetHorizontalAlignment(gfx::ALIGN_CENTER); 1179 (*button)->SetHorizontalAlignment(gfx::ALIGN_CENTER);
1156 } 1180 }
1157 1181
1158 bool has_link = !link_text.empty(); 1182 bool has_link = !link_text.empty();
1159 if (has_link) { 1183 if (has_link) {
1160 *link = CreateLink(link_text, this); 1184 *link = CreateLink(link_text, this);
1161 (*link)->SetHorizontalAlignment(gfx::ALIGN_LEFT); 1185 (*link)->SetHorizontalAlignment(gfx::ALIGN_LEFT);
1162 (*link)->SetAutoColorReadabilityEnabled(false); 1186 (*link)->SetAutoColorReadabilityEnabled(false);
1163 (*link)->SetEnabledColor(kTitleAndButtonTextColor); 1187 (*link)->SetEnabledColor(kTitleAndButtonTextColor);
1164 } 1188 }
1165 1189
1166 if (stack_button) { 1190 if (stack_button) {
1167 DCHECK(has_button); 1191 DCHECK(has_button);
1168 layout->StartRowWithPadding( 1192 layout->StartRowWithPadding(1, 0, 0, unrelated_control_vertical);
1169 1, 0, 0, views::kUnrelatedControlVerticalSpacing);
1170 layout->AddView(*button); 1193 layout->AddView(*button);
1171 if (has_link) { 1194 if (has_link) {
1172 layout->StartRowWithPadding( 1195 layout->StartRowWithPadding(1, 0, 0, related_control_vertical);
1173 1, 0, 0, views::kRelatedControlVerticalSpacing);
1174 (*link)->SetHorizontalAlignment(gfx::ALIGN_CENTER); 1196 (*link)->SetHorizontalAlignment(gfx::ALIGN_CENTER);
1175 layout->AddView(*link); 1197 layout->AddView(*link);
1176 } 1198 }
1177 } else { 1199 } else {
1178 DCHECK(has_link || has_button); 1200 DCHECK(has_link || has_button);
1179 layout->StartRowWithPadding( 1201 layout->StartRowWithPadding(1, 1, 0, unrelated_control_vertical);
1180 1, 1, 0, views::kUnrelatedControlVerticalSpacing);
1181 if (has_link) 1202 if (has_link)
1182 layout->AddView(*link); 1203 layout->AddView(*link);
1183 else 1204 else
1184 layout->SkipColumns(1); 1205 layout->SkipColumns(1);
1185 if (has_button) 1206 if (has_button)
1186 layout->AddView(*button); 1207 layout->AddView(*button);
1187 else 1208 else
1188 layout->SkipColumns(1); 1209 layout->SkipColumns(1);
1189 } 1210 }
1190 1211
(...skipping 24 matching lines...) Expand all
1215 break; 1236 break;
1216 case sync_ui_util::PASSPHRASE_ERROR: 1237 case sync_ui_util::PASSPHRASE_ERROR:
1217 button_out = &sync_error_passphrase_button_; 1238 button_out = &sync_error_passphrase_button_;
1218 break; 1239 break;
1219 case sync_ui_util::NO_SYNC_ERROR: 1240 case sync_ui_util::NO_SYNC_ERROR:
1220 return nullptr; 1241 return nullptr;
1221 default: 1242 default:
1222 NOTREACHED(); 1243 NOTREACHED();
1223 } 1244 }
1224 1245
1246 ChromeLayoutProvider* provider = ChromeLayoutProvider::Get();
1247
1225 // Sets an overall horizontal layout. 1248 // Sets an overall horizontal layout.
1226 views::View* view = new views::View(); 1249 views::View* view = new views::View();
1227 views::BoxLayout* layout = new views::BoxLayout( 1250 views::BoxLayout* layout = new views::BoxLayout(
1228 views::BoxLayout::kHorizontal, kMenuEdgeMargin, kMenuEdgeMargin, 1251 views::BoxLayout::kHorizontal, kMenuEdgeMargin, kMenuEdgeMargin,
1229 views::kUnrelatedControlHorizontalSpacing); 1252 provider->GetDistanceMetric(DISTANCE_UNRELATED_CONTROL_HORIZONTAL));
1230 layout->set_cross_axis_alignment( 1253 layout->set_cross_axis_alignment(
1231 views::BoxLayout::CROSS_AXIS_ALIGNMENT_START); 1254 views::BoxLayout::CROSS_AXIS_ALIGNMENT_START);
1232 view->SetLayoutManager(layout); 1255 view->SetLayoutManager(layout);
1233 1256
1234 // Adds the sync problem icon. 1257 // Adds the sync problem icon.
1235 views::ImageView* sync_problem_icon = new views::ImageView(); 1258 views::ImageView* sync_problem_icon = new views::ImageView();
1236 sync_problem_icon->SetImage( 1259 sync_problem_icon->SetImage(
1237 gfx::CreateVectorIcon(kSyncProblemIcon, 20, gfx::kGoogleRed700)); 1260 gfx::CreateVectorIcon(kSyncProblemIcon, 20, gfx::kGoogleRed700));
1238 view->AddChildView(sync_problem_icon); 1261 view->AddChildView(sync_problem_icon);
1239 1262
1240 // Adds a vertical view to organize the error title, message, and button. 1263 // Adds a vertical view to organize the error title, message, and button.
1241 views::View* vertical_view = new views::View(); 1264 views::View* vertical_view = new views::View();
1242 views::BoxLayout* vertical_layout = 1265 views::BoxLayout* vertical_layout = new views::BoxLayout(
1243 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 1266 views::BoxLayout::kVertical, 0, 0,
1244 views::kRelatedControlSmallVerticalSpacing); 1267 provider->GetDistanceMetric(DISTANCE_RELATED_CONTROL_VERTICAL_SMALL));
1245 vertical_layout->set_cross_axis_alignment( 1268 vertical_layout->set_cross_axis_alignment(
1246 views::BoxLayout::CROSS_AXIS_ALIGNMENT_START); 1269 views::BoxLayout::CROSS_AXIS_ALIGNMENT_START);
1247 vertical_view->SetLayoutManager(vertical_layout); 1270 vertical_view->SetLayoutManager(vertical_layout);
1248 1271
1249 // Adds the title. 1272 // Adds the title.
1250 views::Label* title_label = new views::Label( 1273 views::Label* title_label = new views::Label(
1251 l10n_util::GetStringUTF16(IDS_SYNC_ERROR_USER_MENU_TITLE)); 1274 l10n_util::GetStringUTF16(IDS_SYNC_ERROR_USER_MENU_TITLE));
1252 title_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); 1275 title_label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
1253 title_label->SetEnabledColor(gfx::kGoogleRed700); 1276 title_label->SetEnabledColor(gfx::kGoogleRed700);
1254 vertical_view->AddChildView(title_label); 1277 vertical_view->AddChildView(title_label);
1255 1278
1256 // Adds body content. 1279 // Adds body content.
1257 views::Label* content_label = 1280 views::Label* content_label =
1258 new views::Label(l10n_util::GetStringUTF16(content_string_id)); 1281 new views::Label(l10n_util::GetStringUTF16(content_string_id));
1259 content_label->SetMultiLine(true); 1282 content_label->SetMultiLine(true);
1260 content_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); 1283 content_label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
1261 vertical_view->AddChildView(content_label); 1284 vertical_view->AddChildView(content_label);
1262 1285
1263 // Adds an action button if an action exists. 1286 // Adds an action button if an action exists.
1264 if (button_string_id) { 1287 if (button_string_id) {
1265 // If the button string is specified, then the button itself needs to be 1288 // If the button string is specified, then the button itself needs to be
1266 // already initialized. 1289 // already initialized.
1267 DCHECK(button_out); 1290 DCHECK(button_out);
1268 // Adds a padding row between error title/content and the button. 1291 // Adds a padding row between error title/content and the button.
1269 auto* padding = new views::View; 1292 auto* padding = new views::View;
1270 padding->set_preferred_size( 1293 padding->set_preferred_size(gfx::Size(
1271 gfx::Size(0, views::kRelatedControlVerticalSpacing)); 1294 0,
1295 provider->GetDistanceMetric(views::DISTANCE_RELATED_CONTROL_VERTICAL)));
1272 vertical_view->AddChildView(padding); 1296 vertical_view->AddChildView(padding);
1273 1297
1274 *button_out = views::MdTextButton::CreateSecondaryUiBlueButton( 1298 *button_out = views::MdTextButton::CreateSecondaryUiBlueButton(
1275 this, l10n_util::GetStringUTF16(button_string_id)); 1299 this, l10n_util::GetStringUTF16(button_string_id));
1276 vertical_view->AddChildView(*button_out); 1300 vertical_view->AddChildView(*button_out);
1277 view->SetBorder(views::CreateEmptyBorder( 1301 view->SetBorder(views::CreateEmptyBorder(
1278 0, 0, views::kRelatedControlSmallVerticalSpacing, 0)); 1302 0, 0,
1303 provider->GetDistanceMetric(DISTANCE_RELATED_CONTROL_VERTICAL_SMALL),
1304 0));
1279 } 1305 }
1280 1306
1281 view->AddChildView(vertical_view); 1307 view->AddChildView(vertical_view);
1282 return view; 1308 return view;
1283 } 1309 }
1284 1310
1285 views::View* ProfileChooserView::CreateCurrentProfileView( 1311 views::View* ProfileChooserView::CreateCurrentProfileView(
1286 const AvatarMenu::Item& avatar_item, 1312 const AvatarMenu::Item& avatar_item,
1287 bool is_guest) { 1313 bool is_guest) {
1314 ChromeLayoutProvider* provider = ChromeLayoutProvider::Get();
1315 const int vertical_spacing_small =
1316 provider->GetDistanceMetric(DISTANCE_RELATED_CONTROL_VERTICAL_SMALL);
1317 const int vertical_spacing =
1318 provider->GetDistanceMetric(views::DISTANCE_RELATED_CONTROL_VERTICAL);
1288 views::View* view = new views::View(); 1319 views::View* view = new views::View();
1289 view->SetLayoutManager( 1320 view->SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0,
1290 new views::BoxLayout(views::BoxLayout::kVertical, 0, 1321 vertical_spacing_small, 0));
1291 views::kRelatedControlVerticalSpacing, 0));
1292 1322
1293 // Container for the profile photo and avatar/user name. 1323 // Container for the profile photo and avatar/user name.
1294 BackgroundColorHoverButton* current_profile_card = 1324 BackgroundColorHoverButton* current_profile_card =
1295 new BackgroundColorHoverButton(this, base::string16()); 1325 new BackgroundColorHoverButton(this, base::string16());
1296 views::GridLayout* grid_layout = new views::GridLayout(current_profile_card); 1326 views::GridLayout* grid_layout = new views::GridLayout(current_profile_card);
1297 current_profile_card->SetLayoutManager(grid_layout); 1327 current_profile_card->SetLayoutManager(grid_layout);
1298 views::ColumnSet* columns = grid_layout->AddColumnSet(0); 1328 views::ColumnSet* columns = grid_layout->AddColumnSet(0);
1299 // BackgroundColorHoverButton has already accounted for the left and right 1329 // BackgroundColorHoverButton has already accounted for the left and right
1300 // margins. 1330 // margins.
1301 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 0, 1331 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 0,
1302 views::GridLayout::USE_PREF, 0, 0); 1332 views::GridLayout::USE_PREF, 0, 0);
1303 columns->AddPaddingColumn(0, kMenuEdgeMargin - kBadgeSpacing); 1333 columns->AddPaddingColumn(0, kMenuEdgeMargin - kBadgeSpacing);
1304 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 1, 1334 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 1,
1305 views::GridLayout::USE_PREF, 0, 0); 1335 views::GridLayout::USE_PREF, 0, 0);
1306 grid_layout->AddPaddingRow(0, 0); 1336 grid_layout->AddPaddingRow(0, 0);
1307 const int num_labels = 1337 const int num_labels =
1308 (avatar_item.signed_in && !switches::IsEnableAccountConsistency()) ? 2 1338 (avatar_item.signed_in && !switches::IsEnableAccountConsistency()) ? 2
1309 : 1; 1339 : 1;
1310 int profile_card_height = 1340 int profile_card_height =
1311 kImageSide + 1341 kImageSide + 2 * (kBadgeSpacing + vertical_spacing_small);
1312 2 * (kBadgeSpacing + views::kRelatedControlSmallVerticalSpacing);
1313 const int line_height = profile_card_height / num_labels; 1342 const int line_height = profile_card_height / num_labels;
1314 grid_layout->StartRow(0, 0, line_height); 1343 grid_layout->StartRow(0, 0, line_height);
1315 current_profile_card_ = current_profile_card; 1344 current_profile_card_ = current_profile_card;
1316 1345
1317 // Profile picture, left-aligned. 1346 // Profile picture, left-aligned.
1318 EditableProfilePhoto* current_profile_photo = new EditableProfilePhoto( 1347 EditableProfilePhoto* current_profile_photo = new EditableProfilePhoto(
1319 this, avatar_item.icon, !is_guest, browser_->profile()); 1348 this, avatar_item.icon, !is_guest, browser_->profile());
1320 1349
1321 // Profile name, left-aligned to the right of profile icon. 1350 // Profile name, left-aligned to the right of profile icon.
1322 views::Label* current_profile_name = new views::Label( 1351 views::Label* current_profile_name = new views::Label(
1323 profiles::GetAvatarNameForProfile(browser_->profile()->GetPath())); 1352 profiles::GetAvatarNameForProfile(browser_->profile()->GetPath()));
1324 current_profile_card->set_title(current_profile_name); 1353 current_profile_card->set_title(current_profile_name);
1325 current_profile_name->SetAutoColorReadabilityEnabled(false); 1354 current_profile_name->SetAutoColorReadabilityEnabled(false);
1326 current_profile_name->SetFontList( 1355 current_profile_name->SetFontList(
1327 ui::ResourceBundle::GetSharedInstance().GetFontListWithDelta( 1356 ui::ResourceBundle::GetSharedInstance().GetFontListWithDelta(
1328 1, gfx::Font::FontStyle::NORMAL, gfx::Font::Weight::MEDIUM)); 1357 1, gfx::Font::FontStyle::NORMAL, gfx::Font::Weight::MEDIUM));
1329 current_profile_name->SetHorizontalAlignment(gfx::ALIGN_LEFT); 1358 current_profile_name->SetHorizontalAlignment(gfx::ALIGN_LEFT);
1330 1359
1331 // The grid layout contains one row if not signed in or account consistency is 1360 // 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 1361 // 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 1362 // disabled (the second row is for the email label). For the second case the
1334 // profile photo has to be over 2 rows. 1363 // profile photo has to be over 2 rows.
1335 grid_layout->AddView(current_profile_photo, 1, num_labels); 1364 grid_layout->AddView(current_profile_photo, 1, num_labels);
1336 grid_layout->AddView(current_profile_name, 1, 1, views::GridLayout::LEADING, 1365 grid_layout->AddView(current_profile_name, 1, 1, views::GridLayout::LEADING,
1337 (num_labels == 2) ? views::GridLayout::TRAILING 1366 (num_labels == 2) ? views::GridLayout::TRAILING
1338 : views::GridLayout::CENTER); 1367 : views::GridLayout::CENTER);
1339 current_profile_card_->SetMinSize(gfx::Size( 1368 current_profile_card_->SetMinSize(gfx::Size(
1340 kFixedMenuWidth, current_profile_photo->GetPreferredSize().height() + 1369 kFixedMenuWidth, current_profile_photo->GetPreferredSize().height() +
1341 2 * views::kRelatedControlSmallVerticalSpacing)); 1370 2 * vertical_spacing_small));
1342 view->AddChildView(current_profile_card_); 1371 view->AddChildView(current_profile_card_);
1343 1372
1344 if (is_guest) { 1373 if (is_guest) {
1345 current_profile_card_->SetEnabled(false); 1374 current_profile_card_->SetEnabled(false);
1346 return view; 1375 return view;
1347 } 1376 }
1348 1377
1349 const base::string16 profile_name = 1378 const base::string16 profile_name =
1350 profiles::GetAvatarNameForProfile(browser_->profile()->GetPath()); 1379 profiles::GetAvatarNameForProfile(browser_->profile()->GetPath());
1351 1380
(...skipping 29 matching lines...) Expand all
1381 IDS_PROFILES_EDIT_SIGNED_IN_PROFILE_ACCESSIBLE_NAME, 1410 IDS_PROFILES_EDIT_SIGNED_IN_PROFILE_ACCESSIBLE_NAME,
1382 profile_name, 1411 profile_name,
1383 avatar_item.username)); 1412 avatar_item.username));
1384 return view; 1413 return view;
1385 } 1414 }
1386 1415
1387 SigninManagerBase* signin_manager = SigninManagerFactory::GetForProfile( 1416 SigninManagerBase* signin_manager = SigninManagerFactory::GetForProfile(
1388 browser_->profile()->GetOriginalProfile()); 1417 browser_->profile()->GetOriginalProfile());
1389 if (signin_manager->IsSigninAllowed()) { 1418 if (signin_manager->IsSigninAllowed()) {
1390 views::View* extra_links_view = new views::View(); 1419 views::View* extra_links_view = new views::View();
1391 views::BoxLayout* extra_links_layout = new views::BoxLayout( 1420 views::BoxLayout* extra_links_layout =
1392 views::BoxLayout::kVertical, kMenuEdgeMargin, 1421 new views::BoxLayout(views::BoxLayout::kVertical, kMenuEdgeMargin,
1393 views::kRelatedControlVerticalSpacing, kMenuEdgeMargin); 1422 vertical_spacing, kMenuEdgeMargin);
1394 extra_links_layout->set_cross_axis_alignment( 1423 extra_links_layout->set_cross_axis_alignment(
1395 views::BoxLayout::CROSS_AXIS_ALIGNMENT_START); 1424 views::BoxLayout::CROSS_AXIS_ALIGNMENT_START);
1396 extra_links_view->SetLayoutManager(extra_links_layout); 1425 extra_links_view->SetLayoutManager(extra_links_layout);
1397 views::Label* promo = 1426 views::Label* promo =
1398 new views::Label(l10n_util::GetStringUTF16(IDS_PROFILES_SIGNIN_PROMO)); 1427 new views::Label(l10n_util::GetStringUTF16(IDS_PROFILES_SIGNIN_PROMO));
1399 promo->SetMultiLine(true); 1428 promo->SetMultiLine(true);
1400 promo->SetHorizontalAlignment(gfx::ALIGN_LEFT); 1429 promo->SetHorizontalAlignment(gfx::ALIGN_LEFT);
1401 extra_links_view->AddChildView(promo); 1430 extra_links_view->AddChildView(promo);
1402 1431
1403 signin_current_profile_button_ = 1432 signin_current_profile_button_ =
1404 views::MdTextButton::CreateSecondaryUiBlueButton( 1433 views::MdTextButton::CreateSecondaryUiBlueButton(
1405 this, l10n_util::GetStringFUTF16( 1434 this, l10n_util::GetStringFUTF16(
1406 IDS_SYNC_START_SYNC_BUTTON_LABEL, 1435 IDS_SYNC_START_SYNC_BUTTON_LABEL,
1407 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME))); 1436 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME)));
1408 extra_links_view->AddChildView(signin_current_profile_button_); 1437 extra_links_view->AddChildView(signin_current_profile_button_);
1409 base::RecordAction( 1438 base::RecordAction(
1410 base::UserMetricsAction("Signin_Impression_FromAvatarBubbleSignin")); 1439 base::UserMetricsAction("Signin_Impression_FromAvatarBubbleSignin"));
1411 extra_links_view->SetBorder(views::CreateEmptyBorder( 1440 extra_links_view->SetBorder(
1412 0, 0, views::kRelatedControlSmallVerticalSpacing, 0)); 1441 views::CreateEmptyBorder(0, 0, vertical_spacing_small, 0));
1413 view->AddChildView(extra_links_view); 1442 view->AddChildView(extra_links_view);
1414 } 1443 }
1415 1444
1416 current_profile_card_->SetAccessibleName( 1445 current_profile_card_->SetAccessibleName(
1417 l10n_util::GetStringFUTF16( 1446 l10n_util::GetStringFUTF16(
1418 IDS_PROFILES_EDIT_PROFILE_ACCESSIBLE_NAME, profile_name)); 1447 IDS_PROFILES_EDIT_PROFILE_ACCESSIBLE_NAME, profile_name));
1419 return view; 1448 return view;
1420 } 1449 }
1421 1450
1422 views::View* ProfileChooserView::CreateGuestProfileView() { 1451 views::View* ProfileChooserView::CreateGuestProfileView() {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1459 layout->AddView(new views::Separator()); 1488 layout->AddView(new views::Separator());
1460 layout->StartRow(1, 0); 1489 layout->StartRow(1, 0);
1461 layout->AddView(button); 1490 layout->AddView(button);
1462 } 1491 }
1463 1492
1464 return view; 1493 return view;
1465 } 1494 }
1466 1495
1467 views::View* ProfileChooserView::CreateOptionsView(bool display_lock, 1496 views::View* ProfileChooserView::CreateOptionsView(bool display_lock,
1468 AvatarMenu* avatar_menu) { 1497 AvatarMenu* avatar_menu) {
1498 ChromeLayoutProvider* provider = ChromeLayoutProvider::Get();
1499 const int vertical_spacing =
1500 provider->GetDistanceMetric(views::DISTANCE_RELATED_CONTROL_VERTICAL);
1469 views::View* view = new views::View(); 1501 views::View* view = new views::View();
1470 views::GridLayout* layout = CreateSingleColumnLayout(view, kFixedMenuWidth); 1502 views::GridLayout* layout = CreateSingleColumnLayout(view, kFixedMenuWidth);
1471 1503
1472 const bool is_guest = browser_->profile()->IsGuestSession(); 1504 const bool is_guest = browser_->profile()->IsGuestSession();
1473 const int kIconSize = 20; 1505 const int kIconSize = 20;
1474 // Add the user switching buttons 1506 // Add the user switching buttons
1475 const int kProfileIconSize = 18; 1507 const int kProfileIconSize = 18;
1476 layout->StartRowWithPadding(1, 0, 0, views::kRelatedControlVerticalSpacing); 1508 layout->StartRowWithPadding(1, 0, 0, vertical_spacing);
1477 for (size_t i = 0; i < avatar_menu->GetNumberOfItems(); ++i) { 1509 for (size_t i = 0; i < avatar_menu->GetNumberOfItems(); ++i) {
1478 const AvatarMenu::Item& item = avatar_menu->GetItemAt(i); 1510 const AvatarMenu::Item& item = avatar_menu->GetItemAt(i);
1479 if (!item.active) { 1511 if (!item.active) {
1480 gfx::Image image = profiles::GetSizedAvatarIcon( 1512 gfx::Image image = profiles::GetSizedAvatarIcon(
1481 item.icon, true, kProfileIconSize, kProfileIconSize, 1513 item.icon, true, kProfileIconSize, kProfileIconSize,
1482 profiles::SHAPE_CIRCLE); 1514 profiles::SHAPE_CIRCLE);
1483 views::LabelButton* button = new BackgroundColorHoverButton( 1515 views::LabelButton* button = new BackgroundColorHoverButton(
1484 this, profiles::GetProfileSwitcherTextForItem(item), 1516 this, profiles::GetProfileSwitcherTextForItem(item),
1485 *image.ToImageSkia()); 1517 *image.ToImageSkia());
1486 button->SetImageLabelSpacing(kMenuEdgeMargin); 1518 button->SetImageLabelSpacing(kMenuEdgeMargin);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1535 close_all_windows_button_ = new BackgroundColorHoverButton( 1567 close_all_windows_button_ = new BackgroundColorHoverButton(
1536 this, 1568 this,
1537 l10n_util::GetStringUTF16(IDS_PROFILES_CLOSE_ALL_WINDOWS_BUTTON), 1569 l10n_util::GetStringUTF16(IDS_PROFILES_CLOSE_ALL_WINDOWS_BUTTON),
1538 gfx::CreateVectorIcon(kCloseAllIcon, kIconSize, 1570 gfx::CreateVectorIcon(kCloseAllIcon, kIconSize,
1539 gfx::kChromeIconGrey)); 1571 gfx::kChromeIconGrey));
1540 layout->StartRow(1, 0); 1572 layout->StartRow(1, 0);
1541 layout->AddView(close_all_windows_button_); 1573 layout->AddView(close_all_windows_button_);
1542 } 1574 }
1543 } 1575 }
1544 1576
1545 layout->StartRowWithPadding(1, 0, 0, views::kRelatedControlVerticalSpacing); 1577 layout->StartRowWithPadding(1, 0, 0, vertical_spacing);
1546 return view; 1578 return view;
1547 } 1579 }
1548 1580
1549 views::View* ProfileChooserView::CreateSupervisedUserDisclaimerView() { 1581 views::View* ProfileChooserView::CreateSupervisedUserDisclaimerView() {
1550 views::View* view = new views::View(); 1582 views::View* view = new views::View();
1551 int horizontal_margin = kMenuEdgeMargin; 1583 int horizontal_margin = kMenuEdgeMargin;
1552 views::GridLayout* layout = 1584 views::GridLayout* layout =
1553 CreateSingleColumnLayout(view, kFixedMenuWidth - 2 * horizontal_margin); 1585 CreateSingleColumnLayout(view, kFixedMenuWidth - 2 * horizontal_margin);
1554 view->SetBorder(views::CreateEmptyBorder(0, horizontal_margin, 1586 view->SetBorder(views::CreateEmptyBorder(0, horizontal_margin,
1555 kMenuEdgeMargin, horizontal_margin)); 1587 kMenuEdgeMargin, horizontal_margin));
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1588 // The primary account should always be listed first. 1620 // The primary account should always be listed first.
1589 // TODO(rogerta): we still need to further differentiate the primary account 1621 // 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: 1622 // from the others in the UI, so more work is likely required here:
1591 // crbug.com/311124. 1623 // crbug.com/311124.
1592 CreateAccountButton(layout, primary_account, true, 1624 CreateAccountButton(layout, primary_account, true,
1593 error_account_id == primary_account, kFixedMenuWidth); 1625 error_account_id == primary_account, kFixedMenuWidth);
1594 for (size_t i = 0; i < accounts.size(); ++i) 1626 for (size_t i = 0; i < accounts.size(); ++i)
1595 CreateAccountButton(layout, accounts[i], false, 1627 CreateAccountButton(layout, accounts[i], false,
1596 error_account_id == accounts[i], kFixedMenuWidth); 1628 error_account_id == accounts[i], kFixedMenuWidth);
1597 1629
1630 ChromeLayoutProvider* provider = ChromeLayoutProvider::Get();
1631 const int vertical_spacing =
1632 provider->GetDistanceMetric(views::DISTANCE_RELATED_CONTROL_VERTICAL);
1598 if (!profile->IsSupervised()) { 1633 if (!profile->IsSupervised()) {
1599 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); 1634 layout->AddPaddingRow(0, vertical_spacing);
1600 1635
1601 add_account_link_ = CreateLink(l10n_util::GetStringFUTF16( 1636 add_account_link_ = CreateLink(l10n_util::GetStringFUTF16(
1602 IDS_PROFILES_PROFILE_ADD_ACCOUNT_BUTTON, avatar_item.name), this); 1637 IDS_PROFILES_PROFILE_ADD_ACCOUNT_BUTTON, avatar_item.name), this);
1603 add_account_link_->SetBorder( 1638 add_account_link_->SetBorder(views::CreateEmptyBorder(
1604 views::CreateEmptyBorder(0, views::kButtonVEdgeMarginNew, 1639 0, provider->GetDistanceMetric(DISTANCE_DIALOG_BUTTON_MARGIN),
1605 views::kRelatedControlVerticalSpacing, 0)); 1640 vertical_spacing, 0));
1606 layout->StartRow(1, 0); 1641 layout->StartRow(1, 0);
1607 layout->AddView(add_account_link_); 1642 layout->AddView(add_account_link_);
1608 } 1643 }
1609 1644
1610 return view; 1645 return view;
1611 } 1646 }
1612 1647
1613 void ProfileChooserView::CreateAccountButton(views::GridLayout* layout, 1648 void ProfileChooserView::CreateAccountButton(views::GridLayout* layout,
1614 const std::string& account_id, 1649 const std::string& account_id,
1615 bool is_primary_account, 1650 bool is_primary_account,
1616 bool reauth_required, 1651 bool reauth_required,
1617 int width) { 1652 int width) {
1653 ChromeLayoutProvider* provider = ChromeLayoutProvider::Get();
1618 std::string email = signin_ui_util::GetDisplayEmail(browser_->profile(), 1654 std::string email = signin_ui_util::GetDisplayEmail(browser_->profile(),
1619 account_id); 1655 account_id);
1620 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); 1656 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance();
1621 const gfx::ImageSkia* delete_default_image = 1657 const gfx::ImageSkia* delete_default_image =
1622 rb->GetImageNamed(IDR_CLOSE_1).ToImageSkia(); 1658 rb->GetImageNamed(IDR_CLOSE_1).ToImageSkia();
1623 const int kDeleteButtonWidth = delete_default_image->width(); 1659 const int kDeleteButtonWidth = delete_default_image->width();
1624 gfx::ImageSkia warning_default_image; 1660 gfx::ImageSkia warning_default_image;
1625 int warning_button_width = 0; 1661 int warning_button_width = 0;
1626 if (reauth_required) { 1662 if (reauth_required) {
1627 const int kIconSize = 18; 1663 const int kIconSize = 18;
1628 warning_default_image = gfx::CreateVectorIcon(ui::kWarningIcon, kIconSize, 1664 warning_default_image = gfx::CreateVectorIcon(ui::kWarningIcon, kIconSize,
1629 gfx::kChromeIconGrey); 1665 gfx::kChromeIconGrey);
1630 warning_button_width = kIconSize + views::kRelatedButtonHSpacing; 1666 warning_button_width =
1667 kIconSize +
1668 provider->GetDistanceMetric(views::DISTANCE_RELATED_BUTTON_HORIZONTAL);
1631 } 1669 }
1632 int available_width = width - 2 * views::kButtonHEdgeMarginNew - 1670 int available_width =
1633 kDeleteButtonWidth - warning_button_width; 1671 width - 2 * provider->GetDistanceMetric(DISTANCE_DIALOG_BUTTON_MARGIN) -
1672 kDeleteButtonWidth - warning_button_width;
1634 views::LabelButton* email_button = new BackgroundColorHoverButton( 1673 views::LabelButton* email_button = new BackgroundColorHoverButton(
1635 this, base::UTF8ToUTF16(email), warning_default_image); 1674 this, base::UTF8ToUTF16(email), warning_default_image);
1636 email_button->SetEnabled(reauth_required); 1675 email_button->SetEnabled(reauth_required);
1637 email_button->SetElideBehavior(gfx::ELIDE_EMAIL); 1676 email_button->SetElideBehavior(gfx::ELIDE_EMAIL);
1638 email_button->SetMinSize(gfx::Size(0, kButtonHeight)); 1677 email_button->SetMinSize(gfx::Size(0, kButtonHeight));
1639 email_button->SetMaxSize(gfx::Size(available_width, kButtonHeight)); 1678 email_button->SetMaxSize(gfx::Size(available_width, kButtonHeight));
1640 layout->StartRow(1, 0); 1679 layout->StartRow(1, 0);
1641 layout->AddView(email_button); 1680 layout->AddView(email_button);
1642 1681
1643 if (reauth_required) 1682 if (reauth_required)
1644 reauth_account_button_map_[email_button] = account_id; 1683 reauth_account_button_map_[email_button] = account_id;
1645 1684
1646 // Delete button. 1685 // Delete button.
1647 if (!browser_->profile()->IsSupervised()) { 1686 if (!browser_->profile()->IsSupervised()) {
1648 views::ImageButton* delete_button = new views::ImageButton(this); 1687 views::ImageButton* delete_button = new views::ImageButton(this);
1649 delete_button->SetImageAlignment(views::ImageButton::ALIGN_RIGHT, 1688 delete_button->SetImageAlignment(views::ImageButton::ALIGN_RIGHT,
1650 views::ImageButton::ALIGN_MIDDLE); 1689 views::ImageButton::ALIGN_MIDDLE);
1651 delete_button->SetImage(views::ImageButton::STATE_NORMAL, 1690 delete_button->SetImage(views::ImageButton::STATE_NORMAL,
1652 delete_default_image); 1691 delete_default_image);
1653 delete_button->SetImage(views::ImageButton::STATE_HOVERED, 1692 delete_button->SetImage(views::ImageButton::STATE_HOVERED,
1654 rb->GetImageSkiaNamed(IDR_CLOSE_1_H)); 1693 rb->GetImageSkiaNamed(IDR_CLOSE_1_H));
1655 delete_button->SetImage(views::ImageButton::STATE_PRESSED, 1694 delete_button->SetImage(views::ImageButton::STATE_PRESSED,
1656 rb->GetImageSkiaNamed(IDR_CLOSE_1_P)); 1695 rb->GetImageSkiaNamed(IDR_CLOSE_1_P));
1657 delete_button->SetBounds( 1696 delete_button->SetBounds(
1658 width - views::kButtonHEdgeMarginNew - kDeleteButtonWidth, 1697 width - provider->GetDistanceMetric(DISTANCE_DIALOG_BUTTON_MARGIN) -
1698 kDeleteButtonWidth,
1659 0, kDeleteButtonWidth, kButtonHeight); 1699 0, kDeleteButtonWidth, kButtonHeight);
1660 1700
1661 email_button->set_notify_enter_exit_on_child(true); 1701 email_button->set_notify_enter_exit_on_child(true);
1662 email_button->AddChildView(delete_button); 1702 email_button->AddChildView(delete_button);
1663 1703
1664 // Save the original email address, as the button text could be elided. 1704 // Save the original email address, as the button text could be elided.
1665 delete_account_button_map_[delete_button] = account_id; 1705 delete_account_button_map_[delete_button] = account_id;
1666 } 1706 }
1667 } 1707 }
1668 1708
1669 views::View* ProfileChooserView::CreateAccountRemovalView() { 1709 views::View* ProfileChooserView::CreateAccountRemovalView() {
1710 ChromeLayoutProvider* provider = ChromeLayoutProvider::Get();
1711 const int button_margin =
1712 provider->GetDistanceMetric(DISTANCE_DIALOG_BUTTON_MARGIN);
1713 const int unrelated_vertical_spacing =
1714 provider->GetDistanceMetric(DISTANCE_UNRELATED_CONTROL_VERTICAL);
1715
1670 views::View* view = new views::View(); 1716 views::View* view = new views::View();
1671 views::GridLayout* layout = CreateSingleColumnLayout( 1717 views::GridLayout* layout = CreateSingleColumnLayout(
1672 view, kFixedAccountRemovalViewWidth - 2 * views::kButtonHEdgeMarginNew); 1718 view, kFixedAccountRemovalViewWidth - 2 * button_margin);
1673 view->SetBorder(views::CreateEmptyBorder(0, views::kButtonHEdgeMarginNew, 1719 view->SetBorder(
1674 views::kButtonVEdgeMarginNew, 1720 views::CreateEmptyBorder(0, button_margin, button_margin, button_margin));
1675 views::kButtonHEdgeMarginNew));
1676 1721
1677 const std::string& primary_account = SigninManagerFactory::GetForProfile( 1722 const std::string& primary_account = SigninManagerFactory::GetForProfile(
1678 browser_->profile())->GetAuthenticatedAccountId(); 1723 browser_->profile())->GetAuthenticatedAccountId();
1679 bool is_primary_account = primary_account == account_id_to_remove_; 1724 bool is_primary_account = primary_account == account_id_to_remove_;
1680 1725
1681 // Adds main text. 1726 // Adds main text.
1682 layout->StartRowWithPadding(1, 0, 0, views::kUnrelatedControlVerticalSpacing); 1727 layout->StartRowWithPadding(1, 0, 0, unrelated_vertical_spacing);
1683 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); 1728 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance();
1684 const gfx::FontList& small_font_list = 1729 const gfx::FontList& small_font_list =
1685 rb->GetFontList(ui::ResourceBundle::SmallFont); 1730 rb->GetFontList(ui::ResourceBundle::SmallFont);
1686 1731
1687 if (is_primary_account) { 1732 if (is_primary_account) {
1688 std::string email = signin_ui_util::GetDisplayEmail(browser_->profile(), 1733 std::string email = signin_ui_util::GetDisplayEmail(browser_->profile(),
1689 account_id_to_remove_); 1734 account_id_to_remove_);
1690 std::vector<size_t> offsets; 1735 std::vector<size_t> offsets;
1691 const base::string16 settings_text = 1736 const base::string16 settings_text =
1692 l10n_util::GetStringUTF16(IDS_PROFILES_SETTINGS_LINK); 1737 l10n_util::GetStringUTF16(IDS_PROFILES_SETTINGS_LINK);
(...skipping 15 matching lines...) Expand all
1708 content_label->SetFontList(small_font_list); 1753 content_label->SetFontList(small_font_list);
1709 layout->AddView(content_label); 1754 layout->AddView(content_label);
1710 } 1755 }
1711 1756
1712 // Adds button. 1757 // Adds button.
1713 if (!is_primary_account) { 1758 if (!is_primary_account) {
1714 remove_account_button_ = views::MdTextButton::CreateSecondaryUiBlueButton( 1759 remove_account_button_ = views::MdTextButton::CreateSecondaryUiBlueButton(
1715 this, l10n_util::GetStringUTF16(IDS_PROFILES_ACCOUNT_REMOVAL_BUTTON)); 1760 this, l10n_util::GetStringUTF16(IDS_PROFILES_ACCOUNT_REMOVAL_BUTTON));
1716 remove_account_button_->SetHorizontalAlignment( 1761 remove_account_button_->SetHorizontalAlignment(
1717 gfx::ALIGN_CENTER); 1762 gfx::ALIGN_CENTER);
1718 layout->StartRowWithPadding( 1763 layout->StartRowWithPadding(1, 0, 0, unrelated_vertical_spacing);
1719 1, 0, 0, views::kUnrelatedControlVerticalSpacing);
1720 layout->AddView(remove_account_button_); 1764 layout->AddView(remove_account_button_);
1721 } else { 1765 } else {
1722 layout->AddPaddingRow(0, views::kUnrelatedControlVerticalSpacing); 1766 layout->AddPaddingRow(0, unrelated_vertical_spacing);
1723 } 1767 }
1724 1768
1725 TitleCard* title_card = new TitleCard( 1769 TitleCard* title_card = new TitleCard(
1726 l10n_util::GetStringUTF16(IDS_PROFILES_ACCOUNT_REMOVAL_TITLE), 1770 l10n_util::GetStringUTF16(IDS_PROFILES_ACCOUNT_REMOVAL_TITLE),
1727 this, &account_removal_cancel_button_); 1771 this, &account_removal_cancel_button_);
1728 return TitleCard::AddPaddedTitleCard(view, title_card, 1772 return TitleCard::AddPaddedTitleCard(view, title_card,
1729 kFixedAccountRemovalViewWidth); 1773 kFixedAccountRemovalViewWidth);
1730 } 1774 }
1731 1775
1732 views::View* ProfileChooserView::CreateWelcomeUpgradeTutorialView( 1776 views::View* ProfileChooserView::CreateWelcomeUpgradeTutorialView(
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1780 last_login_result, 1824 last_login_result,
1781 l10n_util::GetStringUTF16(IDS_PROFILES_PROFILE_TUTORIAL_LEARN_MORE), 1825 l10n_util::GetStringUTF16(IDS_PROFILES_PROFILE_TUTORIAL_LEARN_MORE),
1782 base::string16(), 1826 base::string16(),
1783 false /* stack_button */, 1827 false /* stack_button */,
1784 &tutorial_learn_more_link_, 1828 &tutorial_learn_more_link_,
1785 NULL, 1829 NULL,
1786 &tutorial_close_button_); 1830 &tutorial_close_button_);
1787 } 1831 }
1788 1832
1789 views::View* ProfileChooserView::CreateSwitchUserView() { 1833 views::View* ProfileChooserView::CreateSwitchUserView() {
1834 ChromeLayoutProvider* provider = ChromeLayoutProvider::Get();
1835 const int button_margin =
1836 provider->GetDistanceMetric(DISTANCE_DIALOG_BUTTON_MARGIN);
1837 const int unrelated_vertical_spacing =
1838 provider->GetDistanceMetric(DISTANCE_UNRELATED_CONTROL_VERTICAL);
1790 views::View* view = new views::View(); 1839 views::View* view = new views::View();
1791 views::GridLayout* layout = CreateSingleColumnLayout( 1840 views::GridLayout* layout = CreateSingleColumnLayout(
1792 view, kFixedSwitchUserViewWidth); 1841 view, kFixedSwitchUserViewWidth);
1793 views::ColumnSet* columns = layout->AddColumnSet(1); 1842 views::ColumnSet* columns = layout->AddColumnSet(1);
1794 columns->AddPaddingColumn(0, views::kButtonHEdgeMarginNew); 1843 columns->AddPaddingColumn(0, button_margin);
1795 int label_width = 1844 int label_width = kFixedSwitchUserViewWidth - 2 * button_margin;
1796 kFixedSwitchUserViewWidth - 2 * views::kButtonHEdgeMarginNew;
1797 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 0, 1845 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 0,
1798 views::GridLayout::FIXED, label_width, label_width); 1846 views::GridLayout::FIXED, label_width, label_width);
1799 columns->AddPaddingColumn(0, views::kButtonHEdgeMarginNew); 1847 columns->AddPaddingColumn(0, button_margin);
1800 1848
1801 // Adds main text. 1849 // Adds main text.
1802 layout->StartRowWithPadding(1, 1, 0, views::kUnrelatedControlVerticalSpacing); 1850 layout->StartRowWithPadding(1, 1, 0, unrelated_vertical_spacing);
1803 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); 1851 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance();
1804 const gfx::FontList& small_font_list = 1852 const gfx::FontList& small_font_list =
1805 rb->GetFontList(ui::ResourceBundle::SmallFont); 1853 rb->GetFontList(ui::ResourceBundle::SmallFont);
1806 const AvatarMenu::Item& avatar_item = 1854 const AvatarMenu::Item& avatar_item =
1807 avatar_menu_->GetItemAt(avatar_menu_->GetActiveProfileIndex()); 1855 avatar_menu_->GetItemAt(avatar_menu_->GetActiveProfileIndex());
1808 views::Label* content_label = new views::Label( 1856 views::Label* content_label = new views::Label(
1809 l10n_util::GetStringFUTF16( 1857 l10n_util::GetStringFUTF16(
1810 IDS_PROFILES_NOT_YOU_CONTENT_TEXT, avatar_item.name)); 1858 IDS_PROFILES_NOT_YOU_CONTENT_TEXT, avatar_item.name));
1811 content_label->SetMultiLine(true); 1859 content_label->SetMultiLine(true);
1812 content_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); 1860 content_label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
1813 content_label->SetFontList(small_font_list); 1861 content_label->SetFontList(small_font_list);
1814 layout->AddView(content_label); 1862 layout->AddView(content_label);
1815 1863
1816 // Adds "Add person" button. 1864 // Adds "Add person" button.
1817 layout->StartRowWithPadding(1, 0, 0, views::kUnrelatedControlVerticalSpacing); 1865 layout->StartRowWithPadding(1, 0, 0, unrelated_vertical_spacing);
1818 layout->AddView(new views::Separator()); 1866 layout->AddView(new views::Separator());
1819 1867
1820 const int kIconSize = 24; 1868 const int kIconSize = 24;
1821 add_person_button_ = new BackgroundColorHoverButton( 1869 add_person_button_ = new BackgroundColorHoverButton(
1822 this, l10n_util::GetStringUTF16(IDS_PROFILES_ADD_PERSON_BUTTON), 1870 this, l10n_util::GetStringUTF16(IDS_PROFILES_ADD_PERSON_BUTTON),
1823 gfx::CreateVectorIcon(kAccountBoxIcon, kIconSize, gfx::kChromeIconGrey)); 1871 gfx::CreateVectorIcon(kAccountBoxIcon, kIconSize, gfx::kChromeIconGrey));
1824 layout->StartRow(1, 0); 1872 layout->StartRow(1, 0);
1825 layout->AddView(add_person_button_); 1873 layout->AddView(add_person_button_);
1826 1874
1827 // Adds "Disconnect your Google Account" button. 1875 // Adds "Disconnect your Google Account" button.
(...skipping 18 matching lines...) Expand all
1846 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != 1894 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) !=
1847 IncognitoModePrefs::DISABLED; 1895 IncognitoModePrefs::DISABLED;
1848 return incognito_available && !browser_->profile()->IsGuestSession(); 1896 return incognito_available && !browser_->profile()->IsGuestSession();
1849 } 1897 }
1850 1898
1851 void ProfileChooserView::PostActionPerformed( 1899 void ProfileChooserView::PostActionPerformed(
1852 ProfileMetrics::ProfileDesktopMenu action_performed) { 1900 ProfileMetrics::ProfileDesktopMenu action_performed) {
1853 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); 1901 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_);
1854 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; 1902 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE;
1855 } 1903 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698