OLD | NEW |
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/system/user/user_view.h" | 5 #include "ash/system/user/user_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "ash/multi_profile_uma.h" | 9 #include "ash/multi_profile_uma.h" |
10 #include "ash/popup_message.h" | 10 #include "ash/popup_message.h" |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 UserView::UserView(SystemTrayItem* owner, | 204 UserView::UserView(SystemTrayItem* owner, |
205 user::LoginStatus login, | 205 user::LoginStatus login, |
206 MultiProfileIndex index, | 206 MultiProfileIndex index, |
207 bool for_detailed_view) | 207 bool for_detailed_view) |
208 : multiprofile_index_(index), | 208 : multiprofile_index_(index), |
209 user_card_view_(NULL), | 209 user_card_view_(NULL), |
210 owner_(owner), | 210 owner_(owner), |
211 is_user_card_button_(false), | 211 is_user_card_button_(false), |
212 logout_button_(NULL), | 212 logout_button_(NULL), |
213 add_user_disabled_(false), | 213 add_user_disabled_(false), |
214 for_detailed_view_(for_detailed_view) { | 214 for_detailed_view_(for_detailed_view), |
| 215 focus_manager_(NULL) { |
215 CHECK_NE(user::LOGGED_IN_NONE, login); | 216 CHECK_NE(user::LOGGED_IN_NONE, login); |
216 if (!index) { | 217 if (!index) { |
217 // Only the logged in user will have a background. All other users will have | 218 // Only the logged in user will have a background. All other users will have |
218 // to allow the TrayPopupContainer highlighting the menu line. | 219 // to allow the TrayPopupContainer highlighting the menu line. |
219 set_background(views::Background::CreateSolidBackground( | 220 set_background(views::Background::CreateSolidBackground( |
220 login == user::LOGGED_IN_PUBLIC ? kPublicAccountBackgroundColor | 221 login == user::LOGGED_IN_PUBLIC ? kPublicAccountBackgroundColor |
221 : kBackgroundColor)); | 222 : kBackgroundColor)); |
222 } | 223 } |
223 SetLayoutManager(new views::BoxLayout( | 224 SetLayoutManager(new views::BoxLayout( |
224 views::BoxLayout::kHorizontal, 0, 0, kTrayPopupPaddingBetweenItems)); | 225 views::BoxLayout::kHorizontal, 0, 0, kTrayPopupPaddingBetweenItems)); |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
526 } | 527 } |
527 } | 528 } |
528 // Find the screen area which encloses both elements and sets then a mouse | 529 // Find the screen area which encloses both elements and sets then a mouse |
529 // watcher which will close the "menu". | 530 // watcher which will close the "menu". |
530 gfx::Rect area = user_card_view_->GetBoundsInScreen(); | 531 gfx::Rect area = user_card_view_->GetBoundsInScreen(); |
531 area.set_height(2 * area.height()); | 532 area.set_height(2 * area.height()); |
532 mouse_watcher_.reset( | 533 mouse_watcher_.reset( |
533 new views::MouseWatcher(new UserViewMouseWatcherHost(area), this)); | 534 new views::MouseWatcher(new UserViewMouseWatcherHost(area), this)); |
534 mouse_watcher_->Start(); | 535 mouse_watcher_->Start(); |
535 // Install a listener to focus changes so that we can remove the card when | 536 // Install a listener to focus changes so that we can remove the card when |
536 // the focus gets changed. | 537 // the focus gets changed. When called through the destruction of the bubble, |
537 user_card_view_->GetFocusManager()->AddFocusChangeListener(this); | 538 // the FocusManager cannot be determined anymore and we remember it here. |
| 539 focus_manager_ = user_card_view_->GetFocusManager(); |
| 540 focus_manager_->AddFocusChangeListener(this); |
538 } | 541 } |
539 | 542 |
540 void UserView::RemoveAddUserMenuOption() { | 543 void UserView::RemoveAddUserMenuOption() { |
541 if (!add_menu_option_.get()) | 544 if (!add_menu_option_.get()) |
542 return; | 545 return; |
543 user_card_view_->GetFocusManager()->RemoveFocusChangeListener(this); | 546 focus_manager_->RemoveFocusChangeListener(this); |
544 user_card_view_->GetFocusManager()->ClearFocus(); | 547 focus_manager_ = NULL; |
| 548 if (user_card_view_->GetFocusManager()) |
| 549 user_card_view_->GetFocusManager()->ClearFocus(); |
545 popup_message_.reset(); | 550 popup_message_.reset(); |
546 mouse_watcher_.reset(); | 551 mouse_watcher_.reset(); |
547 add_menu_option_.reset(); | 552 add_menu_option_.reset(); |
548 } | 553 } |
549 | 554 |
550 } // namespace tray | 555 } // namespace tray |
551 } // namespace ash | 556 } // namespace ash |
OLD | NEW |