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_avatar_icon_util.h" | 10 #include "chrome/browser/profiles/profile_avatar_icon_util.h" |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 RemoveChildView(supervised_user_avatar_label_); | 208 RemoveChildView(supervised_user_avatar_label_); |
209 delete supervised_user_avatar_label_; | 209 delete supervised_user_avatar_label_; |
210 supervised_user_avatar_label_ = nullptr; | 210 supervised_user_avatar_label_ = nullptr; |
211 } | 211 } |
212 #endif | 212 #endif |
213 RemoveChildView(avatar_button_); | 213 RemoveChildView(avatar_button_); |
214 delete avatar_button_; | 214 delete avatar_button_; |
215 avatar_button_ = nullptr; | 215 avatar_button_ = nullptr; |
216 frame_->GetRootView()->Layout(); | 216 frame_->GetRootView()->Layout(); |
217 } | 217 } |
218 | |
219 gfx::Image avatar; | |
220 gfx::Image taskbar_badge_avatar; | |
221 bool is_rectangle = false; | |
222 | |
223 // Update the avatar button in the window frame and the taskbar overlay. | |
224 bool should_show_avatar_menu = | |
225 avatar_button_ || AvatarMenu::ShouldShowAvatarMenu(); | |
226 | |
227 if (!AvatarMenuButton::GetAvatarImages( | |
228 browser_view_->browser()->profile(), should_show_avatar_menu, &avatar, | |
229 &taskbar_badge_avatar, &is_rectangle)) { | |
230 return; | |
231 } | |
232 | |
233 // Disable the menu when we should not show the menu. | |
234 if (avatar_button_ && !AvatarMenu::ShouldShowAvatarMenu()) | |
235 avatar_button_->SetEnabled(false); | |
236 if (avatar_button_) | |
237 avatar_button_->SetAvatarIcon(avatar, is_rectangle); | |
238 } | 218 } |
239 | 219 |
240 void BrowserNonClientFrameView::UpdateNewAvatarButton( | 220 void BrowserNonClientFrameView::UpdateNewAvatarButton( |
241 views::ButtonListener* listener, | 221 views::ButtonListener* listener, |
242 const NewAvatarButton::AvatarButtonStyle style) { | 222 const NewAvatarButton::AvatarButtonStyle style) { |
243 DCHECK(switches::IsNewAvatarMenu()); | 223 DCHECK(switches::IsNewAvatarMenu()); |
244 // This should never be called in incognito mode. | 224 // This should never be called in incognito mode. |
245 DCHECK(browser_view_->IsRegularOrGuestSession()); | 225 DCHECK(browser_view_->IsRegularOrGuestSession()); |
246 | 226 |
247 if (browser_view_->ShouldShowAvatar()) { | 227 if (browser_view_->ShouldShowAvatar()) { |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 const ProfileInfoCache& cache = | 288 const ProfileInfoCache& cache = |
309 g_browser_process->profile_manager()->GetProfileInfoCache(); | 289 g_browser_process->profile_manager()->GetProfileInfoCache(); |
310 show_decoration = show_decoration && cache.GetNumberOfProfiles() > 1; | 290 show_decoration = show_decoration && cache.GetNumberOfProfiles() > 1; |
311 } | 291 } |
312 chrome::DrawTaskbarDecoration(frame_->GetNativeWindow(), | 292 chrome::DrawTaskbarDecoration(frame_->GetNativeWindow(), |
313 show_decoration | 293 show_decoration |
314 ? (taskbar_badge_avatar.IsEmpty() ? &avatar : &taskbar_badge_avatar) | 294 ? (taskbar_badge_avatar.IsEmpty() ? &avatar : &taskbar_badge_avatar) |
315 : nullptr); | 295 : nullptr); |
316 } | 296 } |
317 } | 297 } |
OLD | NEW |