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

Side by Side 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, 9 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 | « ash/system/user/tray_user.h ('k') | chrome/browser/chromeos/login/login_utils.cc » ('j') | 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/tray_user.h" 5 #include "ash/system/user/tray_user.h"
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/system/tray/system_tray_delegate.h" 8 #include "ash/system/tray/system_tray_delegate.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "grit/ash_strings.h" 10 #include "grit/ash_strings.h"
11 #include "ui/base/resource/resource_bundle.h" 11 #include "ui/base/resource/resource_bundle.h"
12 #include "ui/gfx/size.h" 12 #include "ui/gfx/size.h"
13 #include "ui/views/controls/button/button.h" 13 #include "ui/views/controls/button/button.h"
14 #include "ui/views/controls/button/text_button.h" 14 #include "ui/views/controls/button/text_button.h"
15 #include "ui/views/controls/image_view.h" 15 #include "ui/views/controls/image_view.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 58
59 bool hover_; 59 bool hover_;
60 views::Background* hover_bg_; 60 views::Background* hover_bg_;
61 61
62 DISALLOW_COPY_AND_ASSIGN(TrayButton); 62 DISALLOW_COPY_AND_ASSIGN(TrayButton);
63 }; 63 };
64 64
65 class UserView : public views::View, 65 class UserView : public views::View,
66 public views::ButtonListener { 66 public views::ButtonListener {
67 public: 67 public:
68 UserView() { 68 explicit UserView(ash::user::LoginStatus status)
69 : username_(NULL),
70 email_(NULL),
71 shutdown_(NULL),
72 signout_(NULL),
73 lock_(NULL) {
74 CHECK(status != ash::user::LOGGED_IN_NONE);
69 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 75 SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical,
70 0, 0, 3)); 76 0, 0, 3));
71 77
72 views::View* user = new views::View; 78 if (status != ash::user::LOGGED_IN_GUEST) {
73 user->SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 79 views::View* user = new views::View;
74 14, 5, 0)); 80 user->SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical,
75 ash::SystemTrayDelegate* tray = ash::Shell::GetInstance()->tray_delegate(); 81 14, 5, 0));
76 username_ = new views::Label(ASCIIToUTF16(tray->GetUserDisplayName())); 82 ash::SystemTrayDelegate* tray =
77 username_->SetFont(username_->font().DeriveFont(2)); 83 ash::Shell::GetInstance()->tray_delegate();
78 username_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); 84 username_ = new views::Label(ASCIIToUTF16(tray->GetUserDisplayName()));
79 user->AddChildView(username_); 85 username_->SetFont(username_->font().DeriveFont(2));
86 username_->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
87 user->AddChildView(username_);
80 88
81 email_ = new views::Label(ASCIIToUTF16(tray->GetUserEmail())); 89 email_ = new views::Label(ASCIIToUTF16(tray->GetUserEmail()));
82 email_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); 90 email_->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
83 email_->SetEnabled(false); 91 email_->SetEnabled(false);
84 user->AddChildView(email_); 92 user->AddChildView(email_);
85 93
86 AddChildView(user); 94 AddChildView(user);
95 }
87 96
88 views::View* button_container = new views::View; 97 views::View* button_container = new views::View;
89 views::BoxLayout *layout = new 98 views::BoxLayout *layout = new
90 views::BoxLayout(views::BoxLayout::kHorizontal, 0, 5, 0); 99 views::BoxLayout(views::BoxLayout::kHorizontal, 0, 5, 0);
91 layout->set_spread_blank_space(true); 100 layout->set_spread_blank_space(true);
92 button_container->SetLayoutManager(layout); 101 button_container->SetLayoutManager(layout);
93 102
94 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); 103 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
95 104
96 shutdown_ = new TrayButton(this, bundle.GetLocalizedString( 105 shutdown_ = new TrayButton(this, bundle.GetLocalizedString(
97 IDS_ASH_STATUS_TRAY_SHUT_DOWN)); 106 IDS_ASH_STATUS_TRAY_SHUT_DOWN));
107 shutdown_->set_border(NULL);
108 button_container->AddChildView(shutdown_);
109
98 signout_ = new TrayButton(this, bundle.GetLocalizedString( 110 signout_ = new TrayButton(this, bundle.GetLocalizedString(
99 IDS_ASH_STATUS_TRAY_SIGN_OUT)); 111 status == ash::user::LOGGED_IN_GUEST ? IDS_ASH_STATUS_TRAY_EXIT_GUEST :
100 lock_ = new TrayButton(this, bundle.GetLocalizedString( 112 IDS_ASH_STATUS_TRAY_SIGN_OUT));
101 IDS_ASH_STATUS_TRAY_LOCK));
102 button_container->AddChildView(shutdown_);
103 button_container->AddChildView(signout_);
104 button_container->AddChildView(lock_);
105
106 shutdown_->set_border(NULL);
107 signout_->set_border(views::Border::CreateSolidSidedBorder( 113 signout_->set_border(views::Border::CreateSolidSidedBorder(
108 0, 1, 0, 1, SkColorSetARGB(25, 0, 0, 0))); 114 0, 1, 0, 1, SkColorSetARGB(25, 0, 0, 0)));
109 lock_->set_border(NULL); 115 button_container->AddChildView(signout_);
116
117 if (status != ash::user::LOGGED_IN_GUEST) {
118 lock_ = new TrayButton(this, bundle.GetLocalizedString(
119 IDS_ASH_STATUS_TRAY_LOCK));
120 button_container->AddChildView(lock_);
121 lock_->set_border(NULL);
122 }
110 123
111 AddChildView(button_container); 124 AddChildView(button_container);
112 } 125 }
113 126
114 private: 127 private:
115 // Overridden from views::ButtonListener. 128 // Overridden from views::ButtonListener.
116 virtual void ButtonPressed(views::Button* sender, 129 virtual void ButtonPressed(views::Button* sender,
117 const views::Event& event) OVERRIDE { 130 const views::Event& event) OVERRIDE {
118 ash::SystemTrayDelegate* tray = ash::Shell::GetInstance()->tray_delegate(); 131 ash::SystemTrayDelegate* tray = ash::Shell::GetInstance()->tray_delegate();
119 if (sender == shutdown_) 132 if (sender == shutdown_)
(...skipping 18 matching lines...) Expand all
138 151
139 namespace ash { 152 namespace ash {
140 namespace internal { 153 namespace internal {
141 154
142 TrayUser::TrayUser() { 155 TrayUser::TrayUser() {
143 } 156 }
144 157
145 TrayUser::~TrayUser() { 158 TrayUser::~TrayUser() {
146 } 159 }
147 160
148 views::View* TrayUser::CreateTrayView() { 161 views::View* TrayUser::CreateTrayView(user::LoginStatus status) {
149 views::ImageView* avatar = new views::ImageView; 162 views::ImageView* avatar = new views::ImageView;
150 avatar->SetImage(ash::Shell::GetInstance()->tray_delegate()->GetUserImage()); 163 if (status == user::LOGGED_IN_USER || status == user::LOGGED_IN_OWNER) {
151 avatar->SetImageSize(gfx::Size(32, 32)); 164 avatar->SetImage(
165 ash::Shell::GetInstance()->tray_delegate()->GetUserImage());
166 avatar->SetImageSize(gfx::Size(32, 32));
167 }
152 return avatar; 168 return avatar;
153 } 169 }
154 170
155 views::View* TrayUser::CreateDefaultView() { 171 views::View* TrayUser::CreateDefaultView(user::LoginStatus status) {
156 return new UserView; 172 return status == user::LOGGED_IN_NONE ? NULL : new UserView(status);
157 } 173 }
158 174
159 views::View* TrayUser::CreateDetailedView() { 175 views::View* TrayUser::CreateDetailedView(user::LoginStatus status) {
160 return NULL; 176 return NULL;
161 } 177 }
162 178
163 void TrayUser::DestroyTrayView() { 179 void TrayUser::DestroyTrayView() {
164 } 180 }
165 181
166 void TrayUser::DestroyDefaultView() { 182 void TrayUser::DestroyDefaultView() {
167 } 183 }
168 184
169 void TrayUser::DestroyDetailedView() { 185 void TrayUser::DestroyDetailedView() {
170 } 186 }
171 187
172 } // namespace internal 188 } // namespace internal
173 } // namespace ash 189 } // namespace ash
OLDNEW
« 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