Chromium Code Reviews| 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 e1f40f7308f8a8759e1d5126300b3196ad59b951..ebcb7ebe760991fafd2a8025d1e99c95f423fa49 100644 |
| --- a/chrome/browser/ui/views/profiles/profile_chooser_view.cc |
| +++ b/chrome/browser/ui/views/profiles/profile_chooser_view.cc |
| @@ -80,7 +80,6 @@ |
| #include "ui/views/controls/link.h" |
| #include "ui/views/controls/separator.h" |
| #include "ui/views/controls/styled_label.h" |
| -#include "ui/views/controls/textfield/textfield.h" |
| #include "ui/views/controls/webview/webview.h" |
| #include "ui/views/layout/box_layout.h" |
| #include "ui/views/layout/fill_layout.h" |
| @@ -97,7 +96,6 @@ const int kPasswordCombinedFixedGaiaViewWidth = 360; |
| const int kFixedGaiaViewWidth = 448; |
| const int kFixedAccountRemovalViewWidth = 280; |
| const int kFixedSwitchUserViewWidth = 320; |
| -const int kLargeImageSide = 88; |
| const int kMdImageSide = 40; |
| // Spacing between the edge of the material design user menu and the |
| @@ -114,11 +112,11 @@ bool IsProfileChooser(profiles::BubbleViewMode mode) { |
| } |
| int GetFixedMenuWidth() { |
|
msarda
2017/02/23 11:51:02
Same here: Consider making these constants
jlebel
2017/02/23 18:18:49
Done.
|
| - return switches::IsMaterialDesignUserMenu() ? 240 : 250; |
| + return 240; |
| } |
| int GetProfileBadgeSize() { |
| - return switches::IsMaterialDesignUserMenu() ? 24 : 30; |
| + return 24; |
| } |
| // DEPRECATED: New user menu components should use views::BoxLayout instead. |
| @@ -143,13 +141,6 @@ views::Link* CreateLink(const base::string16& link_text, |
| return link_button; |
| } |
| -gfx::ImageSkia CreateSquarePlaceholderImage(int size) { |
| - SkBitmap bitmap; |
| - bitmap.allocPixels(SkImageInfo::MakeA8(size, size)); |
| - bitmap.eraseARGB(0, 0, 0, 0); |
| - return gfx::ImageSkia::CreateFrom1xBitmap(bitmap); |
| -} |
| - |
| bool HasAuthError(Profile* profile) { |
| const SigninErrorController* error = |
| SigninErrorControllerFactory::GetForProfile(profile); |
| @@ -195,18 +186,12 @@ class BackgroundColorHoverButton : public views::LabelButton { |
| #endif |
| title_(nullptr), |
| subtitle_(nullptr) { |
| - SetImageLabelSpacing(switches::IsMaterialDesignUserMenu() |
| - ? (kMaterialMenuEdgeMargin - 2) |
| - : views::kItemLabelSpacing); |
| - const int button_margin = switches::IsMaterialDesignUserMenu() |
| - ? kMaterialMenuEdgeMargin |
| - : views::kButtonHEdgeMarginNew; |
| - SetBorder(views::CreateEmptyBorder(0, button_margin, 0, button_margin)); |
| + SetImageLabelSpacing(kMaterialMenuEdgeMargin - 2); |
| + SetBorder(views::CreateEmptyBorder(0, kMaterialMenuEdgeMargin, 0, |
| + kMaterialMenuEdgeMargin)); |
| SetFocusForPlatform(); |
| - if (switches::IsMaterialDesignUserMenu()) { |
| - label()->SetHandlesTooltips(false); |
| - } |
| + label()->SetHandlesTooltips(false); |
| } |
| BackgroundColorHoverButton(ProfileChooserView* profile_chooser_view, |
| @@ -370,47 +355,8 @@ void HostView::ViewHierarchyChanged( |
| } // namespace |
| -// RightAlignedIconLabelButton ------------------------------------------------- |
| - |
| -// A custom LabelButton that has a center-aligned text and right aligned icon. |
| -// Only used in non-material-design user menu. |
| -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); |
| - } |
| - |
| - protected: |
| - void Layout() override { |
| - views::LabelButton::Layout(); |
| - |
| - // Keep the text centered and the icon right-aligned by stretching the label |
| - // to take up more of the content area and centering its contents. |
| - gfx::Rect content_bounds = GetContentsBounds(); |
| - gfx::Rect label_bounds = label()->bounds(); |
| - label_bounds.Inset(content_bounds.x() - label_bounds.x(), 0, 0, 0); |
| - label()->SetBoundsRect(label_bounds); |
| - } |
| - |
| - private: |
| - void OnFocus() override { |
| - SetState(STATE_HOVERED); |
| - } |
| - |
| - void OnBlur() override { |
| - SetState(STATE_NORMAL); |
| - } |
| - |
| - DISALLOW_COPY_AND_ASSIGN(RightAlignedIconLabelButton); |
| -}; |
| - |
| // EditableProfilePhoto ------------------------------------------------- |
| -const size_t kProfileBadgeWhitePadding = 2; |
| - |
| // A custom Image control that shows a "change" button when moused over. |
| class EditableProfilePhoto : public views::LabelButton { |
| public: |
| @@ -419,41 +365,18 @@ class EditableProfilePhoto : public views::LabelButton { |
| bool is_editing_allowed, |
| Profile* profile) |
| : views::LabelButton(listener, base::string16()), |
| - interactive_(!switches::IsMaterialDesignUserMenu()), |
| photo_overlay_(nullptr), |
| profile_(profile) { |
| + set_can_process_events_within_subtree(false); |
|
msarda
2017/02/23 11:51:02
Why this change?
jlebel
2017/02/23 18:18:49
To replace:
bool CanProcessEventsWithinSubtree() c
|
| gfx::Image image = profiles::GetSizedAvatarIcon( |
| icon, true, icon_image_side(), icon_image_side()); |
| SetImage(views::LabelButton::STATE_NORMAL, *image.ToImageSkia()); |
| SetBorder(views::NullBorder()); |
| - if (switches::IsMaterialDesignUserMenu()) { |
| - SetMinSize(gfx::Size(GetPreferredSize().width() + badge_spacing(), |
| - GetPreferredSize().height() + badge_spacing() + |
| - views::kRelatedControlSmallVerticalSpacing)); |
| - } else { |
| - SetSize(GetPreferredSize()); |
| - } |
| - |
| - if (switches::IsMaterialDesignUserMenu() || !is_editing_allowed) { |
| - SetEnabled(false); |
| - return; |
| - } |
| - |
| - set_notify_enter_exit_on_child(true); |
| - |
| - // Photo overlay that appears when hovering over the button. |
| - photo_overlay_ = new views::ImageView(); |
| - |
| - 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))); |
| + SetMinSize(gfx::Size(GetPreferredSize().width() + badge_spacing(), |
| + GetPreferredSize().height() + badge_spacing() + |
| + views::kRelatedControlSmallVerticalSpacing)); |
| - photo_overlay_->SetSize(gfx::Size(icon_image_side(), icon_image_side())); |
| - photo_overlay_->SetY(badge_spacing()); |
| - photo_overlay_->SetVisible(false); |
| - AddChildView(photo_overlay_); |
| + SetEnabled(false); |
| } |
| void PaintChildren(const ui::PaintContext& context) override { |
| @@ -479,9 +402,7 @@ class EditableProfilePhoto : public views::LabelButton { |
| icon_image_side() + badge_spacing() - GetProfileBadgeSize(); |
| gfx::Vector2d badge_offset_vector = gfx::Vector2d( |
| GetMirroredXWithWidthInView(badge_offset, GetProfileBadgeSize()), |
| - badge_offset + (switches::IsMaterialDesignUserMenu() |
| - ? views::kRelatedControlSmallVerticalSpacing |
| - : 0)); |
| + badge_offset + views::kRelatedControlSmallVerticalSpacing); |
| gfx::Point center_point = bounds.CenterPoint() + badge_offset_vector; |
| @@ -495,25 +416,11 @@ class EditableProfilePhoto : public views::LabelButton { |
| gfx::VectorIconId icon_id; |
| int icon_size; |
| SkColor icon_color; |
| - if (switches::IsMaterialDesignUserMenu()) { |
| - icon_id = profile_->IsChild() |
| - ? gfx::VectorIconId::ACCOUNT_CHILD_CIRCLE |
| - : gfx::VectorIconId::SUPERVISOR_ACCOUNT_CIRCLE; |
| - icon_size = 22; |
| - icon_color = gfx::kChromeIconGrey; |
| - } else { |
| - // Paint the light blue circle. |
| - flags.setColor(SkColorSetRGB(0xaf, 0xd9, 0xfc)); |
| - canvas->DrawCircle( |
| - center_point, GetProfileBadgeSize() / 2 - kProfileBadgeWhitePadding, |
| - flags); |
| - |
| - icon_id = profile_->IsChild() |
| - ? gfx::VectorIconId::ACCOUNT_CHILD |
| - : gfx::VectorIconId::SUPERVISOR_ACCOUNT; |
| - icon_size = profile_->IsChild() ? 26 : 20; |
| - icon_color = SkColorSetRGB(0, 0x66, 0xff); |
| - } |
| + icon_id = profile_->IsChild() |
| + ? gfx::VectorIconId::ACCOUNT_CHILD_CIRCLE |
| + : gfx::VectorIconId::SUPERVISOR_ACCOUNT_CIRCLE; |
| + icon_size = 22; |
|
msarda
2017/02/23 11:51:03
consider making this a constant.
jlebel
2017/02/23 18:18:49
Done.
|
| + icon_color = gfx::kChromeIconGrey; |
|
msarda
2017/02/23 11:51:02
I think this variable can be removed now.
jlebel
2017/02/23 18:18:49
Done.
|
| // Paint the badge icon. |
| int offset = (GetProfileBadgeSize() - icon_size) / 2; |
| @@ -522,19 +429,14 @@ class EditableProfilePhoto : public views::LabelButton { |
| } |
| } |
| - static int icon_image_side() { |
| - return switches::IsMaterialDesignUserMenu() ? kMdImageSide |
| - : kLargeImageSide; |
| - } |
| + static int icon_image_side() { return kMdImageSide; } |
|
msarda
2017/02/23 11:51:02
Can this this function be replaced by a const?
jlebel
2017/02/23 18:18:49
Done.
|
| static int badge_spacing() { |
|
msarda
2017/02/23 11:51:03
Can this this function be replaced by a const?
jlebel
2017/02/23 18:18:49
Done.
|
| // The space between the right/bottom edge of the profile badge and the |
| // right/bottom edge of the profile icon. |
| - return switches::IsMaterialDesignUserMenu() ? 4 : 0; |
| + return 4; |
| } |
| - bool CanProcessEventsWithinSubtree() const override { return interactive_; } |
| - |
| private: |
| // views::CustomButton: |
| void StateChanged(ButtonState old_state) override { |
| @@ -557,8 +459,6 @@ class EditableProfilePhoto : public views::LabelButton { |
| photo_overlay_->SetVisible(false); |
| } |
| - bool interactive_; |
| - |
| // Image that is shown when hovering over the image button. Can be NULL if |
| // the photo isn't allowed to be edited (e.g. for guest profiles). |
| views::ImageView* photo_overlay_; |
| @@ -568,110 +468,6 @@ class EditableProfilePhoto : public views::LabelButton { |
| DISALLOW_COPY_AND_ASSIGN(EditableProfilePhoto); |
| }; |
| -// EditableProfileName ------------------------------------------------- |
| - |
| -// A custom text control that turns into a textfield for editing when clicked. |
| -// Only used in non-material-design user menu. |
| -class EditableProfileName : public views::View, |
| - public views::ButtonListener { |
| - public: |
| - EditableProfileName(views::TextfieldController* controller, |
| - const base::string16& text, |
| - bool is_editing_allowed) |
| - : button_(nullptr), profile_name_textfield_(nullptr) { |
| - SetLayoutManager( |
| - new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); |
| - |
| - ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); |
| - const gfx::FontList& medium_font_list = |
| - rb->GetFontList(ui::ResourceBundle::MediumFont); |
| - const gfx::Insets textfield_border_insets = |
| - views::Textfield().border()->GetInsets(); |
| - |
| - if (!is_editing_allowed) { |
| - views::Label* name_label = new views::Label(text); |
| - name_label->SetBorder(views::CreateEmptyBorder(textfield_border_insets)); |
| - name_label->SetFontList(medium_font_list); |
| - AddChildView(name_label); |
| - return; |
| - } |
| - |
| - 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_->SetVisible(false); |
| - AddChildView(profile_name_textfield_); |
| - |
| - button_ = new RightAlignedIconLabelButton(this, text); |
| - button_->SetFontListDeprecated(medium_font_list); |
| - // Show an "edit" pencil icon when hovering over. In the default state, |
| - // we need to create an empty placeholder of the correct size, so that |
| - // the text doesn't jump around when the hovered icon appears. |
| - // TODO(estade): revisit colors and press effect. |
| - const int kIconSize = 16; |
| - button_->SetImage(views::LabelButton::STATE_NORMAL, |
| - CreateSquarePlaceholderImage(kIconSize)); |
| - button_->SetImage(views::LabelButton::STATE_HOVERED, |
| - gfx::CreateVectorIcon( |
| - gfx::VectorIconId::MODE_EDIT, kIconSize, |
| - SkColorSetRGB(0x33, 0x33, 0x33))); |
| - button_->SetImage(views::LabelButton::STATE_PRESSED, |
| - gfx::CreateVectorIcon( |
| - gfx::VectorIconId::MODE_EDIT, kIconSize, |
| - SkColorSetRGB(0x20, 0x20, 0x20))); |
| - // 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. |
| - const int kIconTextLabelButtonSpacing = 5; |
| - button_->SetBorder(views::CreateEmptyBorder( |
| - textfield_border_insets + |
| - gfx::Insets(0, kIconSize + kIconTextLabelButtonSpacing, 0, 0))); |
| - AddChildView(button_); |
| - } |
| - |
| - views::Textfield* profile_name_textfield() { |
| - return profile_name_textfield_; |
| - } |
| - |
| - // Hide the editable textfield to show the profile name button instead. |
| - void ShowReadOnlyView() { |
| - button_->SetVisible(true); |
| - profile_name_textfield_->SetVisible(false); |
| - } |
| - |
| - private: |
| - // views::ButtonListener: |
| - void ButtonPressed(views::Button* sender, const ui::Event& event) override { |
| - button_->SetVisible(false); |
| - profile_name_textfield_->SetVisible(true); |
| - profile_name_textfield_->SetText(button_->GetText()); |
| - profile_name_textfield_->SelectAll(false); |
| - profile_name_textfield_->RequestFocus(); |
| - // Re-layouts the view after swaping the controls. |
| - Layout(); |
| - } |
| - |
| - // views::LabelButton: |
| - bool OnKeyReleased(const ui::KeyEvent& event) override { |
| - // Override CustomButton's implementation, which presses the button when |
| - // you press space and clicks it when you release space, as the space can be |
| - // part of the new profile name typed in the textfield. |
| - return false; |
| - } |
| - |
| - // The label button which shows the profile name, and can handle the event to |
| - // make it editable. Can be NULL if the profile name isn't allowed to be |
| - // edited. |
| - RightAlignedIconLabelButton* button_; |
| - |
| - // Textfield that is shown when editing the profile name. Can be NULL if |
| - // the profile name isn't allowed to be edited (e.g. for guest profiles). |
| - views::Textfield* profile_name_textfield_; |
| - |
| - DISALLOW_COPY_AND_ASSIGN(EditableProfileName); |
| -}; |
| - |
| // A title card with one back button right aligned and one label center aligned. |
| class TitleCard : public views::View { |
| public: |
| @@ -764,9 +560,7 @@ void ProfileChooserView::ShowBubble( |
| // container. |
| // Same for material design user menu since fast profile switcher will be |
| // migrated to the left-click menu. |
| - if (view_mode == profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER && |
| - (!profiles::HasProfileSwitchTargets(browser->profile()) || |
| - switches::IsMaterialDesignUserMenu())) { |
| + if (view_mode == profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER) { |
| return; |
| } |
| @@ -843,8 +637,6 @@ void ProfileChooserView::ResetView() { |
| manage_accounts_button_ = nullptr; |
| signin_current_profile_button_ = nullptr; |
| auth_error_email_button_ = nullptr; |
| - current_profile_photo_ = nullptr; |
| - current_profile_name_ = nullptr; |
| current_profile_card_ = nullptr; |
| guest_profile_button_ = nullptr; |
| users_button_ = nullptr; |
| @@ -1127,9 +919,6 @@ void ProfileChooserView::ButtonPressed(views::Button* sender, |
| ShowViewFromMode(account_management_available ? |
| profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT : |
| profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER); |
| - } else if (sender == current_profile_photo_) { |
| - avatar_menu_->EditProfile(avatar_menu_->GetActiveProfileIndex()); |
| - PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_EDIT_IMAGE); |
| } else if (sender == current_profile_card_) { |
| avatar_menu_->EditProfile(avatar_menu_->GetActiveProfileIndex()); |
| PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_EDIT_IMAGE); |
| @@ -1229,40 +1018,6 @@ void ProfileChooserView::StyledLabelLinkClicked(views::StyledLabel* label, |
| chrome::ShowSettings(browser_); |
| } |
| -bool ProfileChooserView::HandleKeyEvent(views::Textfield* sender, |
| - const ui::KeyEvent& key_event) { |
| - if (key_event.type() != ui::ET_KEY_PRESSED) |
| - return false; |
| - |
| - views::Textfield* name_textfield = |
| - current_profile_name_->profile_name_textfield(); |
| - DCHECK(sender == name_textfield); |
| - |
| - if (key_event.key_code() == ui::VKEY_RETURN || |
| - key_event.key_code() == ui::VKEY_TAB) { |
| - // Pressing Tab/Enter commits the new profile name, unless it's empty. |
| - base::string16 new_profile_name = name_textfield->text(); |
| - base::TrimWhitespace(new_profile_name, base::TRIM_ALL, &new_profile_name); |
| - if (new_profile_name.empty()) |
| - return true; |
| - |
| - const AvatarMenu::Item& active_item = avatar_menu_->GetItemAt( |
| - avatar_menu_->GetActiveProfileIndex()); |
| - Profile* profile = g_browser_process->profile_manager()->GetProfile( |
| - active_item.profile_path); |
| - DCHECK(profile); |
| - |
| - if (profile->IsLegacySupervised()) |
| - return true; |
| - |
| - profiles::UpdateProfileName(profile, new_profile_name); |
| - PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_EDIT_NAME); |
| - current_profile_name_->ShowReadOnlyView(); |
| - return true; |
| - } |
| - return false; |
| -} |
| - |
| void ProfileChooserView::PopulateCompleteProfileChooserView( |
| views::GridLayout* layout, |
| AvatarMenu* avatar_menu) { |
| @@ -1280,17 +1035,11 @@ void ProfileChooserView::PopulateCompleteProfileChooserView( |
| item.signed_in && profiles::IsLockAvailable(browser_->profile()), |
| avatar_menu); |
| current_profile_view = |
| - switches::IsMaterialDesignUserMenu() |
| - ? CreateMaterialDesignCurrentProfileView(item, false) |
| - : CreateCurrentProfileView(item, false); |
| - if (IsProfileChooser(view_mode_)) { |
| - if (!switches::IsMaterialDesignUserMenu()) |
| - tutorial_view = CreateTutorialViewIfNeeded(item); |
| - } else { |
| + CreateMaterialDesignCurrentProfileView(item, false); |
| + if (!IsProfileChooser(view_mode_)) { |
| current_profile_accounts = CreateCurrentProfileAccountsView(item); |
| } |
| - if (switches::IsMaterialDesignUserMenu()) |
| - sync_error_view = CreateSyncErrorViewIfNeeded(); |
| + sync_error_view = CreateSyncErrorViewIfNeeded(); |
| } else { |
| other_profiles.push_back(i); |
| } |
| @@ -1329,10 +1078,6 @@ void ProfileChooserView::PopulateCompleteProfileChooserView( |
| } |
| if (browser_->profile()->IsSupervised()) { |
| - if (!switches::IsMaterialDesignUserMenu()) { |
| - layout->StartRow(0, 0); |
| - layout->AddView(new views::Separator()); |
| - } |
| layout->StartRow(1, 0); |
| layout->AddView(CreateSupervisedUserDisclaimerView()); |
| } |
| @@ -1629,112 +1374,6 @@ views::View* ProfileChooserView::CreateSyncErrorViewIfNeeded() { |
| return view; |
| } |
| -views::View* ProfileChooserView::CreateCurrentProfileView( |
| - const AvatarMenu::Item& avatar_item, |
| - bool is_guest) { |
| - views::View* view = new views::View(); |
| - int column_width = GetFixedMenuWidth() - 2 * views::kButtonHEdgeMarginNew; |
| - views::GridLayout* layout = CreateSingleColumnLayout(view, column_width); |
| - layout->SetInsets(views::kButtonVEdgeMarginNew, |
| - views::kButtonHEdgeMarginNew, |
| - views::kUnrelatedControlVerticalSpacing, |
| - views::kButtonHEdgeMarginNew); |
| - |
| - // Profile icon, centered. |
| - int x_offset = (column_width - kLargeImageSide) / 2; |
| - current_profile_photo_ = new EditableProfilePhoto( |
| - this, avatar_item.icon, !is_guest, browser_->profile()); |
| - current_profile_photo_->SetX(x_offset); |
| - SizedContainer* profile_icon_container = |
| - new SizedContainer(gfx::Size(column_width, kLargeImageSide)); |
| - profile_icon_container->AddChildView(current_profile_photo_); |
| - |
| - |
| - layout->StartRow(1, 0); |
| - layout->AddView(profile_icon_container); |
| - |
| - // Profile name, centered. |
| - bool editing_allowed = !is_guest && |
| - !browser_->profile()->IsLegacySupervised(); |
| - current_profile_name_ = new EditableProfileName( |
| - this, |
| - profiles::GetAvatarNameForProfile(browser_->profile()->GetPath()), |
| - editing_allowed); |
| - layout->StartRowWithPadding(1, 0, 0, |
| - views::kRelatedControlSmallVerticalSpacing); |
| - layout->StartRow(1, 0); |
| - layout->AddView(current_profile_name_); |
| - |
| - if (is_guest) |
| - return view; |
| - |
| - // The available links depend on the type of profile that is active. |
| - if (avatar_item.signed_in) { |
| - layout->StartRow(1, 0); |
| - 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_CENTER); |
| - layout->AddView(manage_accounts_link_); |
| - } else { |
| - // Badge the email address if there's an authentication error. |
| - if (HasAuthError(browser_->profile())) { |
| - 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, 18, |
| - gfx::kChromeIconGrey)); |
| - auth_error_email_button_->SetFocusForPlatform(); |
| - gfx::Insets insets = |
| - views::LabelButtonAssetBorder::GetDefaultInsetsForStyle( |
| - views::Button::STYLE_TEXTBUTTON); |
| - auth_error_email_button_->SetBorder(views::CreateEmptyBorder( |
| - insets.top(), insets.left(), insets.bottom(), insets.right())); |
| - layout->AddView(auth_error_email_button_); |
| - } else { |
| - // Add a small padding between the email button and the profile name. |
| - layout->StartRowWithPadding(1, 0, 0, 2); |
| - views::Label* email_label = new views::Label(avatar_item.username); |
| - email_label->SetElideBehavior(gfx::ELIDE_EMAIL); |
| - email_label->SetEnabled(false); |
| - layout->AddView(email_label); |
| - } |
| - } |
| - } else { |
| - 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); |
| - layout->StartRowWithPadding(1, 0, 0, |
| - views::kRelatedControlSmallVerticalSpacing); |
| - layout->StartRow(1, 0); |
| - layout->AddView(promo); |
| - |
| - signin_current_profile_button_ = |
| - views::MdTextButton::CreateSecondaryUiBlueButton( |
| - this, l10n_util::GetStringFUTF16( |
| - IDS_SYNC_START_SYNC_BUTTON_LABEL, |
| - l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME))); |
| - layout->StartRowWithPadding(1, 0, 0, |
| - views::kRelatedControlVerticalSpacing); |
| - layout->StartRow(1, 0); |
| - layout->AddView(signin_current_profile_button_); |
| - content::RecordAction( |
| - base::UserMetricsAction("Signin_Impression_FromAvatarBubbleSignin")); |
| - } |
| - } |
| - |
| - return view; |
| -} |
| - |
| views::View* ProfileChooserView::CreateMaterialDesignCurrentProfileView( |
| const AvatarMenu::Item& avatar_item, |
| bool is_guest) { |
| @@ -1871,9 +1510,7 @@ views::View* ProfileChooserView::CreateGuestProfileView() { |
| IDS_PROFILES_GUEST_PROFILE_NAME); |
| guest_avatar_item.signed_in = false; |
| - return switches::IsMaterialDesignUserMenu() |
| - ? CreateMaterialDesignCurrentProfileView(guest_avatar_item, true) |
| - : CreateCurrentProfileView(guest_avatar_item, true); |
| + return CreateMaterialDesignCurrentProfileView(guest_avatar_item, true); |
| } |
| views::View* ProfileChooserView::CreateOtherProfilesView( |
| @@ -1916,57 +1553,46 @@ views::View* ProfileChooserView::CreateOptionsView(bool display_lock, |
| CreateSingleColumnLayout(view, GetFixedMenuWidth()); |
| const bool is_guest = browser_->profile()->IsGuestSession(); |
| - const int kIconSize = switches::IsMaterialDesignUserMenu() ? 20 : 16; |
| - if (switches::IsMaterialDesignUserMenu()) { |
| - // Add the user switching buttons |
| - const int kProfileIconSize = 18; |
| - layout->StartRowWithPadding(1, 0, 0, views::kRelatedControlVerticalSpacing); |
| - for (size_t i = 0; i < avatar_menu->GetNumberOfItems(); ++i) { |
| - const AvatarMenu::Item& item = avatar_menu->GetItemAt(i); |
| - if (!item.active) { |
| - gfx::Image image = profiles::GetSizedAvatarIcon( |
| - item.icon, true, kProfileIconSize, kProfileIconSize, |
| - profiles::SHAPE_CIRCLE); |
| - views::LabelButton* button = new BackgroundColorHoverButton( |
| - this, profiles::GetProfileSwitcherTextForItem(item), |
| - *image.ToImageSkia()); |
| - button->SetImageLabelSpacing(kMaterialMenuEdgeMargin); |
| - open_other_profile_indexes_map_[button] = i; |
| - |
| - layout->StartRow(1, 0); |
| - layout->AddView(button); |
| - } |
| + const int kIconSize = 20; |
| + // Add the user switching buttons |
| + const int kProfileIconSize = 18; |
| + layout->StartRowWithPadding(1, 0, 0, views::kRelatedControlVerticalSpacing); |
| + for (size_t i = 0; i < avatar_menu->GetNumberOfItems(); ++i) { |
| + const AvatarMenu::Item& item = avatar_menu->GetItemAt(i); |
| + if (!item.active) { |
| + gfx::Image image = profiles::GetSizedAvatarIcon( |
| + item.icon, true, kProfileIconSize, kProfileIconSize, |
| + profiles::SHAPE_CIRCLE); |
| + views::LabelButton* button = new BackgroundColorHoverButton( |
| + this, profiles::GetProfileSwitcherTextForItem(item), |
| + *image.ToImageSkia()); |
| + button->SetImageLabelSpacing(kMaterialMenuEdgeMargin); |
| + open_other_profile_indexes_map_[button] = i; |
| + |
| + layout->StartRow(1, 0); |
| + layout->AddView(button); |
| } |
| + } |
| - // Add the "Guest" button for browsing as guest |
| - if (!is_guest) { |
| - PrefService* service = g_browser_process->local_state(); |
| - DCHECK(service); |
| - if (service->GetBoolean(prefs::kBrowserGuestModeEnabled)) { |
| - guest_profile_button_ = new BackgroundColorHoverButton( |
| - this, l10n_util::GetStringUTF16(IDS_GUEST_PROFILE_NAME), |
| - gfx::CreateVectorIcon(gfx::VectorIconId::ACCOUNT_CIRCLE, kIconSize, |
| - gfx::kChromeIconGrey)); |
| - layout->StartRow(1, 0); |
| - layout->AddView(guest_profile_button_); |
| - } |
| + // Add the "Guest" button for browsing as guest |
| + if (!is_guest) { |
| + PrefService* service = g_browser_process->local_state(); |
| + DCHECK(service); |
| + if (service->GetBoolean(prefs::kBrowserGuestModeEnabled)) { |
| + guest_profile_button_ = new BackgroundColorHoverButton( |
| + this, l10n_util::GetStringUTF16(IDS_GUEST_PROFILE_NAME), |
| + gfx::CreateVectorIcon(gfx::VectorIconId::ACCOUNT_CIRCLE, kIconSize, |
| + gfx::kChromeIconGrey)); |
| + layout->StartRow(1, 0); |
| + layout->AddView(guest_profile_button_); |
| } |
| } |
| - base::string16 text; |
| - gfx::VectorIconId settings_icon; |
| - if (switches::IsMaterialDesignUserMenu()) { |
| - text = is_guest |
| - ? l10n_util::GetStringUTF16(IDS_PROFILES_EXIT_GUEST) |
| + base::string16 text = |
| + is_guest ? l10n_util::GetStringUTF16(IDS_PROFILES_EXIT_GUEST) |
| : l10n_util::GetStringUTF16(IDS_PROFILES_MANAGE_USERS_BUTTON); |
| - settings_icon = |
| - is_guest ? gfx::VectorIconId::CLOSE_ALL : gfx::VectorIconId::SETTINGS; |
| - } else { |
| - text = is_guest |
| - ? l10n_util::GetStringUTF16(IDS_PROFILES_EXIT_GUEST) |
| - : l10n_util::GetStringUTF16(IDS_PROFILES_SWITCH_USERS_BUTTON); |
| - settings_icon = gfx::VectorIconId::ACCOUNT_BOX; |
| - } |
| + gfx::VectorIconId settings_icon = |
| + is_guest ? gfx::VectorIconId::CLOSE_ALL : gfx::VectorIconId::SETTINGS; |
| users_button_ = new BackgroundColorHoverButton( |
| this, text, gfx::CreateVectorIcon(settings_icon, kIconSize, |
| gfx::kChromeIconGrey)); |
| @@ -1974,32 +1600,14 @@ views::View* ProfileChooserView::CreateOptionsView(bool display_lock, |
| layout->StartRow(1, 0); |
| layout->AddView(users_button_); |
| - if (!switches::IsMaterialDesignUserMenu() && ShouldShowGoIncognito()) { |
| - layout->StartRow(1, 0); |
| - layout->AddView(new views::Separator()); |
| - |
| - ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); |
| - go_incognito_button_ = new BackgroundColorHoverButton( |
| - this, |
| - l10n_util::GetStringUTF16(IDS_PROFILES_GO_INCOGNITO_BUTTON), |
| - *rb->GetImageSkiaNamed(IDR_ICON_PROFILES_MENU_INCOGNITO)); |
| - layout->StartRow(1, 0); |
| - layout->AddView(go_incognito_button_); |
| - } |
| - |
| if (display_lock) { |
| - if (!switches::IsMaterialDesignUserMenu()) { |
| - layout->StartRow(1, 0); |
| - layout->AddView(new views::Separator()); |
| - } |
| - |
| lock_button_ = new BackgroundColorHoverButton( |
| this, l10n_util::GetStringUTF16(IDS_PROFILES_PROFILE_SIGNOUT_BUTTON), |
| gfx::CreateVectorIcon(gfx::VectorIconId::LOCK, kIconSize, |
| gfx::kChromeIconGrey)); |
| layout->StartRow(1, 0); |
| layout->AddView(lock_button_); |
| - } else if (switches::IsMaterialDesignUserMenu() && !is_guest) { |
| + } else if (!is_guest) { |
| int num_browsers = 0; |
| for (auto* browser : *BrowserList::GetInstance()) { |
| if (browser->profile()->GetOriginalProfile() == |
| @@ -2017,25 +1625,17 @@ views::View* ProfileChooserView::CreateOptionsView(bool display_lock, |
| } |
| } |
| - if (switches::IsMaterialDesignUserMenu()) |
| - layout->StartRowWithPadding(1, 0, 0, views::kRelatedControlVerticalSpacing); |
| + layout->StartRowWithPadding(1, 0, 0, views::kRelatedControlVerticalSpacing); |
| return view; |
| } |
| views::View* ProfileChooserView::CreateSupervisedUserDisclaimerView() { |
| views::View* view = new views::View(); |
| - int horizontal_margin = switches::IsMaterialDesignUserMenu() ? |
| - kMaterialMenuEdgeMargin : views::kButtonHEdgeMarginNew; |
| + int horizontal_margin = kMaterialMenuEdgeMargin; |
| views::GridLayout* layout = CreateSingleColumnLayout( |
| view, GetFixedMenuWidth() - 2 * horizontal_margin); |
| - if (switches::IsMaterialDesignUserMenu()) { |
| - layout->SetInsets(0, horizontal_margin, |
| - kMaterialMenuEdgeMargin, horizontal_margin); |
| - } else { |
| - layout->SetInsets( |
| - views::kRelatedControlVerticalSpacing, horizontal_margin, |
| - views::kRelatedControlVerticalSpacing, horizontal_margin); |
| - } |
| + layout->SetInsets(0, horizontal_margin, kMaterialMenuEdgeMargin, |
| + horizontal_margin); |
| views::Label* disclaimer = new views::Label( |
| avatar_menu_->GetSupervisedUserInformation()); |