Chromium Code Reviews| 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/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 177 } | 177 } |
| 178 | 178 |
| 179 // BackgroundColorHoverButton ------------------------------------------------- | 179 // BackgroundColorHoverButton ------------------------------------------------- |
| 180 | 180 |
| 181 // A custom button that allows for setting a background color when hovered over. | 181 // A custom button that allows for setting a background color when hovered over. |
| 182 class BackgroundColorHoverButton : public views::LabelButton { | 182 class BackgroundColorHoverButton : public views::LabelButton { |
| 183 public: | 183 public: |
| 184 BackgroundColorHoverButton(views::ButtonListener* listener, | 184 BackgroundColorHoverButton(views::ButtonListener* listener, |
| 185 const base::string16& text) | 185 const base::string16& text) |
| 186 : views::LabelButton(listener, text) { | 186 : views::LabelButton(listener, text) { |
| 187 SetImageLabelSpacing(views::kItemLabelSpacing); | 187 SetImageLabelSpacing(switches::IsMaterialDesignUserMenu() |
| 188 ? (kMaterialMenuEdgeMargin - 2) | |
| 189 : views::kItemLabelSpacing); | |
| 188 const int button_margin = switches::IsMaterialDesignUserMenu() | 190 const int button_margin = switches::IsMaterialDesignUserMenu() |
| 189 ? kMaterialMenuEdgeMargin | 191 ? kMaterialMenuEdgeMargin |
| 190 : views::kButtonHEdgeMarginNew; | 192 : views::kButtonHEdgeMarginNew; |
| 191 SetBorder( | 193 SetBorder( |
| 192 views::Border::CreateEmptyBorder(0, button_margin, 0, button_margin)); | 194 views::Border::CreateEmptyBorder(0, button_margin, 0, button_margin)); |
| 193 SetFocusForPlatform(); | 195 SetFocusForPlatform(); |
| 194 set_request_focus_on_press(true); | 196 set_request_focus_on_press(true); |
| 195 } | 197 } |
| 196 | 198 |
| 197 BackgroundColorHoverButton(views::ButtonListener* listener, | 199 BackgroundColorHoverButton(views::ButtonListener* listener, |
| (...skipping 1508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1706 layout->StartRowWithPadding(1, 0, 0, views::kRelatedControlVerticalSpacing); | 1708 layout->StartRowWithPadding(1, 0, 0, views::kRelatedControlVerticalSpacing); |
| 1707 for (size_t i = 0; i < avatar_menu->GetNumberOfItems(); ++i) { | 1709 for (size_t i = 0; i < avatar_menu->GetNumberOfItems(); ++i) { |
| 1708 const AvatarMenu::Item& item = avatar_menu->GetItemAt(i); | 1710 const AvatarMenu::Item& item = avatar_menu->GetItemAt(i); |
| 1709 if (!item.active) { | 1711 if (!item.active) { |
| 1710 gfx::Image image = profiles::GetSizedAvatarIcon( | 1712 gfx::Image image = profiles::GetSizedAvatarIcon( |
| 1711 item.icon, true, kProfileIconSize, kProfileIconSize, | 1713 item.icon, true, kProfileIconSize, kProfileIconSize, |
| 1712 profiles::SHAPE_CIRCLE); | 1714 profiles::SHAPE_CIRCLE); |
| 1713 views::LabelButton* button = new BackgroundColorHoverButton( | 1715 views::LabelButton* button = new BackgroundColorHoverButton( |
| 1714 this, profiles::GetProfileSwitcherTextForItem(item), | 1716 this, profiles::GetProfileSwitcherTextForItem(item), |
| 1715 *image.ToImageSkia()); | 1717 *image.ToImageSkia()); |
| 1718 button->SetImageLabelSpacing(kMaterialMenuEdgeMargin); | |
| 1716 open_other_profile_indexes_map_[button] = i; | 1719 open_other_profile_indexes_map_[button] = i; |
| 1717 | 1720 |
| 1718 layout->StartRow(1, 0); | 1721 layout->StartRow(1, 0); |
| 1719 layout->AddView(button); | 1722 layout->AddView(button); |
| 1720 } | 1723 } |
| 1721 } | 1724 } |
| 1722 | 1725 |
| 1723 // Add the "Guest" button for browsing as guest | 1726 // Add the "Guest" button for browsing as guest |
| 1724 if (!browser_->profile()->IsGuestSession()) { | 1727 if (!browser_->profile()->IsGuestSession()) { |
| 1725 PrefService* service = g_browser_process->local_state(); | 1728 PrefService* service = g_browser_process->local_state(); |
| 1726 DCHECK(service); | 1729 DCHECK(service); |
| 1727 if (service->GetBoolean(prefs::kBrowserGuestModeEnabled)) { | 1730 if (service->GetBoolean(prefs::kBrowserGuestModeEnabled)) { |
| 1728 guest_profile_button_ = new BackgroundColorHoverButton( | 1731 guest_profile_button_ = new BackgroundColorHoverButton( |
| 1729 this, l10n_util::GetStringUTF16(IDS_GUEST_PROFILE_NAME), | 1732 this, l10n_util::GetStringUTF16(IDS_GUEST_PROFILE_NAME), |
| 1730 gfx::CreateVectorIcon(gfx::VectorIconId::ACCOUNT_CIRCLE, kIconSize, | 1733 gfx::CreateVectorIcon(gfx::VectorIconId::ACCOUNT_CIRCLE, kIconSize, |
| 1731 gfx::kChromeIconGrey)); | 1734 gfx::kChromeIconGrey)); |
| 1732 layout->StartRow(1, 0); | 1735 layout->StartRow(1, 0); |
| 1733 layout->AddView(guest_profile_button_); | 1736 layout->AddView(guest_profile_button_); |
| 1734 } | 1737 } |
| 1735 } | 1738 } |
| 1736 } | 1739 } |
| 1737 | 1740 |
| 1738 base::string16 text = browser_->profile()->IsGuestSession() ? | 1741 base::string16 text; |
| 1739 l10n_util::GetStringUTF16(IDS_PROFILES_EXIT_GUEST) : | 1742 gfx::VectorIconId settings_icon; |
| 1740 l10n_util::GetStringUTF16(IDS_PROFILES_SWITCH_USERS_BUTTON); | 1743 if (switches::IsMaterialDesignUserMenu()) { |
| 1741 gfx::VectorIconId settings_icon = gfx::VectorIconId::ACCOUNT_BOX; | 1744 text = browser_->profile()->IsGuestSession() ? |
|
sky
2016/07/19 17:57:53
nit: how about a variable around 1704ish for is_gu
| |
| 1742 if (!browser_->profile()->IsGuestSession() | 1745 l10n_util::GetStringUTF16(IDS_PROFILES_EXIT_GUEST) : |
| 1743 && switches::IsMaterialDesignUserMenu()) { | 1746 l10n_util::GetStringUTF16(IDS_PROFILES_MANAGE_USERS_BUTTON); |
| 1744 text = l10n_util::GetStringUTF16(IDS_PROFILES_MANAGE_USERS_BUTTON); | 1747 settings_icon = browser_->profile()->IsGuestSession() ? |
| 1745 settings_icon = gfx::VectorIconId::SETTINGS; | 1748 gfx::VectorIconId::CLOSE_ALL : gfx::VectorIconId::SETTINGS; |
| 1749 } else { | |
| 1750 text = browser_->profile()->IsGuestSession() ? | |
| 1751 l10n_util::GetStringUTF16(IDS_PROFILES_EXIT_GUEST) : | |
| 1752 l10n_util::GetStringUTF16(IDS_PROFILES_SWITCH_USERS_BUTTON); | |
| 1753 settings_icon = gfx::VectorIconId::ACCOUNT_BOX; | |
| 1746 } | 1754 } |
| 1747 users_button_ = new BackgroundColorHoverButton( | 1755 users_button_ = new BackgroundColorHoverButton( |
| 1748 this, text, gfx::CreateVectorIcon(settings_icon, kIconSize, | 1756 this, text, gfx::CreateVectorIcon(settings_icon, kIconSize, |
| 1749 gfx::kChromeIconGrey)); | 1757 gfx::kChromeIconGrey)); |
| 1750 | 1758 |
| 1751 layout->StartRow(1, 0); | 1759 layout->StartRow(1, 0); |
| 1752 layout->AddView(users_button_); | 1760 layout->AddView(users_button_); |
| 1753 | 1761 |
| 1754 if (!switches::IsMaterialDesignUserMenu() && ShouldShowGoIncognito()) { | 1762 if (!switches::IsMaterialDesignUserMenu() && ShouldShowGoIncognito()) { |
| 1755 layout->StartRow(1, 0); | 1763 layout->StartRow(1, 0); |
| (...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2158 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != | 2166 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != |
| 2159 IncognitoModePrefs::DISABLED; | 2167 IncognitoModePrefs::DISABLED; |
| 2160 return incognito_available && !browser_->profile()->IsGuestSession(); | 2168 return incognito_available && !browser_->profile()->IsGuestSession(); |
| 2161 } | 2169 } |
| 2162 | 2170 |
| 2163 void ProfileChooserView::PostActionPerformed( | 2171 void ProfileChooserView::PostActionPerformed( |
| 2164 ProfileMetrics::ProfileDesktopMenu action_performed) { | 2172 ProfileMetrics::ProfileDesktopMenu action_performed) { |
| 2165 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); | 2173 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); |
| 2166 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; | 2174 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; |
| 2167 } | 2175 } |
| OLD | NEW |