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 bc52d45b3f8ba417b1386a8840d47f4d0d889bd0..21a21eff9ef451054e7645073723ab17c49718c3 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 |
| @@ -5,6 +5,8 @@ |
| #include "chrome/browser/ui/views/frame/browser_non_client_frame_view.h" |
| #include "chrome/browser/browser_process.h" |
| +#include "chrome/browser/managed_mode.h" |
| +#include "chrome/browser/profiles/avatar_menu_model.h" |
| #include "chrome/browser/profiles/profile.h" |
| #include "chrome/browser/profiles/profile_info_cache.h" |
| #include "chrome/browser/profiles/profile_manager.h" |
| @@ -24,8 +26,9 @@ BrowserNonClientFrameView::~BrowserNonClientFrameView() { |
| void BrowserNonClientFrameView::UpdateAvatarInfo() { |
| if (browser_view_->ShouldShowAvatar()) { |
| if (!avatar_button_.get()) { |
| - avatar_button_.reset(new AvatarMenuButton( |
| - browser_view_->browser(), !browser_view_->IsOffTheRecord())); |
| + avatar_button_.reset( |
| + new AvatarMenuButton(browser_view_->browser(), |
| + browser_view_->IsOffTheRecord())); |
| AddChildView(avatar_button_.get()); |
| frame_->GetRootView()->Layout(); |
| } |
| @@ -35,39 +38,41 @@ void BrowserNonClientFrameView::UpdateAvatarInfo() { |
| frame_->GetRootView()->Layout(); |
| } |
| - // For popups and panels which don't have the avatar button, we still |
| - // need to draw the taskbar decoration. |
| - if (browser_view_->IsBrowserTypeNormal()) { |
| - if (!avatar_button_.get()) |
| - return; |
| - } |
| - |
| + gfx::Image avatar; |
|
sky
2012/04/25 17:12:26
Is there some place else this code could exist? It
Bernhard Bauer
2012/04/25 17:57:30
I'm not sure I follow. Where would you suggest to
sky
2012/04/25 19:44:33
It felt like this code isn't really specific to wh
|
| + string16 text; |
| + bool is_gaia_picture = false; |
| if (browser_view_->IsGuestSession()) { |
| - const gfx::Image avatar(new SkBitmap(browser_view_->GetGuestAvatarIcon())); |
| - if (avatar_button_.get()) |
| - avatar_button_->SetAvatarIcon(avatar, false); |
| - DrawTaskBarDecoration(frame_->GetNativeWindow(), &avatar); |
| + avatar = gfx::Image(browser_view_->GetGuestAvatarIcon()); |
| } else if (browser_view_->IsOffTheRecord()) { |
| - const gfx::Image avatar(new SkBitmap(browser_view_->GetOTRAvatarIcon())); |
| - if (avatar_button_.get()) |
| - avatar_button_->SetAvatarIcon(avatar, false); |
| - DrawTaskBarDecoration(frame_->GetNativeWindow(), &avatar); |
| - } else { |
| + avatar = gfx::Image(browser_view_->GetOTRAvatarIcon()); |
| + } else if (ManagedMode::IsInManagedMode()) { |
| + avatar = gfx::Image(browser_view_->GetManagedModeAvatarIcon()); |
| + } else if (AvatarMenuModel::ShouldShowAvatarMenu()) { |
| ProfileInfoCache& cache = |
| g_browser_process->profile_manager()->GetProfileInfoCache(); |
| Profile* profile = browser_view_->browser()->profile(); |
| size_t index = cache.GetIndexOfProfileWithPath(profile->GetPath()); |
| - if (index != std::string::npos) { |
| - bool is_gaia_picture = |
| - cache.IsUsingGAIAPictureOfProfileAtIndex(index) && |
| - cache.GetGAIAPictureOfProfileAtIndex(index); |
| - const gfx::Image& avatar = cache.GetAvatarIconOfProfileAtIndex(index); |
| - if (avatar_button_.get()) { |
| - avatar_button_->SetAvatarIcon(avatar, is_gaia_picture); |
| - avatar_button_->SetText(cache.GetNameOfProfileAtIndex(index)); |
| - } |
| - DrawTaskBarDecoration(frame_->GetNativeWindow(), &avatar); |
| - } |
| + if (index == std::string::npos) |
| + return; |
| + is_gaia_picture = |
| + cache.IsUsingGAIAPictureOfProfileAtIndex(index) && |
| + cache.GetGAIAPictureOfProfileAtIndex(index); |
| + avatar = cache.GetAvatarIconOfProfileAtIndex(index); |
| + text = cache.GetNameOfProfileAtIndex(index); |
| + } |
| + if (avatar_button_.get()) { |
| + avatar_button_->SetAvatarIcon(avatar, is_gaia_picture); |
| + if (!text.empty()) |
| + avatar_button_->SetText(text); |
| + } |
| + |
| + // For popups and panels which don't have the avatar button, we still |
| + // need to draw the taskbar decoration. |
| + if (AvatarMenuModel::ShouldShowAvatarMenu() || |
| + ManagedMode::IsInManagedMode()) { |
| + DrawTaskBarDecoration(frame_->GetNativeWindow(), &avatar); |
| + } else { |
| + DrawTaskBarDecoration(frame_->GetNativeWindow(), NULL); |
| } |
| } |