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 <algorithm> | 7 #include <algorithm> |
8 #include <climits> | 8 #include <climits> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 gfx::Rect contents_area(GetContentsBounds()); | 425 gfx::Rect contents_area(GetContentsBounds()); |
426 if (user_card_ && logout_button_) { | 426 if (user_card_ && logout_button_) { |
427 // Give the logout button the space it requests. | 427 // Give the logout button the space it requests. |
428 gfx::Rect logout_area = contents_area; | 428 gfx::Rect logout_area = contents_area; |
429 logout_area.ClampToCenteredSize(logout_button_->GetPreferredSize()); | 429 logout_area.ClampToCenteredSize(logout_button_->GetPreferredSize()); |
430 logout_area.set_x(contents_area.right() - logout_area.width()); | 430 logout_area.set_x(contents_area.right() - logout_area.width()); |
431 logout_button_->SetBoundsRect(logout_area); | 431 logout_button_->SetBoundsRect(logout_area); |
432 | 432 |
433 // Give the remaining space to the user card. | 433 // Give the remaining space to the user card. |
434 gfx::Rect user_card_area = contents_area; | 434 gfx::Rect user_card_area = contents_area; |
435 user_card_area.set_width(contents_area.width() - | 435 int remaining_width = contents_area.width() - |
436 (logout_area.width() + kTrayPopupPaddingBetweenItems)); | 436 (logout_area.width() + kTrayPopupPaddingBetweenItems); |
| 437 user_card_area.set_width(std::max(0, remaining_width)); |
437 user_card_->SetBoundsRect(user_card_area); | 438 user_card_->SetBoundsRect(user_card_area); |
438 } else if (user_card_) { | 439 } else if (user_card_) { |
439 user_card_->SetBoundsRect(contents_area); | 440 user_card_->SetBoundsRect(contents_area); |
440 } else if (logout_button_) { | 441 } else if (logout_button_) { |
441 logout_button_->SetBoundsRect(contents_area); | 442 logout_button_->SetBoundsRect(contents_area); |
442 } | 443 } |
443 } | 444 } |
444 | 445 |
445 void UserView::ButtonPressed(views::Button* sender, const ui::Event& event) { | 446 void UserView::ButtonPressed(views::Button* sender, const ui::Event& event) { |
446 DCHECK_EQ(logout_button_, sender); | 447 DCHECK_EQ(logout_button_, sender); |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
636 // Check for null to avoid crbug.com/150944. | 637 // Check for null to avoid crbug.com/150944. |
637 if (avatar_) { | 638 if (avatar_) { |
638 avatar_->SetImage( | 639 avatar_->SetImage( |
639 ash::Shell::GetInstance()->system_tray_delegate()->GetUserImage(), | 640 ash::Shell::GetInstance()->system_tray_delegate()->GetUserImage(), |
640 gfx::Size(kUserIconSize, kUserIconSize)); | 641 gfx::Size(kUserIconSize, kUserIconSize)); |
641 } | 642 } |
642 } | 643 } |
643 | 644 |
644 } // namespace internal | 645 } // namespace internal |
645 } // namespace ash | 646 } // namespace ash |
OLD | NEW |