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

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

Issue 2729623002: Update vector icons in browser profiles code (bubble, etc.) to structs. (Closed)
Patch Set: fix mac Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/views/profiles/new_avatar_button.cc ('k') | ui/gfx/vector_icons/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/browser/browser_process.h" 11 #include "chrome/browser/browser_process.h"
11 #include "chrome/browser/lifetime/application_lifetime.h" 12 #include "chrome/browser/lifetime/application_lifetime.h"
12 #include "chrome/browser/prefs/incognito_mode_prefs.h" 13 #include "chrome/browser/prefs/incognito_mode_prefs.h"
13 #include "chrome/browser/profiles/profile_avatar_icon_util.h" 14 #include "chrome/browser/profiles/profile_avatar_icon_util.h"
14 #include "chrome/browser/profiles/profile_manager.h" 15 #include "chrome/browser/profiles/profile_manager.h"
15 #include "chrome/browser/profiles/profile_metrics.h" 16 #include "chrome/browser/profiles/profile_metrics.h"
16 #include "chrome/browser/profiles/profile_window.h" 17 #include "chrome/browser/profiles/profile_window.h"
17 #include "chrome/browser/profiles/profiles_state.h" 18 #include "chrome/browser/profiles/profiles_state.h"
18 #include "chrome/browser/signin/chrome_signin_helper.h" 19 #include "chrome/browser/signin/chrome_signin_helper.h"
19 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" 20 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 #include "ui/compositor/paint_recorder.h" 61 #include "ui/compositor/paint_recorder.h"
61 #include "ui/gfx/canvas.h" 62 #include "ui/gfx/canvas.h"
62 #include "ui/gfx/color_palette.h" 63 #include "ui/gfx/color_palette.h"
63 #include "ui/gfx/image/canvas_image_source.h" 64 #include "ui/gfx/image/canvas_image_source.h"
64 #include "ui/gfx/image/image.h" 65 #include "ui/gfx/image/image.h"
65 #include "ui/gfx/image/image_skia.h" 66 #include "ui/gfx/image/image_skia.h"
66 #include "ui/gfx/paint_vector_icon.h" 67 #include "ui/gfx/paint_vector_icon.h"
67 #include "ui/gfx/path.h" 68 #include "ui/gfx/path.h"
68 #include "ui/gfx/skia_util.h" 69 #include "ui/gfx/skia_util.h"
69 #include "ui/gfx/text_elider.h" 70 #include "ui/gfx/text_elider.h"
70 #include "ui/gfx/vector_icons_public.h"
71 #include "ui/native_theme/common_theme.h" 71 #include "ui/native_theme/common_theme.h"
72 #include "ui/native_theme/native_theme.h" 72 #include "ui/native_theme/native_theme.h"
73 #include "ui/vector_icons/vector_icons.h"
73 #include "ui/views/controls/button/blue_button.h" 74 #include "ui/views/controls/button/blue_button.h"
74 #include "ui/views/controls/button/image_button.h" 75 #include "ui/views/controls/button/image_button.h"
75 #include "ui/views/controls/button/label_button.h" 76 #include "ui/views/controls/button/label_button.h"
76 #include "ui/views/controls/button/label_button_border.h" 77 #include "ui/views/controls/button/label_button_border.h"
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"
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 447
447 set_notify_enter_exit_on_child(true); 448 set_notify_enter_exit_on_child(true);
448 449
449 // Photo overlay that appears when hovering over the button. 450 // Photo overlay that appears when hovering over the button.
450 photo_overlay_ = new views::ImageView(); 451 photo_overlay_ = new views::ImageView();
451 452
452 const SkColor kBackgroundColor = SkColorSetARGB(65, 255, 255, 255); 453 const SkColor kBackgroundColor = SkColorSetARGB(65, 255, 255, 255);
453 photo_overlay_->set_background( 454 photo_overlay_->set_background(
454 views::Background::CreateSolidBackground(kBackgroundColor)); 455 views::Background::CreateSolidBackground(kBackgroundColor));
455 photo_overlay_->SetImage(gfx::CreateVectorIcon( 456 photo_overlay_->SetImage(gfx::CreateVectorIcon(
456 gfx::VectorIconId::PHOTO_CAMERA, 48u, SkColorSetRGB(0x33, 0x33, 0x33))); 457 kPhotoCameraIcon, 48u, SkColorSetRGB(0x33, 0x33, 0x33)));
457 458
458 photo_overlay_->SetSize(gfx::Size(icon_image_side(), icon_image_side())); 459 photo_overlay_->SetSize(gfx::Size(icon_image_side(), icon_image_side()));
459 photo_overlay_->SetY(badge_spacing()); 460 photo_overlay_->SetY(badge_spacing());
460 photo_overlay_->SetVisible(false); 461 photo_overlay_->SetVisible(false);
461 AddChildView(photo_overlay_); 462 AddChildView(photo_overlay_);
462 } 463 }
463 464
464 void PaintChildren(const ui::PaintContext& context) override { 465 void PaintChildren(const ui::PaintContext& context) override {
465 { 466 {
466 // Display any children (the "change photo" overlay) as a circle. 467 // Display any children (the "change photo" overlay) as a circle.
(...skipping 23 matching lines...) Expand all
490 491
491 gfx::Point center_point = bounds.CenterPoint() + badge_offset_vector; 492 gfx::Point center_point = bounds.CenterPoint() + badge_offset_vector;
492 493
493 // Paint the circular background. 494 // Paint the circular background.
494 cc::PaintFlags flags; 495 cc::PaintFlags flags;
495 flags.setAntiAlias(true); 496 flags.setAntiAlias(true);
496 flags.setColor(GetNativeTheme()->GetSystemColor( 497 flags.setColor(GetNativeTheme()->GetSystemColor(
497 ui::NativeTheme::kColorId_BubbleBackground)); 498 ui::NativeTheme::kColorId_BubbleBackground));
498 canvas->DrawCircle(center_point, GetProfileBadgeSize() / 2, flags); 499 canvas->DrawCircle(center_point, GetProfileBadgeSize() / 2, flags);
499 500
500 gfx::VectorIconId icon_id; 501 const gfx::VectorIcon* icon = nullptr;
Peter Kasting 2017/03/02 23:12:51 Nit: I'd avoid initializing this to avoid implying
Evan Stade 2017/03/03 00:36:38 Done.
501 int icon_size; 502 int icon_size;
502 SkColor icon_color; 503 SkColor icon_color;
503 if (switches::IsMaterialDesignUserMenu()) { 504 if (switches::IsMaterialDesignUserMenu()) {
504 icon_id = profile_->IsChild() 505 icon = profile_->IsChild() ? &kAccountChildCircleIcon
505 ? gfx::VectorIconId::ACCOUNT_CHILD_CIRCLE 506 : &kSupervisorAccountCircleIcon;
506 : gfx::VectorIconId::SUPERVISOR_ACCOUNT_CIRCLE;
507 icon_size = 22; 507 icon_size = 22;
508 icon_color = gfx::kChromeIconGrey; 508 icon_color = gfx::kChromeIconGrey;
509 } else { 509 } else {
510 // Paint the light blue circle. 510 // Paint the light blue circle.
511 flags.setColor(SkColorSetRGB(0xaf, 0xd9, 0xfc)); 511 flags.setColor(SkColorSetRGB(0xaf, 0xd9, 0xfc));
512 canvas->DrawCircle( 512 canvas->DrawCircle(
513 center_point, GetProfileBadgeSize() / 2 - kProfileBadgeWhitePadding, 513 center_point, GetProfileBadgeSize() / 2 - kProfileBadgeWhitePadding,
514 flags); 514 flags);
515 515
516 icon_id = profile_->IsChild() 516 icon =
517 ? gfx::VectorIconId::ACCOUNT_CHILD 517 profile_->IsChild() ? &kAccountChildIcon : &kSupervisorAccountIcon;
518 : gfx::VectorIconId::SUPERVISOR_ACCOUNT;
519 icon_size = profile_->IsChild() ? 26 : 20; 518 icon_size = profile_->IsChild() ? 26 : 20;
520 icon_color = SkColorSetRGB(0, 0x66, 0xff); 519 icon_color = SkColorSetRGB(0, 0x66, 0xff);
521 } 520 }
522 521
523 // Paint the badge icon. 522 // Paint the badge icon.
524 int offset = (GetProfileBadgeSize() - icon_size) / 2; 523 int offset = (GetProfileBadgeSize() - icon_size) / 2;
525 canvas->Translate(badge_offset_vector + gfx::Vector2d(offset, offset)); 524 canvas->Translate(badge_offset_vector + gfx::Vector2d(offset, offset));
526 gfx::PaintVectorIcon(canvas, icon_id, icon_size, icon_color); 525 gfx::PaintVectorIcon(canvas, *icon, icon_size, icon_color);
527 } 526 }
528 } 527 }
529 528
530 static int icon_image_side() { 529 static int icon_image_side() {
531 return switches::IsMaterialDesignUserMenu() ? kMdImageSide 530 return switches::IsMaterialDesignUserMenu() ? kMdImageSide
532 : kLargeImageSide; 531 : kLargeImageSide;
533 } 532 }
534 533
535 static int badge_spacing() { 534 static int badge_spacing() {
536 // The space between the right/bottom edge of the profile badge and the 535 // The space between the right/bottom edge of the profile badge and the
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 button_ = new RightAlignedIconLabelButton(this, text); 611 button_ = new RightAlignedIconLabelButton(this, text);
613 button_->SetFontListDeprecated(medium_font_list); 612 button_->SetFontListDeprecated(medium_font_list);
614 // Show an "edit" pencil icon when hovering over. In the default state, 613 // Show an "edit" pencil icon when hovering over. In the default state,
615 // we need to create an empty placeholder of the correct size, so that 614 // we need to create an empty placeholder of the correct size, so that
616 // the text doesn't jump around when the hovered icon appears. 615 // the text doesn't jump around when the hovered icon appears.
617 // TODO(estade): revisit colors and press effect. 616 // TODO(estade): revisit colors and press effect.
618 const int kIconSize = 16; 617 const int kIconSize = 16;
619 button_->SetImage(views::LabelButton::STATE_NORMAL, 618 button_->SetImage(views::LabelButton::STATE_NORMAL,
620 CreateSquarePlaceholderImage(kIconSize)); 619 CreateSquarePlaceholderImage(kIconSize));
621 button_->SetImage(views::LabelButton::STATE_HOVERED, 620 button_->SetImage(views::LabelButton::STATE_HOVERED,
622 gfx::CreateVectorIcon( 621 gfx::CreateVectorIcon(kModeEditIcon, kIconSize,
623 gfx::VectorIconId::MODE_EDIT, kIconSize, 622 SkColorSetRGB(0x33, 0x33, 0x33)));
624 SkColorSetRGB(0x33, 0x33, 0x33)));
625 button_->SetImage(views::LabelButton::STATE_PRESSED, 623 button_->SetImage(views::LabelButton::STATE_PRESSED,
626 gfx::CreateVectorIcon( 624 gfx::CreateVectorIcon(kModeEditIcon, kIconSize,
627 gfx::VectorIconId::MODE_EDIT, kIconSize, 625 SkColorSetRGB(0x20, 0x20, 0x20)));
628 SkColorSetRGB(0x20, 0x20, 0x20)));
629 // We need to add a left padding as well as a small top/bottom padding 626 // We need to add a left padding as well as a small top/bottom padding
630 // to the text to account for the textfield's border. 627 // to the text to account for the textfield's border.
631 const int kIconTextLabelButtonSpacing = 5; 628 const int kIconTextLabelButtonSpacing = 5;
632 button_->SetBorder(views::CreateEmptyBorder( 629 button_->SetBorder(views::CreateEmptyBorder(
633 textfield_border_insets + 630 textfield_border_insets +
634 gfx::Insets(0, kIconSize + kIconTextLabelButtonSpacing, 0, 0))); 631 gfx::Insets(0, kIconSize + kIconTextLabelButtonSpacing, 0, 0)));
635 AddChildView(button_); 632 AddChildView(button_);
636 } 633 }
637 634
638 views::Textfield* profile_name_textfield() { 635 views::Textfield* profile_name_textfield() {
(...skipping 949 matching lines...) Expand 10 before | Expand all | Expand 10 after
1588 views::View* view = new views::View(); 1585 views::View* view = new views::View();
1589 views::BoxLayout* layout = new views::BoxLayout( 1586 views::BoxLayout* layout = new views::BoxLayout(
1590 views::BoxLayout::kHorizontal, kMaterialMenuEdgeMargin, 1587 views::BoxLayout::kHorizontal, kMaterialMenuEdgeMargin,
1591 kMaterialMenuEdgeMargin, views::kUnrelatedControlHorizontalSpacing); 1588 kMaterialMenuEdgeMargin, views::kUnrelatedControlHorizontalSpacing);
1592 layout->set_cross_axis_alignment( 1589 layout->set_cross_axis_alignment(
1593 views::BoxLayout::CROSS_AXIS_ALIGNMENT_START); 1590 views::BoxLayout::CROSS_AXIS_ALIGNMENT_START);
1594 view->SetLayoutManager(layout); 1591 view->SetLayoutManager(layout);
1595 1592
1596 // Adds the sync problem icon. 1593 // Adds the sync problem icon.
1597 views::ImageView* sync_problem_icon = new views::ImageView(); 1594 views::ImageView* sync_problem_icon = new views::ImageView();
1598 sync_problem_icon->SetImage(gfx::CreateVectorIcon( 1595 sync_problem_icon->SetImage(
1599 gfx::VectorIconId::SYNC_PROBLEM, 20, gfx::kGoogleRed700)); 1596 gfx::CreateVectorIcon(kSyncProblemIcon, 20, gfx::kGoogleRed700));
1600 view->AddChildView(sync_problem_icon); 1597 view->AddChildView(sync_problem_icon);
1601 1598
1602 // Adds a vertical view to organize the error title, message, and button. 1599 // Adds a vertical view to organize the error title, message, and button.
1603 views::View* vertical_view = new views::View(); 1600 views::View* vertical_view = new views::View();
1604 views::BoxLayout* vertical_layout = 1601 views::BoxLayout* vertical_layout =
1605 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 1602 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0,
1606 views::kRelatedControlSmallVerticalSpacing); 1603 views::kRelatedControlSmallVerticalSpacing);
1607 vertical_layout->set_cross_axis_alignment( 1604 vertical_layout->set_cross_axis_alignment(
1608 views::BoxLayout::CROSS_AXIS_ALIGNMENT_START); 1605 views::BoxLayout::CROSS_AXIS_ALIGNMENT_START);
1609 vertical_view->SetLayoutManager(vertical_layout); 1606 vertical_view->SetLayoutManager(vertical_layout);
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
1694 manage_accounts_link_->SetHorizontalAlignment(gfx::ALIGN_CENTER); 1691 manage_accounts_link_->SetHorizontalAlignment(gfx::ALIGN_CENTER);
1695 layout->AddView(manage_accounts_link_); 1692 layout->AddView(manage_accounts_link_);
1696 } else { 1693 } else {
1697 // Badge the email address if there's an authentication error. 1694 // Badge the email address if there's an authentication error.
1698 if (HasAuthError(browser_->profile())) { 1695 if (HasAuthError(browser_->profile())) {
1699 auth_error_email_button_ = 1696 auth_error_email_button_ =
1700 new RightAlignedIconLabelButton(this, avatar_item.username); 1697 new RightAlignedIconLabelButton(this, avatar_item.username);
1701 auth_error_email_button_->SetElideBehavior(gfx::ELIDE_EMAIL); 1698 auth_error_email_button_->SetElideBehavior(gfx::ELIDE_EMAIL);
1702 auth_error_email_button_->SetImage( 1699 auth_error_email_button_->SetImage(
1703 views::LabelButton::STATE_NORMAL, 1700 views::LabelButton::STATE_NORMAL,
1704 gfx::CreateVectorIcon(gfx::VectorIconId::WARNING, 18, 1701 gfx::CreateVectorIcon(ui::kWarningIcon, 18, gfx::kChromeIconGrey));
1705 gfx::kChromeIconGrey));
1706 auth_error_email_button_->SetFocusForPlatform(); 1702 auth_error_email_button_->SetFocusForPlatform();
1707 gfx::Insets insets = 1703 gfx::Insets insets =
1708 views::LabelButtonAssetBorder::GetDefaultInsetsForStyle( 1704 views::LabelButtonAssetBorder::GetDefaultInsetsForStyle(
1709 views::Button::STYLE_TEXTBUTTON); 1705 views::Button::STYLE_TEXTBUTTON);
1710 auth_error_email_button_->SetBorder(views::CreateEmptyBorder( 1706 auth_error_email_button_->SetBorder(views::CreateEmptyBorder(
1711 insets.top(), insets.left(), insets.bottom(), insets.right())); 1707 insets.top(), insets.left(), insets.bottom(), insets.right()));
1712 layout->AddView(auth_error_email_button_); 1708 layout->AddView(auth_error_email_button_);
1713 } else { 1709 } else {
1714 // Add a small padding between the email button and the profile name. 1710 // Add a small padding between the email button and the profile name.
1715 layout->StartRowWithPadding(1, 0, 0, 2); 1711 layout->StartRowWithPadding(1, 0, 0, 2);
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
1956 } 1952 }
1957 } 1953 }
1958 1954
1959 // Add the "Guest" button for browsing as guest 1955 // Add the "Guest" button for browsing as guest
1960 if (!is_guest) { 1956 if (!is_guest) {
1961 PrefService* service = g_browser_process->local_state(); 1957 PrefService* service = g_browser_process->local_state();
1962 DCHECK(service); 1958 DCHECK(service);
1963 if (service->GetBoolean(prefs::kBrowserGuestModeEnabled)) { 1959 if (service->GetBoolean(prefs::kBrowserGuestModeEnabled)) {
1964 guest_profile_button_ = new BackgroundColorHoverButton( 1960 guest_profile_button_ = new BackgroundColorHoverButton(
1965 this, l10n_util::GetStringUTF16(IDS_GUEST_PROFILE_NAME), 1961 this, l10n_util::GetStringUTF16(IDS_GUEST_PROFILE_NAME),
1966 gfx::CreateVectorIcon(gfx::VectorIconId::ACCOUNT_CIRCLE, kIconSize, 1962 gfx::CreateVectorIcon(kAccountCircleIcon, kIconSize,
1967 gfx::kChromeIconGrey)); 1963 gfx::kChromeIconGrey));
1968 layout->StartRow(1, 0); 1964 layout->StartRow(1, 0);
1969 layout->AddView(guest_profile_button_); 1965 layout->AddView(guest_profile_button_);
1970 } 1966 }
1971 } 1967 }
1972 } 1968 }
1973 1969
1974 base::string16 text; 1970 base::string16 text;
1975 gfx::VectorIconId settings_icon; 1971 const gfx::VectorIcon* settings_icon = nullptr;
1976 if (switches::IsMaterialDesignUserMenu()) { 1972 if (switches::IsMaterialDesignUserMenu()) {
1977 text = is_guest 1973 text = is_guest
1978 ? l10n_util::GetStringUTF16(IDS_PROFILES_EXIT_GUEST) 1974 ? l10n_util::GetStringUTF16(IDS_PROFILES_EXIT_GUEST)
1979 : l10n_util::GetStringUTF16(IDS_PROFILES_MANAGE_USERS_BUTTON); 1975 : l10n_util::GetStringUTF16(IDS_PROFILES_MANAGE_USERS_BUTTON);
1980 settings_icon = 1976 settings_icon = is_guest ? &kCloseAllIcon : &kSettingsIcon;
1981 is_guest ? gfx::VectorIconId::CLOSE_ALL : gfx::VectorIconId::SETTINGS;
1982 } else { 1977 } else {
1983 text = is_guest 1978 text = is_guest
1984 ? l10n_util::GetStringUTF16(IDS_PROFILES_EXIT_GUEST) 1979 ? l10n_util::GetStringUTF16(IDS_PROFILES_EXIT_GUEST)
1985 : l10n_util::GetStringUTF16(IDS_PROFILES_SWITCH_USERS_BUTTON); 1980 : l10n_util::GetStringUTF16(IDS_PROFILES_SWITCH_USERS_BUTTON);
1986 settings_icon = gfx::VectorIconId::ACCOUNT_BOX; 1981 settings_icon = &kAccountBoxIcon;
1987 } 1982 }
1988 users_button_ = new BackgroundColorHoverButton( 1983 users_button_ = new BackgroundColorHoverButton(
1989 this, text, gfx::CreateVectorIcon(settings_icon, kIconSize, 1984 this, text,
1990 gfx::kChromeIconGrey)); 1985 gfx::CreateVectorIcon(*settings_icon, kIconSize, gfx::kChromeIconGrey));
1991 1986
1992 layout->StartRow(1, 0); 1987 layout->StartRow(1, 0);
1993 layout->AddView(users_button_); 1988 layout->AddView(users_button_);
1994 1989
1995 if (!switches::IsMaterialDesignUserMenu() && ShouldShowGoIncognito()) { 1990 if (!switches::IsMaterialDesignUserMenu() && ShouldShowGoIncognito()) {
1996 layout->StartRow(1, 0); 1991 layout->StartRow(1, 0);
1997 layout->AddView(new views::Separator()); 1992 layout->AddView(new views::Separator());
1998 1993
1999 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); 1994 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance();
2000 go_incognito_button_ = new BackgroundColorHoverButton( 1995 go_incognito_button_ = new BackgroundColorHoverButton(
2001 this, 1996 this,
2002 l10n_util::GetStringUTF16(IDS_PROFILES_GO_INCOGNITO_BUTTON), 1997 l10n_util::GetStringUTF16(IDS_PROFILES_GO_INCOGNITO_BUTTON),
2003 *rb->GetImageSkiaNamed(IDR_ICON_PROFILES_MENU_INCOGNITO)); 1998 *rb->GetImageSkiaNamed(IDR_ICON_PROFILES_MENU_INCOGNITO));
2004 layout->StartRow(1, 0); 1999 layout->StartRow(1, 0);
2005 layout->AddView(go_incognito_button_); 2000 layout->AddView(go_incognito_button_);
2006 } 2001 }
2007 2002
2008 if (display_lock) { 2003 if (display_lock) {
2009 if (!switches::IsMaterialDesignUserMenu()) { 2004 if (!switches::IsMaterialDesignUserMenu()) {
2010 layout->StartRow(1, 0); 2005 layout->StartRow(1, 0);
2011 layout->AddView(new views::Separator()); 2006 layout->AddView(new views::Separator());
2012 } 2007 }
2013 2008
2014 lock_button_ = new BackgroundColorHoverButton( 2009 lock_button_ = new BackgroundColorHoverButton(
2015 this, l10n_util::GetStringUTF16(IDS_PROFILES_PROFILE_SIGNOUT_BUTTON), 2010 this, l10n_util::GetStringUTF16(IDS_PROFILES_PROFILE_SIGNOUT_BUTTON),
2016 gfx::CreateVectorIcon(gfx::VectorIconId::LOCK, kIconSize, 2011 gfx::CreateVectorIcon(kLockIcon, kIconSize, gfx::kChromeIconGrey));
2017 gfx::kChromeIconGrey));
2018 layout->StartRow(1, 0); 2012 layout->StartRow(1, 0);
2019 layout->AddView(lock_button_); 2013 layout->AddView(lock_button_);
2020 } else if (switches::IsMaterialDesignUserMenu() && !is_guest) { 2014 } else if (switches::IsMaterialDesignUserMenu() && !is_guest) {
2021 int num_browsers = 0; 2015 int num_browsers = 0;
2022 for (auto* browser : *BrowserList::GetInstance()) { 2016 for (auto* browser : *BrowserList::GetInstance()) {
2023 if (browser->profile()->GetOriginalProfile() == 2017 if (browser->profile()->GetOriginalProfile() ==
2024 browser_->profile()->GetOriginalProfile()) 2018 browser_->profile()->GetOriginalProfile())
2025 num_browsers++; 2019 num_browsers++;
2026 } 2020 }
2027 if (num_browsers > 1) { 2021 if (num_browsers > 1) {
2028 close_all_windows_button_ = new BackgroundColorHoverButton( 2022 close_all_windows_button_ = new BackgroundColorHoverButton(
2029 this, 2023 this,
2030 l10n_util::GetStringUTF16(IDS_PROFILES_CLOSE_ALL_WINDOWS_BUTTON), 2024 l10n_util::GetStringUTF16(IDS_PROFILES_CLOSE_ALL_WINDOWS_BUTTON),
2031 gfx::CreateVectorIcon(gfx::VectorIconId::CLOSE_ALL, kIconSize, 2025 gfx::CreateVectorIcon(kCloseAllIcon, kIconSize,
2032 gfx::kChromeIconGrey)); 2026 gfx::kChromeIconGrey));
2033 layout->StartRow(1, 0); 2027 layout->StartRow(1, 0);
2034 layout->AddView(close_all_windows_button_); 2028 layout->AddView(close_all_windows_button_);
2035 } 2029 }
2036 } 2030 }
2037 2031
2038 if (switches::IsMaterialDesignUserMenu()) 2032 if (switches::IsMaterialDesignUserMenu())
2039 layout->StartRowWithPadding(1, 0, 0, views::kRelatedControlVerticalSpacing); 2033 layout->StartRowWithPadding(1, 0, 0, views::kRelatedControlVerticalSpacing);
2040 return view; 2034 return view;
2041 } 2035 }
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
2120 std::string email = signin_ui_util::GetDisplayEmail(browser_->profile(), 2114 std::string email = signin_ui_util::GetDisplayEmail(browser_->profile(),
2121 account_id); 2115 account_id);
2122 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); 2116 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance();
2123 const gfx::ImageSkia* delete_default_image = 2117 const gfx::ImageSkia* delete_default_image =
2124 rb->GetImageNamed(IDR_CLOSE_1).ToImageSkia(); 2118 rb->GetImageNamed(IDR_CLOSE_1).ToImageSkia();
2125 const int kDeleteButtonWidth = delete_default_image->width(); 2119 const int kDeleteButtonWidth = delete_default_image->width();
2126 gfx::ImageSkia warning_default_image; 2120 gfx::ImageSkia warning_default_image;
2127 int warning_button_width = 0; 2121 int warning_button_width = 0;
2128 if (reauth_required) { 2122 if (reauth_required) {
2129 const int kIconSize = 18; 2123 const int kIconSize = 18;
2130 warning_default_image = gfx::CreateVectorIcon( 2124 warning_default_image = gfx::CreateVectorIcon(ui::kWarningIcon, kIconSize,
2131 gfx::VectorIconId::WARNING, kIconSize, gfx::kChromeIconGrey); 2125 gfx::kChromeIconGrey);
2132 warning_button_width = kIconSize + views::kRelatedButtonHSpacing; 2126 warning_button_width = kIconSize + views::kRelatedButtonHSpacing;
2133 } 2127 }
2134 int available_width = width - 2 * views::kButtonHEdgeMarginNew - 2128 int available_width = width - 2 * views::kButtonHEdgeMarginNew -
2135 kDeleteButtonWidth - warning_button_width; 2129 kDeleteButtonWidth - warning_button_width;
2136 views::LabelButton* email_button = new BackgroundColorHoverButton( 2130 views::LabelButton* email_button = new BackgroundColorHoverButton(
2137 this, base::UTF8ToUTF16(email), warning_default_image); 2131 this, base::UTF8ToUTF16(email), warning_default_image);
2138 email_button->SetEnabled(reauth_required); 2132 email_button->SetEnabled(reauth_required);
2139 email_button->SetElideBehavior(gfx::ELIDE_EMAIL); 2133 email_button->SetElideBehavior(gfx::ELIDE_EMAIL);
2140 email_button->SetMinSize(gfx::Size(0, kButtonHeight)); 2134 email_button->SetMinSize(gfx::Size(0, kButtonHeight));
2141 email_button->SetMaxSize(gfx::Size(available_width, kButtonHeight)); 2135 email_button->SetMaxSize(gfx::Size(available_width, kButtonHeight));
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
2362 content_label->SetFontList(small_font_list); 2356 content_label->SetFontList(small_font_list);
2363 layout->AddView(content_label); 2357 layout->AddView(content_label);
2364 2358
2365 // Adds "Add person" button. 2359 // Adds "Add person" button.
2366 layout->StartRowWithPadding(1, 0, 0, views::kUnrelatedControlVerticalSpacing); 2360 layout->StartRowWithPadding(1, 0, 0, views::kUnrelatedControlVerticalSpacing);
2367 layout->AddView(new views::Separator()); 2361 layout->AddView(new views::Separator());
2368 2362
2369 const int kIconSize = 24; 2363 const int kIconSize = 24;
2370 add_person_button_ = new BackgroundColorHoverButton( 2364 add_person_button_ = new BackgroundColorHoverButton(
2371 this, l10n_util::GetStringUTF16(IDS_PROFILES_ADD_PERSON_BUTTON), 2365 this, l10n_util::GetStringUTF16(IDS_PROFILES_ADD_PERSON_BUTTON),
2372 gfx::CreateVectorIcon(gfx::VectorIconId::ACCOUNT_BOX, kIconSize, 2366 gfx::CreateVectorIcon(kAccountBoxIcon, kIconSize, gfx::kChromeIconGrey));
2373 gfx::kChromeIconGrey));
2374 layout->StartRow(1, 0); 2367 layout->StartRow(1, 0);
2375 layout->AddView(add_person_button_); 2368 layout->AddView(add_person_button_);
2376 2369
2377 // Adds "Disconnect your Google Account" button. 2370 // Adds "Disconnect your Google Account" button.
2378 layout->StartRow(1, 0); 2371 layout->StartRow(1, 0);
2379 layout->AddView(new views::Separator()); 2372 layout->AddView(new views::Separator());
2380 2373
2381 disconnect_button_ = new BackgroundColorHoverButton( 2374 disconnect_button_ = new BackgroundColorHoverButton(
2382 this, l10n_util::GetStringUTF16(IDS_PROFILES_DISCONNECT_BUTTON), 2375 this, l10n_util::GetStringUTF16(IDS_PROFILES_DISCONNECT_BUTTON),
2383 gfx::CreateVectorIcon(gfx::VectorIconId::REMOVE_BOX, kIconSize, 2376 gfx::CreateVectorIcon(kRemoveBoxIcon, kIconSize, gfx::kChromeIconGrey));
2384 gfx::kChromeIconGrey));
2385 layout->StartRow(1, 0); 2377 layout->StartRow(1, 0);
2386 layout->AddView(disconnect_button_); 2378 layout->AddView(disconnect_button_);
2387 2379
2388 TitleCard* title_card = new TitleCard( 2380 TitleCard* title_card = new TitleCard(
2389 l10n_util::GetStringFUTF16(IDS_PROFILES_NOT_YOU, avatar_item.name), 2381 l10n_util::GetStringFUTF16(IDS_PROFILES_NOT_YOU, avatar_item.name),
2390 this, &switch_user_cancel_button_); 2382 this, &switch_user_cancel_button_);
2391 return TitleCard::AddPaddedTitleCard(view, title_card, 2383 return TitleCard::AddPaddedTitleCard(view, title_card,
2392 kFixedSwitchUserViewWidth); 2384 kFixedSwitchUserViewWidth);
2393 } 2385 }
2394 2386
2395 bool ProfileChooserView::ShouldShowGoIncognito() const { 2387 bool ProfileChooserView::ShouldShowGoIncognito() const {
2396 bool incognito_available = 2388 bool incognito_available =
2397 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != 2389 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) !=
2398 IncognitoModePrefs::DISABLED; 2390 IncognitoModePrefs::DISABLED;
2399 return incognito_available && !browser_->profile()->IsGuestSession(); 2391 return incognito_available && !browser_->profile()->IsGuestSession();
2400 } 2392 }
2401 2393
2402 void ProfileChooserView::PostActionPerformed( 2394 void ProfileChooserView::PostActionPerformed(
2403 ProfileMetrics::ProfileDesktopMenu action_performed) { 2395 ProfileMetrics::ProfileDesktopMenu action_performed) {
2404 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); 2396 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_);
2405 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; 2397 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE;
2406 } 2398 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/profiles/new_avatar_button.cc ('k') | ui/gfx/vector_icons/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698