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

Side by Side Diff: ash/common/system/chromeos/session/logout_button_tray.cc

Issue 2414533002: ash: Use legacy size for legacy logout button. (Closed)
Patch Set: Created 4 years, 2 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
« 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/common/system/chromeos/session/logout_button_tray.h" 5 #include "ash/common/system/chromeos/session/logout_button_tray.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "ash/common/material_design/material_design_controller.h" 10 #include "ash/common/material_design/material_design_controller.h"
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 button->set_bg_color_override(gfx::kGoogleRed700); 112 button->set_bg_color_override(gfx::kGoogleRed700);
113 // Base font size + 2 = 14. 113 // Base font size + 2 = 14.
114 // TODO(estade): should this 2 be shared with other tray views? See 114 // TODO(estade): should this 2 be shared with other tray views? See
115 // crbug.com/623987 115 // crbug.com/623987
116 button->AdjustFontSize(2); 116 button->AdjustFontSize(2);
117 button_ = button; 117 button_ = button;
118 } else { 118 } else {
119 button_ = new LogoutButton(this); 119 button_ = new LogoutButton(this);
120 } 120 }
121 tray_container()->AddChildView(button_); 121 tray_container()->AddChildView(button_);
122 if (!ash::MaterialDesignController::IsShelfMaterial()) 122 if (!MaterialDesignController::IsShelfMaterial())
123 tray_container()->SetBorder(views::Border::NullBorder()); 123 tray_container()->SetBorder(views::Border::NullBorder());
124 WmShell::Get()->system_tray_notifier()->AddLogoutButtonObserver(this); 124 WmShell::Get()->system_tray_notifier()->AddLogoutButtonObserver(this);
125 } 125 }
126 126
127 LogoutButtonTray::~LogoutButtonTray() { 127 LogoutButtonTray::~LogoutButtonTray() {
128 WmShell::Get()->system_tray_notifier()->RemoveLogoutButtonObserver(this); 128 WmShell::Get()->system_tray_notifier()->RemoveLogoutButtonObserver(this);
129 } 129 }
130 130
131 void LogoutButtonTray::SetShelfAlignment(ShelfAlignment alignment) { 131 void LogoutButtonTray::SetShelfAlignment(ShelfAlignment alignment) {
132 // We must first update the button so that 132 // We must first update the button so that
133 // TrayBackgroundView::SetShelfAlignment() can lay it out correctly. 133 // TrayBackgroundView::SetShelfAlignment() can lay it out correctly.
134 UpdateButtonTextAndImage(login_status_, alignment); 134 UpdateButtonTextAndImage(login_status_, alignment);
135 TrayBackgroundView::SetShelfAlignment(alignment); 135 TrayBackgroundView::SetShelfAlignment(alignment);
136 if (!ash::MaterialDesignController::IsShelfMaterial()) 136 if (!MaterialDesignController::IsShelfMaterial())
137 tray_container()->SetBorder(views::Border::NullBorder()); 137 tray_container()->SetBorder(views::Border::NullBorder());
138 } 138 }
139 139
140 base::string16 LogoutButtonTray::GetAccessibleNameForTray() { 140 base::string16 LogoutButtonTray::GetAccessibleNameForTray() {
141 return button_->GetText(); 141 return button_->GetText();
142 } 142 }
143 143
144 void LogoutButtonTray::HideBubbleWithView( 144 void LogoutButtonTray::HideBubbleWithView(
145 const views::TrayBubbleView* bubble_view) {} 145 const views::TrayBubbleView* bubble_view) {}
146 146
(...skipping 28 matching lines...) Expand all
175 SetVisible(show_logout_button_in_tray_ && 175 SetVisible(show_logout_button_in_tray_ &&
176 login_status_ != LoginStatus::NOT_LOGGED_IN && 176 login_status_ != LoginStatus::NOT_LOGGED_IN &&
177 login_status_ != LoginStatus::LOCKED); 177 login_status_ != LoginStatus::LOCKED);
178 } 178 }
179 179
180 void LogoutButtonTray::UpdateButtonTextAndImage(LoginStatus login_status, 180 void LogoutButtonTray::UpdateButtonTextAndImage(LoginStatus login_status,
181 ShelfAlignment alignment) { 181 ShelfAlignment alignment) {
182 login_status_ = login_status; 182 login_status_ = login_status;
183 const base::string16 title = 183 const base::string16 title =
184 user::GetLocalizedSignOutStringForStatus(login_status, false); 184 user::GetLocalizedSignOutStringForStatus(login_status, false);
185 const int kButtonMinSize = MaterialDesignController::IsShelfMaterial()
sadrul 2016/10/12 00:43:42 I think this would just be 'const int button_size
xiyuan 2016/10/12 15:28:11 Done.
186 ? kTrayItemSize
187 : GetTrayConstant(TRAY_ITEM_HEIGHT_LEGACY);
185 if (alignment == SHELF_ALIGNMENT_BOTTOM) { 188 if (alignment == SHELF_ALIGNMENT_BOTTOM) {
186 button_->SetText(title); 189 button_->SetText(title);
187 button_->SetImage(views::LabelButton::STATE_NORMAL, gfx::ImageSkia()); 190 button_->SetImage(views::LabelButton::STATE_NORMAL, gfx::ImageSkia());
188 button_->SetMinSize(gfx::Size(0, kTrayItemSize)); 191 button_->SetMinSize(gfx::Size(0, kButtonMinSize));
189 } else { 192 } else {
190 button_->SetText(base::string16()); 193 button_->SetText(base::string16());
191 button_->SetAccessibleName(title); 194 button_->SetAccessibleName(title);
192 button_->SetImage( 195 button_->SetImage(
193 views::LabelButton::STATE_NORMAL, 196 views::LabelButton::STATE_NORMAL,
194 gfx::CreateVectorIcon(gfx::VectorIconId::SHELF_LOGOUT, kTrayIconColor)); 197 gfx::CreateVectorIcon(gfx::VectorIconId::SHELF_LOGOUT, kTrayIconColor));
195 button_->SetMinSize(gfx::Size(kTrayItemSize, kTrayItemSize)); 198 button_->SetMinSize(gfx::Size(kButtonMinSize, kButtonMinSize));
196 } 199 }
197 UpdateVisibility(); 200 UpdateVisibility();
198 } 201 }
199 202
200 } // namespace ash 203 } // 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