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

Side by Side Diff: ash/common/system/user/user_view.cc

Issue 2684313004: Additional cleanup of pre-md system menu user row code. (Closed)
Patch Set: Created 3 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 unified diff | Download patch
« no previous file with comments | « ash/common/system/user/user_view.h ('k') | ash/resources/ash_resources.grd » ('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 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/user/user_view.h" 5 #include "ash/common/system/user/user_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "ash/common/multi_profile_uma.h" 10 #include "ash/common/multi_profile_uma.h"
11 #include "ash/common/popup_message.h"
12 #include "ash/common/session/session_state_delegate.h" 11 #include "ash/common/session/session_state_delegate.h"
13 #include "ash/common/shell_delegate.h" 12 #include "ash/common/shell_delegate.h"
14 #include "ash/common/system/tray/system_tray.h" 13 #include "ash/common/system/tray/system_tray.h"
15 #include "ash/common/system/tray/system_tray_controller.h" 14 #include "ash/common/system/tray/system_tray_controller.h"
16 #include "ash/common/system/tray/system_tray_delegate.h" 15 #include "ash/common/system/tray/system_tray_delegate.h"
17 #include "ash/common/system/tray/tray_constants.h" 16 #include "ash/common/system/tray/tray_constants.h"
18 #include "ash/common/system/tray/tray_popup_item_style.h" 17 #include "ash/common/system/tray/tray_popup_item_style.h"
19 #include "ash/common/system/tray/tray_popup_utils.h" 18 #include "ash/common/system/tray/tray_popup_utils.h"
20 #include "ash/common/system/user/button_from_view.h" 19 #include "ash/common/system/user/button_from_view.h"
21 #include "ash/common/system/user/login_status.h" 20 #include "ash/common/system/user/login_status.h"
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 229
231 if (IsActiveUser()) 230 if (IsActiveUser())
232 SetBorder(base::MakeUnique<ActiveUserBorder>()); 231 SetBorder(base::MakeUnique<ActiveUserBorder>());
233 } 232 }
234 233
235 UserView::~UserView() { 234 UserView::~UserView() {
236 RemoveAddUserMenuOption(); 235 RemoveAddUserMenuOption();
237 } 236 }
238 237
239 TrayUser::TestState UserView::GetStateForTest() const { 238 TrayUser::TestState UserView::GetStateForTest() const {
240 if (add_menu_option_.get()) { 239 if (add_menu_option_)
241 return add_user_enabled_ ? TrayUser::ACTIVE : TrayUser::ACTIVE_BUT_DISABLED; 240 return add_user_enabled_ ? TrayUser::ACTIVE : TrayUser::ACTIVE_BUT_DISABLED;
242 }
243 241
244 if (!is_user_card_button_) 242 if (!is_user_card_button_)
245 return TrayUser::SHOWN; 243 return TrayUser::SHOWN;
246 244
247 return static_cast<ButtonFromView*>(user_card_view_)->is_hovered_for_test() 245 return static_cast<ButtonFromView*>(user_card_view_)->is_hovered_for_test()
248 ? TrayUser::HOVERED 246 ? TrayUser::HOVERED
249 : TrayUser::SHOWN; 247 : TrayUser::SHOWN;
250 } 248 }
251 249
252 gfx::Rect UserView::GetBoundsInScreenOfUserButtonForTest() { 250 gfx::Rect UserView::GetBoundsInScreenOfUserButtonForTest() {
(...skipping 18 matching lines...) Expand all
271 IsMultiProfileSupportedAndUserActive()) { 269 IsMultiProfileSupportedAndUserActive()) {
272 if (IsActiveUser()) { 270 if (IsActiveUser()) {
273 ToggleAddUserMenuOption(); 271 ToggleAddUserMenuOption();
274 } else { 272 } else {
275 RemoveAddUserMenuOption(); 273 RemoveAddUserMenuOption();
276 SwitchUser(user_index_); 274 SwitchUser(user_index_);
277 // Since the user list is about to change the system menu should get 275 // Since the user list is about to change the system menu should get
278 // closed. 276 // closed.
279 owner_->system_tray()->CloseSystemBubble(); 277 owner_->system_tray()->CloseSystemBubble();
280 } 278 }
281 } else if (add_menu_option_.get() && 279 } else if (add_menu_option_ &&
282 sender->GetWidget() == add_menu_option_.get()) { 280 sender->GetWidget() == add_menu_option_.get()) {
283 RemoveAddUserMenuOption(); 281 RemoveAddUserMenuOption();
284 // Let the user add another account to the session. 282 // Let the user add another account to the session.
285 MultiProfileUMA::RecordSigninUser(MultiProfileUMA::SIGNIN_USER_BY_TRAY); 283 MultiProfileUMA::RecordSigninUser(MultiProfileUMA::SIGNIN_USER_BY_TRAY);
286 WmShell::Get()->system_tray_delegate()->ShowUserLogin(); 284 WmShell::Get()->system_tray_delegate()->ShowUserLogin();
287 owner_->system_tray()->CloseSystemBubble(); 285 owner_->system_tray()->CloseSystemBubble();
288 } else { 286 } else {
289 NOTREACHED(); 287 NOTREACHED();
290 } 288 }
291 } 289 }
(...skipping 26 matching lines...) Expand all
318 new ButtonFromView(contents_view, this, 316 new ButtonFromView(contents_view, this,
319 IsActiveUser() ? TrayPopupInkDropStyle::INSET_BOUNDS 317 IsActiveUser() ? TrayPopupInkDropStyle::INSET_BOUNDS
320 : TrayPopupInkDropStyle::FILL_BOUNDS); 318 : TrayPopupInkDropStyle::FILL_BOUNDS);
321 user_card_view_ = button; 319 user_card_view_ = button;
322 is_user_card_button_ = true; 320 is_user_card_button_ = true;
323 } 321 }
324 AddChildViewAt(user_card_view_, 0); 322 AddChildViewAt(user_card_view_, 0);
325 } 323 }
326 324
327 void UserView::ToggleAddUserMenuOption() { 325 void UserView::ToggleAddUserMenuOption() {
328 if (add_menu_option_.get()) { 326 if (add_menu_option_) {
329 RemoveAddUserMenuOption(); 327 RemoveAddUserMenuOption();
330 return; 328 return;
331 } 329 }
332 330
333 // Note: We do not need to install a global event handler to delete this 331 // Note: We do not need to install a global event handler to delete this
334 // item since it will destroyed automatically before the menu / user menu item 332 // item since it will destroyed automatically before the menu / user menu item
335 // gets destroyed.. 333 // gets destroyed..
336 add_menu_option_.reset(new views::Widget); 334 add_menu_option_.reset(new views::Widget);
337 views::Widget::InitParams params; 335 views::Widget::InitParams params;
338 params.type = views::Widget::InitParams::TYPE_TOOLTIP; 336 params.type = views::Widget::InitParams::TYPE_TOOLTIP;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 } 389 }
392 390
393 // Install a listener to focus changes so that we can remove the card when 391 // Install a listener to focus changes so that we can remove the card when
394 // the focus gets changed. When called through the destruction of the bubble, 392 // the focus gets changed. When called through the destruction of the bubble,
395 // the FocusManager cannot be determined anymore and we remember it here. 393 // the FocusManager cannot be determined anymore and we remember it here.
396 focus_manager_ = user_card_view_->GetFocusManager(); 394 focus_manager_ = user_card_view_->GetFocusManager();
397 focus_manager_->AddFocusChangeListener(this); 395 focus_manager_->AddFocusChangeListener(this);
398 } 396 }
399 397
400 void UserView::RemoveAddUserMenuOption() { 398 void UserView::RemoveAddUserMenuOption() {
401 if (!add_menu_option_.get()) 399 if (!add_menu_option_)
402 return; 400 return;
403 focus_manager_->RemoveFocusChangeListener(this); 401 focus_manager_->RemoveFocusChangeListener(this);
404 focus_manager_ = nullptr; 402 focus_manager_ = nullptr;
405 if (user_card_view_->GetFocusManager()) 403 if (user_card_view_->GetFocusManager())
406 user_card_view_->GetFocusManager()->ClearFocus(); 404 user_card_view_->GetFocusManager()->ClearFocus();
407 popup_message_.reset();
408 add_menu_option_.reset(); 405 add_menu_option_.reset();
409 } 406 }
410 407
411 } // namespace tray 408 } // namespace tray
412 } // namespace ash 409 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/system/user/user_view.h ('k') | ash/resources/ash_resources.grd » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698