| 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 "ash/system/user/tray_user.h" | 5 #include "ash/system/user/tray_user.h" |
| 6 | 6 |
| 7 #include "ash/session/session_controller.h" | 7 #include "ash/session/session_controller.h" |
| 8 #include "ash/shelf/wm_shelf_util.h" | 8 #include "ash/shelf/wm_shelf.h" |
| 9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 10 #include "ash/shell_port.h" | 10 #include "ash/shell_port.h" |
| 11 #include "ash/strings/grit/ash_strings.h" | 11 #include "ash/strings/grit/ash_strings.h" |
| 12 #include "ash/system/tray/system_tray.h" | 12 #include "ash/system/tray/system_tray.h" |
| 13 #include "ash/system/tray/tray_constants.h" | 13 #include "ash/system/tray/tray_constants.h" |
| 14 #include "ash/system/tray/tray_item_view.h" | 14 #include "ash/system/tray/tray_item_view.h" |
| 15 #include "ash/system/tray/tray_utils.h" | 15 #include "ash/system/tray/tray_utils.h" |
| 16 #include "ash/system/user/rounded_image_view.h" | 16 #include "ash/system/user/rounded_image_view.h" |
| 17 #include "ash/system/user/user_view.h" | 17 #include "ash/system/user/user_view.h" |
| 18 #include "base/logging.h" | 18 #include "base/logging.h" |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 } else if (status == LoginStatus::GUEST) { | 162 } else if (status == LoginStatus::GUEST) { |
| 163 label_->SetText(l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_GUEST_LABEL)); | 163 label_->SetText(l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_GUEST_LABEL)); |
| 164 } | 164 } |
| 165 | 165 |
| 166 UpdateAvatarImage(status); | 166 UpdateAvatarImage(status); |
| 167 | 167 |
| 168 // Update layout after setting label_ and avatar_ with new login status. | 168 // Update layout after setting label_ and avatar_ with new login status. |
| 169 UpdateLayoutOfItem(); | 169 UpdateLayoutOfItem(); |
| 170 } | 170 } |
| 171 | 171 |
| 172 void TrayUser::UpdateAfterShelfAlignmentChange(ShelfAlignment alignment) { | 172 void TrayUser::UpdateAfterShelfAlignmentChange() { |
| 173 // Inactive users won't have a layout. | 173 // Inactive users won't have a layout. |
| 174 if (!layout_view_) | 174 if (!layout_view_) |
| 175 return; | 175 return; |
| 176 if (IsHorizontalAlignment(alignment)) { | 176 if (system_tray()->shelf()->IsHorizontalAlignment()) { |
| 177 if (avatar_) { | 177 if (avatar_) { |
| 178 avatar_->SetCornerRadii(0, kTrayRoundedBorderRadius, | 178 avatar_->SetCornerRadii(0, kTrayRoundedBorderRadius, |
| 179 kTrayRoundedBorderRadius, 0); | 179 kTrayRoundedBorderRadius, 0); |
| 180 } | 180 } |
| 181 if (label_) { | 181 if (label_) { |
| 182 // If label_ hasn't figured out its size yet, do that first. | 182 // If label_ hasn't figured out its size yet, do that first. |
| 183 if (label_->GetContentsBounds().height() == 0) | 183 if (label_->GetContentsBounds().height() == 0) |
| 184 label_->SizeToPreferredSize(); | 184 label_->SizeToPreferredSize(); |
| 185 int height = label_->GetContentsBounds().height(); | 185 int height = label_->GetContentsBounds().height(); |
| 186 int vertical_pad = (kTrayItemSize - height) / 2; | 186 int vertical_pad = (kTrayItemSize - height) / 2; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 CHECK(user_session); | 242 CHECK(user_session); |
| 243 avatar_->SetImage(user_session->avatar, | 243 avatar_->SetImage(user_session->avatar, |
| 244 gfx::Size(kTrayItemSize, kTrayItemSize)); | 244 gfx::Size(kTrayItemSize, kTrayItemSize)); |
| 245 | 245 |
| 246 // Unit tests might come here with no images for some users. | 246 // Unit tests might come here with no images for some users. |
| 247 if (avatar_->size().IsEmpty()) | 247 if (avatar_->size().IsEmpty()) |
| 248 avatar_->SetSize(gfx::Size(kTrayItemSize, kTrayItemSize)); | 248 avatar_->SetSize(gfx::Size(kTrayItemSize, kTrayItemSize)); |
| 249 } | 249 } |
| 250 | 250 |
| 251 void TrayUser::UpdateLayoutOfItem() { | 251 void TrayUser::UpdateLayoutOfItem() { |
| 252 UpdateAfterShelfAlignmentChange(system_tray()->shelf_alignment()); | 252 UpdateAfterShelfAlignmentChange(); |
| 253 } | 253 } |
| 254 | 254 |
| 255 } // namespace ash | 255 } // namespace ash |
| OLD | NEW |