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

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

Issue 171523004: Stop using the old-style profile names when using --new-profile-management (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: moved new tests behind no-android/no-cros ifdef Created 6 years, 10 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
« no previous file with comments | « chrome/browser/ui/views/new_avatar_button.h ('k') | chrome/browser/ui/views/profile_chooser_view.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/new_avatar_button.cc
diff --git a/chrome/browser/ui/views/new_avatar_button.cc b/chrome/browser/ui/views/new_avatar_button.cc
index b91c36a20e4e315ed79186c03ea13e0f226031bc..5c145ef4ac9f4bc884fab3812cffeb9ac5afe9eb 100644
--- a/chrome/browser/ui/views/new_avatar_button.cc
+++ b/chrome/browser/ui/views/new_avatar_button.cc
@@ -8,6 +8,7 @@
#include "chrome/browser/browser_process.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/profiles/profiles_state.h"
+#include "chrome/browser/ui/browser.h"
#include "grit/generated_resources.h"
#include "grit/theme_resources.h"
#include "ui/base/l10n/l10n_util.h"
@@ -97,16 +98,13 @@ NewAvatarButton::NewAvatarButton(
rb->GetImageNamed(IDR_AVATAR_GLASS_BUTTON_DROPARROW).ToImageSkia());
}
- avatar_menu_.reset(new AvatarMenu(
- &g_browser_process->profile_manager()->GetProfileInfoCache(),
- this,
- browser_));
- avatar_menu_->RebuildMenu();
-
+ g_browser_process->profile_manager()->GetProfileInfoCache().AddObserver(this);
SchedulePaint();
}
NewAvatarButton::~NewAvatarButton() {
+ g_browser_process->profile_manager()->
+ GetProfileInfoCache().RemoveObserver(this);
}
void NewAvatarButton::OnPaint(gfx::Canvas* canvas) {
@@ -134,10 +132,27 @@ void NewAvatarButton::OnPaint(gfx::Canvas* canvas) {
PaintMenuMarker(canvas);
}
-void NewAvatarButton::OnAvatarMenuChanged(AvatarMenu* avatar_menu) {
+void NewAvatarButton::OnProfileAdded(const base::FilePath& profile_path) {
+ UpdateAvatarButtonAndRelayoutParent();
+}
+
+void NewAvatarButton::OnProfileWasRemoved(
+ const base::FilePath& profile_path,
+ const base::string16& profile_name) {
+ UpdateAvatarButtonAndRelayoutParent();
+}
+
+void NewAvatarButton::OnProfileNameChanged(
+ const base::FilePath& profile_path,
+ const base::string16& old_profile_name) {
+ UpdateAvatarButtonAndRelayoutParent();
+}
+
+void NewAvatarButton::UpdateAvatarButtonAndRelayoutParent() {
// We want the button to resize if the new text is shorter.
ClearMaxTextSize();
- SetText(GetElidedText(profiles::GetActiveProfileDisplayName(browser_)));
+ SetText(GetElidedText(
+ profiles::GetAvatarNameForProfile(browser_->profile())));
// Because the width of the button might have changed, the parent browser
// frame needs to recalculate the button bounds and redraw it.
« no previous file with comments | « chrome/browser/ui/views/new_avatar_button.h ('k') | chrome/browser/ui/views/profile_chooser_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698