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 367aae14668740feee129b4c8320e7f2ee7a8ec2..e12d7e88396b10d93fd39320157566ae9976a4fd 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 |
@@ -9,11 +9,13 @@ |
#include "chrome/browser/profiles/profile.h" |
#include "chrome/browser/profiles/profile_info_cache.h" |
#include "chrome/browser/profiles/profile_manager.h" |
+#include "chrome/browser/profiles/profiles_state.h" |
#include "chrome/browser/ui/view_ids.h" |
#include "chrome/browser/ui/views/avatar_label.h" |
#include "chrome/browser/ui/views/avatar_menu_button.h" |
#include "chrome/browser/ui/views/frame/browser_view.h" |
#include "chrome/browser/ui/views/frame/taskbar_decorator.h" |
+#include "chrome/browser/ui/views/new_avatar_button.h" |
#include "grit/generated_resources.h" |
#include "grit/theme_resources.h" |
#include "third_party/skia/include/core/SkColor.h" |
@@ -28,7 +30,8 @@ BrowserNonClientFrameView::BrowserNonClientFrameView(BrowserFrame* frame, |
: frame_(frame), |
browser_view_(browser_view), |
avatar_button_(NULL), |
- avatar_label_(NULL) { |
+ avatar_label_(NULL), |
+ new_avatar_button_(NULL) { |
} |
BrowserNonClientFrameView::~BrowserNonClientFrameView() { |
@@ -41,7 +44,12 @@ void BrowserNonClientFrameView::VisibilityChanged(views::View* starting_from, |
// The first time UpdateAvatarInfo() is called the window is not visible so |
// DrawTaskBarDecoration() has no effect. Therefore we need to call it again |
// once the window is visible. |
- UpdateAvatarInfo(); |
+ bool is_incognito = browser_view_->IsOffTheRecord() && |
+ !browser_view_->IsGuestSession(); |
+ if (!is_incognito && profiles::IsNewProfileManagementEnabled()) |
+ UpdateNewStyleAvatarInfo(); |
sky
2013/09/26 20:21:39
Why do we need this here and not at init time?
noms (inactive)
2013/10/01 17:42:21
I don't fully understand the comment about DrawTas
|
+ else |
+ UpdateAvatarInfo(); |
} |
void BrowserNonClientFrameView::OnThemeChanged() { |
@@ -111,3 +119,37 @@ void BrowserNonClientFrameView::UpdateAvatarInfo() { |
frame_->GetNativeWindow(), |
AvatarMenu::ShouldShowAvatarMenu() ? &avatar : NULL); |
} |
+ |
+void BrowserNonClientFrameView::UpdateNewStyleAvatarInfo() { |
+ DCHECK(profiles::IsNewProfileManagementEnabled()); |
+ // This should never be called in incognito mode. |
+ if (browser_view_->IsOffTheRecord()) |
+ DCHECK(browser_view_->IsGuestSession()); |
+ |
+ if (browser_view_->ShouldShowAvatar()) { |
+ if (!new_avatar_button_) { |
+ // The name of the profile that should be displayed in the button. |
+ string16 profile_name; |
+ if (browser_view_->IsGuestSession()) { |
+ profile_name = l10n_util::GetStringUTF16(IDS_GUEST_PROFILE_NAME); |
+ } else { |
+ 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) |
+ profile_name = cache.GetNameOfProfileAtIndex(index); |
+ } |
+ new_avatar_button_ = new NewAvatarButton(browser_view_, profile_name); |
+ new_avatar_button_->set_id(VIEW_ID_NEW_AVATAR_BUTTON); |
+ AddChildView(new_avatar_button_); |
+ frame_->GetRootView()->Layout(); |
+ } |
+ } else if (new_avatar_button_) { |
+ RemoveChildView(new_avatar_button_); |
+ delete new_avatar_button_; |
+ new_avatar_button_ = NULL; |
+ frame_->GetRootView()->Layout(); |
+ } |
+} |
+ |