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

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: Adding tmp variable Created 3 years, 10 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 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 public: 306 public:
307 explicit SizedContainer(const gfx::Size& preferred_size) 307 explicit SizedContainer(const gfx::Size& preferred_size)
308 : preferred_size_(preferred_size) {} 308 : preferred_size_(preferred_size) {}
309 309
310 gfx::Size GetPreferredSize() const override { return preferred_size_; } 310 gfx::Size GetPreferredSize() const override { return preferred_size_; }
311 311
312 private: 312 private:
313 gfx::Size preferred_size_; 313 gfx::Size preferred_size_;
314 }; 314 };
315 315
316 // NonInteractiveContainer -------------------------------------------------
317
318 // A simple container view that does not process events within subtree.
319 class NonInteractiveContainer : public views::View {
320 public:
321 NonInteractiveContainer() {}
322
323 // views::CanProcessEventsWithinSubtree:
324 bool CanProcessEventsWithinSubtree() const override { return false; }
325
326 private:
327 DISALLOW_COPY_AND_ASSIGN(NonInteractiveContainer);
328 };
329
330 // A view to host the GAIA webview overlapped with a back button. This class 316 // A view to host the GAIA webview overlapped with a back button. This class
331 // is needed to reparent the back button inside a native view so that on 317 // is needed to reparent the back button inside a native view so that on
332 // windows, user input can be be properly routed to the button. 318 // windows, user input can be be properly routed to the button.
333 class HostView : public views::View { 319 class HostView : public views::View {
334 public: 320 public:
335 HostView() {} 321 HostView() {}
336 322
337 private: 323 private:
338 // views::View: 324 // views::View:
339 void ViewHierarchyChanged( 325 void ViewHierarchyChanged(
(...skipping 1399 matching lines...) Expand 10 before | Expand all | Expand 10 after
1739 const AvatarMenu::Item& avatar_item, 1725 const AvatarMenu::Item& avatar_item,
1740 bool is_guest) { 1726 bool is_guest) {
1741 views::View* view = new views::View(); 1727 views::View* view = new views::View();
1742 view->SetLayoutManager( 1728 view->SetLayoutManager(
1743 new views::BoxLayout(views::BoxLayout::kVertical, 0, 1729 new views::BoxLayout(views::BoxLayout::kVertical, 0,
1744 views::kRelatedControlVerticalSpacing, 0)); 1730 views::kRelatedControlVerticalSpacing, 0));
1745 1731
1746 // Container for the profile photo and avatar/user name. 1732 // Container for the profile photo and avatar/user name.
1747 BackgroundColorHoverButton* current_profile_card = 1733 BackgroundColorHoverButton* current_profile_card =
1748 new BackgroundColorHoverButton(this, base::string16()); 1734 new BackgroundColorHoverButton(this, base::string16());
1735 views::GridLayout* grid_layout = new views::GridLayout(current_profile_card);
1736 current_profile_card->SetLayoutManager(grid_layout);
1737 views::ColumnSet* columns = grid_layout->AddColumnSet(0);
1738 columns->AddPaddingColumn(0, kMaterialMenuEdgeMargin);
1739 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 0,
1740 views::GridLayout::USE_PREF, 0, 0);
1741 columns->AddPaddingColumn(
1742 0, kMaterialMenuEdgeMargin - EditableProfilePhoto::badge_spacing());
1743 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 1,
1744 views::GridLayout::USE_PREF, 0, 0);
1745 columns->AddPaddingColumn(0, kMaterialMenuEdgeMargin);
1746 grid_layout->AddPaddingRow(0, 0);
1747 int profile_card_height = EditableProfilePhoto::icon_image_side() +
1748 2 *
1749 (EditableProfilePhoto::badge_spacing() +
1750 views::kRelatedControlSmallVerticalSpacing);
1751 grid_layout->StartRow(
1752 0, 0,
1753 avatar_item.signed_in ? (profile_card_height / 2) : profile_card_height);
jlebel 2017/02/23 13:38:23 I don't know why there is a format change here. gi
Peter Kasting 2017/02/24 00:48:40 git cl format's formatting here is fine, IMO sligh
1749 current_profile_card_ = current_profile_card; 1754 current_profile_card_ = current_profile_card;
1750 1755
1751 // Profile picture, left-aligned. 1756 // Profile picture, left-aligned.
1752 EditableProfilePhoto* current_profile_photo = new EditableProfilePhoto( 1757 EditableProfilePhoto* current_profile_photo = new EditableProfilePhoto(
1753 this, avatar_item.icon, !is_guest, browser_->profile()); 1758 this, avatar_item.icon, !is_guest, browser_->profile());
1754 1759
1755 // Profile name, left-aligned to the right of profile icon. 1760 // Profile name, left-aligned to the right of profile icon.
1756 views::Label* current_profile_name = new views::Label( 1761 views::Label* current_profile_name = new views::Label(
1757 profiles::GetAvatarNameForProfile(browser_->profile()->GetPath())); 1762 profiles::GetAvatarNameForProfile(browser_->profile()->GetPath()));
1758 current_profile_card->set_title(current_profile_name); 1763 current_profile_card->set_title(current_profile_name);
1759 current_profile_name->SetFontList( 1764 current_profile_name->SetFontList(
1760 ui::ResourceBundle::GetSharedInstance().GetFontListWithDelta( 1765 ui::ResourceBundle::GetSharedInstance().GetFontListWithDelta(
1761 1, gfx::Font::FontStyle::NORMAL, gfx::Font::Weight::MEDIUM)); 1766 1, gfx::Font::FontStyle::NORMAL, gfx::Font::Weight::MEDIUM));
1762 current_profile_name->SetHorizontalAlignment(gfx::ALIGN_LEFT); 1767 current_profile_name->SetHorizontalAlignment(gfx::ALIGN_LEFT);
1763 NonInteractiveContainer* profile_name_container =
1764 new NonInteractiveContainer();
1765 int name_container_v_spacing =
1766 (current_profile_photo->GetPreferredSize().height() -
1767 current_profile_name->GetPreferredSize().height()) / 2;
1768 views::BoxLayout* profile_name_layout = new views::BoxLayout(
1769 views::BoxLayout::kVertical, 0, name_container_v_spacing, 0);
1770 profile_name_container->SetLayoutManager(profile_name_layout);
1771 profile_name_container->AddChildView(current_profile_name);
1772 1768
1773 const int between_child_spacing = 1769 // The grid layout contains one row if not signed in or account consistency is
1774 kMaterialMenuEdgeMargin - EditableProfilePhoto::badge_spacing(); 1770 // enabled. It contains 2 rows if signed in and account consistency is
1775 current_profile_card_->SetLayoutManager(new views::BoxLayout( 1771 // disabled (the second row is for the email label). For the second case the
1776 views::BoxLayout::kHorizontal, 0, 1772 // profile photo has to be over 2 rows.
1777 views::kRelatedControlSmallVerticalSpacing, between_child_spacing)); 1773 int row_span =
1778 current_profile_card_->AddChildView(current_profile_photo); 1774 (avatar_item.signed_in && !switches::IsEnableAccountConsistency()) ? 2
1779 current_profile_card_->AddChildView(profile_name_container); 1775 : 1;
1776 grid_layout->AddView(current_profile_photo, 1, row_span);
1777 grid_layout->AddView(current_profile_name, 1, 1, views::GridLayout::LEADING,
1778 avatar_item.signed_in ? views::GridLayout::TRAILING
1779 : views::GridLayout::CENTER);
1780 current_profile_card_->SetMinSize(gfx::Size( 1780 current_profile_card_->SetMinSize(gfx::Size(
1781 GetFixedMenuWidth(), current_profile_photo->GetPreferredSize().height() + 1781 GetFixedMenuWidth(), current_profile_photo->GetPreferredSize().height() +
1782 2 * views::kRelatedControlSmallVerticalSpacing)); 1782 2 * views::kRelatedControlSmallVerticalSpacing));
1783 view->AddChildView(current_profile_card_); 1783 view->AddChildView(current_profile_card_);
1784 1784
1785 if (is_guest) { 1785 if (is_guest) {
1786 current_profile_card_->SetEnabled(false); 1786 current_profile_card_->SetEnabled(false);
1787 return view; 1787 return view;
1788 } 1788 }
1789 1789
(...skipping 12 matching lines...) Expand all
1802 manage_accounts_button_->SetHorizontalAlignment(gfx::ALIGN_LEFT); 1802 manage_accounts_button_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
1803 manage_accounts_button_->SetMinSize( 1803 manage_accounts_button_->SetMinSize(
1804 gfx::Size(GetFixedMenuWidth(), kButtonHeight)); 1804 gfx::Size(GetFixedMenuWidth(), kButtonHeight));
1805 view->AddChildView(manage_accounts_button_); 1805 view->AddChildView(manage_accounts_button_);
1806 } else { 1806 } else {
1807 views::Label* email_label = new views::Label(avatar_item.username); 1807 views::Label* email_label = new views::Label(avatar_item.username);
1808 current_profile_card->set_subtitle(email_label); 1808 current_profile_card->set_subtitle(email_label);
1809 email_label->SetElideBehavior(gfx::ELIDE_EMAIL); 1809 email_label->SetElideBehavior(gfx::ELIDE_EMAIL);
1810 email_label->SetEnabled(false); 1810 email_label->SetEnabled(false);
1811 email_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); 1811 email_label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
1812 name_container_v_spacing = 1812 grid_layout->StartRow(1, 0);
1813 (current_profile_photo->GetPreferredSize().height() - 1813 // Skip first column for the profile icon.
1814 current_profile_name->GetPreferredSize().height() - 1814 grid_layout->SkipColumns(1);
1815 email_label->GetPreferredSize().height()) / 2; 1815 grid_layout->AddView(email_label, 1, 1, views::GridLayout::LEADING,
1816 profile_name_layout->set_inside_border_insets( 1816 views::GridLayout::LEADING);
1817 gfx::Insets(name_container_v_spacing, 0));
1818 profile_name_container->AddChildView(email_label);
1819 } 1817 }
1820 1818
1821 current_profile_card_->SetAccessibleName( 1819 current_profile_card_->SetAccessibleName(
1822 l10n_util::GetStringFUTF16( 1820 l10n_util::GetStringFUTF16(
1823 IDS_PROFILES_EDIT_SIGNED_IN_PROFILE_ACCESSIBLE_NAME, 1821 IDS_PROFILES_EDIT_SIGNED_IN_PROFILE_ACCESSIBLE_NAME,
1824 profile_name, 1822 profile_name,
1825 avatar_item.username)); 1823 avatar_item.username));
1826 return view; 1824 return view;
1827 } 1825 }
1828 1826
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after
2380 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != 2378 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) !=
2381 IncognitoModePrefs::DISABLED; 2379 IncognitoModePrefs::DISABLED;
2382 return incognito_available && !browser_->profile()->IsGuestSession(); 2380 return incognito_available && !browser_->profile()->IsGuestSession();
2383 } 2381 }
2384 2382
2385 void ProfileChooserView::PostActionPerformed( 2383 void ProfileChooserView::PostActionPerformed(
2386 ProfileMetrics::ProfileDesktopMenu action_performed) { 2384 ProfileMetrics::ProfileDesktopMenu action_performed) {
2387 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); 2385 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_);
2388 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; 2386 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE;
2389 } 2387 }
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