| OLD | NEW |
| 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 Loading... |
| 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 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 432 | 433 |
| 433 set_notify_enter_exit_on_child(true); | 434 set_notify_enter_exit_on_child(true); |
| 434 | 435 |
| 435 // Photo overlay that appears when hovering over the button. | 436 // Photo overlay that appears when hovering over the button. |
| 436 photo_overlay_ = new views::ImageView(); | 437 photo_overlay_ = new views::ImageView(); |
| 437 | 438 |
| 438 const SkColor kBackgroundColor = SkColorSetARGB(65, 255, 255, 255); | 439 const SkColor kBackgroundColor = SkColorSetARGB(65, 255, 255, 255); |
| 439 photo_overlay_->set_background( | 440 photo_overlay_->set_background( |
| 440 views::Background::CreateSolidBackground(kBackgroundColor)); | 441 views::Background::CreateSolidBackground(kBackgroundColor)); |
| 441 photo_overlay_->SetImage(gfx::CreateVectorIcon( | 442 photo_overlay_->SetImage(gfx::CreateVectorIcon( |
| 442 gfx::VectorIconId::PHOTO_CAMERA, 48u, SkColorSetRGB(0x33, 0x33, 0x33))); | 443 kPhotoCameraIcon, 48u, SkColorSetRGB(0x33, 0x33, 0x33))); |
| 443 | 444 |
| 444 photo_overlay_->SetSize(gfx::Size(icon_image_side(), icon_image_side())); | 445 photo_overlay_->SetSize(gfx::Size(icon_image_side(), icon_image_side())); |
| 445 photo_overlay_->SetY(badge_spacing()); | 446 photo_overlay_->SetY(badge_spacing()); |
| 446 photo_overlay_->SetVisible(false); | 447 photo_overlay_->SetVisible(false); |
| 447 AddChildView(photo_overlay_); | 448 AddChildView(photo_overlay_); |
| 448 } | 449 } |
| 449 | 450 |
| 450 void PaintChildren(const ui::PaintContext& context) override { | 451 void PaintChildren(const ui::PaintContext& context) override { |
| 451 { | 452 { |
| 452 // Display any children (the "change photo" overlay) as a circle. | 453 // Display any children (the "change photo" overlay) as a circle. |
| (...skipping 23 matching lines...) Expand all Loading... |
| 476 | 477 |
| 477 gfx::Point center_point = bounds.CenterPoint() + badge_offset_vector; | 478 gfx::Point center_point = bounds.CenterPoint() + badge_offset_vector; |
| 478 | 479 |
| 479 // Paint the circular background. | 480 // Paint the circular background. |
| 480 cc::PaintFlags flags; | 481 cc::PaintFlags flags; |
| 481 flags.setAntiAlias(true); | 482 flags.setAntiAlias(true); |
| 482 flags.setColor(GetNativeTheme()->GetSystemColor( | 483 flags.setColor(GetNativeTheme()->GetSystemColor( |
| 483 ui::NativeTheme::kColorId_BubbleBackground)); | 484 ui::NativeTheme::kColorId_BubbleBackground)); |
| 484 canvas->DrawCircle(center_point, GetProfileBadgeSize() / 2, flags); | 485 canvas->DrawCircle(center_point, GetProfileBadgeSize() / 2, flags); |
| 485 | 486 |
| 486 gfx::VectorIconId icon_id; | 487 const gfx::VectorIcon* icon; |
| 487 int icon_size; | 488 int icon_size; |
| 488 SkColor icon_color; | 489 SkColor icon_color; |
| 489 if (switches::IsMaterialDesignUserMenu()) { | 490 if (switches::IsMaterialDesignUserMenu()) { |
| 490 icon_id = profile_->IsChild() | 491 icon = profile_->IsChild() ? &kAccountChildCircleIcon |
| 491 ? gfx::VectorIconId::ACCOUNT_CHILD_CIRCLE | 492 : &kSupervisorAccountCircleIcon; |
| 492 : gfx::VectorIconId::SUPERVISOR_ACCOUNT_CIRCLE; | |
| 493 icon_size = 22; | 493 icon_size = 22; |
| 494 icon_color = gfx::kChromeIconGrey; | 494 icon_color = gfx::kChromeIconGrey; |
| 495 } else { | 495 } else { |
| 496 // Paint the light blue circle. | 496 // Paint the light blue circle. |
| 497 flags.setColor(SkColorSetRGB(0xaf, 0xd9, 0xfc)); | 497 flags.setColor(SkColorSetRGB(0xaf, 0xd9, 0xfc)); |
| 498 canvas->DrawCircle( | 498 canvas->DrawCircle( |
| 499 center_point, GetProfileBadgeSize() / 2 - kProfileBadgeWhitePadding, | 499 center_point, GetProfileBadgeSize() / 2 - kProfileBadgeWhitePadding, |
| 500 flags); | 500 flags); |
| 501 | 501 |
| 502 icon_id = profile_->IsChild() | 502 icon = |
| 503 ? gfx::VectorIconId::ACCOUNT_CHILD | 503 profile_->IsChild() ? &kAccountChildIcon : &kSupervisorAccountIcon; |
| 504 : gfx::VectorIconId::SUPERVISOR_ACCOUNT; | |
| 505 icon_size = profile_->IsChild() ? 26 : 20; | 504 icon_size = profile_->IsChild() ? 26 : 20; |
| 506 icon_color = SkColorSetRGB(0, 0x66, 0xff); | 505 icon_color = SkColorSetRGB(0, 0x66, 0xff); |
| 507 } | 506 } |
| 508 | 507 |
| 509 // Paint the badge icon. | 508 // Paint the badge icon. |
| 510 int offset = (GetProfileBadgeSize() - icon_size) / 2; | 509 int offset = (GetProfileBadgeSize() - icon_size) / 2; |
| 511 canvas->Translate(badge_offset_vector + gfx::Vector2d(offset, offset)); | 510 canvas->Translate(badge_offset_vector + gfx::Vector2d(offset, offset)); |
| 512 gfx::PaintVectorIcon(canvas, icon_id, icon_size, icon_color); | 511 gfx::PaintVectorIcon(canvas, *icon, icon_size, icon_color); |
| 513 } | 512 } |
| 514 } | 513 } |
| 515 | 514 |
| 516 static int icon_image_side() { | 515 static int icon_image_side() { |
| 517 return switches::IsMaterialDesignUserMenu() ? kMdImageSide | 516 return switches::IsMaterialDesignUserMenu() ? kMdImageSide |
| 518 : kLargeImageSide; | 517 : kLargeImageSide; |
| 519 } | 518 } |
| 520 | 519 |
| 521 static int badge_spacing() { | 520 static int badge_spacing() { |
| 522 // The space between the right/bottom edge of the profile badge and the | 521 // 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 Loading... |
| 598 button_ = new RightAlignedIconLabelButton(this, text); | 597 button_ = new RightAlignedIconLabelButton(this, text); |
| 599 button_->SetFontListDeprecated(medium_font_list); | 598 button_->SetFontListDeprecated(medium_font_list); |
| 600 // Show an "edit" pencil icon when hovering over. In the default state, | 599 // Show an "edit" pencil icon when hovering over. In the default state, |
| 601 // we need to create an empty placeholder of the correct size, so that | 600 // we need to create an empty placeholder of the correct size, so that |
| 602 // the text doesn't jump around when the hovered icon appears. | 601 // the text doesn't jump around when the hovered icon appears. |
| 603 // TODO(estade): revisit colors and press effect. | 602 // TODO(estade): revisit colors and press effect. |
| 604 const int kIconSize = 16; | 603 const int kIconSize = 16; |
| 605 button_->SetImage(views::LabelButton::STATE_NORMAL, | 604 button_->SetImage(views::LabelButton::STATE_NORMAL, |
| 606 CreateSquarePlaceholderImage(kIconSize)); | 605 CreateSquarePlaceholderImage(kIconSize)); |
| 607 button_->SetImage(views::LabelButton::STATE_HOVERED, | 606 button_->SetImage(views::LabelButton::STATE_HOVERED, |
| 608 gfx::CreateVectorIcon( | 607 gfx::CreateVectorIcon(kModeEditIcon, kIconSize, |
| 609 gfx::VectorIconId::MODE_EDIT, kIconSize, | 608 SkColorSetRGB(0x33, 0x33, 0x33))); |
| 610 SkColorSetRGB(0x33, 0x33, 0x33))); | |
| 611 button_->SetImage(views::LabelButton::STATE_PRESSED, | 609 button_->SetImage(views::LabelButton::STATE_PRESSED, |
| 612 gfx::CreateVectorIcon( | 610 gfx::CreateVectorIcon(kModeEditIcon, kIconSize, |
| 613 gfx::VectorIconId::MODE_EDIT, kIconSize, | 611 SkColorSetRGB(0x20, 0x20, 0x20))); |
| 614 SkColorSetRGB(0x20, 0x20, 0x20))); | |
| 615 // We need to add a left padding as well as a small top/bottom padding | 612 // We need to add a left padding as well as a small top/bottom padding |
| 616 // to the text to account for the textfield's border. | 613 // to the text to account for the textfield's border. |
| 617 const int kIconTextLabelButtonSpacing = 5; | 614 const int kIconTextLabelButtonSpacing = 5; |
| 618 button_->SetBorder(views::CreateEmptyBorder( | 615 button_->SetBorder(views::CreateEmptyBorder( |
| 619 textfield_border_insets + | 616 textfield_border_insets + |
| 620 gfx::Insets(0, kIconSize + kIconTextLabelButtonSpacing, 0, 0))); | 617 gfx::Insets(0, kIconSize + kIconTextLabelButtonSpacing, 0, 0))); |
| 621 AddChildView(button_); | 618 AddChildView(button_); |
| 622 } | 619 } |
| 623 | 620 |
| 624 views::Textfield* profile_name_textfield() { | 621 views::Textfield* profile_name_textfield() { |
| (...skipping 949 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1574 views::View* view = new views::View(); | 1571 views::View* view = new views::View(); |
| 1575 views::BoxLayout* layout = new views::BoxLayout( | 1572 views::BoxLayout* layout = new views::BoxLayout( |
| 1576 views::BoxLayout::kHorizontal, kMaterialMenuEdgeMargin, | 1573 views::BoxLayout::kHorizontal, kMaterialMenuEdgeMargin, |
| 1577 kMaterialMenuEdgeMargin, views::kUnrelatedControlHorizontalSpacing); | 1574 kMaterialMenuEdgeMargin, views::kUnrelatedControlHorizontalSpacing); |
| 1578 layout->set_cross_axis_alignment( | 1575 layout->set_cross_axis_alignment( |
| 1579 views::BoxLayout::CROSS_AXIS_ALIGNMENT_START); | 1576 views::BoxLayout::CROSS_AXIS_ALIGNMENT_START); |
| 1580 view->SetLayoutManager(layout); | 1577 view->SetLayoutManager(layout); |
| 1581 | 1578 |
| 1582 // Adds the sync problem icon. | 1579 // Adds the sync problem icon. |
| 1583 views::ImageView* sync_problem_icon = new views::ImageView(); | 1580 views::ImageView* sync_problem_icon = new views::ImageView(); |
| 1584 sync_problem_icon->SetImage(gfx::CreateVectorIcon( | 1581 sync_problem_icon->SetImage( |
| 1585 gfx::VectorIconId::SYNC_PROBLEM, 20, gfx::kGoogleRed700)); | 1582 gfx::CreateVectorIcon(kSyncProblemIcon, 20, gfx::kGoogleRed700)); |
| 1586 view->AddChildView(sync_problem_icon); | 1583 view->AddChildView(sync_problem_icon); |
| 1587 | 1584 |
| 1588 // Adds a vertical view to organize the error title, message, and button. | 1585 // Adds a vertical view to organize the error title, message, and button. |
| 1589 views::View* vertical_view = new views::View(); | 1586 views::View* vertical_view = new views::View(); |
| 1590 views::BoxLayout* vertical_layout = | 1587 views::BoxLayout* vertical_layout = |
| 1591 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, | 1588 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, |
| 1592 views::kRelatedControlSmallVerticalSpacing); | 1589 views::kRelatedControlSmallVerticalSpacing); |
| 1593 vertical_layout->set_cross_axis_alignment( | 1590 vertical_layout->set_cross_axis_alignment( |
| 1594 views::BoxLayout::CROSS_AXIS_ALIGNMENT_START); | 1591 views::BoxLayout::CROSS_AXIS_ALIGNMENT_START); |
| 1595 vertical_view->SetLayoutManager(vertical_layout); | 1592 vertical_view->SetLayoutManager(vertical_layout); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1680 manage_accounts_link_->SetHorizontalAlignment(gfx::ALIGN_CENTER); | 1677 manage_accounts_link_->SetHorizontalAlignment(gfx::ALIGN_CENTER); |
| 1681 layout->AddView(manage_accounts_link_); | 1678 layout->AddView(manage_accounts_link_); |
| 1682 } else { | 1679 } else { |
| 1683 // Badge the email address if there's an authentication error. | 1680 // Badge the email address if there's an authentication error. |
| 1684 if (HasAuthError(browser_->profile())) { | 1681 if (HasAuthError(browser_->profile())) { |
| 1685 auth_error_email_button_ = | 1682 auth_error_email_button_ = |
| 1686 new RightAlignedIconLabelButton(this, avatar_item.username); | 1683 new RightAlignedIconLabelButton(this, avatar_item.username); |
| 1687 auth_error_email_button_->SetElideBehavior(gfx::ELIDE_EMAIL); | 1684 auth_error_email_button_->SetElideBehavior(gfx::ELIDE_EMAIL); |
| 1688 auth_error_email_button_->SetImage( | 1685 auth_error_email_button_->SetImage( |
| 1689 views::LabelButton::STATE_NORMAL, | 1686 views::LabelButton::STATE_NORMAL, |
| 1690 gfx::CreateVectorIcon(gfx::VectorIconId::WARNING, 18, | 1687 gfx::CreateVectorIcon(ui::kWarningIcon, 18, gfx::kChromeIconGrey)); |
| 1691 gfx::kChromeIconGrey)); | |
| 1692 auth_error_email_button_->SetFocusForPlatform(); | 1688 auth_error_email_button_->SetFocusForPlatform(); |
| 1693 gfx::Insets insets = | 1689 gfx::Insets insets = |
| 1694 views::LabelButtonAssetBorder::GetDefaultInsetsForStyle( | 1690 views::LabelButtonAssetBorder::GetDefaultInsetsForStyle( |
| 1695 views::Button::STYLE_TEXTBUTTON); | 1691 views::Button::STYLE_TEXTBUTTON); |
| 1696 auth_error_email_button_->SetBorder(views::CreateEmptyBorder( | 1692 auth_error_email_button_->SetBorder(views::CreateEmptyBorder( |
| 1697 insets.top(), insets.left(), insets.bottom(), insets.right())); | 1693 insets.top(), insets.left(), insets.bottom(), insets.right())); |
| 1698 layout->AddView(auth_error_email_button_); | 1694 layout->AddView(auth_error_email_button_); |
| 1699 } else { | 1695 } else { |
| 1700 // Add a small padding between the email button and the profile name. | 1696 // Add a small padding between the email button and the profile name. |
| 1701 layout->StartRowWithPadding(1, 0, 0, 2); | 1697 layout->StartRowWithPadding(1, 0, 0, 2); |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1953 } | 1949 } |
| 1954 } | 1950 } |
| 1955 | 1951 |
| 1956 // Add the "Guest" button for browsing as guest | 1952 // Add the "Guest" button for browsing as guest |
| 1957 if (!is_guest) { | 1953 if (!is_guest) { |
| 1958 PrefService* service = g_browser_process->local_state(); | 1954 PrefService* service = g_browser_process->local_state(); |
| 1959 DCHECK(service); | 1955 DCHECK(service); |
| 1960 if (service->GetBoolean(prefs::kBrowserGuestModeEnabled)) { | 1956 if (service->GetBoolean(prefs::kBrowserGuestModeEnabled)) { |
| 1961 guest_profile_button_ = new BackgroundColorHoverButton( | 1957 guest_profile_button_ = new BackgroundColorHoverButton( |
| 1962 this, l10n_util::GetStringUTF16(IDS_GUEST_PROFILE_NAME), | 1958 this, l10n_util::GetStringUTF16(IDS_GUEST_PROFILE_NAME), |
| 1963 gfx::CreateVectorIcon(gfx::VectorIconId::ACCOUNT_CIRCLE, kIconSize, | 1959 gfx::CreateVectorIcon(kAccountCircleIcon, kIconSize, |
| 1964 gfx::kChromeIconGrey)); | 1960 gfx::kChromeIconGrey)); |
| 1965 layout->StartRow(1, 0); | 1961 layout->StartRow(1, 0); |
| 1966 layout->AddView(guest_profile_button_); | 1962 layout->AddView(guest_profile_button_); |
| 1967 } | 1963 } |
| 1968 } | 1964 } |
| 1969 } | 1965 } |
| 1970 | 1966 |
| 1971 base::string16 text; | 1967 base::string16 text = l10n_util::GetStringUTF16( |
| 1972 gfx::VectorIconId settings_icon; | 1968 is_guest ? IDS_PROFILES_EXIT_GUEST |
| 1973 if (switches::IsMaterialDesignUserMenu()) { | 1969 : (switches::IsMaterialDesignUserMenu() |
| 1974 text = is_guest | 1970 ? IDS_PROFILES_MANAGE_USERS_BUTTON |
| 1975 ? l10n_util::GetStringUTF16(IDS_PROFILES_EXIT_GUEST) | 1971 : IDS_PROFILES_SWITCH_USERS_BUTTON)); |
| 1976 : l10n_util::GetStringUTF16(IDS_PROFILES_MANAGE_USERS_BUTTON); | 1972 const gfx::VectorIcon& settings_icon = |
| 1977 settings_icon = | 1973 switches::IsMaterialDesignUserMenu() |
| 1978 is_guest ? gfx::VectorIconId::CLOSE_ALL : gfx::VectorIconId::SETTINGS; | 1974 ? (is_guest ? kCloseAllIcon : kSettingsIcon) |
| 1979 } else { | 1975 : kAccountBoxIcon; |
| 1980 text = is_guest | |
| 1981 ? l10n_util::GetStringUTF16(IDS_PROFILES_EXIT_GUEST) | |
| 1982 : l10n_util::GetStringUTF16(IDS_PROFILES_SWITCH_USERS_BUTTON); | |
| 1983 settings_icon = gfx::VectorIconId::ACCOUNT_BOX; | |
| 1984 } | |
| 1985 users_button_ = new BackgroundColorHoverButton( | 1976 users_button_ = new BackgroundColorHoverButton( |
| 1986 this, text, gfx::CreateVectorIcon(settings_icon, kIconSize, | 1977 this, text, |
| 1987 gfx::kChromeIconGrey)); | 1978 gfx::CreateVectorIcon(settings_icon, kIconSize, gfx::kChromeIconGrey)); |
| 1988 | 1979 |
| 1989 layout->StartRow(1, 0); | 1980 layout->StartRow(1, 0); |
| 1990 layout->AddView(users_button_); | 1981 layout->AddView(users_button_); |
| 1991 | 1982 |
| 1992 if (!switches::IsMaterialDesignUserMenu() && ShouldShowGoIncognito()) { | 1983 if (!switches::IsMaterialDesignUserMenu() && ShouldShowGoIncognito()) { |
| 1993 layout->StartRow(1, 0); | 1984 layout->StartRow(1, 0); |
| 1994 layout->AddView(new views::Separator()); | 1985 layout->AddView(new views::Separator()); |
| 1995 | 1986 |
| 1996 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); | 1987 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); |
| 1997 go_incognito_button_ = new BackgroundColorHoverButton( | 1988 go_incognito_button_ = new BackgroundColorHoverButton( |
| 1998 this, | 1989 this, |
| 1999 l10n_util::GetStringUTF16(IDS_PROFILES_GO_INCOGNITO_BUTTON), | 1990 l10n_util::GetStringUTF16(IDS_PROFILES_GO_INCOGNITO_BUTTON), |
| 2000 *rb->GetImageSkiaNamed(IDR_ICON_PROFILES_MENU_INCOGNITO)); | 1991 *rb->GetImageSkiaNamed(IDR_ICON_PROFILES_MENU_INCOGNITO)); |
| 2001 layout->StartRow(1, 0); | 1992 layout->StartRow(1, 0); |
| 2002 layout->AddView(go_incognito_button_); | 1993 layout->AddView(go_incognito_button_); |
| 2003 } | 1994 } |
| 2004 | 1995 |
| 2005 if (display_lock) { | 1996 if (display_lock) { |
| 2006 if (!switches::IsMaterialDesignUserMenu()) { | 1997 if (!switches::IsMaterialDesignUserMenu()) { |
| 2007 layout->StartRow(1, 0); | 1998 layout->StartRow(1, 0); |
| 2008 layout->AddView(new views::Separator()); | 1999 layout->AddView(new views::Separator()); |
| 2009 } | 2000 } |
| 2010 | 2001 |
| 2011 lock_button_ = new BackgroundColorHoverButton( | 2002 lock_button_ = new BackgroundColorHoverButton( |
| 2012 this, l10n_util::GetStringUTF16(IDS_PROFILES_PROFILE_SIGNOUT_BUTTON), | 2003 this, l10n_util::GetStringUTF16(IDS_PROFILES_PROFILE_SIGNOUT_BUTTON), |
| 2013 gfx::CreateVectorIcon(gfx::VectorIconId::LOCK, kIconSize, | 2004 gfx::CreateVectorIcon(kLockIcon, kIconSize, gfx::kChromeIconGrey)); |
| 2014 gfx::kChromeIconGrey)); | |
| 2015 layout->StartRow(1, 0); | 2005 layout->StartRow(1, 0); |
| 2016 layout->AddView(lock_button_); | 2006 layout->AddView(lock_button_); |
| 2017 } else if (switches::IsMaterialDesignUserMenu() && !is_guest) { | 2007 } else if (switches::IsMaterialDesignUserMenu() && !is_guest) { |
| 2018 int num_browsers = 0; | 2008 int num_browsers = 0; |
| 2019 for (auto* browser : *BrowserList::GetInstance()) { | 2009 for (auto* browser : *BrowserList::GetInstance()) { |
| 2020 if (browser->profile()->GetOriginalProfile() == | 2010 if (browser->profile()->GetOriginalProfile() == |
| 2021 browser_->profile()->GetOriginalProfile()) | 2011 browser_->profile()->GetOriginalProfile()) |
| 2022 num_browsers++; | 2012 num_browsers++; |
| 2023 } | 2013 } |
| 2024 if (num_browsers > 1) { | 2014 if (num_browsers > 1) { |
| 2025 close_all_windows_button_ = new BackgroundColorHoverButton( | 2015 close_all_windows_button_ = new BackgroundColorHoverButton( |
| 2026 this, | 2016 this, |
| 2027 l10n_util::GetStringUTF16(IDS_PROFILES_CLOSE_ALL_WINDOWS_BUTTON), | 2017 l10n_util::GetStringUTF16(IDS_PROFILES_CLOSE_ALL_WINDOWS_BUTTON), |
| 2028 gfx::CreateVectorIcon(gfx::VectorIconId::CLOSE_ALL, kIconSize, | 2018 gfx::CreateVectorIcon(kCloseAllIcon, kIconSize, |
| 2029 gfx::kChromeIconGrey)); | 2019 gfx::kChromeIconGrey)); |
| 2030 layout->StartRow(1, 0); | 2020 layout->StartRow(1, 0); |
| 2031 layout->AddView(close_all_windows_button_); | 2021 layout->AddView(close_all_windows_button_); |
| 2032 } | 2022 } |
| 2033 } | 2023 } |
| 2034 | 2024 |
| 2035 if (switches::IsMaterialDesignUserMenu()) | 2025 if (switches::IsMaterialDesignUserMenu()) |
| 2036 layout->StartRowWithPadding(1, 0, 0, views::kRelatedControlVerticalSpacing); | 2026 layout->StartRowWithPadding(1, 0, 0, views::kRelatedControlVerticalSpacing); |
| 2037 return view; | 2027 return view; |
| 2038 } | 2028 } |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2117 std::string email = signin_ui_util::GetDisplayEmail(browser_->profile(), | 2107 std::string email = signin_ui_util::GetDisplayEmail(browser_->profile(), |
| 2118 account_id); | 2108 account_id); |
| 2119 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); | 2109 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); |
| 2120 const gfx::ImageSkia* delete_default_image = | 2110 const gfx::ImageSkia* delete_default_image = |
| 2121 rb->GetImageNamed(IDR_CLOSE_1).ToImageSkia(); | 2111 rb->GetImageNamed(IDR_CLOSE_1).ToImageSkia(); |
| 2122 const int kDeleteButtonWidth = delete_default_image->width(); | 2112 const int kDeleteButtonWidth = delete_default_image->width(); |
| 2123 gfx::ImageSkia warning_default_image; | 2113 gfx::ImageSkia warning_default_image; |
| 2124 int warning_button_width = 0; | 2114 int warning_button_width = 0; |
| 2125 if (reauth_required) { | 2115 if (reauth_required) { |
| 2126 const int kIconSize = 18; | 2116 const int kIconSize = 18; |
| 2127 warning_default_image = gfx::CreateVectorIcon( | 2117 warning_default_image = gfx::CreateVectorIcon(ui::kWarningIcon, kIconSize, |
| 2128 gfx::VectorIconId::WARNING, kIconSize, gfx::kChromeIconGrey); | 2118 gfx::kChromeIconGrey); |
| 2129 warning_button_width = kIconSize + views::kRelatedButtonHSpacing; | 2119 warning_button_width = kIconSize + views::kRelatedButtonHSpacing; |
| 2130 } | 2120 } |
| 2131 int available_width = width - 2 * views::kButtonHEdgeMarginNew - | 2121 int available_width = width - 2 * views::kButtonHEdgeMarginNew - |
| 2132 kDeleteButtonWidth - warning_button_width; | 2122 kDeleteButtonWidth - warning_button_width; |
| 2133 views::LabelButton* email_button = new BackgroundColorHoverButton( | 2123 views::LabelButton* email_button = new BackgroundColorHoverButton( |
| 2134 this, base::UTF8ToUTF16(email), warning_default_image); | 2124 this, base::UTF8ToUTF16(email), warning_default_image); |
| 2135 email_button->SetEnabled(reauth_required); | 2125 email_button->SetEnabled(reauth_required); |
| 2136 email_button->SetElideBehavior(gfx::ELIDE_EMAIL); | 2126 email_button->SetElideBehavior(gfx::ELIDE_EMAIL); |
| 2137 email_button->SetMinSize(gfx::Size(0, kButtonHeight)); | 2127 email_button->SetMinSize(gfx::Size(0, kButtonHeight)); |
| 2138 email_button->SetMaxSize(gfx::Size(available_width, kButtonHeight)); | 2128 email_button->SetMaxSize(gfx::Size(available_width, kButtonHeight)); |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2359 content_label->SetFontList(small_font_list); | 2349 content_label->SetFontList(small_font_list); |
| 2360 layout->AddView(content_label); | 2350 layout->AddView(content_label); |
| 2361 | 2351 |
| 2362 // Adds "Add person" button. | 2352 // Adds "Add person" button. |
| 2363 layout->StartRowWithPadding(1, 0, 0, views::kUnrelatedControlVerticalSpacing); | 2353 layout->StartRowWithPadding(1, 0, 0, views::kUnrelatedControlVerticalSpacing); |
| 2364 layout->AddView(new views::Separator()); | 2354 layout->AddView(new views::Separator()); |
| 2365 | 2355 |
| 2366 const int kIconSize = 24; | 2356 const int kIconSize = 24; |
| 2367 add_person_button_ = new BackgroundColorHoverButton( | 2357 add_person_button_ = new BackgroundColorHoverButton( |
| 2368 this, l10n_util::GetStringUTF16(IDS_PROFILES_ADD_PERSON_BUTTON), | 2358 this, l10n_util::GetStringUTF16(IDS_PROFILES_ADD_PERSON_BUTTON), |
| 2369 gfx::CreateVectorIcon(gfx::VectorIconId::ACCOUNT_BOX, kIconSize, | 2359 gfx::CreateVectorIcon(kAccountBoxIcon, kIconSize, gfx::kChromeIconGrey)); |
| 2370 gfx::kChromeIconGrey)); | |
| 2371 layout->StartRow(1, 0); | 2360 layout->StartRow(1, 0); |
| 2372 layout->AddView(add_person_button_); | 2361 layout->AddView(add_person_button_); |
| 2373 | 2362 |
| 2374 // Adds "Disconnect your Google Account" button. | 2363 // Adds "Disconnect your Google Account" button. |
| 2375 layout->StartRow(1, 0); | 2364 layout->StartRow(1, 0); |
| 2376 layout->AddView(new views::Separator()); | 2365 layout->AddView(new views::Separator()); |
| 2377 | 2366 |
| 2378 disconnect_button_ = new BackgroundColorHoverButton( | 2367 disconnect_button_ = new BackgroundColorHoverButton( |
| 2379 this, l10n_util::GetStringUTF16(IDS_PROFILES_DISCONNECT_BUTTON), | 2368 this, l10n_util::GetStringUTF16(IDS_PROFILES_DISCONNECT_BUTTON), |
| 2380 gfx::CreateVectorIcon(gfx::VectorIconId::REMOVE_BOX, kIconSize, | 2369 gfx::CreateVectorIcon(kRemoveBoxIcon, kIconSize, gfx::kChromeIconGrey)); |
| 2381 gfx::kChromeIconGrey)); | |
| 2382 layout->StartRow(1, 0); | 2370 layout->StartRow(1, 0); |
| 2383 layout->AddView(disconnect_button_); | 2371 layout->AddView(disconnect_button_); |
| 2384 | 2372 |
| 2385 TitleCard* title_card = new TitleCard( | 2373 TitleCard* title_card = new TitleCard( |
| 2386 l10n_util::GetStringFUTF16(IDS_PROFILES_NOT_YOU, avatar_item.name), | 2374 l10n_util::GetStringFUTF16(IDS_PROFILES_NOT_YOU, avatar_item.name), |
| 2387 this, &switch_user_cancel_button_); | 2375 this, &switch_user_cancel_button_); |
| 2388 return TitleCard::AddPaddedTitleCard(view, title_card, | 2376 return TitleCard::AddPaddedTitleCard(view, title_card, |
| 2389 kFixedSwitchUserViewWidth); | 2377 kFixedSwitchUserViewWidth); |
| 2390 } | 2378 } |
| 2391 | 2379 |
| 2392 bool ProfileChooserView::ShouldShowGoIncognito() const { | 2380 bool ProfileChooserView::ShouldShowGoIncognito() const { |
| 2393 bool incognito_available = | 2381 bool incognito_available = |
| 2394 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != | 2382 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != |
| 2395 IncognitoModePrefs::DISABLED; | 2383 IncognitoModePrefs::DISABLED; |
| 2396 return incognito_available && !browser_->profile()->IsGuestSession(); | 2384 return incognito_available && !browser_->profile()->IsGuestSession(); |
| 2397 } | 2385 } |
| 2398 | 2386 |
| 2399 void ProfileChooserView::PostActionPerformed( | 2387 void ProfileChooserView::PostActionPerformed( |
| 2400 ProfileMetrics::ProfileDesktopMenu action_performed) { | 2388 ProfileMetrics::ProfileDesktopMenu action_performed) { |
| 2401 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); | 2389 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); |
| 2402 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; | 2390 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; |
| 2403 } | 2391 } |
| OLD | NEW |