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 faea78af5046460c3dc338fce761ccc99a3a04d7..dd510d65894f7dfd41c188c63a7ae3eedc5135a2 100644 |
--- a/chrome/browser/ui/views/profiles/profile_chooser_view.cc |
+++ b/chrome/browser/ui/views/profiles/profile_chooser_view.cc |
@@ -83,13 +83,23 @@ namespace { |
// Helpers -------------------------------------------------------------------- |
-const int kFixedMenuWidth = 250; |
const int kButtonHeight = 32; |
const int kPasswordCombinedFixedGaiaViewWidth = 360; |
const int kFixedGaiaViewWidth = 448; |
const int kFixedAccountRemovalViewWidth = 280; |
const int kFixedSwitchUserViewWidth = 320; |
const int kLargeImageSide = 88; |
+const int kMediumImageSide = 40; |
+ |
+const int kTextfieldLabelHorizontalSpacing = 4; |
+const int kProfileHorizontalSpacing = 16; |
Evan Stade
2016/06/13 23:14:41
pretty sure you should use kMaterialMenuHorizontal
Jane
2016/06/14 14:47:21
Done. You have a point; I didn't think this way be
|
+ |
+// Vertical spacing between the edge of the material design user menu and the |
+// top or bottom of the menu items. |
+const int kMaterialMenuVerticalEdgeMargin = 16; |
+// Horizontal spacing between the edge of the material design user menu and the |
+// left or right of the menu items. |
+const int kMaterialMenuHorizontalEdgeMargin = 16; |
const int kVerticalSpacing = 16; |
@@ -100,6 +110,7 @@ bool IsProfileChooser(profiles::BubbleViewMode mode) { |
mode == profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER; |
} |
+// DEPRECATED: New user menu components should use views::BoxLayout instead. |
// Creates a GridLayout with a single column. This ensures that all the child |
// views added get auto-expanded to fill the full width of the bubble. |
views::GridLayout* CreateSingleColumnLayout(views::View* view, int width) { |
@@ -263,14 +274,17 @@ void HostView::ViewHierarchyChanged( |
// RightAlignedIconLabelButton ------------------------------------------------- |
-// A custom LabelButton that has a centered text and right aligned icon. |
+// A custom LabelButton that has a left-aligned text and right aligned icon. |
+// For non-material-design user menu, it has centered text instead. |
class RightAlignedIconLabelButton : public views::LabelButton { |
public: |
RightAlignedIconLabelButton(views::ButtonListener* listener, |
const base::string16& text) |
: views::LabelButton(listener, text) { |
SetHorizontalAlignment(gfx::ALIGN_RIGHT); |
- label()->SetHorizontalAlignment(gfx::ALIGN_CENTER); |
+ label()->SetHorizontalAlignment(switches::IsMaterialDesignUserMenu() |
+ ? gfx::ALIGN_LEFT |
+ : gfx::ALIGN_CENTER); |
} |
protected: |
@@ -308,8 +322,11 @@ class EditableProfilePhoto : public views::LabelButton { |
const gfx::Rect& bounds) |
: views::LabelButton(listener, base::string16()), |
photo_overlay_(NULL) { |
- gfx::Image image = profiles::GetSizedAvatarIcon( |
- icon, true, kLargeImageSide, kLargeImageSide); |
+ const int icon_image_side = switches::IsMaterialDesignUserMenu() |
+ ? kMediumImageSide |
+ : kLargeImageSide; |
+ gfx::Image image = profiles::GetSizedAvatarIcon(icon, true, icon_image_side, |
+ icon_image_side); |
SetImage(views::LabelButton::STATE_NORMAL, *image.ToImageSkia()); |
SetBorder(views::Border::NullBorder()); |
SetBoundsRect(bounds); |
@@ -332,8 +349,10 @@ class EditableProfilePhoto : public views::LabelButton { |
const SkColor kBackgroundColor = SkColorSetARGB(65, 255, 255, 255); |
photo_overlay_->set_background( |
views::Background::CreateSolidBackground(kBackgroundColor)); |
- photo_overlay_->SetImage(gfx::CreateVectorIcon( |
- gfx::VectorIconId::PHOTO_CAMERA, 48u, SkColorSetRGB(0x33, 0x33, 0x33))); |
+ photo_overlay_->SetImage( |
+ gfx::CreateVectorIcon(gfx::VectorIconId::PHOTO_CAMERA, |
+ switches::IsMaterialDesignUserMenu() ? 22u : 48u, |
+ SkColorSetRGB(0x33, 0x33, 0x33))); |
photo_overlay_->SetSize(bounds.size()); |
photo_overlay_->SetVisible(false); |
@@ -405,6 +424,8 @@ class EditableProfileName : public views::View, |
label_ = new views::Label(text); |
Evan Stade
2016/06/13 23:14:40
since you asked me to find other constants I don't
Jane
2016/06/14 14:47:21
Done.
I appreciate the close attention that you ar
|
label_->SetBorder(views::Border::CreateEmptyBorder(2, 0, 2, 0)); |
Evan Stade
2016/06/13 23:14:41
are these 2s distinct from the 2s below?
Jane
2016/06/14 14:47:21
I assume so, but then again, I'm not touching any
Evan Stade
2016/06/14 15:16:26
I'm a bit perplexed by your stance on pre-existing
Jane
2016/06/14 21:39:57
Done. Makes sense, I set 2 to be border_width.
|
label_->SetFontList(medium_font_list); |
+ if (switches::IsMaterialDesignUserMenu()) |
+ label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
AddChildView(label_); |
return; |
} |
@@ -426,19 +447,25 @@ class EditableProfileName : public views::View, |
gfx::CreateVectorIcon( |
gfx::VectorIconId::MODE_EDIT, kIconSize, |
SkColorSetRGB(0x20, 0x20, 0x20))); |
- // To center the text, we need to offest it by the width of the icon we |
- // are adding and its padding. We need to also add a small top/bottom |
- // padding to account for the textfield's border. |
- const int kIconTextLabelButtonSpacing = 5; |
- button_->SetBorder(views::Border::CreateEmptyBorder( |
- 2, kIconSize + kIconTextLabelButtonSpacing, 2, 0)); |
+ // We need to add a left padding as well as a small top/bottom padding |
+ // to the text to account for the textfield's border. |
+ if (switches::IsMaterialDesignUserMenu()) { |
+ button_->SetBorder(views::Border::CreateEmptyBorder( |
Evan Stade
2016/06/13 23:14:40
OK, I may have misunderstood the purpose of kTextf
Jane
2016/06/14 14:47:21
Done. Thanks, didn't know this before.
(Although t
|
+ 2, kTextfieldLabelHorizontalSpacing, 2, 0)); |
+ } else { |
+ const int kIconTextLabelButtonSpacing = 5; |
+ button_->SetBorder(views::Border::CreateEmptyBorder( |
+ 2, kIconSize + kIconTextLabelButtonSpacing, 2, 0)); |
+ } |
AddChildView(button_); |
profile_name_textfield_ = new views::Textfield(); |
// Textfield that overlaps the button. |
profile_name_textfield_->set_controller(controller); |
profile_name_textfield_->SetFontList(medium_font_list); |
- profile_name_textfield_->SetHorizontalAlignment(gfx::ALIGN_CENTER); |
+ profile_name_textfield_->SetHorizontalAlignment( |
+ switches::IsMaterialDesignUserMenu() ? gfx::ALIGN_LEFT |
+ : gfx::ALIGN_CENTER); |
profile_name_textfield_->SetVisible(false); |
AddChildView(profile_name_textfield_); |
} |
@@ -565,13 +592,19 @@ class TitleCard : public views::View { |
// ProfileBadge -------------------------------------------------------- |
const size_t kProfileBadgeSize = 30; |
+const size_t kSmallProfileBadgeSize = 24; |
const size_t kProfileBadgeWhitePadding = 2; |
// Draws a white circle, then a light blue circle, then a dark blue icon. |
class ProfileBadge : public gfx::CanvasImageSource { |
public: |
ProfileBadge(gfx::VectorIconId id, size_t icon_size) |
- : CanvasImageSource(gfx::Size(kProfileBadgeSize, kProfileBadgeSize), |
+ : CanvasImageSource(gfx::Size(switches::IsMaterialDesignUserMenu() |
+ ? kSmallProfileBadgeSize |
+ : kProfileBadgeSize, |
+ switches::IsMaterialDesignUserMenu() |
+ ? kSmallProfileBadgeSize |
+ : kProfileBadgeSize), |
false), |
id_(id), |
icon_size_(icon_size) {} |
@@ -592,7 +625,9 @@ class ProfileBadge : public gfx::CanvasImageSource { |
canvas->DrawCircle(bounds.CenterPoint(), |
size.width() / 2 - kProfileBadgeWhitePadding, paint); |
- int offset = (kProfileBadgeSize - icon_size_) / 2; |
+ int offset = ((switches::IsMaterialDesignUserMenu() ? kSmallProfileBadgeSize |
Evan Stade
2016/06/13 23:14:40
this ternary appears 3 times
Jane
2016/06/14 14:47:21
I did realize this and I wanted to make it a const
Evan Stade
2016/06/14 15:16:26
I think that would be an improvement. The badge si
Jane
2016/06/14 21:39:56
Done.
|
+ : kProfileBadgeSize) - |
+ icon_size_) / 2; |
canvas->Translate(gfx::Vector2d(offset, offset)); |
gfx::PaintVectorIcon(canvas, id_, icon_size_, SkColorSetRGB(0, 0x66, 0xff)); |
} |
@@ -607,9 +642,10 @@ class ProfileBadge : public gfx::CanvasImageSource { |
gfx::ImageSkia CreateBadgeForProfile(Profile* profile) { |
ProfileBadge* badge = |
profile->IsChild() |
- ? new ProfileBadge(gfx::VectorIconId::ACCOUNT_CHILD_INVERT, 26) |
- : new ProfileBadge(gfx::VectorIconId::SUPERVISOR_ACCOUNT, 20); |
- |
+ ? new ProfileBadge(gfx::VectorIconId::ACCOUNT_CHILD_INVERT, |
+ switches::IsMaterialDesignUserMenu() ? 21 : 26) |
+ : new ProfileBadge(gfx::VectorIconId::SUPERVISOR_ACCOUNT, |
+ switches::IsMaterialDesignUserMenu() ? 16 : 20); |
return gfx::ImageSkia(badge, badge->size()); |
} |
@@ -664,6 +700,11 @@ void ProfileChooserView::Hide() { |
profile_bubble_->GetWidget()->Close(); |
} |
+// static |
+int ProfileChooserView::GetFixedMenuWidth() { |
+ return switches::IsMaterialDesignUserMenu() ? 240 : 250; |
+} |
+ |
ProfileChooserView::ProfileChooserView(views::View* anchor_view, |
Browser* browser, |
profiles::BubbleViewMode view_mode, |
@@ -839,7 +880,7 @@ void ProfileChooserView::ShowView(profiles::BubbleViewMode view_to_display, |
case profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT: |
case profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER: |
case profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER: |
- layout = CreateSingleColumnLayout(this, kFixedMenuWidth); |
+ layout = CreateSingleColumnLayout(this, GetFixedMenuWidth()); |
sub_view = CreateProfileChooserView(avatar_menu); |
break; |
} |
@@ -1089,7 +1130,10 @@ void ProfileChooserView::PopulateCompleteProfileChooserView( |
if (item.active) { |
option_buttons_view = CreateOptionsView( |
item.signed_in && profiles::IsLockAvailable(browser_->profile())); |
- current_profile_view = CreateCurrentProfileView(item, false); |
+ current_profile_view = |
+ switches::IsMaterialDesignUserMenu() |
+ ? CreateMaterialDesignCurrentProfileView(item, false) |
+ : CreateCurrentProfileView(item, false); |
if (IsProfileChooser(view_mode_)) { |
tutorial_view = CreateTutorialViewIfNeeded(item); |
} else { |
@@ -1126,8 +1170,10 @@ void ProfileChooserView::PopulateCompleteProfileChooserView( |
} |
if (browser_->profile()->IsSupervised()) { |
- layout->StartRow(0, 0); |
- layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); |
+ if (!switches::IsMaterialDesignUserMenu()) { |
+ layout->StartRow(0, 0); |
+ layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); |
+ } |
layout->StartRow(1, 0); |
layout->AddView(CreateSupervisedUserDisclaimerView()); |
} |
@@ -1159,7 +1205,8 @@ void ProfileChooserView::PopulateMinimalProfileChooserView( |
views::View* ProfileChooserView::CreateProfileChooserView( |
AvatarMenu* avatar_menu) { |
views::View* view = new views::View(); |
- views::GridLayout* layout = CreateSingleColumnLayout(view, kFixedMenuWidth); |
+ views::GridLayout* layout = |
+ CreateSingleColumnLayout(view, GetFixedMenuWidth()); |
if (view_mode_ == profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER) { |
PopulateMinimalProfileChooserView(layout, avatar_menu); |
@@ -1234,8 +1281,8 @@ views::View* ProfileChooserView::CreateTutorialView( |
views::View* view = new views::View(); |
view->set_background(views::Background::CreateSolidBackground( |
profiles::kAvatarTutorialBackgroundColor)); |
- views::GridLayout* layout = CreateSingleColumnLayout(view, |
- kFixedMenuWidth - 2 * views::kButtonHEdgeMarginNew); |
+ views::GridLayout* layout = CreateSingleColumnLayout( |
+ view, GetFixedMenuWidth() - 2 * views::kButtonHEdgeMarginNew); |
// Creates a second column set for buttons and links. |
views::ColumnSet* button_columns = layout->AddColumnSet(1); |
button_columns->AddColumn(views::GridLayout::LEADING, |
@@ -1337,7 +1384,7 @@ views::View* ProfileChooserView::CreateCurrentProfileView( |
const AvatarMenu::Item& avatar_item, |
bool is_guest) { |
views::View* view = new views::View(); |
- int column_width = kFixedMenuWidth - 2 * views::kButtonHEdgeMarginNew; |
+ int column_width = GetFixedMenuWidth() - 2 * views::kButtonHEdgeMarginNew; |
views::GridLayout* layout = CreateSingleColumnLayout(view, column_width); |
layout->SetInsets(views::kButtonVEdgeMarginNew, |
views::kButtonHEdgeMarginNew, |
@@ -1450,6 +1497,149 @@ views::View* ProfileChooserView::CreateCurrentProfileView( |
return view; |
} |
+views::View* ProfileChooserView::CreateMaterialDesignCurrentProfileView( |
+ const AvatarMenu::Item& avatar_item, |
+ bool is_guest) { |
+ views::View* view = new views::View(); |
+ int column_width = |
Evan Stade
2016/06/13 23:14:41
are you sure the box layout can't grow wider than
Jane
2016/06/14 14:47:21
I'm only using column_width as the width for profi
Evan Stade
2016/06/14 15:16:26
what sets the width of the box layout then?
Jane
2016/06/14 21:39:57
I thought the width of the box layout would be det
Evan Stade
2016/06/16 21:56:34
Well, that would set its preferred size. But in th
Jane
2016/06/17 19:52:23
Done. Removed column_width.
|
+ GetFixedMenuWidth() - 2 * kMaterialMenuHorizontalEdgeMargin; |
+ view->SetLayoutManager(new views::BoxLayout( |
+ views::BoxLayout::kVertical, |
+ kMaterialMenuHorizontalEdgeMargin, |
+ views::kRelatedControlVerticalSpacing, |
+ views::kRelatedControlVerticalSpacing)); |
+ |
+ // Profile picture, left-aligned. |
+ const int profile_bar_height = 56; |
+ current_profile_photo_ = new EditableProfilePhoto( |
+ this, avatar_item.icon, !is_guest, |
+ gfx::Rect(0, (profile_bar_height - kMediumImageSide) / 2, |
+ kMediumImageSide, kMediumImageSide)); |
Evan Stade
2016/06/13 23:14:40
Yyou're doing layout at construction time, which i
Jane
2016/06/14 14:47:21
This is a very good suggestion. I thought about us
Evan Stade
2016/06/14 15:16:26
When I said "or overriding Layout()", I guess I sh
Jane
2016/06/14 21:39:57
Done. I added a couple of containers to the view,
Evan Stade
2016/06/16 21:56:33
SizedContainers are just a different way of hardco
Jane
2016/06/17 19:52:23
Point taken. See edits/comments in the newest patc
|
+ SizedContainer* profile_container = |
+ new SizedContainer(gfx::Size(column_width, profile_bar_height)); |
+ profile_container->AddChildView(current_profile_photo_); |
+ |
+ // Add supervised badge for supervised profile. |
+ if (browser_->profile()->IsSupervised()) { |
+ const int badge_spacing = 4; |
+ views::ImageView* supervised_icon = new views::ImageView(); |
+ supervised_icon->SetImage(CreateBadgeForProfile(browser_->profile())); |
+ gfx::Size preferred_size = supervised_icon->GetPreferredSize(); |
+ gfx::Rect parent_bounds = current_profile_photo_->bounds(); |
+ supervised_icon->SetBounds( |
+ parent_bounds.right() - preferred_size.width() + badge_spacing, |
+ parent_bounds.bottom() - preferred_size.height() + badge_spacing, |
+ preferred_size.width(), preferred_size.height()); |
+ profile_container->AddChildView(supervised_icon); |
+ } |
+ |
+ // Profile name, left-aligned to the right of profile icon. |
+ bool editing_allowed = |
+ !is_guest && !browser_->profile()->IsLegacySupervised(); |
+ current_profile_name_ = new EditableProfileName( |
+ this, profiles::GetAvatarNameForProfile(browser_->profile()->GetPath()), |
+ editing_allowed); |
+ gfx::Rect photo_bounds = current_profile_photo_->bounds(); |
+ const int textfield_left_margin = |
+ kProfileHorizontalSpacing - |
+ (editing_allowed ? kTextfieldLabelHorizontalSpacing : 0); |
+ current_profile_name_->SetBounds( |
+ photo_bounds.width() + textfield_left_margin, |
+ views::kRelatedControlVerticalSpacing, |
+ profile_container->GetPreferredSize().width() - photo_bounds.width() - |
+ textfield_left_margin, |
+ profile_container->GetPreferredSize().height() / 2 - |
+ views::kRelatedControlVerticalSpacing); |
+ profile_container->AddChildView(current_profile_name_); |
+ |
+ // Center-align the avatar name if the profile is not signed in. |
+ if (is_guest || !avatar_item.signed_in) { |
+ current_profile_name_->SetY( |
+ (profile_container->GetPreferredSize().height() - |
+ current_profile_name_->height()) / |
+ 2); |
+ view->AddChildView(profile_container); |
Evan Stade
2016/06/13 23:14:40
can't you do this unconditionally?
Jane
2016/06/14 14:47:21
No, because more child views will be added to prof
Evan Stade
2016/06/14 15:16:26
Not sure I understand. Why can't you add child vie
Jane
2016/06/14 21:39:56
Done.
What I meant was more along the line of how
|
+ } |
+ |
+ if (is_guest) |
+ return view; |
+ |
+ // The available links depend on the type of profile that is active. |
+ if (avatar_item.signed_in) { |
+ // Calculate the position and size for links available for signed-in |
+ // profiles. |
+ const int x_coordinate = photo_bounds.width() + kProfileHorizontalSpacing; |
Evan Stade
2016/06/13 23:14:40
If profile_container had a layout manager this wou
Jane
2016/06/14 14:47:21
Same as above.
|
+ const int y_coordinate = profile_container->GetPreferredSize().height() / 2; |
+ const int width = profile_container->GetPreferredSize().width() - |
+ photo_bounds.width() - kProfileHorizontalSpacing; |
+ const int height = profile_container->GetPreferredSize().height() / 2 - |
+ views::kRelatedControlVerticalSpacing; |
+ |
+ if (switches::IsEnableAccountConsistency()) { |
+ base::string16 link_title = l10n_util::GetStringUTF16( |
+ IsProfileChooser(view_mode_) |
+ ? IDS_PROFILES_PROFILE_MANAGE_ACCOUNTS_BUTTON |
+ : IDS_PROFILES_PROFILE_HIDE_MANAGE_ACCOUNTS_BUTTON); |
+ manage_accounts_link_ = CreateLink(link_title, this); |
+ manage_accounts_link_->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
+ manage_accounts_link_->SetBounds(x_coordinate, y_coordinate, width, |
+ height); |
+ profile_container->AddChildView(manage_accounts_link_); |
+ } else if (HasAuthError(browser_->profile())) { |
+ // Badge the email address if there's an authentication error. |
+ auth_error_email_button_ = |
+ new RightAlignedIconLabelButton(this, avatar_item.username); |
+ auth_error_email_button_->SetElideBehavior(gfx::ELIDE_EMAIL); |
+ auth_error_email_button_->SetImage( |
+ views::LabelButton::STATE_NORMAL, |
+ gfx::CreateVectorIcon(gfx::VectorIconId::WARNING, 12, |
+ gfx::kChromeIconGrey)); |
+ auth_error_email_button_->SetFocusForPlatform(); |
+ auth_error_email_button_->set_request_focus_on_press(true); |
Evan Stade
2016/06/13 23:14:40
why do you want this non-default behavior
Jane
2016/06/14 14:47:21
As mentioned before, this code is basically copied
Evan Stade
2016/06/14 15:16:26
If there are large blocks of code you're about to
Jane
2016/06/14 21:39:57
I just deleted this block instead, this is probabl
|
+ gfx::Insets insets = |
+ views::LabelButtonAssetBorder::GetDefaultInsetsForStyle( |
+ views::Button::STYLE_TEXTBUTTON); |
+ auth_error_email_button_->SetBorder(views::Border::CreateEmptyBorder( |
+ insets.top(), insets.left(), insets.bottom(), insets.right())); |
+ auth_error_email_button_->SetBounds(x_coordinate - insets.left(), |
+ y_coordinate, width, height); |
+ profile_container->AddChildView(auth_error_email_button_); |
+ } else { |
+ views::Label* email_label = new views::Label(avatar_item.username); |
+ email_label->SetElideBehavior(gfx::ELIDE_EMAIL); |
+ email_label->SetEnabled(false); |
+ email_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
+ email_label->SetBounds(x_coordinate, y_coordinate, width, height); |
+ profile_container->AddChildView(email_label); |
+ } |
+ view->AddChildView(profile_container); |
+ return view; |
+ } |
+ |
+ SigninManagerBase* signin_manager = SigninManagerFactory::GetForProfile( |
+ browser_->profile()->GetOriginalProfile()); |
+ if (signin_manager->IsSigninAllowed()) { |
+ views::Label* promo = |
+ new views::Label(l10n_util::GetStringUTF16(IDS_PROFILES_SIGNIN_PROMO)); |
+ promo->SetMultiLine(true); |
+ promo->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
+ view->AddChildView(promo); |
+ |
+ signin_current_profile_link_ = |
Evan Stade
2016/06/13 23:14:40
this is not really a link...
Jane
2016/06/14 14:47:21
Done.
Same as above, but since this code will live
|
+ views::MdTextButton::CreateSecondaryUiBlueButton( |
+ this, l10n_util::GetStringFUTF16( |
+ IDS_SYNC_START_SYNC_BUTTON_LABEL, |
+ l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME))); |
+ signin_current_profile_link_->SetMinSize(gfx::Size(0, 36)); |
Evan Stade
2016/06/13 23:14:41
here's a constant I don't understand the need for
Jane
2016/06/14 14:47:21
This was supposed to define the height of the butt
Evan Stade
2016/06/14 15:16:26
yes, i think the height should be the same as all
Jane
2016/06/14 21:39:57
I put it here because SetMinSize of LabelButton se
Evan Stade
2016/06/16 21:56:33
Yes, I do think you can/should. For example, there
Jane
2016/06/17 19:52:23
Done.
|
+ view->AddChildView(signin_current_profile_link_); |
+ content::RecordAction( |
+ base::UserMetricsAction("Signin_Impression_FromAvatarBubbleSignin")); |
+ view->AddChildView(padding_view); |
Evan Stade
2016/06/13 23:14:40
if you need padding under the md text button, perh
Jane
2016/06/14 14:47:21
I tried adding:
view->SetBorder(views::Border
Evan Stade
2016/06/14 15:16:26
I dunno, is there something else setting a border
Jane
2016/06/14 21:39:57
Done. It works now.
|
+ } |
+ |
+ return view; |
+} |
+ |
views::View* ProfileChooserView::CreateGuestProfileView() { |
gfx::Image guest_icon = |
ui::ResourceBundle::GetSharedInstance().GetImageNamed( |
@@ -1460,13 +1650,16 @@ views::View* ProfileChooserView::CreateGuestProfileView() { |
IDS_PROFILES_GUEST_PROFILE_NAME); |
guest_avatar_item.signed_in = false; |
- return CreateCurrentProfileView(guest_avatar_item, true); |
+ return switches::IsMaterialDesignUserMenu() |
+ ? CreateMaterialDesignCurrentProfileView(guest_avatar_item, true) |
+ : CreateCurrentProfileView(guest_avatar_item, true); |
} |
views::View* ProfileChooserView::CreateOtherProfilesView( |
const Indexes& avatars_to_show) { |
views::View* view = new views::View(); |
- views::GridLayout* layout = CreateSingleColumnLayout(view, kFixedMenuWidth); |
+ views::GridLayout* layout = |
+ CreateSingleColumnLayout(view, GetFixedMenuWidth()); |
for (size_t index : avatars_to_show) { |
const AvatarMenu::Item& item = avatar_menu_->GetItemAt(index); |
@@ -1497,7 +1690,8 @@ views::View* ProfileChooserView::CreateOtherProfilesView( |
views::View* ProfileChooserView::CreateOptionsView(bool display_lock) { |
views::View* view = new views::View(); |
- views::GridLayout* layout = CreateSingleColumnLayout(view, kFixedMenuWidth); |
+ views::GridLayout* layout = |
+ CreateSingleColumnLayout(view, GetFixedMenuWidth()); |
base::string16 text = browser_->profile()->IsGuestSession() ? |
l10n_util::GetStringUTF16(IDS_PROFILES_EXIT_GUEST) : |
@@ -1547,11 +1741,18 @@ views::View* ProfileChooserView::CreateOptionsView(bool display_lock) { |
views::View* ProfileChooserView::CreateSupervisedUserDisclaimerView() { |
views::View* view = new views::View(); |
views::GridLayout* layout = CreateSingleColumnLayout( |
- view, kFixedMenuWidth - 2 * views::kButtonHEdgeMarginNew); |
- layout->SetInsets(views::kRelatedControlVerticalSpacing, |
- views::kButtonHEdgeMarginNew, |
- views::kRelatedControlVerticalSpacing, |
- views::kButtonHEdgeMarginNew); |
+ view, GetFixedMenuWidth() - 2 * views::kButtonHEdgeMarginNew); |
+ if (switches::IsMaterialDesignUserMenu()) { |
+ layout->SetInsets(0, |
+ kMaterialMenuHorizontalEdgeMargin, |
+ kMaterialMenuVerticalEdgeMargin, |
+ kMaterialMenuHorizontalEdgeMargin); |
+ } else { |
+ layout->SetInsets( |
+ views::kRelatedControlVerticalSpacing, views::kButtonHEdgeMarginNew, |
+ views::kRelatedControlVerticalSpacing, views::kButtonHEdgeMarginNew); |
+ } |
+ |
views::Label* disclaimer = new views::Label( |
avatar_menu_->GetSupervisedUserInformation()); |
disclaimer->SetMultiLine(true); |
@@ -1571,7 +1772,8 @@ views::View* ProfileChooserView::CreateCurrentProfileAccountsView( |
views::View* view = new views::View(); |
view->set_background(views::Background::CreateSolidBackground( |
profiles::kAvatarBubbleAccountsBackgroundColor)); |
- views::GridLayout* layout = CreateSingleColumnLayout(view, kFixedMenuWidth); |
+ views::GridLayout* layout = |
+ CreateSingleColumnLayout(view, GetFixedMenuWidth()); |
Profile* profile = browser_->profile(); |
std::string primary_account = |
@@ -1588,10 +1790,10 @@ views::View* ProfileChooserView::CreateCurrentProfileAccountsView( |
// from the others in the UI, so more work is likely required here: |
// crbug.com/311124. |
CreateAccountButton(layout, primary_account, true, |
- error_account_id == primary_account, kFixedMenuWidth); |
+ error_account_id == primary_account, GetFixedMenuWidth()); |
for (size_t i = 0; i < accounts.size(); ++i) |
CreateAccountButton(layout, accounts[i], false, |
- error_account_id == accounts[i], kFixedMenuWidth); |
+ error_account_id == accounts[i], GetFixedMenuWidth()); |
if (!profile->IsSupervised()) { |
layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |