OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/views/frame/browser_non_client_frame_view.h" | 5 #include "chrome/browser/ui/views/frame/browser_non_client_frame_view.h" |
6 | 6 |
7 #include "chrome/browser/browser_process.h" | 7 #include "chrome/browser/browser_process.h" |
8 #include "chrome/browser/profiles/avatar_menu.h" | 8 #include "chrome/browser/profiles/avatar_menu.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/profiles/profile_info_cache.h" | 10 #include "chrome/browser/profiles/profile_info_cache.h" |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 string16 text; | 88 string16 text; |
89 bool is_rectangle = false; | 89 bool is_rectangle = false; |
90 if (browser_view_->IsGuestSession()) { | 90 if (browser_view_->IsGuestSession()) { |
91 avatar = rb.GetImageNamed(browser_view_->GetGuestIconResourceID()); | 91 avatar = rb.GetImageNamed(browser_view_->GetGuestIconResourceID()); |
92 } else if (browser_view_->IsOffTheRecord()) { | 92 } else if (browser_view_->IsOffTheRecord()) { |
93 avatar = rb.GetImageNamed(browser_view_->GetOTRIconResourceID()); | 93 avatar = rb.GetImageNamed(browser_view_->GetOTRIconResourceID()); |
94 } else if (avatar_button_ || AvatarMenu::ShouldShowAvatarMenu()) { | 94 } else if (avatar_button_ || AvatarMenu::ShouldShowAvatarMenu()) { |
95 ProfileInfoCache& cache = | 95 ProfileInfoCache& cache = |
96 g_browser_process->profile_manager()->GetProfileInfoCache(); | 96 g_browser_process->profile_manager()->GetProfileInfoCache(); |
97 Profile* profile = browser_view_->browser()->profile(); | 97 Profile* profile = browser_view_->browser()->profile(); |
98 size_t index = cache.GetIndexOfProfileWithPath(profile->GetPath()); | 98 |
99 if (index == std::string::npos) | 99 ProfileInfoEntry entry; |
| 100 if (!cache.GetInfoForProfile(profile->GetPath(), &entry)) |
100 return; | 101 return; |
101 text = cache.GetNameOfProfileAtIndex(index); | 102 |
| 103 text = entry.GetDisplayName(); |
102 | 104 |
103 AvatarMenu::GetImageForMenuButton(browser_view_->browser()->profile(), | 105 AvatarMenu::GetImageForMenuButton(browser_view_->browser()->profile(), |
104 &avatar, | 106 &avatar, |
105 &is_rectangle); | 107 &is_rectangle); |
106 // Disable the menu when we should not show the menu. | 108 // Disable the menu when we should not show the menu. |
107 if (avatar_button_ && !AvatarMenu::ShouldShowAvatarMenu()) | 109 if (avatar_button_ && !AvatarMenu::ShouldShowAvatarMenu()) |
108 avatar_button_->SetEnabled(false); | 110 avatar_button_->SetEnabled(false); |
109 } | 111 } |
110 if (avatar_button_) { | 112 if (avatar_button_) { |
111 avatar_button_->SetAvatarIcon(avatar, is_rectangle); | 113 avatar_button_->SetAvatarIcon(avatar, is_rectangle); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 void BrowserNonClientFrameView::ShowProfileChooserViewBubble() { | 149 void BrowserNonClientFrameView::ShowProfileChooserViewBubble() { |
148 gfx::Point origin; | 150 gfx::Point origin; |
149 views::View::ConvertPointToScreen(new_avatar_button(), &origin); | 151 views::View::ConvertPointToScreen(new_avatar_button(), &origin); |
150 gfx::Rect bounds(origin, size()); | 152 gfx::Rect bounds(origin, size()); |
151 | 153 |
152 ProfileChooserView::ShowBubble( | 154 ProfileChooserView::ShowBubble( |
153 new_avatar_button(), views::BubbleBorder::TOP_RIGHT, | 155 new_avatar_button(), views::BubbleBorder::TOP_RIGHT, |
154 views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE, bounds, | 156 views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE, bounds, |
155 browser_view_->browser()); | 157 browser_view_->browser()); |
156 } | 158 } |
OLD | NEW |