Chromium Code Reviews| Index: chrome/browser/ui/views/frame/browser_non_client_frame_view.cc |
| diff --git a/chrome/browser/ui/views/frame/browser_non_client_frame_view.cc b/chrome/browser/ui/views/frame/browser_non_client_frame_view.cc |
| index d0b5d24f553746a5e9bf404f7223e4416f5f37e1..2b49ab3b240609ef8af51a264471d3a69f0d320a 100644 |
| --- a/chrome/browser/ui/views/frame/browser_non_client_frame_view.cc |
| +++ b/chrome/browser/ui/views/frame/browser_non_client_frame_view.cc |
| @@ -15,7 +15,6 @@ |
| #include "chrome/browser/ui/view_ids.h" |
| #include "chrome/browser/ui/views/frame/browser_view.h" |
| #include "chrome/browser/ui/views/frame/taskbar_decorator.h" |
| -#include "chrome/browser/ui/views/profiles/avatar_menu_button.h" |
| #include "chrome/browser/ui/views/tabs/tab_strip.h" |
| #include "components/signin/core/common/profile_management_switches.h" |
| #include "grit/theme_resources.h" |
| @@ -154,46 +153,36 @@ gfx::ImageSkia BrowserNonClientFrameView::GetFrameOverlayImage() const { |
| return GetFrameOverlayImage(ShouldPaintAsActive()); |
| } |
| -void BrowserNonClientFrameView::UpdateOldAvatarButton() { |
| - if (browser_view_->ShouldShowAvatar()) { |
| - if (!avatar_button_) { |
| - avatar_button_ = new AvatarMenuButton(browser_view_); |
| - avatar_button_->set_id(VIEW_ID_AVATAR_BUTTON); |
| - AddChildView(avatar_button_); |
| - // Invalidate here because adding a child does not invalidate the layout. |
| - InvalidateLayout(); |
| - frame_->GetRootView()->Layout(); |
| - } |
| - } else if (avatar_button_) { |
| - RemoveChildView(avatar_button_); |
| - delete avatar_button_; |
| - avatar_button_ = nullptr; |
| +void BrowserNonClientFrameView::UpdateProfileIndicatorIcon() { |
| + if (!profile_indicator_) { |
| + profile_indicator_ = new ProfileIndicatorIcon(browser_view_); |
| + profile_indicator_->set_id(VIEW_ID_PROFILE_INDICATOR_ICON); |
| + AddChildView(profile_indicator_); |
| + // Invalidate here because adding a child does not invalidate the layout. |
| + InvalidateLayout(); |
| frame_->GetRootView()->Layout(); |
| } |
| - gfx::Image avatar; |
| - gfx::Image taskbar_badge_avatar; |
| - bool is_rectangle = false; |
| - |
| - // Update the avatar button in the window frame and the taskbar overlay. |
| - bool should_show_avatar_menu = |
| - avatar_button_ || AvatarMenu::ShouldShowAvatarMenu(); |
| - |
| - if (!AvatarMenuButton::GetAvatarImages(this, should_show_avatar_menu, &avatar, |
| - &taskbar_badge_avatar, &is_rectangle)) |
| - return; |
| + gfx::Image icon; |
| + const Profile* profile = browser_view()->browser()->profile(); |
| + if (profile->GetProfileType() == Profile::INCOGNITO_PROFILE) { |
| + icon = gfx::Image(GetOTRAvatarIcon()); |
| + } else { |
| +#if defined(OS_CHROMEOS) |
| + bool unused; |
| + AvatarMenu::GetImageForMenuButton(profile->GetPath(), &icon, &unused); |
|
Peter Kasting
2016/05/17 03:51:42
Nit: Does this need to be conditionally compiled i
Evan Stade
2016/05/17 18:13:08
I wanted to add the NOTREACHED to document that th
Peter Kasting
2016/05/18 02:44:01
Can we just have a comment that says "only reached
Evan Stade
2016/05/20 22:04:42
I personally don't have a problem with ifdefs. Sur
Peter Kasting
2016/05/20 22:24:22
How you have it is fine.
|
| +#else |
| + NOTREACHED(); |
| +#endif |
| + } |
| - // Disable the menu when we should not show the menu. |
| - if (avatar_button_ && !AvatarMenu::ShouldShowAvatarMenu()) |
| - avatar_button_->SetEnabled(false); |
| - if (avatar_button_) |
| - avatar_button_->SetAvatarIcon(avatar, is_rectangle); |
| + profile_indicator_->SetIcon(icon); |
| } |
| void BrowserNonClientFrameView::ViewHierarchyChanged( |
| const ViewHierarchyChangedDetails& details) { |
| if (details.is_add && details.child == this) |
| - UpdateAvatar(); |
| + UpdateProfileIcons(); |
| } |
| void BrowserNonClientFrameView::ActivationChanged(bool active) { |
| @@ -203,7 +192,7 @@ void BrowserNonClientFrameView::ActivationChanged(bool active) { |
| // reflect that the window is inactive, we force NonClientFrameView to see |
| // the "correct" state as an override. |
| set_active_state_override(&active); |
| - UpdateAvatar(); |
| + UpdateProfileIcons(); |
| set_active_state_override(nullptr); |
| // Changing the activation state may change the toolbar top separator color |
| @@ -229,7 +218,7 @@ void BrowserNonClientFrameView::OnProfileWasRemoved( |
| void BrowserNonClientFrameView::OnProfileAvatarChanged( |
| const base::FilePath& profile_path) { |
| UpdateTaskbarDecoration(); |
| - UpdateAvatar(); |
| + UpdateProfileIcons(); |
| } |
| const ui::ThemeProvider* |
| @@ -240,36 +229,33 @@ BrowserNonClientFrameView::GetThemeProviderForProfile() const { |
| } |
| void BrowserNonClientFrameView::UpdateTaskbarDecoration() { |
| - gfx::Image avatar; |
| - gfx::Image taskbar_badge_avatar; |
| - bool is_rectangle; |
| - // Only need to update the taskbar overlay here. If GetAvatarImages() |
| - // returns false, don't bother trying to update the taskbar decoration since |
| - // the returned images are not initialized. This can happen if the user |
| - // deletes the current profile. |
| - if (AvatarMenuButton::GetAvatarImages( |
| - this, AvatarMenu::ShouldShowAvatarMenu(), &avatar, |
| - &taskbar_badge_avatar, &is_rectangle)) { |
| - // For popups and panels which don't have the avatar button, we still |
| - // need to draw the taskbar decoration. Even though we have an icon on the |
| - // window's relaunch details, we draw over it because the user may have |
| - // pinned the badge-less Chrome shortcut which will cause windows to ignore |
| - // the relaunch details. |
| - // TODO(calamity): ideally this should not be necessary but due to issues |
| - // with the default shortcut being pinned, we add the runtime badge for |
| - // safety. See crbug.com/313800. |
| - bool show_decoration = AvatarMenu::ShouldShowAvatarMenu() && |
| - !browser_view_->browser()->profile()->IsGuestSession(); |
| - // In tests, make sure that the browser process and profile manager are |
| - // valid before using. |
| - if (g_browser_process && g_browser_process->profile_manager()) { |
| - const ProfileAttributesStorage& storage = |
| - g_browser_process->profile_manager()->GetProfileAttributesStorage(); |
| - show_decoration = show_decoration && storage.GetNumberOfProfiles() > 1; |
| - } |
| - chrome::DrawTaskbarDecoration(frame_->GetNativeWindow(), |
| - show_decoration |
| - ? (taskbar_badge_avatar.IsEmpty() ? &avatar : &taskbar_badge_avatar) |
| - : nullptr); |
| +#if defined(OS_WIN) |
| + if (browser_view()->browser()->profile()->IsGuestSession() || |
| + // In tests, make sure that the browser process and profile manager are |
| + // valid before using. |
|
Peter Kasting
2016/05/17 03:51:42
Nit: Comment might be clearer as "Tests may not ha
Evan Stade
2016/05/17 18:13:08
Done.
|
| + (g_browser_process && g_browser_process->profile_manager() && |
| + g_browser_process->profile_manager() |
| + ->GetProfileAttributesStorage() |
| + .GetNumberOfProfiles() <= 1)) { |
| + chrome::DrawTaskbarDecoration(frame_->GetNativeWindow(), nullptr); |
|
Peter Kasting
2016/05/17 03:51:42
If you're going to make this whole block ifdefed f
Evan Stade
2016/05/17 18:13:08
Done.
|
| + return; |
| } |
| + |
| + // For popups and panels which don't have the avatar button, we still |
| + // need to draw the taskbar decoration. Even though we have an icon on the |
| + // window's relaunch details, we draw over it because the user may have |
| + // pinned the badge-less Chrome shortcut which will cause windows to ignore |
|
Peter Kasting
2016/05/17 03:51:42
Nit: While here: windows -> Windows ?
Evan Stade
2016/05/17 18:13:08
Done.
|
| + // the relaunch details. |
| + // TODO(calamity): ideally this should not be necessary but due to issues |
| + // with the default shortcut being pinned, we add the runtime badge for |
| + // safety. See crbug.com/313800. |
| + gfx::Image decoration; |
| + bool unused; |
|
Peter Kasting
2016/05/17 03:51:42
Nit: This is the second place in this file that do
Evan Stade
2016/05/17 18:13:08
turns out it's not used anywhere any more. Removed
|
| + AvatarMenu::GetImageForMenuButton( |
| + browser_view()->browser()->profile()->GetPath(), &decoration, &unused); |
| + // This can happen if the user deletes the current profile. |
| + if (decoration.IsEmpty()) |
| + return; |
| + chrome::DrawTaskbarDecoration(frame_->GetNativeWindow(), &decoration); |
| +#endif |
| } |