| Index: chrome/browser/ui/views/frame/glass_browser_frame_view.cc
|
| ===================================================================
|
| --- chrome/browser/ui/views/frame/glass_browser_frame_view.cc (revision 91576)
|
| +++ chrome/browser/ui/views/frame/glass_browser_frame_view.cc (working copy)
|
| @@ -8,8 +8,11 @@
|
| #include "base/utf_string_conversions.h"
|
| #include "chrome/app/chrome_command_ids.h"
|
| #include "chrome/app/chrome_dll_resource.h"
|
| +#include "chrome/browser/browser_process.h"
|
| #include "chrome/browser/prefs/pref_service.h"
|
| #include "chrome/browser/profiles/profile.h"
|
| +#include "chrome/browser/profiles/profile_info_cache.h"
|
| +#include "chrome/browser/profiles/profile_manager.h"
|
| #include "chrome/browser/themes/theme_service.h"
|
| #include "chrome/browser/ui/profile_menu_model.h"
|
| #include "chrome/browser/ui/views/avatar_menu_button.h"
|
| @@ -29,6 +32,7 @@
|
| #include "ui/base/theme_provider.h"
|
| #include "ui/gfx/canvas_skia.h"
|
| #include "ui/gfx/icon_util.h"
|
| +#include "ui/gfx/image/image.h"
|
| #include "views/window/client_view.h"
|
| #include "views/window/window_resources.h"
|
|
|
| @@ -87,23 +91,12 @@
|
| // AvatarMenuButton takes ownership of |menu_model|.
|
| avatar_button_.reset(new AvatarMenuButton(std::wstring(), menu_model));
|
| AddChildView(avatar_button_.get());
|
| -
|
| - if (browser_view_->IsOffTheRecord()) {
|
| - avatar_button_->SetIcon(browser_view_->GetOTRAvatarIcon());
|
| - } else {
|
| - // TODO(sail) Get the avatar icon assigned to this profile.
|
| - ResourceBundle& rb = ResourceBundle::GetSharedInstance();
|
| - avatar_button_->SetIcon(*rb.GetBitmapNamed(IDR_PROFILE_AVATAR_1));
|
| - // TODO(sail) Also need to call SetHoverIcon() and SetPushedIcon().
|
| + UpdateAvatarInfo();
|
| + if (!browser_view_->IsOffTheRecord()) {
|
| + registrar_.Add(this, NotificationType::PROFILE_CACHED_INFO_CHANGED,
|
| + NotificationService::AllSources());
|
| }
|
| }
|
| -
|
| - // If multi-profile is enabled set up login notifications.
|
| - const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess();
|
| - if (browser_command_line.HasSwitch(switches::kMultiProfiles) &&
|
| - !browser_view->IsOffTheRecord()) {
|
| - RegisterLoginNotifications();
|
| - }
|
| }
|
|
|
| GlassBrowserFrameView::~GlassBrowserFrameView() {
|
| @@ -526,18 +519,17 @@
|
| void GlassBrowserFrameView::Observe(NotificationType type,
|
| const NotificationSource& source,
|
| const NotificationDetails& details) {
|
| - DCHECK_EQ(NotificationType::PREF_CHANGED, type.value);
|
| - std::string* name = Details<std::string>(details).ptr();
|
| - if (prefs::kGoogleServicesUsername == *name)
|
| - LayoutAvatar();
|
| + switch (type.value) {
|
| + case NotificationType::PROFILE_CACHED_INFO_CHANGED:
|
| + UpdateAvatarInfo();
|
| + LayoutAvatar();
|
| + break;
|
| + default:
|
| + NOTREACHED() << "Got a notification we didn't register for!";
|
| + break;
|
| + }
|
| }
|
|
|
| -void GlassBrowserFrameView::RegisterLoginNotifications() {
|
| - PrefService* pref_service = browser_view_->browser()->profile()->GetPrefs();
|
| - DCHECK(pref_service);
|
| - username_pref_.Init(prefs::kGoogleServicesUsername, pref_service, this);
|
| -}
|
| -
|
| // static
|
| void GlassBrowserFrameView::InitThrobberIcons() {
|
| static bool initialized = false;
|
| @@ -550,3 +542,18 @@
|
| initialized = true;
|
| }
|
| }
|
| +
|
| +void GlassBrowserFrameView::UpdateAvatarInfo() {
|
| + if (browser_view_->IsOffTheRecord()) {
|
| + avatar_button_->SetIcon(browser_view_->GetOTRAvatarIcon());
|
| + } 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) {
|
| + avatar_button_->SetIcon(cache.GetAvatarIconOfProfileAtIndex(index));
|
| + avatar_button_->SetText(cache.GetNameOfProfileAtIndex(index));
|
| + }
|
| + }
|
| +}
|
|
|