Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3575)

Unified Diff: chrome/browser/ui/views/frame/browser_non_client_frame_view.cc

Issue 24647003: Redesign of the avatar menu button. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: better fix for app/popup browser crash Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..d7f46d93d0cb37d718c2f9cb9c4f2651def06fe3 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,14 @@
#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 "chrome/browser/ui/views/profile_chooser_view.h"
#include "grit/generated_resources.h"
#include "grit/theme_resources.h"
#include "third_party/skia/include/core/SkColor.h"
@@ -28,7 +31,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 +45,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() {
@@ -59,8 +65,7 @@ void BrowserNonClientFrameView::UpdateAvatarInfo() {
AddChildView(avatar_label_);
}
avatar_button_ = new AvatarMenuButton(
- browser_view_->browser(),
- browser_view_->IsOffTheRecord() && !browser_view_->IsGuestSession());
+ browser_view_->browser(), !browser_view_->IsRegularOrGuestSession());
avatar_button_->set_id(VIEW_ID_AVATAR_BUTTON);
AddChildView(avatar_button_);
frame_->GetRootView()->Layout();
@@ -111,3 +116,37 @@ void BrowserNonClientFrameView::UpdateAvatarInfo() {
frame_->GetNativeWindow(),
AvatarMenu::ShouldShowAvatarMenu() ? &avatar : NULL);
}
+
+void BrowserNonClientFrameView::UpdateNewStyleAvatarInfo(
+ views::ButtonListener* listener,
+ const NewAvatarButton::AvatarButtonStyle style) {
+ DCHECK(profiles::IsNewProfileManagementEnabled());
+ // This should never be called in incognito mode.
+ DCHECK(browser_view_->IsRegularOrGuestSession());
+
+ if (browser_view_->ShouldShowAvatar()) {
+ if (!new_avatar_button_) {
+ string16 profile_name =
+ profiles::GetActiveProfileDisplayName(browser_view_->browser());
+ new_avatar_button_ = new NewAvatarButton(listener, profile_name, style);
+ new_avatar_button_->set_id(VIEW_ID_NEW_AVATAR_BUTTON);
+ AddChildView(new_avatar_button_);
+ frame_->GetRootView()->Layout();
+ }
+ } else if (new_avatar_button_) {
+ delete new_avatar_button_;
+ new_avatar_button_ = NULL;
+ frame_->GetRootView()->Layout();
+ }
+}
+
+void BrowserNonClientFrameView::ShowProfileChooserViewBubble() {
+ gfx::Point origin;
+ views::View::ConvertPointToScreen(new_avatar_button(), &origin);
+ gfx::Rect bounds(origin, size());
+
+ ProfileChooserView::ShowBubble(
+ new_avatar_button(), views::BubbleBorder::TOP_RIGHT,
+ views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE, bounds,
+ browser_view_->browser());
+}

Powered by Google App Engine
This is Rietveld 408576698