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

Unified Diff: chrome/browser/ui/views/avatar_menu_bubble_view.cc

Issue 8907001: Update avatar bubble if profile info changes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address review comments Created 9 years 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
« no previous file with comments | « chrome/browser/ui/views/avatar_menu_bubble_view.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/avatar_menu_bubble_view.cc
diff --git a/chrome/browser/ui/views/avatar_menu_bubble_view.cc b/chrome/browser/ui/views/avatar_menu_bubble_view.cc
index 9f1b0816bbb73414ca795ccb99911cccdf942864..594827121fa0838491d88b244e4655dc83252f6e 100644
--- a/chrome/browser/ui/views/avatar_menu_bubble_view.cc
+++ b/chrome/browser/ui/views/avatar_menu_bubble_view.cc
@@ -351,14 +351,15 @@ AvatarMenuBubbleView::AvatarMenuBubbleView(
avatar_menu_model_.reset(new AvatarMenuModel(
&g_browser_process->profile_manager()->GetProfileInfoCache(),
this, browser_));
- // Build the menu for the first time.
- OnAvatarMenuModelChanged(avatar_menu_model_.get());
}
AvatarMenuBubbleView::~AvatarMenuBubbleView() {
}
gfx::Size AvatarMenuBubbleView::GetPreferredSize() {
+ if (!add_profile_link_)
+ return gfx::Size();
+
int max_width = 0;
int total_height = 0;
for (size_t i = 0; i < item_views_.size(); ++i) {
@@ -431,6 +432,16 @@ bool AvatarMenuBubbleView::AcceleratorPressed(
return true;
}
+void AvatarMenuBubbleView::ViewHierarchyChanged(bool is_add,
+ views::View* parent,
+ views::View* child) {
+ // Build the menu for the first time.
+ if (!add_profile_link_ && is_add && child == this)
msw 2011/12/13 03:20:23 I don't think |this| will be added as a child more
sail 2011/12/13 19:28:47 It doesn't make sense to call OnAvatarMenuModelCha
msw 2011/12/13 21:15:06 I'd just DCHECK(!add_profile_link_) in OnAvatarMen
+ OnAvatarMenuModelChanged(avatar_menu_model_.get());
+
+ views::BubbleDelegateView::ViewHierarchyChanged(is_add, parent, child);
+}
+
void AvatarMenuBubbleView::ButtonPressed(views::Button* sender,
const views::Event& event) {
for (size_t i = 0; i < item_views_.size(); ++i) {
@@ -497,5 +508,7 @@ void AvatarMenuBubbleView::OnAvatarMenuModelChanged(
add_profile_link_->SetEnabledColor(SkColorSetRGB(0xe3, 0xed, 0xf6));
AddChildView(add_profile_link_);
- PreferredSizeChanged();
+ // If the bubble has already been shown then resize and reposition the bubble.
+ Layout();
+ SizeToContents();
}
« no previous file with comments | « chrome/browser/ui/views/avatar_menu_bubble_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698