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

Unified Diff: ash/system/user/tray_user.cc

Issue 9580024: ash uber tray: Allow customizing each item depending on whether the user is logged in or not. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: missing file Created 8 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/system/user/tray_user.h ('k') | chrome/browser/chromeos/login/login_utils.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/system/user/tray_user.cc
diff --git a/ash/system/tray_user.cc b/ash/system/user/tray_user.cc
similarity index 66%
rename from ash/system/tray_user.cc
rename to ash/system/user/tray_user.cc
index 1cdfde50c10ed97e801ad11a7de1639daa9c6d19..912f92f0b09e1185e7228150dd8ea337c567d1b4 100644
--- a/ash/system/tray_user.cc
+++ b/ash/system/user/tray_user.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "ash/system/tray_user.h"
+#include "ash/system/user/tray_user.h"
#include "ash/shell.h"
#include "ash/system/tray/system_tray_delegate.h"
@@ -65,25 +65,34 @@ class TrayButton : public views::TextButton {
class UserView : public views::View,
public views::ButtonListener {
public:
- UserView() {
+ explicit UserView(ash::user::LoginStatus status)
+ : username_(NULL),
+ email_(NULL),
+ shutdown_(NULL),
+ signout_(NULL),
+ lock_(NULL) {
+ CHECK(status != ash::user::LOGGED_IN_NONE);
SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical,
0, 0, 3));
- views::View* user = new views::View;
- user->SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical,
- 14, 5, 0));
- ash::SystemTrayDelegate* tray = ash::Shell::GetInstance()->tray_delegate();
- username_ = new views::Label(ASCIIToUTF16(tray->GetUserDisplayName()));
- username_->SetFont(username_->font().DeriveFont(2));
- username_->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
- user->AddChildView(username_);
-
- email_ = new views::Label(ASCIIToUTF16(tray->GetUserEmail()));
- email_->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
- email_->SetEnabled(false);
- user->AddChildView(email_);
-
- AddChildView(user);
+ if (status != ash::user::LOGGED_IN_GUEST) {
+ views::View* user = new views::View;
+ user->SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical,
+ 14, 5, 0));
+ ash::SystemTrayDelegate* tray =
+ ash::Shell::GetInstance()->tray_delegate();
+ username_ = new views::Label(ASCIIToUTF16(tray->GetUserDisplayName()));
+ username_->SetFont(username_->font().DeriveFont(2));
+ username_->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
+ user->AddChildView(username_);
+
+ email_ = new views::Label(ASCIIToUTF16(tray->GetUserEmail()));
+ email_->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
+ email_->SetEnabled(false);
+ user->AddChildView(email_);
+
+ AddChildView(user);
+ }
views::View* button_container = new views::View;
views::BoxLayout *layout = new
@@ -95,18 +104,22 @@ class UserView : public views::View,
shutdown_ = new TrayButton(this, bundle.GetLocalizedString(
IDS_ASH_STATUS_TRAY_SHUT_DOWN));
- signout_ = new TrayButton(this, bundle.GetLocalizedString(
- IDS_ASH_STATUS_TRAY_SIGN_OUT));
- lock_ = new TrayButton(this, bundle.GetLocalizedString(
- IDS_ASH_STATUS_TRAY_LOCK));
+ shutdown_->set_border(NULL);
button_container->AddChildView(shutdown_);
- button_container->AddChildView(signout_);
- button_container->AddChildView(lock_);
- shutdown_->set_border(NULL);
+ signout_ = new TrayButton(this, bundle.GetLocalizedString(
+ status == ash::user::LOGGED_IN_GUEST ? IDS_ASH_STATUS_TRAY_EXIT_GUEST :
+ IDS_ASH_STATUS_TRAY_SIGN_OUT));
signout_->set_border(views::Border::CreateSolidSidedBorder(
0, 1, 0, 1, SkColorSetARGB(25, 0, 0, 0)));
- lock_->set_border(NULL);
+ button_container->AddChildView(signout_);
+
+ if (status != ash::user::LOGGED_IN_GUEST) {
+ lock_ = new TrayButton(this, bundle.GetLocalizedString(
+ IDS_ASH_STATUS_TRAY_LOCK));
+ button_container->AddChildView(lock_);
+ lock_->set_border(NULL);
+ }
AddChildView(button_container);
}
@@ -145,18 +158,21 @@ TrayUser::TrayUser() {
TrayUser::~TrayUser() {
}
-views::View* TrayUser::CreateTrayView() {
+views::View* TrayUser::CreateTrayView(user::LoginStatus status) {
views::ImageView* avatar = new views::ImageView;
- avatar->SetImage(ash::Shell::GetInstance()->tray_delegate()->GetUserImage());
- avatar->SetImageSize(gfx::Size(32, 32));
+ if (status == user::LOGGED_IN_USER || status == user::LOGGED_IN_OWNER) {
+ avatar->SetImage(
+ ash::Shell::GetInstance()->tray_delegate()->GetUserImage());
+ avatar->SetImageSize(gfx::Size(32, 32));
+ }
return avatar;
}
-views::View* TrayUser::CreateDefaultView() {
- return new UserView;
+views::View* TrayUser::CreateDefaultView(user::LoginStatus status) {
+ return status == user::LOGGED_IN_NONE ? NULL : new UserView(status);
}
-views::View* TrayUser::CreateDetailedView() {
+views::View* TrayUser::CreateDetailedView(user::LoginStatus status) {
return NULL;
}
« no previous file with comments | « ash/system/user/tray_user.h ('k') | chrome/browser/chromeos/login/login_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698