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

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

Issue 2710543002: Linux/Windows: Adding tooltip in profile switcher menu. (Closed)
Patch Set: Nit 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 | « no previous file | no next file » | 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/browser/browser_process.h" 10 #include "chrome/browser/browser_process.h"
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 public: 310 public:
311 explicit SizedContainer(const gfx::Size& preferred_size) 311 explicit SizedContainer(const gfx::Size& preferred_size)
312 : preferred_size_(preferred_size) {} 312 : preferred_size_(preferred_size) {}
313 313
314 gfx::Size GetPreferredSize() const override { return preferred_size_; } 314 gfx::Size GetPreferredSize() const override { return preferred_size_; }
315 315
316 private: 316 private:
317 gfx::Size preferred_size_; 317 gfx::Size preferred_size_;
318 }; 318 };
319 319
320 // NonInteractiveContainer -------------------------------------------------
321
322 // A simple container view that does not process events within subtree.
323 class NonInteractiveContainer : public views::View {
324 public:
325 NonInteractiveContainer() {}
326
327 // views::CanProcessEventsWithinSubtree:
328 bool CanProcessEventsWithinSubtree() const override { return false; }
329
330 private:
331 DISALLOW_COPY_AND_ASSIGN(NonInteractiveContainer);
332 };
333
334 // A view to host the GAIA webview overlapped with a back button. This class 320 // A view to host the GAIA webview overlapped with a back button. This class
335 // is needed to reparent the back button inside a native view so that on 321 // is needed to reparent the back button inside a native view so that on
336 // windows, user input can be be properly routed to the button. 322 // windows, user input can be be properly routed to the button.
337 class HostView : public views::View { 323 class HostView : public views::View {
338 public: 324 public:
339 HostView() {} 325 HostView() {}
340 326
341 private: 327 private:
342 // views::View: 328 // views::View:
343 void ViewHierarchyChanged( 329 void ViewHierarchyChanged(
(...skipping 1408 matching lines...) Expand 10 before | Expand all | Expand 10 after
1752 const AvatarMenu::Item& avatar_item, 1738 const AvatarMenu::Item& avatar_item,
1753 bool is_guest) { 1739 bool is_guest) {
1754 views::View* view = new views::View(); 1740 views::View* view = new views::View();
1755 view->SetLayoutManager( 1741 view->SetLayoutManager(
1756 new views::BoxLayout(views::BoxLayout::kVertical, 0, 1742 new views::BoxLayout(views::BoxLayout::kVertical, 0,
1757 views::kRelatedControlVerticalSpacing, 0)); 1743 views::kRelatedControlVerticalSpacing, 0));
1758 1744
1759 // Container for the profile photo and avatar/user name. 1745 // Container for the profile photo and avatar/user name.
1760 BackgroundColorHoverButton* current_profile_card = 1746 BackgroundColorHoverButton* current_profile_card =
1761 new BackgroundColorHoverButton(this, base::string16()); 1747 new BackgroundColorHoverButton(this, base::string16());
1748 views::GridLayout* grid_layout = new views::GridLayout(current_profile_card);
1749 current_profile_card->SetLayoutManager(grid_layout);
1750 views::ColumnSet* columns = grid_layout->AddColumnSet(0);
1751 columns->AddPaddingColumn(0, kMaterialMenuEdgeMargin);
1752 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 0,
1753 views::GridLayout::USE_PREF, 0, 0);
1754 columns->AddPaddingColumn(
1755 0, kMaterialMenuEdgeMargin - EditableProfilePhoto::badge_spacing());
1756 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 1,
1757 views::GridLayout::USE_PREF, 0, 0);
1758 columns->AddPaddingColumn(0, kMaterialMenuEdgeMargin);
1759 grid_layout->AddPaddingRow(0, 0);
1760 const int num_labels =
1761 (avatar_item.signed_in && !switches::IsEnableAccountConsistency()) ? 2
1762 : 1;
1763 int profile_card_height = EditableProfilePhoto::icon_image_side() +
1764 2 *
1765 (EditableProfilePhoto::badge_spacing() +
1766 views::kRelatedControlSmallVerticalSpacing);
1767 const int line_height = profile_card_height / num_labels;
1768 grid_layout->StartRow(0, 0, line_height);
1762 current_profile_card_ = current_profile_card; 1769 current_profile_card_ = current_profile_card;
1763 1770
1764 // Profile picture, left-aligned. 1771 // Profile picture, left-aligned.
1765 EditableProfilePhoto* current_profile_photo = new EditableProfilePhoto( 1772 EditableProfilePhoto* current_profile_photo = new EditableProfilePhoto(
1766 this, avatar_item.icon, !is_guest, browser_->profile()); 1773 this, avatar_item.icon, !is_guest, browser_->profile());
1767 1774
1768 // Profile name, left-aligned to the right of profile icon. 1775 // Profile name, left-aligned to the right of profile icon.
1769 views::Label* current_profile_name = new views::Label( 1776 views::Label* current_profile_name = new views::Label(
1770 profiles::GetAvatarNameForProfile(browser_->profile()->GetPath())); 1777 profiles::GetAvatarNameForProfile(browser_->profile()->GetPath()));
1771 current_profile_card->set_title(current_profile_name); 1778 current_profile_card->set_title(current_profile_name);
1772 current_profile_name->SetAutoColorReadabilityEnabled(false); 1779 current_profile_name->SetAutoColorReadabilityEnabled(false);
1773 current_profile_name->SetFontList( 1780 current_profile_name->SetFontList(
1774 ui::ResourceBundle::GetSharedInstance().GetFontListWithDelta( 1781 ui::ResourceBundle::GetSharedInstance().GetFontListWithDelta(
1775 1, gfx::Font::FontStyle::NORMAL, gfx::Font::Weight::MEDIUM)); 1782 1, gfx::Font::FontStyle::NORMAL, gfx::Font::Weight::MEDIUM));
1776 current_profile_name->SetHorizontalAlignment(gfx::ALIGN_LEFT); 1783 current_profile_name->SetHorizontalAlignment(gfx::ALIGN_LEFT);
1777 NonInteractiveContainer* profile_name_container =
1778 new NonInteractiveContainer();
1779 int name_container_v_spacing =
1780 (current_profile_photo->GetPreferredSize().height() -
1781 current_profile_name->GetPreferredSize().height()) / 2;
1782 views::BoxLayout* profile_name_layout = new views::BoxLayout(
1783 views::BoxLayout::kVertical, 0, name_container_v_spacing, 0);
1784 profile_name_container->SetLayoutManager(profile_name_layout);
1785 profile_name_container->AddChildView(current_profile_name);
1786 1784
1787 const int between_child_spacing = 1785 // The grid layout contains one row if not signed in or account consistency is
1788 kMaterialMenuEdgeMargin - EditableProfilePhoto::badge_spacing(); 1786 // enabled. It contains 2 rows if signed in and account consistency is
1789 current_profile_card_->SetLayoutManager(new views::BoxLayout( 1787 // disabled (the second row is for the email label). For the second case the
1790 views::BoxLayout::kHorizontal, 0, 1788 // profile photo has to be over 2 rows.
1791 views::kRelatedControlSmallVerticalSpacing, between_child_spacing)); 1789 grid_layout->AddView(current_profile_photo, 1, num_labels);
1792 current_profile_card_->AddChildView(current_profile_photo); 1790 grid_layout->AddView(current_profile_name, 1, 1, views::GridLayout::LEADING,
1793 current_profile_card_->AddChildView(profile_name_container); 1791 (num_labels == 2) ? views::GridLayout::TRAILING
1792 : views::GridLayout::CENTER);
1794 current_profile_card_->SetMinSize(gfx::Size( 1793 current_profile_card_->SetMinSize(gfx::Size(
1795 GetFixedMenuWidth(), current_profile_photo->GetPreferredSize().height() + 1794 GetFixedMenuWidth(), current_profile_photo->GetPreferredSize().height() +
1796 2 * views::kRelatedControlSmallVerticalSpacing)); 1795 2 * views::kRelatedControlSmallVerticalSpacing));
1797 view->AddChildView(current_profile_card_); 1796 view->AddChildView(current_profile_card_);
1798 1797
1799 if (is_guest) { 1798 if (is_guest) {
1800 current_profile_card_->SetEnabled(false); 1799 current_profile_card_->SetEnabled(false);
1801 return view; 1800 return view;
1802 } 1801 }
1803 1802
(...skipping 13 matching lines...) Expand all
1817 manage_accounts_button_->SetMinSize( 1816 manage_accounts_button_->SetMinSize(
1818 gfx::Size(GetFixedMenuWidth(), kButtonHeight)); 1817 gfx::Size(GetFixedMenuWidth(), kButtonHeight));
1819 view->AddChildView(manage_accounts_button_); 1818 view->AddChildView(manage_accounts_button_);
1820 } else { 1819 } else {
1821 views::Label* email_label = new views::Label(avatar_item.username); 1820 views::Label* email_label = new views::Label(avatar_item.username);
1822 current_profile_card->set_subtitle(email_label); 1821 current_profile_card->set_subtitle(email_label);
1823 email_label->SetAutoColorReadabilityEnabled(false); 1822 email_label->SetAutoColorReadabilityEnabled(false);
1824 email_label->SetElideBehavior(gfx::ELIDE_EMAIL); 1823 email_label->SetElideBehavior(gfx::ELIDE_EMAIL);
1825 email_label->SetEnabled(false); 1824 email_label->SetEnabled(false);
1826 email_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); 1825 email_label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
1827 name_container_v_spacing = 1826 grid_layout->StartRow(1, 0);
1828 (current_profile_photo->GetPreferredSize().height() - 1827 // Skip first column for the profile icon.
1829 current_profile_name->GetPreferredSize().height() - 1828 grid_layout->SkipColumns(1);
1830 email_label->GetPreferredSize().height()) / 2; 1829 grid_layout->AddView(email_label, 1, 1, views::GridLayout::LEADING,
1831 profile_name_layout->set_inside_border_insets( 1830 views::GridLayout::LEADING);
1832 gfx::Insets(name_container_v_spacing, 0));
1833 profile_name_container->AddChildView(email_label);
1834 } 1831 }
1835 1832
1836 current_profile_card_->SetAccessibleName( 1833 current_profile_card_->SetAccessibleName(
1837 l10n_util::GetStringFUTF16( 1834 l10n_util::GetStringFUTF16(
1838 IDS_PROFILES_EDIT_SIGNED_IN_PROFILE_ACCESSIBLE_NAME, 1835 IDS_PROFILES_EDIT_SIGNED_IN_PROFILE_ACCESSIBLE_NAME,
1839 profile_name, 1836 profile_name,
1840 avatar_item.username)); 1837 avatar_item.username));
1841 return view; 1838 return view;
1842 } 1839 }
1843 1840
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after
2397 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != 2394 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) !=
2398 IncognitoModePrefs::DISABLED; 2395 IncognitoModePrefs::DISABLED;
2399 return incognito_available && !browser_->profile()->IsGuestSession(); 2396 return incognito_available && !browser_->profile()->IsGuestSession();
2400 } 2397 }
2401 2398
2402 void ProfileChooserView::PostActionPerformed( 2399 void ProfileChooserView::PostActionPerformed(
2403 ProfileMetrics::ProfileDesktopMenu action_performed) { 2400 ProfileMetrics::ProfileDesktopMenu action_performed) {
2404 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); 2401 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_);
2405 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; 2402 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE;
2406 } 2403 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698