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

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

Issue 2023093002: Reflow of the profile items in desktop user menu (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@move-profile-icon
Patch Set: Rebased and addressed comments Created 4 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/browser/browser_process.h" 10 #include "chrome/browser/browser_process.h"
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 #include "ui/views/layout/box_layout.h" 76 #include "ui/views/layout/box_layout.h"
77 #include "ui/views/layout/fill_layout.h" 77 #include "ui/views/layout/fill_layout.h"
78 #include "ui/views/layout/grid_layout.h" 78 #include "ui/views/layout/grid_layout.h"
79 #include "ui/views/layout/layout_constants.h" 79 #include "ui/views/layout/layout_constants.h"
80 #include "ui/views/widget/widget.h" 80 #include "ui/views/widget/widget.h"
81 81
82 namespace { 82 namespace {
83 83
84 // Helpers -------------------------------------------------------------------- 84 // Helpers --------------------------------------------------------------------
85 85
86 const int kFixedMenuWidth = 250;
87 const int kButtonHeight = 32; 86 const int kButtonHeight = 32;
88 const int kPasswordCombinedFixedGaiaViewWidth = 360; 87 const int kPasswordCombinedFixedGaiaViewWidth = 360;
89 const int kFixedGaiaViewWidth = 448; 88 const int kFixedGaiaViewWidth = 448;
90 const int kFixedAccountRemovalViewWidth = 280; 89 const int kFixedAccountRemovalViewWidth = 280;
91 const int kFixedSwitchUserViewWidth = 320; 90 const int kFixedSwitchUserViewWidth = 320;
92 const int kLargeImageSide = 88; 91 const int kLargeImageSide = 88;
92 const int kMediumImageSide = 40;
93 93
94 const int kTextfieldLabelHorizontalSpacing = 4;
95 const int kProfileHorizontalSpacing = 16;
94 const int kVerticalSpacing = 16; 96 const int kVerticalSpacing = 16;
95 97
96 const int kTitleViewNativeWidgetOffset = 8; 98 const int kTitleViewNativeWidgetOffset = 8;
97 99
98 bool IsProfileChooser(profiles::BubbleViewMode mode) { 100 bool IsProfileChooser(profiles::BubbleViewMode mode) {
99 return mode == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER || 101 return mode == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER ||
100 mode == profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER; 102 mode == profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER;
101 } 103 }
102 104
103 // Creates a GridLayout with a single column. This ensures that all the child 105 // Creates a GridLayout with a single column. This ensures that all the child
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 gfx::Rect bounds(title_view_->GetPreferredSize()); 258 gfx::Rect bounds(title_view_->GetPreferredSize());
257 title_view_->SetBoundsRect(bounds); 259 title_view_->SetBoundsRect(bounds);
258 bounds.Offset(kTitleViewNativeWidgetOffset, kTitleViewNativeWidgetOffset); 260 bounds.Offset(kTitleViewNativeWidgetOffset, kTitleViewNativeWidgetOffset);
259 title_widget_->SetBounds(bounds); 261 title_widget_->SetBounds(bounds);
260 } 262 }
261 263
262 } // namespace 264 } // namespace
263 265
264 // RightAlignedIconLabelButton ------------------------------------------------- 266 // RightAlignedIconLabelButton -------------------------------------------------
265 267
266 // A custom LabelButton that has a centered text and right aligned icon. 268 // A custom LabelButton that has a left-aligned text and right aligned icon.
269 // For non-material-design user menu, it has centered text instead.
267 class RightAlignedIconLabelButton : public views::LabelButton { 270 class RightAlignedIconLabelButton : public views::LabelButton {
268 public: 271 public:
269 RightAlignedIconLabelButton(views::ButtonListener* listener, 272 RightAlignedIconLabelButton(views::ButtonListener* listener,
270 const base::string16& text) 273 const base::string16& text)
271 : views::LabelButton(listener, text) { 274 : views::LabelButton(listener, text) {
272 SetHorizontalAlignment(gfx::ALIGN_RIGHT); 275 SetHorizontalAlignment(gfx::ALIGN_RIGHT);
273 label()->SetHorizontalAlignment(gfx::ALIGN_CENTER); 276 label()->SetHorizontalAlignment(switches::IsMaterialDesignUserMenu()
277 ? gfx::ALIGN_LEFT
278 : gfx::ALIGN_CENTER);
274 } 279 }
275 280
276 protected: 281 protected:
277 void Layout() override { 282 void Layout() override {
278 views::LabelButton::Layout(); 283 views::LabelButton::Layout();
279 284
280 // Keep the text centered and the icon right-aligned by stretching the label 285 // Keep the text centered and the icon right-aligned by stretching the label
281 // to take up more of the content area and centering its contents. 286 // to take up more of the content area and centering its contents.
282 gfx::Rect content_bounds = GetContentsBounds(); 287 gfx::Rect content_bounds = GetContentsBounds();
283 gfx::Rect label_bounds = label()->bounds(); 288 gfx::Rect label_bounds = label()->bounds();
(...skipping 17 matching lines...) Expand all
301 306
302 // A custom Image control that shows a "change" button when moused over. 307 // A custom Image control that shows a "change" button when moused over.
303 class EditableProfilePhoto : public views::LabelButton { 308 class EditableProfilePhoto : public views::LabelButton {
304 public: 309 public:
305 EditableProfilePhoto(views::ButtonListener* listener, 310 EditableProfilePhoto(views::ButtonListener* listener,
306 const gfx::Image& icon, 311 const gfx::Image& icon,
307 bool is_editing_allowed, 312 bool is_editing_allowed,
308 const gfx::Rect& bounds) 313 const gfx::Rect& bounds)
309 : views::LabelButton(listener, base::string16()), 314 : views::LabelButton(listener, base::string16()),
310 photo_overlay_(NULL) { 315 photo_overlay_(NULL) {
311 gfx::Image image = profiles::GetSizedAvatarIcon( 316 const int icon_image_side = switches::IsMaterialDesignUserMenu()
312 icon, true, kLargeImageSide, kLargeImageSide); 317 ? kMediumImageSide
318 : kLargeImageSide;
319 gfx::Image image = profiles::GetSizedAvatarIcon(icon, true, icon_image_side,
320 icon_image_side);
313 SetImage(views::LabelButton::STATE_NORMAL, *image.ToImageSkia()); 321 SetImage(views::LabelButton::STATE_NORMAL, *image.ToImageSkia());
314 SetBorder(views::Border::NullBorder()); 322 SetBorder(views::Border::NullBorder());
315 SetBoundsRect(bounds); 323 SetBoundsRect(bounds);
316 324
317 // Calculate the circular mask that will be used to display the photo. 325 // Calculate the circular mask that will be used to display the photo.
318 circular_mask_.addCircle(SkIntToScalar(bounds.width() / 2), 326 circular_mask_.addCircle(SkIntToScalar(bounds.width() / 2),
319 SkIntToScalar(bounds.height() / 2), 327 SkIntToScalar(bounds.height() / 2),
320 SkIntToScalar(bounds.width() / 2)); 328 SkIntToScalar(bounds.width() / 2));
321 329
322 if (!is_editing_allowed) { 330 if (!is_editing_allowed) {
323 SetEnabled(false); 331 SetEnabled(false);
324 return; 332 return;
325 } 333 }
326 334
327 set_notify_enter_exit_on_child(true); 335 set_notify_enter_exit_on_child(true);
328 336
329 // Photo overlay that appears when hovering over the button. 337 // Photo overlay that appears when hovering over the button.
330 photo_overlay_ = new views::ImageView(); 338 photo_overlay_ = new views::ImageView();
331 339
332 const SkColor kBackgroundColor = SkColorSetARGB(65, 255, 255, 255); 340 const SkColor kBackgroundColor = SkColorSetARGB(65, 255, 255, 255);
333 photo_overlay_->set_background( 341 photo_overlay_->set_background(
334 views::Background::CreateSolidBackground(kBackgroundColor)); 342 views::Background::CreateSolidBackground(kBackgroundColor));
335 photo_overlay_->SetImage(gfx::CreateVectorIcon( 343 photo_overlay_->SetImage(
336 gfx::VectorIconId::PHOTO_CAMERA, 48u, SkColorSetRGB(0x33, 0x33, 0x33))); 344 gfx::CreateVectorIcon(gfx::VectorIconId::PHOTO_CAMERA,
345 switches::IsMaterialDesignUserMenu() ? 22u : 48u,
346 SkColorSetRGB(0x33, 0x33, 0x33)));
337 347
338 photo_overlay_->SetSize(bounds.size()); 348 photo_overlay_->SetSize(bounds.size());
339 photo_overlay_->SetVisible(false); 349 photo_overlay_->SetVisible(false);
340 AddChildView(photo_overlay_); 350 AddChildView(photo_overlay_);
341 } 351 }
342 352
343 void OnPaint(gfx::Canvas* canvas) override { 353 void OnPaint(gfx::Canvas* canvas) override {
344 // Display the profile picture as a circle. 354 // Display the profile picture as a circle.
345 canvas->ClipPath(circular_mask_, true); 355 canvas->ClipPath(circular_mask_, true);
346 views::LabelButton::OnPaint(canvas); 356 views::LabelButton::OnPaint(canvas);
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); 408 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0));
399 409
400 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); 410 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance();
401 const gfx::FontList& medium_font_list = 411 const gfx::FontList& medium_font_list =
402 rb->GetFontList(ui::ResourceBundle::MediumFont); 412 rb->GetFontList(ui::ResourceBundle::MediumFont);
403 413
404 if (!is_editing_allowed) { 414 if (!is_editing_allowed) {
405 label_ = new views::Label(text); 415 label_ = new views::Label(text);
406 label_->SetBorder(views::Border::CreateEmptyBorder(2, 0, 2, 0)); 416 label_->SetBorder(views::Border::CreateEmptyBorder(2, 0, 2, 0));
407 label_->SetFontList(medium_font_list); 417 label_->SetFontList(medium_font_list);
418 if (switches::IsMaterialDesignUserMenu())
419 label_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
408 AddChildView(label_); 420 AddChildView(label_);
409 return; 421 return;
410 } 422 }
411 423
412 button_ = new RightAlignedIconLabelButton(this, text); 424 button_ = new RightAlignedIconLabelButton(this, text);
413 button_->SetFontList(medium_font_list); 425 button_->SetFontList(medium_font_list);
414 // Show an "edit" pencil icon when hovering over. In the default state, 426 // Show an "edit" pencil icon when hovering over. In the default state,
415 // we need to create an empty placeholder of the correct size, so that 427 // we need to create an empty placeholder of the correct size, so that
416 // the text doesn't jump around when the hovered icon appears. 428 // the text doesn't jump around when the hovered icon appears.
417 // TODO(estade): revisit colors and press effect. 429 // TODO(estade): revisit colors and press effect.
418 const int kIconSize = 16; 430 const int kIconSize = 16;
419 button_->SetImage(views::LabelButton::STATE_NORMAL, 431 button_->SetImage(views::LabelButton::STATE_NORMAL,
420 CreateSquarePlaceholderImage(kIconSize)); 432 CreateSquarePlaceholderImage(kIconSize));
421 button_->SetImage(views::LabelButton::STATE_HOVERED, 433 button_->SetImage(views::LabelButton::STATE_HOVERED,
422 gfx::CreateVectorIcon( 434 gfx::CreateVectorIcon(
423 gfx::VectorIconId::MODE_EDIT, kIconSize, 435 gfx::VectorIconId::MODE_EDIT, kIconSize,
424 SkColorSetRGB(0x33, 0x33, 0x33))); 436 SkColorSetRGB(0x33, 0x33, 0x33)));
425 button_->SetImage(views::LabelButton::STATE_PRESSED, 437 button_->SetImage(views::LabelButton::STATE_PRESSED,
426 gfx::CreateVectorIcon( 438 gfx::CreateVectorIcon(
427 gfx::VectorIconId::MODE_EDIT, kIconSize, 439 gfx::VectorIconId::MODE_EDIT, kIconSize,
428 SkColorSetRGB(0x20, 0x20, 0x20))); 440 SkColorSetRGB(0x20, 0x20, 0x20)));
429 // To center the text, we need to offest it by the width of the icon we 441 // We need to add a left padding as well as a small top/bottom padding
430 // are adding and its padding. We need to also add a small top/bottom 442 // to the text to account for the textfield's border.
431 // padding to account for the textfield's border. 443 if (switches::IsMaterialDesignUserMenu()) {
432 const int kIconTextLabelButtonSpacing = 5; 444 button_->SetBorder(views::Border::CreateEmptyBorder(
433 button_->SetBorder(views::Border::CreateEmptyBorder( 445 2, kTextfieldLabelHorizontalSpacing, 2, 0));
434 2, kIconSize + kIconTextLabelButtonSpacing, 2, 0)); 446 } else {
447 const int kIconTextLabelButtonSpacing = 5;
448 button_->SetBorder(views::Border::CreateEmptyBorder(
449 2, kIconSize + kIconTextLabelButtonSpacing, 2, 0));
450 }
435 AddChildView(button_); 451 AddChildView(button_);
436 452
437 profile_name_textfield_ = new views::Textfield(); 453 profile_name_textfield_ = new views::Textfield();
438 // Textfield that overlaps the button. 454 // Textfield that overlaps the button.
439 profile_name_textfield_->set_controller(controller); 455 profile_name_textfield_->set_controller(controller);
440 profile_name_textfield_->SetFontList(medium_font_list); 456 profile_name_textfield_->SetFontList(medium_font_list);
441 profile_name_textfield_->SetHorizontalAlignment(gfx::ALIGN_CENTER); 457 profile_name_textfield_->SetHorizontalAlignment(
458 switches::IsMaterialDesignUserMenu() ? gfx::ALIGN_LEFT
459 : gfx::ALIGN_CENTER);
442 profile_name_textfield_->SetVisible(false); 460 profile_name_textfield_->SetVisible(false);
443 AddChildView(profile_name_textfield_); 461 AddChildView(profile_name_textfield_);
444 } 462 }
445 463
446 views::Textfield* profile_name_textfield() { 464 views::Textfield* profile_name_textfield() {
447 return profile_name_textfield_; 465 return profile_name_textfield_;
448 } 466 }
449 467
450 // Hide the editable textfield to show the profile name button instead. 468 // Hide the editable textfield to show the profile name button instead.
451 void ShowReadOnlyView() { 469 void ShowReadOnlyView() {
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
558 576
559 views::ImageButton* back_button_; 577 views::ImageButton* back_button_;
560 views::Label* title_label_; 578 views::Label* title_label_;
561 579
562 DISALLOW_COPY_AND_ASSIGN(TitleCard); 580 DISALLOW_COPY_AND_ASSIGN(TitleCard);
563 }; 581 };
564 582
565 // ProfileBadge -------------------------------------------------------- 583 // ProfileBadge --------------------------------------------------------
566 584
567 const size_t kProfileBadgeSize = 30; 585 const size_t kProfileBadgeSize = 30;
586 const size_t kSmallProfileBadgeSize = 24;
568 const size_t kProfileBadgeWhitePadding = 2; 587 const size_t kProfileBadgeWhitePadding = 2;
569 588
570 // Draws a white circle, then a light blue circle, then a dark blue icon. 589 // Draws a white circle, then a light blue circle, then a dark blue icon.
571 class ProfileBadge : public gfx::CanvasImageSource { 590 class ProfileBadge : public gfx::CanvasImageSource {
572 public: 591 public:
573 ProfileBadge(gfx::VectorIconId id, size_t icon_size) 592 ProfileBadge(gfx::VectorIconId id, size_t icon_size)
574 : CanvasImageSource(gfx::Size(kProfileBadgeSize, kProfileBadgeSize), 593 : CanvasImageSource(gfx::Size(switches::IsMaterialDesignUserMenu()
594 ? kSmallProfileBadgeSize
595 : kProfileBadgeSize,
596 switches::IsMaterialDesignUserMenu()
597 ? kSmallProfileBadgeSize
598 : kProfileBadgeSize),
575 false), 599 false),
576 id_(id), 600 id_(id),
577 icon_size_(icon_size) {} 601 icon_size_(icon_size) {}
578 602
579 ~ProfileBadge() override {} 603 ~ProfileBadge() override {}
580 604
581 // CanvasImageSource: 605 // CanvasImageSource:
582 void Draw(gfx::Canvas* canvas) override { 606 void Draw(gfx::Canvas* canvas) override {
583 const SkISize size = canvas->sk_canvas()->getBaseLayerSize(); 607 const SkISize size = canvas->sk_canvas()->getBaseLayerSize();
584 gfx::Rect bounds(0, 0, size.width(), size.height()); 608 gfx::Rect bounds(0, 0, size.width(), size.height());
585 609
586 SkPaint paint; 610 SkPaint paint;
587 paint.setAntiAlias(true); 611 paint.setAntiAlias(true);
588 paint.setColor(SK_ColorWHITE); 612 paint.setColor(SK_ColorWHITE);
589 canvas->DrawCircle(bounds.CenterPoint(), size.width() / 2, paint); 613 canvas->DrawCircle(bounds.CenterPoint(), size.width() / 2, paint);
590 614
591 paint.setColor(SkColorSetRGB(0xAF, 0xD9, 0xFC)); 615 paint.setColor(SkColorSetRGB(0xAF, 0xD9, 0xFC));
592 canvas->DrawCircle(bounds.CenterPoint(), 616 canvas->DrawCircle(bounds.CenterPoint(),
593 size.width() / 2 - kProfileBadgeWhitePadding, paint); 617 size.width() / 2 - kProfileBadgeWhitePadding, paint);
594 618
595 int offset = (kProfileBadgeSize - icon_size_) / 2; 619 int offset = ((switches::IsMaterialDesignUserMenu() ? kSmallProfileBadgeSize
620 : kProfileBadgeSize) -
621 icon_size_) / 2;
596 canvas->Translate(gfx::Vector2d(offset, offset)); 622 canvas->Translate(gfx::Vector2d(offset, offset));
597 gfx::PaintVectorIcon(canvas, id_, icon_size_, SkColorSetRGB(0, 0x66, 0xff)); 623 gfx::PaintVectorIcon(canvas, id_, icon_size_, SkColorSetRGB(0, 0x66, 0xff));
598 } 624 }
599 625
600 private: 626 private:
601 const gfx::VectorIconId id_; 627 const gfx::VectorIconId id_;
602 const size_t icon_size_; 628 const size_t icon_size_;
603 629
604 DISALLOW_COPY_AND_ASSIGN(ProfileBadge); 630 DISALLOW_COPY_AND_ASSIGN(ProfileBadge);
605 }; 631 };
606 632
607 gfx::ImageSkia CreateBadgeForProfile(Profile* profile) { 633 gfx::ImageSkia CreateBadgeForProfile(Profile* profile) {
608 ProfileBadge* badge = 634 ProfileBadge* badge =
609 profile->IsChild() 635 profile->IsChild()
610 ? new ProfileBadge(gfx::VectorIconId::ACCOUNT_CHILD_INVERT, 26) 636 ? new ProfileBadge(gfx::VectorIconId::ACCOUNT_CHILD_INVERT,
611 : new ProfileBadge(gfx::VectorIconId::SUPERVISOR_ACCOUNT, 20); 637 switches::IsMaterialDesignUserMenu() ? 21 : 26)
612 638 : new ProfileBadge(gfx::VectorIconId::SUPERVISOR_ACCOUNT,
639 switches::IsMaterialDesignUserMenu() ? 16 : 20);
613 return gfx::ImageSkia(badge, badge->size()); 640 return gfx::ImageSkia(badge, badge->size());
614 } 641 }
615 642
616 // ProfileChooserView --------------------------------------------------------- 643 // ProfileChooserView ---------------------------------------------------------
617 644
618 // static 645 // static
619 ProfileChooserView* ProfileChooserView::profile_bubble_ = nullptr; 646 ProfileChooserView* ProfileChooserView::profile_bubble_ = nullptr;
620 bool ProfileChooserView::close_on_deactivate_for_testing_ = true; 647 bool ProfileChooserView::close_on_deactivate_for_testing_ = true;
621 648
622 // static 649 // static
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
657 bool ProfileChooserView::IsShowing() { 684 bool ProfileChooserView::IsShowing() {
658 return profile_bubble_ != NULL; 685 return profile_bubble_ != NULL;
659 } 686 }
660 687
661 // static 688 // static
662 void ProfileChooserView::Hide() { 689 void ProfileChooserView::Hide() {
663 if (IsShowing()) 690 if (IsShowing())
664 profile_bubble_->GetWidget()->Close(); 691 profile_bubble_->GetWidget()->Close();
665 } 692 }
666 693
694 // static
695 int ProfileChooserView::GetFixedMenuWidth() {
696 return switches::IsMaterialDesignUserMenu() ? 240 : 250;
697 }
698
667 ProfileChooserView::ProfileChooserView(views::View* anchor_view, 699 ProfileChooserView::ProfileChooserView(views::View* anchor_view,
668 Browser* browser, 700 Browser* browser,
669 profiles::BubbleViewMode view_mode, 701 profiles::BubbleViewMode view_mode,
670 profiles::TutorialMode tutorial_mode, 702 profiles::TutorialMode tutorial_mode,
671 signin::GAIAServiceType service_type, 703 signin::GAIAServiceType service_type,
672 signin_metrics::AccessPoint access_point) 704 signin_metrics::AccessPoint access_point)
673 : BubbleDialogDelegateView(anchor_view, views::BubbleBorder::TOP_RIGHT), 705 : BubbleDialogDelegateView(anchor_view, views::BubbleBorder::TOP_RIGHT),
674 browser_(browser), 706 browser_(browser),
675 view_mode_(view_mode), 707 view_mode_(view_mode),
676 tutorial_mode_(tutorial_mode), 708 tutorial_mode_(tutorial_mode),
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
832 break; 864 break;
833 case profiles::BUBBLE_VIEW_MODE_SWITCH_USER: 865 case profiles::BUBBLE_VIEW_MODE_SWITCH_USER:
834 layout = CreateSingleColumnLayout(this, kFixedSwitchUserViewWidth); 866 layout = CreateSingleColumnLayout(this, kFixedSwitchUserViewWidth);
835 sub_view = CreateSwitchUserView(); 867 sub_view = CreateSwitchUserView();
836 ProfileMetrics::LogProfileNewAvatarMenuNotYou( 868 ProfileMetrics::LogProfileNewAvatarMenuNotYou(
837 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_VIEW); 869 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_VIEW);
838 break; 870 break;
839 case profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT: 871 case profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT:
840 case profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER: 872 case profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER:
841 case profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER: 873 case profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER:
842 layout = CreateSingleColumnLayout(this, kFixedMenuWidth); 874 layout = CreateSingleColumnLayout(this, GetFixedMenuWidth());
843 sub_view = CreateProfileChooserView(avatar_menu); 875 sub_view = CreateProfileChooserView(avatar_menu);
844 break; 876 break;
845 } 877 }
846 // Clears tutorial mode for all non-profile-chooser views. 878 // Clears tutorial mode for all non-profile-chooser views.
847 if (view_mode_ != profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER) 879 if (view_mode_ != profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER)
848 tutorial_mode_ = profiles::TUTORIAL_MODE_NONE; 880 tutorial_mode_ = profiles::TUTORIAL_MODE_NONE;
849 881
850 layout->StartRow(1, 0); 882 layout->StartRow(1, 0);
851 layout->AddView(sub_view); 883 layout->AddView(sub_view);
852 Layout(); 884 Layout();
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
1082 Indexes other_profiles; 1114 Indexes other_profiles;
1083 views::View* tutorial_view = NULL; 1115 views::View* tutorial_view = NULL;
1084 views::View* current_profile_view = NULL; 1116 views::View* current_profile_view = NULL;
1085 views::View* current_profile_accounts = NULL; 1117 views::View* current_profile_accounts = NULL;
1086 views::View* option_buttons_view = NULL; 1118 views::View* option_buttons_view = NULL;
1087 for (size_t i = 0; i < avatar_menu->GetNumberOfItems(); ++i) { 1119 for (size_t i = 0; i < avatar_menu->GetNumberOfItems(); ++i) {
1088 const AvatarMenu::Item& item = avatar_menu->GetItemAt(i); 1120 const AvatarMenu::Item& item = avatar_menu->GetItemAt(i);
1089 if (item.active) { 1121 if (item.active) {
1090 option_buttons_view = CreateOptionsView( 1122 option_buttons_view = CreateOptionsView(
1091 item.signed_in && profiles::IsLockAvailable(browser_->profile())); 1123 item.signed_in && profiles::IsLockAvailable(browser_->profile()));
1092 current_profile_view = CreateCurrentProfileView(item, false); 1124 current_profile_view =
1125 switches::IsMaterialDesignUserMenu()
1126 ? CreateMaterialDesignCurrentProfileView(item, false)
1127 : CreateCurrentProfileView(item, false);
1093 if (IsProfileChooser(view_mode_)) { 1128 if (IsProfileChooser(view_mode_)) {
1094 tutorial_view = CreateTutorialViewIfNeeded(item); 1129 tutorial_view = CreateTutorialViewIfNeeded(item);
1095 } else { 1130 } else {
1096 current_profile_accounts = CreateCurrentProfileAccountsView(item); 1131 current_profile_accounts = CreateCurrentProfileAccountsView(item);
1097 } 1132 }
1098 } else { 1133 } else {
1099 other_profiles.push_back(i); 1134 other_profiles.push_back(i);
1100 } 1135 }
1101 } 1136 }
1102 1137
(...skipping 16 matching lines...) Expand all
1119 1154
1120 if (!IsProfileChooser(view_mode_)) { 1155 if (!IsProfileChooser(view_mode_)) {
1121 DCHECK(current_profile_accounts); 1156 DCHECK(current_profile_accounts);
1122 layout->StartRow(0, 0); 1157 layout->StartRow(0, 0);
1123 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); 1158 layout->AddView(new views::Separator(views::Separator::HORIZONTAL));
1124 layout->StartRow(1, 0); 1159 layout->StartRow(1, 0);
1125 layout->AddView(current_profile_accounts); 1160 layout->AddView(current_profile_accounts);
1126 } 1161 }
1127 1162
1128 if (browser_->profile()->IsSupervised()) { 1163 if (browser_->profile()->IsSupervised()) {
1129 layout->StartRow(0, 0); 1164 if (!switches::IsMaterialDesignUserMenu()) {
1130 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); 1165 layout->StartRow(0, 0);
1166 layout->AddView(new views::Separator(views::Separator::HORIZONTAL));
1167 }
1131 layout->StartRow(1, 0); 1168 layout->StartRow(1, 0);
1132 layout->AddView(CreateSupervisedUserDisclaimerView()); 1169 layout->AddView(CreateSupervisedUserDisclaimerView());
1133 } 1170 }
1134 1171
1135 layout->StartRow(0, 0); 1172 layout->StartRow(0, 0);
1136 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); 1173 layout->AddView(new views::Separator(views::Separator::HORIZONTAL));
1137 1174
1138 if (option_buttons_view) { 1175 if (option_buttons_view) {
1139 layout->StartRow(0, 0); 1176 layout->StartRow(0, 0);
1140 layout->AddView(option_buttons_view); 1177 layout->AddView(option_buttons_view);
(...skipping 11 matching lines...) Expand all
1152 } 1189 }
1153 } 1190 }
1154 1191
1155 layout->StartRow(1, 0); 1192 layout->StartRow(1, 0);
1156 layout->AddView(CreateOtherProfilesView(other_profiles)); 1193 layout->AddView(CreateOtherProfilesView(other_profiles));
1157 } 1194 }
1158 1195
1159 views::View* ProfileChooserView::CreateProfileChooserView( 1196 views::View* ProfileChooserView::CreateProfileChooserView(
1160 AvatarMenu* avatar_menu) { 1197 AvatarMenu* avatar_menu) {
1161 views::View* view = new views::View(); 1198 views::View* view = new views::View();
1162 views::GridLayout* layout = CreateSingleColumnLayout(view, kFixedMenuWidth); 1199 views::GridLayout* layout =
1200 CreateSingleColumnLayout(view, GetFixedMenuWidth());
1163 1201
1164 if (view_mode_ == profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER) { 1202 if (view_mode_ == profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER) {
1165 PopulateMinimalProfileChooserView(layout, avatar_menu); 1203 PopulateMinimalProfileChooserView(layout, avatar_menu);
1166 // The user is using right-click switching, no need to tell them about it. 1204 // The user is using right-click switching, no need to tell them about it.
1167 PrefService* local_state = g_browser_process->local_state(); 1205 PrefService* local_state = g_browser_process->local_state();
1168 local_state->SetBoolean( 1206 local_state->SetBoolean(
1169 prefs::kProfileAvatarRightClickTutorialDismissed, true); 1207 prefs::kProfileAvatarRightClickTutorialDismissed, true);
1170 } else { 1208 } else {
1171 PopulateCompleteProfileChooserView(layout, avatar_menu); 1209 PopulateCompleteProfileChooserView(layout, avatar_menu);
1172 } 1210 }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1227 const base::string16& button_text, 1265 const base::string16& button_text,
1228 bool stack_button, 1266 bool stack_button,
1229 views::Link** link, 1267 views::Link** link,
1230 views::LabelButton** button, 1268 views::LabelButton** button,
1231 views::ImageButton** close_button) { 1269 views::ImageButton** close_button) {
1232 tutorial_mode_ = tutorial_mode; 1270 tutorial_mode_ = tutorial_mode;
1233 1271
1234 views::View* view = new views::View(); 1272 views::View* view = new views::View();
1235 view->set_background(views::Background::CreateSolidBackground( 1273 view->set_background(views::Background::CreateSolidBackground(
1236 profiles::kAvatarTutorialBackgroundColor)); 1274 profiles::kAvatarTutorialBackgroundColor));
1237 views::GridLayout* layout = CreateSingleColumnLayout(view, 1275 views::GridLayout* layout = CreateSingleColumnLayout(
1238 kFixedMenuWidth - 2 * views::kButtonHEdgeMarginNew); 1276 view, GetFixedMenuWidth() - 2 * views::kButtonHEdgeMarginNew);
1239 // Creates a second column set for buttons and links. 1277 // Creates a second column set for buttons and links.
1240 views::ColumnSet* button_columns = layout->AddColumnSet(1); 1278 views::ColumnSet* button_columns = layout->AddColumnSet(1);
1241 button_columns->AddColumn(views::GridLayout::LEADING, 1279 button_columns->AddColumn(views::GridLayout::LEADING,
1242 views::GridLayout::CENTER, 0, views::GridLayout::USE_PREF, 0, 0); 1280 views::GridLayout::CENTER, 0, views::GridLayout::USE_PREF, 0, 0);
1243 button_columns->AddPaddingColumn( 1281 button_columns->AddPaddingColumn(
1244 1, views::kUnrelatedControlHorizontalSpacing); 1282 1, views::kUnrelatedControlHorizontalSpacing);
1245 button_columns->AddColumn(views::GridLayout::TRAILING, 1283 button_columns->AddColumn(views::GridLayout::TRAILING,
1246 views::GridLayout::CENTER, 0, views::GridLayout::USE_PREF, 0, 0); 1284 views::GridLayout::CENTER, 0, views::GridLayout::USE_PREF, 0, 0);
1247 layout->SetInsets(views::kButtonVEdgeMarginNew, 1285 layout->SetInsets(views::kButtonVEdgeMarginNew,
1248 views::kButtonHEdgeMarginNew, 1286 views::kButtonHEdgeMarginNew,
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
1330 layout->SkipColumns(1); 1368 layout->SkipColumns(1);
1331 } 1369 }
1332 1370
1333 return view; 1371 return view;
1334 } 1372 }
1335 1373
1336 views::View* ProfileChooserView::CreateCurrentProfileView( 1374 views::View* ProfileChooserView::CreateCurrentProfileView(
1337 const AvatarMenu::Item& avatar_item, 1375 const AvatarMenu::Item& avatar_item,
1338 bool is_guest) { 1376 bool is_guest) {
1339 views::View* view = new views::View(); 1377 views::View* view = new views::View();
1340 int column_width = kFixedMenuWidth - 2 * views::kButtonHEdgeMarginNew; 1378 int column_width = GetFixedMenuWidth() - 2 * views::kButtonHEdgeMarginNew;
1341 views::GridLayout* layout = CreateSingleColumnLayout(view, column_width); 1379 views::GridLayout* layout = CreateSingleColumnLayout(view, column_width);
1342 layout->SetInsets(views::kButtonVEdgeMarginNew, 1380 layout->SetInsets(views::kButtonVEdgeMarginNew,
1343 views::kButtonHEdgeMarginNew, 1381 views::kButtonHEdgeMarginNew,
1344 views::kUnrelatedControlVerticalSpacing, 1382 views::kUnrelatedControlVerticalSpacing,
1345 views::kButtonHEdgeMarginNew); 1383 views::kButtonHEdgeMarginNew);
1346 1384
1347 // Profile icon, centered. 1385 // Profile icon, centered.
1348 int x_offset = (column_width - kLargeImageSide) / 2; 1386 int x_offset = (column_width - kLargeImageSide) / 2;
1349 current_profile_photo_ = new EditableProfilePhoto( 1387 current_profile_photo_ = new EditableProfilePhoto(
1350 this, avatar_item.icon, !is_guest, 1388 this, avatar_item.icon, !is_guest,
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
1443 layout->StartRow(1, 0); 1481 layout->StartRow(1, 0);
1444 layout->AddView(signin_current_profile_link_); 1482 layout->AddView(signin_current_profile_link_);
1445 content::RecordAction( 1483 content::RecordAction(
1446 base::UserMetricsAction("Signin_Impression_FromAvatarBubbleSignin")); 1484 base::UserMetricsAction("Signin_Impression_FromAvatarBubbleSignin"));
1447 } 1485 }
1448 } 1486 }
1449 1487
1450 return view; 1488 return view;
1451 } 1489 }
1452 1490
1491 views::View* ProfileChooserView::CreateMaterialDesignCurrentProfileView(
1492 const AvatarMenu::Item& avatar_item,
1493 bool is_guest) {
1494 views::View* view = new views::View();
1495 int column_width =
1496 GetFixedMenuWidth() - 2 * views::kMaterialMenuHorizontalEdgeMargin;
1497 views::GridLayout* layout = CreateSingleColumnLayout(view, column_width);
1498 layout->SetInsets(views::kRelatedControlVerticalSpacing,
1499 views::kMaterialMenuHorizontalEdgeMargin,
1500 views::kRelatedControlVerticalSpacing,
1501 views::kMaterialMenuHorizontalEdgeMargin);
1502
1503 // Profile picture, left-aligned.
1504 const int profile_bar_height = 56;
1505 current_profile_photo_ = new EditableProfilePhoto(
1506 this, avatar_item.icon, !is_guest,
1507 gfx::Rect(0, (profile_bar_height - kMediumImageSide) / 2,
1508 kMediumImageSide, kMediumImageSide));
1509 SizedContainer* profile_container =
1510 new SizedContainer(gfx::Size(column_width, profile_bar_height));
1511 profile_container->AddChildView(current_profile_photo_);
1512
1513 // Add supervised badge for supervised profile.
1514 if (browser_->profile()->IsSupervised()) {
1515 const int badge_spacing = 4;
1516 views::ImageView* supervised_icon = new views::ImageView();
1517 supervised_icon->SetImage(CreateBadgeForProfile(browser_->profile()));
1518 gfx::Size preferred_size = supervised_icon->GetPreferredSize();
1519 gfx::Rect parent_bounds = current_profile_photo_->bounds();
1520 supervised_icon->SetBounds(
1521 parent_bounds.right() - preferred_size.width() + badge_spacing,
1522 parent_bounds.bottom() - preferred_size.height() + badge_spacing,
1523 preferred_size.width(), preferred_size.height());
1524 profile_container->AddChildView(supervised_icon);
1525 }
1526
1527 // Profile name, left-aligned to the right of profile icon.
1528 bool editing_allowed =
1529 !is_guest && !browser_->profile()->IsLegacySupervised();
1530 current_profile_name_ = new EditableProfileName(
1531 this, profiles::GetAvatarNameForProfile(browser_->profile()->GetPath()),
1532 editing_allowed);
1533 gfx::Rect photo_bounds = current_profile_photo_->bounds();
1534 const int textfield_left_margin =
1535 kProfileHorizontalSpacing -
1536 (editing_allowed ? kTextfieldLabelHorizontalSpacing : 0);
1537 current_profile_name_->SetBounds(
1538 photo_bounds.width() + textfield_left_margin,
1539 views::kRelatedControlVerticalSpacing,
1540 profile_container->GetPreferredSize().width() - photo_bounds.width() -
1541 textfield_left_margin,
1542 profile_container->GetPreferredSize().height() / 2 -
1543 views::kRelatedControlVerticalSpacing);
1544 profile_container->AddChildView(current_profile_name_);
1545
1546 // Center-align the avatar name if the profile is not signed in.
1547 if (is_guest || !avatar_item.signed_in) {
1548 current_profile_name_->SetY(
1549 (profile_container->GetPreferredSize().height() -
1550 current_profile_name_->height()) /
1551 2);
1552 layout->StartRow(1, 0);
1553 layout->AddView(profile_container);
1554 }
1555
1556 if (is_guest)
1557 return view;
1558
1559 // The available links depend on the type of profile that is active.
1560 if (avatar_item.signed_in) {
1561 // Calculate the position and size for links available for signed-in
1562 // profiles.
1563 const int x_coordinate = photo_bounds.width() + kProfileHorizontalSpacing;
1564 const int y_coordinate = profile_container->GetPreferredSize().height() / 2;
1565 const int width = profile_container->GetPreferredSize().width() -
1566 photo_bounds.width() - kProfileHorizontalSpacing;
1567 const int height = profile_container->GetPreferredSize().height() / 2 -
1568 views::kRelatedControlVerticalSpacing;
1569 layout->StartRow(1, 0);
1570
1571 if (switches::IsEnableAccountConsistency()) {
1572 base::string16 link_title = l10n_util::GetStringUTF16(
1573 IsProfileChooser(view_mode_)
1574 ? IDS_PROFILES_PROFILE_MANAGE_ACCOUNTS_BUTTON
1575 : IDS_PROFILES_PROFILE_HIDE_MANAGE_ACCOUNTS_BUTTON);
1576 manage_accounts_link_ = CreateLink(link_title, this);
1577 manage_accounts_link_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
1578 manage_accounts_link_->SetBounds(x_coordinate, y_coordinate, width,
1579 height);
1580 profile_container->AddChildView(manage_accounts_link_);
1581 } else if (HasAuthError(browser_->profile())) {
1582 // Badge the email address if there's an authentication error.
1583 auth_error_email_button_ =
1584 new RightAlignedIconLabelButton(this, avatar_item.username);
1585 auth_error_email_button_->SetElideBehavior(gfx::ELIDE_EMAIL);
1586 auth_error_email_button_->SetImage(
1587 views::LabelButton::STATE_NORMAL,
1588 gfx::CreateVectorIcon(gfx::VectorIconId::WARNING, 12,
1589 gfx::kChromeIconGrey));
1590 auth_error_email_button_->SetFocusForPlatform();
1591 auth_error_email_button_->set_request_focus_on_press(true);
1592 gfx::Insets insets =
1593 views::LabelButtonAssetBorder::GetDefaultInsetsForStyle(
1594 views::Button::STYLE_TEXTBUTTON);
1595 auth_error_email_button_->SetBorder(views::Border::CreateEmptyBorder(
1596 insets.top(), insets.left(), insets.bottom(), insets.right()));
1597 auth_error_email_button_->SetBounds(x_coordinate - insets.left(),
1598 y_coordinate, width, height);
1599 profile_container->AddChildView(auth_error_email_button_);
1600 } else {
1601 views::Label* email_label = new views::Label(avatar_item.username);
1602 email_label->SetElideBehavior(gfx::ELIDE_EMAIL);
1603 email_label->SetEnabled(false);
1604 email_label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
1605 email_label->SetBounds(x_coordinate, y_coordinate, width, height);
1606 profile_container->AddChildView(email_label);
1607 }
1608 layout->AddView(profile_container);
1609 return view;
1610 }
1611
1612 SigninManagerBase* signin_manager = SigninManagerFactory::GetForProfile(
1613 browser_->profile()->GetOriginalProfile());
1614 if (signin_manager->IsSigninAllowed()) {
1615 views::Label* promo =
1616 new views::Label(l10n_util::GetStringUTF16(IDS_PROFILES_SIGNIN_PROMO));
1617 promo->SetMultiLine(true);
1618 promo->SetHorizontalAlignment(gfx::ALIGN_LEFT);
1619 layout->StartRowWithPadding(1, 0, 0, views::kRelatedControlVerticalSpacing);
1620 layout->StartRow(1, 0);
1621 layout->AddView(promo);
1622
1623 signin_current_profile_link_ =
1624 views::MdTextButton::CreateSecondaryUiBlueButton(
1625 this, l10n_util::GetStringFUTF16(
1626 IDS_SYNC_START_SYNC_BUTTON_LABEL,
1627 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME)));
1628 signin_current_profile_link_->SetMinSize(gfx::Size(0, 36));
1629 layout->StartRowWithPadding(1, 0, 0, views::kRelatedControlVerticalSpacing);
1630 layout->StartRow(1, 0);
1631 layout->AddView(signin_current_profile_link_);
1632 content::RecordAction(
1633 base::UserMetricsAction("Signin_Impression_FromAvatarBubbleSignin"));
1634 layout->StartRowWithPadding(1, 0, 0, views::kLabelToControlVerticalSpacing);
1635 }
1636
1637 return view;
1638 }
1639
1453 views::View* ProfileChooserView::CreateGuestProfileView() { 1640 views::View* ProfileChooserView::CreateGuestProfileView() {
1454 gfx::Image guest_icon = 1641 gfx::Image guest_icon =
1455 ui::ResourceBundle::GetSharedInstance().GetImageNamed( 1642 ui::ResourceBundle::GetSharedInstance().GetImageNamed(
1456 profiles::GetPlaceholderAvatarIconResourceID()); 1643 profiles::GetPlaceholderAvatarIconResourceID());
1457 AvatarMenu::Item guest_avatar_item(0, base::FilePath(), guest_icon); 1644 AvatarMenu::Item guest_avatar_item(0, base::FilePath(), guest_icon);
1458 guest_avatar_item.active = true; 1645 guest_avatar_item.active = true;
1459 guest_avatar_item.name = l10n_util::GetStringUTF16( 1646 guest_avatar_item.name = l10n_util::GetStringUTF16(
1460 IDS_PROFILES_GUEST_PROFILE_NAME); 1647 IDS_PROFILES_GUEST_PROFILE_NAME);
1461 guest_avatar_item.signed_in = false; 1648 guest_avatar_item.signed_in = false;
1462 1649
1463 return CreateCurrentProfileView(guest_avatar_item, true); 1650 return switches::IsMaterialDesignUserMenu()
1651 ? CreateMaterialDesignCurrentProfileView(guest_avatar_item, true)
1652 : CreateCurrentProfileView(guest_avatar_item, true);
1464 } 1653 }
1465 1654
1466 views::View* ProfileChooserView::CreateOtherProfilesView( 1655 views::View* ProfileChooserView::CreateOtherProfilesView(
1467 const Indexes& avatars_to_show) { 1656 const Indexes& avatars_to_show) {
1468 views::View* view = new views::View(); 1657 views::View* view = new views::View();
1469 views::GridLayout* layout = CreateSingleColumnLayout(view, kFixedMenuWidth); 1658 views::GridLayout* layout =
1659 CreateSingleColumnLayout(view, GetFixedMenuWidth());
1470 1660
1471 for (size_t index : avatars_to_show) { 1661 for (size_t index : avatars_to_show) {
1472 const AvatarMenu::Item& item = avatar_menu_->GetItemAt(index); 1662 const AvatarMenu::Item& item = avatar_menu_->GetItemAt(index);
1473 const int kSmallImageSide = 32; 1663 const int kSmallImageSide = 32;
1474 1664
1475 // Use the low-res, small default avatars in the fast user switcher, like 1665 // Use the low-res, small default avatars in the fast user switcher, like
1476 // we do in the menu bar. 1666 // we do in the menu bar.
1477 gfx::Image item_icon; 1667 gfx::Image item_icon;
1478 AvatarMenu::GetImageForMenuButton(item.profile_path, &item_icon); 1668 AvatarMenu::GetImageForMenuButton(item.profile_path, &item_icon);
1479 1669
(...skipping 10 matching lines...) Expand all
1490 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); 1680 layout->AddView(new views::Separator(views::Separator::HORIZONTAL));
1491 layout->StartRow(1, 0); 1681 layout->StartRow(1, 0);
1492 layout->AddView(button); 1682 layout->AddView(button);
1493 } 1683 }
1494 1684
1495 return view; 1685 return view;
1496 } 1686 }
1497 1687
1498 views::View* ProfileChooserView::CreateOptionsView(bool display_lock) { 1688 views::View* ProfileChooserView::CreateOptionsView(bool display_lock) {
1499 views::View* view = new views::View(); 1689 views::View* view = new views::View();
1500 views::GridLayout* layout = CreateSingleColumnLayout(view, kFixedMenuWidth); 1690 views::GridLayout* layout =
1691 CreateSingleColumnLayout(view, GetFixedMenuWidth());
1501 1692
1502 base::string16 text = browser_->profile()->IsGuestSession() ? 1693 base::string16 text = browser_->profile()->IsGuestSession() ?
1503 l10n_util::GetStringUTF16(IDS_PROFILES_EXIT_GUEST) : 1694 l10n_util::GetStringUTF16(IDS_PROFILES_EXIT_GUEST) :
1504 l10n_util::GetStringUTF16(IDS_PROFILES_SWITCH_USERS_BUTTON); 1695 l10n_util::GetStringUTF16(IDS_PROFILES_SWITCH_USERS_BUTTON);
1505 if (!browser_->profile()->IsGuestSession() 1696 if (!browser_->profile()->IsGuestSession()
1506 && switches::IsMaterialDesignUserMenu()) { 1697 && switches::IsMaterialDesignUserMenu()) {
1507 text = l10n_util::GetStringUTF16(IDS_PROFILES_MANAGE_USERS_BUTTON); 1698 text = l10n_util::GetStringUTF16(IDS_PROFILES_MANAGE_USERS_BUTTON);
1508 } 1699 }
1509 const int kIconSize = 16; 1700 const int kIconSize = 16;
1510 1701
(...skipping 29 matching lines...) Expand all
1540 gfx::kChromeIconGrey)); 1731 gfx::kChromeIconGrey));
1541 layout->StartRow(1, 0); 1732 layout->StartRow(1, 0);
1542 layout->AddView(lock_button_); 1733 layout->AddView(lock_button_);
1543 } 1734 }
1544 return view; 1735 return view;
1545 } 1736 }
1546 1737
1547 views::View* ProfileChooserView::CreateSupervisedUserDisclaimerView() { 1738 views::View* ProfileChooserView::CreateSupervisedUserDisclaimerView() {
1548 views::View* view = new views::View(); 1739 views::View* view = new views::View();
1549 views::GridLayout* layout = CreateSingleColumnLayout( 1740 views::GridLayout* layout = CreateSingleColumnLayout(
1550 view, kFixedMenuWidth - 2 * views::kButtonHEdgeMarginNew); 1741 view, GetFixedMenuWidth() - 2 * views::kButtonHEdgeMarginNew);
1551 layout->SetInsets(views::kRelatedControlVerticalSpacing, 1742 if (switches::IsMaterialDesignUserMenu()) {
1552 views::kButtonHEdgeMarginNew, 1743 layout->SetInsets(0,
1553 views::kRelatedControlVerticalSpacing, 1744 views::kMaterialMenuHorizontalEdgeMargin,
1554 views::kButtonHEdgeMarginNew); 1745 views::kMaterialMenuVerticalEdgeMargin,
1746 views::kMaterialMenuHorizontalEdgeMargin);
1747 } else {
1748 layout->SetInsets(
1749 views::kRelatedControlVerticalSpacing, views::kButtonHEdgeMarginNew,
1750 views::kRelatedControlVerticalSpacing, views::kButtonHEdgeMarginNew);
1751 }
1752
1555 views::Label* disclaimer = new views::Label( 1753 views::Label* disclaimer = new views::Label(
1556 avatar_menu_->GetSupervisedUserInformation()); 1754 avatar_menu_->GetSupervisedUserInformation());
1557 disclaimer->SetMultiLine(true); 1755 disclaimer->SetMultiLine(true);
1558 disclaimer->SetAllowCharacterBreak(true); 1756 disclaimer->SetAllowCharacterBreak(true);
1559 disclaimer->SetHorizontalAlignment(gfx::ALIGN_LEFT); 1757 disclaimer->SetHorizontalAlignment(gfx::ALIGN_LEFT);
1560 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); 1758 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance();
1561 disclaimer->SetFontList(rb->GetFontList(ui::ResourceBundle::SmallFont)); 1759 disclaimer->SetFontList(rb->GetFontList(ui::ResourceBundle::SmallFont));
1562 layout->StartRow(1, 0); 1760 layout->StartRow(1, 0);
1563 layout->AddView(disclaimer); 1761 layout->AddView(disclaimer);
1564 1762
1565 return view; 1763 return view;
1566 } 1764 }
1567 1765
1568 views::View* ProfileChooserView::CreateCurrentProfileAccountsView( 1766 views::View* ProfileChooserView::CreateCurrentProfileAccountsView(
1569 const AvatarMenu::Item& avatar_item) { 1767 const AvatarMenu::Item& avatar_item) {
1570 DCHECK(avatar_item.signed_in); 1768 DCHECK(avatar_item.signed_in);
1571 views::View* view = new views::View(); 1769 views::View* view = new views::View();
1572 view->set_background(views::Background::CreateSolidBackground( 1770 view->set_background(views::Background::CreateSolidBackground(
1573 profiles::kAvatarBubbleAccountsBackgroundColor)); 1771 profiles::kAvatarBubbleAccountsBackgroundColor));
1574 views::GridLayout* layout = CreateSingleColumnLayout(view, kFixedMenuWidth); 1772 views::GridLayout* layout =
1773 CreateSingleColumnLayout(view, GetFixedMenuWidth());
1575 1774
1576 Profile* profile = browser_->profile(); 1775 Profile* profile = browser_->profile();
1577 std::string primary_account = 1776 std::string primary_account =
1578 SigninManagerFactory::GetForProfile(profile)->GetAuthenticatedAccountId(); 1777 SigninManagerFactory::GetForProfile(profile)->GetAuthenticatedAccountId();
1579 DCHECK(!primary_account.empty()); 1778 DCHECK(!primary_account.empty());
1580 std::vector<std::string>accounts = 1779 std::vector<std::string>accounts =
1581 profiles::GetSecondaryAccountsForProfile(profile, primary_account); 1780 profiles::GetSecondaryAccountsForProfile(profile, primary_account);
1582 1781
1583 // Get state of authentication error, if any. 1782 // Get state of authentication error, if any.
1584 std::string error_account_id = GetAuthErrorAccountId(profile); 1783 std::string error_account_id = GetAuthErrorAccountId(profile);
1585 1784
1586 // The primary account should always be listed first. 1785 // The primary account should always be listed first.
1587 // TODO(rogerta): we still need to further differentiate the primary account 1786 // TODO(rogerta): we still need to further differentiate the primary account
1588 // from the others in the UI, so more work is likely required here: 1787 // from the others in the UI, so more work is likely required here:
1589 // crbug.com/311124. 1788 // crbug.com/311124.
1590 CreateAccountButton(layout, primary_account, true, 1789 CreateAccountButton(layout, primary_account, true,
1591 error_account_id == primary_account, kFixedMenuWidth); 1790 error_account_id == primary_account, GetFixedMenuWidth());
1592 for (size_t i = 0; i < accounts.size(); ++i) 1791 for (size_t i = 0; i < accounts.size(); ++i)
1593 CreateAccountButton(layout, accounts[i], false, 1792 CreateAccountButton(layout, accounts[i], false,
1594 error_account_id == accounts[i], kFixedMenuWidth); 1793 error_account_id == accounts[i], GetFixedMenuWidth());
1595 1794
1596 if (!profile->IsSupervised()) { 1795 if (!profile->IsSupervised()) {
1597 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); 1796 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing);
1598 1797
1599 add_account_link_ = CreateLink(l10n_util::GetStringFUTF16( 1798 add_account_link_ = CreateLink(l10n_util::GetStringFUTF16(
1600 IDS_PROFILES_PROFILE_ADD_ACCOUNT_BUTTON, avatar_item.name), this); 1799 IDS_PROFILES_PROFILE_ADD_ACCOUNT_BUTTON, avatar_item.name), this);
1601 add_account_link_->SetBorder(views::Border::CreateEmptyBorder( 1800 add_account_link_->SetBorder(views::Border::CreateEmptyBorder(
1602 0, views::kButtonVEdgeMarginNew, 1801 0, views::kButtonVEdgeMarginNew,
1603 views::kRelatedControlVerticalSpacing, 0)); 1802 views::kRelatedControlVerticalSpacing, 0));
1604 layout->StartRow(1, 0); 1803 layout->StartRow(1, 0);
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
1894 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != 2093 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) !=
1895 IncognitoModePrefs::DISABLED; 2094 IncognitoModePrefs::DISABLED;
1896 return incognito_available && !browser_->profile()->IsGuestSession(); 2095 return incognito_available && !browser_->profile()->IsGuestSession();
1897 } 2096 }
1898 2097
1899 void ProfileChooserView::PostActionPerformed( 2098 void ProfileChooserView::PostActionPerformed(
1900 ProfileMetrics::ProfileDesktopMenu action_performed) { 2099 ProfileMetrics::ProfileDesktopMenu action_performed) {
1901 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); 2100 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_);
1902 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; 2101 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE;
1903 } 2102 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698