Commit 888af740 authored by Thomas Lukaszewicz's avatar Thomas Lukaszewicz Committed by Commit Bot

Removed remaining use of GetInstanceForNativeUi() from profile Menu.

Removed remaining use of global NativeTheme accessor from profile
menu and added color update capability on theme change.

Fixed spacing on HoverButtons taking image views for consistency with
other constructors.

Bug: None
Change-Id: I717a45fb068a3bd35b992797e38e729da1cd3521
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2072998
Commit-Queue: Thomas Lukaszewicz <tluk@chromium.org>
Reviewed-by: default avatarPeter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/master@{#745058}
parent 852f077e
...@@ -84,7 +84,8 @@ HoverButton::HoverButton(views::ButtonListener* button_listener, ...@@ -84,7 +84,8 @@ HoverButton::HoverButton(views::ButtonListener* button_listener,
SetFocusBehavior(FocusBehavior::ALWAYS); SetFocusBehavior(FocusBehavior::ALWAYS);
const int vert_spacing = ChromeLayoutProvider::Get()->GetDistanceMetric( const int vert_spacing = ChromeLayoutProvider::Get()->GetDistanceMetric(
DISTANCE_CONTROL_LIST_VERTICAL); DISTANCE_CONTROL_LIST_VERTICAL) /
2;
SetBorder(CreateBorderWithVerticalSpacing(vert_spacing)); SetBorder(CreateBorderWithVerticalSpacing(vert_spacing));
SetInkDropMode(InkDropMode::ON); SetInkDropMode(InkDropMode::ON);
......
...@@ -55,7 +55,7 @@ class HoverButton : public views::LabelButton { ...@@ -55,7 +55,7 @@ class HoverButton : public views::LabelButton {
HoverButton(views::ButtonListener* button_listener, HoverButton(views::ButtonListener* button_listener,
std::unique_ptr<views::View> icon_view, std::unique_ptr<views::View> icon_view,
const base::string16& title, const base::string16& title,
const base::string16& subtitle, const base::string16& subtitle = base::string16(),
std::unique_ptr<views::View> secondary_view = nullptr, std::unique_ptr<views::View> secondary_view = nullptr,
bool resize_row_for_secondary_view = true, bool resize_row_for_secondary_view = true,
bool secondary_view_can_process_events = false); bool secondary_view_can_process_events = false);
......
...@@ -55,10 +55,10 @@ void IncognitoMenuView::BuildMenu() { ...@@ -55,10 +55,10 @@ void IncognitoMenuView::BuildMenu() {
incognito_window_count) incognito_window_count)
: base::string16()); : base::string16());
AddFeatureButton( AddFeatureButton(
ImageForMenu(kCloseAllIcon),
l10n_util::GetStringUTF16(IDS_INCOGNITO_PROFILE_MENU_CLOSE_BUTTON), l10n_util::GetStringUTF16(IDS_INCOGNITO_PROFILE_MENU_CLOSE_BUTTON),
base::BindRepeating(&IncognitoMenuView::OnExitButtonClicked, base::BindRepeating(&IncognitoMenuView::OnExitButtonClicked,
base::Unretained(this))); base::Unretained(this)),
kCloseAllIcon);
} }
base::string16 IncognitoMenuView::GetAccessibleWindowTitle() const { base::string16 IncognitoMenuView::GetAccessibleWindowTitle() const {
......
...@@ -65,8 +65,6 @@ namespace { ...@@ -65,8 +65,6 @@ namespace {
// Helpers -------------------------------------------------------------------- // Helpers --------------------------------------------------------------------
constexpr float kShortcutIconToImageRatio = 9.0 / 16.0;
ProfileAttributesEntry* GetProfileAttributesEntry(Profile* profile) { ProfileAttributesEntry* GetProfileAttributesEntry(Profile* profile) {
ProfileAttributesEntry* entry; ProfileAttributesEntry* entry;
CHECK(g_browser_process->profile_manager() CHECK(g_browser_process->profile_manager()
...@@ -410,19 +408,18 @@ void ProfileMenuView::BuildGuestIdentity() { ...@@ -410,19 +408,18 @@ void ProfileMenuView::BuildGuestIdentity() {
void ProfileMenuView::BuildAutofillButtons() { void ProfileMenuView::BuildAutofillButtons() {
AddShortcutFeatureButton( AddShortcutFeatureButton(
ImageForMenu(kKeyIcon, kShortcutIconToImageRatio), kKeyIcon, l10n_util::GetStringUTF16(IDS_PROFILES_PASSWORDS_LINK),
l10n_util::GetStringUTF16(IDS_PROFILES_PASSWORDS_LINK),
base::BindRepeating(&ProfileMenuView::OnPasswordsButtonClicked, base::BindRepeating(&ProfileMenuView::OnPasswordsButtonClicked,
base::Unretained(this))); base::Unretained(this)));
AddShortcutFeatureButton( AddShortcutFeatureButton(
ImageForMenu(kCreditCardIcon, kShortcutIconToImageRatio), kCreditCardIcon,
l10n_util::GetStringUTF16(IDS_PROFILES_CREDIT_CARDS_LINK), l10n_util::GetStringUTF16(IDS_PROFILES_CREDIT_CARDS_LINK),
base::BindRepeating(&ProfileMenuView::OnCreditCardsButtonClicked, base::BindRepeating(&ProfileMenuView::OnCreditCardsButtonClicked,
base::Unretained(this))); base::Unretained(this)));
AddShortcutFeatureButton( AddShortcutFeatureButton(
ImageForMenu(vector_icons::kLocationOnIcon, kShortcutIconToImageRatio), vector_icons::kLocationOnIcon,
l10n_util::GetStringUTF16(IDS_PROFILES_ADDRESSES_LINK), l10n_util::GetStringUTF16(IDS_PROFILES_ADDRESSES_LINK),
base::BindRepeating(&ProfileMenuView::OnAddressesButtonClicked, base::BindRepeating(&ProfileMenuView::OnAddressesButtonClicked,
base::Unretained(this))); base::Unretained(this)));
...@@ -513,37 +510,42 @@ void ProfileMenuView::BuildFeatureButtons() { ...@@ -513,37 +510,42 @@ void ProfileMenuView::BuildFeatureButtons() {
!is_guest && identity_manager->HasPrimaryAccount(); !is_guest && identity_manager->HasPrimaryAccount();
if (has_unconsented_account && !IsSyncPaused(profile)) { if (has_unconsented_account && !IsSyncPaused(profile)) {
AddFeatureButton(
#if BUILDFLAG(GOOGLE_CHROME_BRANDING) #if BUILDFLAG(GOOGLE_CHROME_BRANDING)
// The Google G icon needs to be shrunk, so it won't look too big // The Google G icon needs to be shrunk, so it won't look too big compared
// compared to the other icons. // to the other icons.
ImageForMenu(kGoogleGLogoIcon, /*icon_to_image_ratio=*/0.75), AddFeatureButton(
l10n_util::GetStringUTF16(IDS_SETTINGS_MANAGE_GOOGLE_ACCOUNT),
base::BindRepeating(
&ProfileMenuView::OnManageGoogleAccountButtonClicked,
base::Unretained(this)),
kGoogleGLogoIcon,
/*icon_to_image_ratio=*/0.75f);
#else #else
gfx::ImageSkia(), AddFeatureButton(
#endif
l10n_util::GetStringUTF16(IDS_SETTINGS_MANAGE_GOOGLE_ACCOUNT), l10n_util::GetStringUTF16(IDS_SETTINGS_MANAGE_GOOGLE_ACCOUNT),
base::BindRepeating( base::BindRepeating(
&ProfileMenuView::OnManageGoogleAccountButtonClicked, &ProfileMenuView::OnManageGoogleAccountButtonClicked,
base::Unretained(this))); base::Unretained(this)));
#endif
} }
int window_count = CountBrowsersFor(profile); int window_count = CountBrowsersFor(profile);
if (window_count > 1) { if (window_count > 1) {
AddFeatureButton( AddFeatureButton(
ImageForMenu(vector_icons::kCloseIcon),
l10n_util::GetPluralStringFUTF16(IDS_PROFILES_CLOSE_X_WINDOWS_BUTTON, l10n_util::GetPluralStringFUTF16(IDS_PROFILES_CLOSE_X_WINDOWS_BUTTON,
window_count), window_count),
base::BindRepeating(&ProfileMenuView::OnExitProfileButtonClicked, base::BindRepeating(&ProfileMenuView::OnExitProfileButtonClicked,
base::Unretained(this))); base::Unretained(this)),
vector_icons::kCloseIcon);
} }
// The sign-out button is always at the bottom. // The sign-out button is always at the bottom.
if (has_unconsented_account && !has_primary_account) { if (has_unconsented_account && !has_primary_account) {
AddFeatureButton( AddFeatureButton(
ImageForMenu(kSignOutIcon),
l10n_util::GetStringUTF16(IDS_SCREEN_LOCK_SIGN_OUT), l10n_util::GetStringUTF16(IDS_SCREEN_LOCK_SIGN_OUT),
base::BindRepeating(&ProfileMenuView::OnSignoutButtonClicked, base::BindRepeating(&ProfileMenuView::OnSignoutButtonClicked,
base::Unretained(this))); base::Unretained(this)),
kSignOutIcon);
} }
} }
...@@ -585,7 +587,7 @@ void ProfileMenuView::BuildSelectableProfiles() { ...@@ -585,7 +587,7 @@ void ProfileMenuView::BuildSelectableProfiles() {
void ProfileMenuView::BuildProfileManagementFeatureButtons() { void ProfileMenuView::BuildProfileManagementFeatureButtons() {
AddProfileManagementShortcutFeatureButton( AddProfileManagementShortcutFeatureButton(
ImageForMenu(vector_icons::kSettingsIcon, kShortcutIconToImageRatio), vector_icons::kSettingsIcon,
l10n_util::GetStringUTF16(IDS_PROFILES_MANAGE_USERS_BUTTON), l10n_util::GetStringUTF16(IDS_PROFILES_MANAGE_USERS_BUTTON),
base::BindRepeating(&ProfileMenuView::OnManageProfilesButtonClicked, base::BindRepeating(&ProfileMenuView::OnManageProfilesButtonClicked,
base::Unretained(this))); base::Unretained(this)));
...@@ -594,8 +596,7 @@ void ProfileMenuView::BuildProfileManagementFeatureButtons() { ...@@ -594,8 +596,7 @@ void ProfileMenuView::BuildProfileManagementFeatureButtons() {
DCHECK(service); DCHECK(service);
if (service->GetBoolean(prefs::kBrowserAddPersonEnabled)) { if (service->GetBoolean(prefs::kBrowserAddPersonEnabled)) {
AddProfileManagementFeatureButton( AddProfileManagementFeatureButton(
ImageForMenu(kAddIcon, /*icon_to_image_ratio=*/0.75), kAddIcon, l10n_util::GetStringUTF16(IDS_ADD),
l10n_util::GetStringUTF16(IDS_ADD),
base::BindRepeating(&ProfileMenuView::OnAddNewProfileButtonClicked, base::BindRepeating(&ProfileMenuView::OnAddNewProfileButtonClicked,
base::Unretained(this))); base::Unretained(this)));
} }
......
...@@ -107,29 +107,25 @@ class ProfileMenuViewBase : public content::WebContentsDelegate, ...@@ -107,29 +107,25 @@ class ProfileMenuViewBase : public content::WebContentsDelegate,
SyncInfoContainerBackgroundState background_state, SyncInfoContainerBackgroundState background_state,
base::RepeatingClosure action, base::RepeatingClosure action,
bool show_badge = true); bool show_badge = true);
void AddShortcutFeatureButton(const gfx::ImageSkia& icon, void AddShortcutFeatureButton(const gfx::VectorIcon& icon,
const base::string16& text, const base::string16& text,
base::RepeatingClosure action); base::RepeatingClosure action);
void AddFeatureButton(const gfx::ImageSkia& icon, void AddFeatureButton(const base::string16& text,
const base::string16& text, base::RepeatingClosure action,
base::RepeatingClosure action); const gfx::VectorIcon& icon = gfx::kNoneIcon,
float icon_to_image_ratio = 1.0f);
void SetProfileManagementHeading(const base::string16& heading); void SetProfileManagementHeading(const base::string16& heading);
void AddSelectableProfile(const gfx::ImageSkia& image, void AddSelectableProfile(const gfx::ImageSkia& image,
const base::string16& name, const base::string16& name,
bool is_guest, bool is_guest,
base::RepeatingClosure action); base::RepeatingClosure action);
void AddProfileManagementShortcutFeatureButton(const gfx::ImageSkia& icon, void AddProfileManagementShortcutFeatureButton(const gfx::VectorIcon& icon,
const base::string16& text, const base::string16& text,
base::RepeatingClosure action); base::RepeatingClosure action);
void AddProfileManagementFeatureButton(const gfx::ImageSkia& icon, void AddProfileManagementFeatureButton(const gfx::VectorIcon& icon,
const base::string16& text, const base::string16& text,
base::RepeatingClosure action); base::RepeatingClosure action);
// 0 < |icon_to_image_ratio| <= 1 is the size ratio of |icon| in the returned
// image. E.g. a value of 0.8 means that |icon| only takes up 80% of the
// returned image, with the rest being padding around it.
gfx::ImageSkia ImageForMenu(const gfx::VectorIcon& icon,
float icon_to_image_ratio = 1.0f) const;
gfx::ImageSkia ColoredImageForMenu(const gfx::VectorIcon& icon, gfx::ImageSkia ColoredImageForMenu(const gfx::VectorIcon& icon,
SkColor color) const; SkColor color) const;
// Should be called inside each button/link action. // Should be called inside each button/link action.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment