Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(254)

Side by Side Diff: ash/system/user/tray_user.cc

Issue 12052016: ash: Prevent negative sizes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 // Check for null to avoid crbug.com/150944. 640 // Check for null to avoid crbug.com/150944.
640 if (avatar_) { 641 if (avatar_) {
641 avatar_->SetImage( 642 avatar_->SetImage(
642 ash::Shell::GetInstance()->system_tray_delegate()->GetUserImage(), 643 ash::Shell::GetInstance()->system_tray_delegate()->GetUserImage(),
643 gfx::Size(kUserIconSize, kUserIconSize)); 644 gfx::Size(kUserIconSize, kUserIconSize));
644 } 645 }
645 } 646 }
646 647
647 } // namespace internal 648 } // namespace internal
648 } // namespace ash 649 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698