| 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..0aee6e2ba3556aaa60a172e41c966f116592277d 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,9 @@ 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();
|
| + if (!browser_view_->IsRegularOrGuestSession() ||
|
| + !profiles::IsNewProfileManagementEnabled())
|
| + UpdateAvatarInfo();
|
| }
|
|
|
| void BrowserNonClientFrameView::OnThemeChanged() {
|
| @@ -111,3 +116,36 @@ void BrowserNonClientFrameView::UpdateAvatarInfo() {
|
| frame_->GetNativeWindow(),
|
| AvatarMenu::ShouldShowAvatarMenu() ? &avatar : NULL);
|
| }
|
| +
|
| +void BrowserNonClientFrameView::UpdateNewStyleAvatarInfo() {
|
| + DCHECK(profiles::IsNewProfileManagementEnabled());
|
| + // This should never be called in incognito mode.
|
| + DCHECK(browser_view_->IsRegularOrGuestSession());
|
| +
|
| + 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();
|
| + }
|
| +}
|
| +
|
|
|