| 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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 const ProfileInfoCache& cache = | 290 const ProfileInfoCache& cache = |
| 311 g_browser_process->profile_manager()->GetProfileInfoCache(); | 291 g_browser_process->profile_manager()->GetProfileInfoCache(); |
| 312 show_decoration = show_decoration && cache.GetNumberOfProfiles() > 1; | 292 show_decoration = show_decoration && cache.GetNumberOfProfiles() > 1; |
| 313 } | 293 } |
| 314 chrome::DrawTaskbarDecoration(frame_->GetNativeWindow(), | 294 chrome::DrawTaskbarDecoration(frame_->GetNativeWindow(), |
| 315 show_decoration | 295 show_decoration |
| 316 ? (taskbar_badge_avatar.IsEmpty() ? &avatar : &taskbar_badge_avatar) | 296 ? (taskbar_badge_avatar.IsEmpty() ? &avatar : &taskbar_badge_avatar) |
| 317 : nullptr); | 297 : nullptr); |
| 318 } | 298 } |
| 319 } | 299 } |
| OLD | NEW |