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

Unified 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, 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/profiles/profile_chooser_view.cc
diff --git a/chrome/browser/ui/views/profiles/profile_chooser_view.cc b/chrome/browser/ui/views/profiles/profile_chooser_view.cc
index 62702bafaa002d87581ca857030af1a37f487b39..18131f622a29a6fae7c9ef6ce4347d1de315ab95 100644
--- a/chrome/browser/ui/views/profiles/profile_chooser_view.cc
+++ b/chrome/browser/ui/views/profiles/profile_chooser_view.cc
@@ -317,20 +317,6 @@ class SizedContainer : public views::View {
gfx::Size preferred_size_;
};
-// NonInteractiveContainer -------------------------------------------------
-
-// A simple container view that does not process events within subtree.
-class NonInteractiveContainer : public views::View {
- public:
- NonInteractiveContainer() {}
-
- // views::CanProcessEventsWithinSubtree:
- bool CanProcessEventsWithinSubtree() const override { return false; }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(NonInteractiveContainer);
-};
-
// A view to host the GAIA webview overlapped with a back button. This class
// is needed to reparent the back button inside a native view so that on
// windows, user input can be be properly routed to the button.
@@ -1759,6 +1745,27 @@ views::View* ProfileChooserView::CreateMaterialDesignCurrentProfileView(
// Container for the profile photo and avatar/user name.
BackgroundColorHoverButton* current_profile_card =
new BackgroundColorHoverButton(this, base::string16());
+ views::GridLayout* grid_layout = new views::GridLayout(current_profile_card);
+ current_profile_card->SetLayoutManager(grid_layout);
+ views::ColumnSet* columns = grid_layout->AddColumnSet(0);
+ columns->AddPaddingColumn(0, kMaterialMenuEdgeMargin);
+ columns->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 0,
+ views::GridLayout::USE_PREF, 0, 0);
+ columns->AddPaddingColumn(
+ 0, kMaterialMenuEdgeMargin - EditableProfilePhoto::badge_spacing());
+ columns->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 1,
+ views::GridLayout::USE_PREF, 0, 0);
+ columns->AddPaddingColumn(0, kMaterialMenuEdgeMargin);
+ grid_layout->AddPaddingRow(0, 0);
+ const int num_labels =
+ (avatar_item.signed_in && !switches::IsEnableAccountConsistency()) ? 2
+ : 1;
+ int profile_card_height = EditableProfilePhoto::icon_image_side() +
+ 2 *
+ (EditableProfilePhoto::badge_spacing() +
+ views::kRelatedControlSmallVerticalSpacing);
+ const int line_height = profile_card_height / num_labels;
+ grid_layout->StartRow(0, 0, line_height);
current_profile_card_ = current_profile_card;
// Profile picture, left-aligned.
@@ -1774,23 +1781,15 @@ views::View* ProfileChooserView::CreateMaterialDesignCurrentProfileView(
ui::ResourceBundle::GetSharedInstance().GetFontListWithDelta(
1, gfx::Font::FontStyle::NORMAL, gfx::Font::Weight::MEDIUM));
current_profile_name->SetHorizontalAlignment(gfx::ALIGN_LEFT);
- NonInteractiveContainer* profile_name_container =
- new NonInteractiveContainer();
- int name_container_v_spacing =
- (current_profile_photo->GetPreferredSize().height() -
- current_profile_name->GetPreferredSize().height()) / 2;
- views::BoxLayout* profile_name_layout = new views::BoxLayout(
- views::BoxLayout::kVertical, 0, name_container_v_spacing, 0);
- profile_name_container->SetLayoutManager(profile_name_layout);
- profile_name_container->AddChildView(current_profile_name);
-
- const int between_child_spacing =
- kMaterialMenuEdgeMargin - EditableProfilePhoto::badge_spacing();
- current_profile_card_->SetLayoutManager(new views::BoxLayout(
- views::BoxLayout::kHorizontal, 0,
- views::kRelatedControlSmallVerticalSpacing, between_child_spacing));
- current_profile_card_->AddChildView(current_profile_photo);
- current_profile_card_->AddChildView(profile_name_container);
+
+ // The grid layout contains one row if not signed in or account consistency is
+ // enabled. It contains 2 rows if signed in and account consistency is
+ // disabled (the second row is for the email label). For the second case the
+ // profile photo has to be over 2 rows.
+ grid_layout->AddView(current_profile_photo, 1, num_labels);
+ grid_layout->AddView(current_profile_name, 1, 1, views::GridLayout::LEADING,
+ (num_labels == 2) ? views::GridLayout::TRAILING
+ : views::GridLayout::CENTER);
current_profile_card_->SetMinSize(gfx::Size(
GetFixedMenuWidth(), current_profile_photo->GetPreferredSize().height() +
2 * views::kRelatedControlSmallVerticalSpacing));
@@ -1824,13 +1823,11 @@ views::View* ProfileChooserView::CreateMaterialDesignCurrentProfileView(
email_label->SetElideBehavior(gfx::ELIDE_EMAIL);
email_label->SetEnabled(false);
email_label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
- name_container_v_spacing =
- (current_profile_photo->GetPreferredSize().height() -
- current_profile_name->GetPreferredSize().height() -
- email_label->GetPreferredSize().height()) / 2;
- profile_name_layout->set_inside_border_insets(
- gfx::Insets(name_container_v_spacing, 0));
- profile_name_container->AddChildView(email_label);
+ grid_layout->StartRow(1, 0);
+ // Skip first column for the profile icon.
+ grid_layout->SkipColumns(1);
+ grid_layout->AddView(email_label, 1, 1, views::GridLayout::LEADING,
+ views::GridLayout::LEADING);
}
current_profile_card_->SetAccessibleName(
« 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