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

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

Issue 2835233005: Revert of Introduce a type of View background that stays in sync with its host (Closed)
Patch Set: Created 3 years, 8 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
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/system/user/user_view.h" 5 #include "ash/system/user/user_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "ash/multi_profile_uma.h" 10 #include "ash/multi_profile_uma.h"
(...skipping 19 matching lines...) Expand all
30 #include "ash/wm_window.h" 30 #include "ash/wm_window.h"
31 #include "base/memory/ptr_util.h" 31 #include "base/memory/ptr_util.h"
32 #include "components/signin/core/account_id/account_id.h" 32 #include "components/signin/core/account_id/account_id.h"
33 #include "components/user_manager/user_info.h" 33 #include "components/user_manager/user_info.h"
34 #include "ui/base/l10n/l10n_util.h" 34 #include "ui/base/l10n/l10n_util.h"
35 #include "ui/base/resource/resource_bundle.h" 35 #include "ui/base/resource/resource_bundle.h"
36 #include "ui/gfx/canvas.h" 36 #include "ui/gfx/canvas.h"
37 #include "ui/gfx/color_utils.h" 37 #include "ui/gfx/color_utils.h"
38 #include "ui/gfx/geometry/insets.h" 38 #include "ui/gfx/geometry/insets.h"
39 #include "ui/gfx/paint_vector_icon.h" 39 #include "ui/gfx/paint_vector_icon.h"
40 #include "ui/native_theme/native_theme.h"
41 #include "ui/views/controls/button/label_button.h" 40 #include "ui/views/controls/button/label_button.h"
42 #include "ui/views/controls/label.h" 41 #include "ui/views/controls/label.h"
43 #include "ui/views/controls/separator.h" 42 #include "ui/views/controls/separator.h"
44 #include "ui/views/layout/fill_layout.h" 43 #include "ui/views/layout/fill_layout.h"
45 #include "ui/views/painter.h" 44 #include "ui/views/painter.h"
46 45
47 namespace ash { 46 namespace ash {
48 namespace tray { 47 namespace tray {
49 48
50 namespace { 49 namespace {
(...skipping 16 matching lines...) Expand all
67 controller->SwitchActiveUser( 66 controller->SwitchActiveUser(
68 controller->GetUserSession(user_index)->account_id); 67 controller->GetUserSession(user_index)->account_id);
69 } 68 }
70 69
71 bool IsMultiProfileSupportedAndUserActive() { 70 bool IsMultiProfileSupportedAndUserActive() {
72 return Shell::Get()->shell_delegate()->IsMultiProfilesEnabled() && 71 return Shell::Get()->shell_delegate()->IsMultiProfilesEnabled() &&
73 !Shell::Get()->session_controller()->IsUserSessionBlocked(); 72 !Shell::Get()->session_controller()->IsUserSessionBlocked();
74 } 73 }
75 74
76 // Creates the view shown in the user switcher popup ("AddUserMenuOption"). 75 // Creates the view shown in the user switcher popup ("AddUserMenuOption").
77 views::View* CreateAddUserView(AddUserSessionPolicy policy) { 76 views::View* CreateAddUserView(AddUserSessionPolicy policy,
77 views::ButtonListener* listener) {
78 auto* view = new views::View; 78 auto* view = new views::View;
79 const int icon_padding = (kMenuButtonSize - kMenuIconSize) / 2; 79 const int icon_padding = (kMenuButtonSize - kMenuIconSize) / 2;
80 auto* layout = 80 auto* layout =
81 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 81 new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0,
82 kTrayPopupLabelHorizontalPadding + icon_padding); 82 kTrayPopupLabelHorizontalPadding + icon_padding);
83 layout->set_minimum_cross_axis_size(kTrayPopupItemMinHeight); 83 layout->set_minimum_cross_axis_size(kTrayPopupItemMinHeight);
84 view->SetLayoutManager(layout); 84 view->SetLayoutManager(layout);
85 view->set_background(views::Background::CreateThemedSolidBackground( 85 view->set_background(
86 view, ui::NativeTheme::kColorId_BubbleBackground)); 86 views::Background::CreateSolidBackground(kBackgroundColor));
87 87
88 int message_id = 0; 88 int message_id = 0;
89 switch (policy) { 89 switch (policy) {
90 case AddUserSessionPolicy::ALLOWED: { 90 case AddUserSessionPolicy::ALLOWED: {
91 message_id = IDS_ASH_STATUS_TRAY_SIGN_IN_ANOTHER_ACCOUNT; 91 message_id = IDS_ASH_STATUS_TRAY_SIGN_IN_ANOTHER_ACCOUNT;
92 92
93 auto* icon = new views::ImageView(); 93 auto* icon = new views::ImageView();
94 icon->SetImage( 94 icon->SetImage(
95 gfx::CreateVectorIcon(kSystemMenuNewUserIcon, kMenuIconColor)); 95 gfx::CreateVectorIcon(kSystemMenuNewUserIcon, kMenuIconColor));
96 view->AddChildView(icon); 96 view->AddChildView(icon);
(...skipping 20 matching lines...) Expand all
117 if (policy != AddUserSessionPolicy::ALLOWED) { 117 if (policy != AddUserSessionPolicy::ALLOWED) {
118 label_style.set_font_style(TrayPopupItemStyle::FontStyle::CAPTION); 118 label_style.set_font_style(TrayPopupItemStyle::FontStyle::CAPTION);
119 label_style.set_color_style(TrayPopupItemStyle::ColorStyle::INACTIVE); 119 label_style.set_color_style(TrayPopupItemStyle::ColorStyle::INACTIVE);
120 vertical_padding += kMenuSeparatorVerticalPadding; 120 vertical_padding += kMenuSeparatorVerticalPadding;
121 } 121 }
122 label_style.SetupLabel(command_label); 122 label_style.SetupLabel(command_label);
123 view->AddChildView(command_label); 123 view->AddChildView(command_label);
124 view->SetBorder(views::CreateEmptyBorder(vertical_padding, icon_padding, 124 view->SetBorder(views::CreateEmptyBorder(vertical_padding, icon_padding,
125 vertical_padding, 125 vertical_padding,
126 kTrayPopupLabelHorizontalPadding)); 126 kTrayPopupLabelHorizontalPadding));
127 if (policy == AddUserSessionPolicy::ALLOWED) {
128 auto* button =
129 new ButtonFromView(view, listener, TrayPopupInkDropStyle::INSET_BOUNDS);
130 button->SetAccessibleName(
131 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_SIGN_IN_ANOTHER_ACCOUNT));
132 return button;
133 }
127 134
128 return view; 135 return view;
129 } 136 }
130 137
131 class UserViewMouseWatcherHost : public views::MouseWatcherHost { 138 class UserViewMouseWatcherHost : public views::MouseWatcherHost {
132 public: 139 public:
133 explicit UserViewMouseWatcherHost(const gfx::Rect& screen_area) 140 explicit UserViewMouseWatcherHost(const gfx::Rect& screen_area)
134 : screen_area_(screen_area) {} 141 : screen_area_(screen_area) {}
135 ~UserViewMouseWatcherHost() override {} 142 ~UserViewMouseWatcherHost() override {}
136 143
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 auto* layout = new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0); 221 auto* layout = new views::BoxLayout(views::BoxLayout::kHorizontal, 0, 0, 0);
215 SetLayoutManager(layout); 222 SetLayoutManager(layout);
216 layout->set_cross_axis_alignment( 223 layout->set_cross_axis_alignment(
217 views::BoxLayout::CROSS_AXIS_ALIGNMENT_CENTER); 224 views::BoxLayout::CROSS_AXIS_ALIGNMENT_CENTER);
218 layout->SetFlexForView(user_card_container_, 1); 225 layout->SetFlexForView(user_card_container_, 1);
219 226
220 SetBorder(base::MakeUnique<ActiveUserBorder>()); 227 SetBorder(base::MakeUnique<ActiveUserBorder>());
221 } 228 }
222 229
223 UserView::~UserView() { 230 UserView::~UserView() {
224 HideUserDropdownWidget(); 231 RemoveAddUserMenuOption();
225 } 232 }
226 233
227 TrayUser::TestState UserView::GetStateForTest() const { 234 TrayUser::TestState UserView::GetStateForTest() const {
228 if (user_dropdown_widget_) 235 if (add_menu_option_)
229 return add_user_enabled_ ? TrayUser::ACTIVE : TrayUser::ACTIVE_BUT_DISABLED; 236 return add_user_enabled_ ? TrayUser::ACTIVE : TrayUser::ACTIVE_BUT_DISABLED;
230 237
231 // If the container is the user card view itself, there's no ButtonFromView 238 // If the container is the user card view itself, there's no ButtonFromView
232 // wrapping it. 239 // wrapping it.
233 if (user_card_container_ == user_card_view_) 240 if (user_card_container_ == user_card_view_)
234 return TrayUser::SHOWN; 241 return TrayUser::SHOWN;
235 242
236 return static_cast<ButtonFromView*>(user_card_container_) 243 return static_cast<ButtonFromView*>(user_card_container_)
237 ->is_hovered_for_test() 244 ->is_hovered_for_test()
238 ? TrayUser::HOVERED 245 ? TrayUser::HOVERED
239 : TrayUser::SHOWN; 246 : TrayUser::SHOWN;
240 } 247 }
241 248
242 gfx::Rect UserView::GetBoundsInScreenOfUserButtonForTest() { 249 gfx::Rect UserView::GetBoundsInScreenOfUserButtonForTest() {
243 return user_card_container_->GetBoundsInScreen(); 250 return user_card_container_->GetBoundsInScreen();
244 } 251 }
245 252
246 int UserView::GetHeightForWidth(int width) const { 253 int UserView::GetHeightForWidth(int width) const {
247 return GetPreferredSize().height(); 254 return GetPreferredSize().height();
248 } 255 }
249 256
250 void UserView::ButtonPressed(views::Button* sender, const ui::Event& event) { 257 void UserView::ButtonPressed(views::Button* sender, const ui::Event& event) {
251 if (sender == logout_button_) { 258 if (sender == logout_button_) {
252 ShellPort::Get()->RecordUserMetricsAction(UMA_STATUS_AREA_SIGN_OUT); 259 ShellPort::Get()->RecordUserMetricsAction(UMA_STATUS_AREA_SIGN_OUT);
253 HideUserDropdownWidget(); 260 RemoveAddUserMenuOption();
254 Shell::Get()->system_tray_controller()->SignOut(); 261 Shell::Get()->system_tray_controller()->SignOut();
255 } else if (sender == user_card_container_ && 262 } else if (sender == user_card_container_ &&
256 IsMultiProfileSupportedAndUserActive()) { 263 IsMultiProfileSupportedAndUserActive()) {
257 ToggleUserDropdownWidget(); 264 ToggleAddUserMenuOption();
258 } else if (user_dropdown_widget_ && 265 } else if (add_menu_option_ &&
259 sender->GetWidget() == user_dropdown_widget_.get()) { 266 sender->GetWidget() == add_menu_option_.get()) {
260 DCHECK_EQ(Shell::Get()->session_controller()->NumberOfLoggedInUsers(), 267 DCHECK_EQ(Shell::Get()->session_controller()->NumberOfLoggedInUsers(),
261 sender->parent()->child_count() - 1); 268 sender->parent()->child_count() - 1);
262 const int index_in_add_menu = sender->parent()->GetIndexOf(sender); 269 const int index_in_add_menu = sender->parent()->GetIndexOf(sender);
263 // The last item is the "sign in another user" row. 270 // The last item is the "sign in another user" row.
264 if (index_in_add_menu == sender->parent()->child_count() - 1) { 271 if (index_in_add_menu == sender->parent()->child_count() - 1) {
265 MultiProfileUMA::RecordSigninUser(MultiProfileUMA::SIGNIN_USER_BY_TRAY); 272 MultiProfileUMA::RecordSigninUser(MultiProfileUMA::SIGNIN_USER_BY_TRAY);
266 Shell::Get()->system_tray_delegate()->ShowUserLogin(); 273 Shell::Get()->system_tray_delegate()->ShowUserLogin();
267 } else { 274 } else {
268 const int user_index = index_in_add_menu; 275 const int user_index = index_in_add_menu;
269 SwitchUser(user_index); 276 SwitchUser(user_index);
270 } 277 }
271 HideUserDropdownWidget(); 278 RemoveAddUserMenuOption();
272 owner_->system_tray()->CloseSystemBubble(); 279 owner_->system_tray()->CloseSystemBubble();
273 } else { 280 } else {
274 NOTREACHED(); 281 NOTREACHED();
275 } 282 }
276 } 283 }
277 284
278 void UserView::OnWillChangeFocus(View* focused_before, View* focused_now) { 285 void UserView::OnWillChangeFocus(View* focused_before, View* focused_now) {
279 if (focused_now) 286 if (focused_now)
280 HideUserDropdownWidget(); 287 RemoveAddUserMenuOption();
281 } 288 }
282 289
283 void UserView::OnDidChangeFocus(View* focused_before, View* focused_now) { 290 void UserView::OnDidChangeFocus(View* focused_before, View* focused_now) {
284 // Nothing to do here. 291 // Nothing to do here.
285 } 292 }
286 293
287 void UserView::AddLogoutButton(LoginStatus login) { 294 void UserView::AddLogoutButton(LoginStatus login) {
288 AddChildView(TrayPopupUtils::CreateVerticalSeparator()); 295 AddChildView(TrayPopupUtils::CreateVerticalSeparator());
289 logout_button_ = TrayPopupUtils::CreateTrayPopupBorderlessButton( 296 logout_button_ = TrayPopupUtils::CreateTrayPopupBorderlessButton(
290 this, user::GetLocalizedSignOutStringForStatus(login, true)); 297 this, user::GetLocalizedSignOutStringForStatus(login, true));
291 AddChildView(logout_button_); 298 AddChildView(logout_button_);
292 } 299 }
293 300
294 void UserView::AddUserCard(LoginStatus login) { 301 void UserView::AddUserCard(LoginStatus login) {
295 DCHECK(!user_card_container_); 302 DCHECK(!user_card_container_);
296 DCHECK(!user_card_view_); 303 DCHECK(!user_card_view_);
297 user_card_view_ = new UserCardView(login, 0); 304 user_card_view_ = new UserCardView(login, 0);
298 // The entry is clickable when no system modal dialog is open and the multi 305 // The entry is clickable when no system modal dialog is open and the multi
299 // profile option is active. 306 // profile option is active.
300 if (!ShellPort::Get()->IsSystemModalWindowOpen() && 307 if (!ShellPort::Get()->IsSystemModalWindowOpen() &&
301 IsMultiProfileSupportedAndUserActive()) { 308 IsMultiProfileSupportedAndUserActive()) {
302 user_card_container_ = new ButtonFromView( 309 user_card_container_ = new ButtonFromView(
303 user_card_view_, this, TrayPopupInkDropStyle::INSET_BOUNDS); 310 user_card_view_, this, TrayPopupInkDropStyle::INSET_BOUNDS);
304 } else { 311 } else {
305 user_card_container_ = user_card_view_; 312 user_card_container_ = user_card_view_;
306 } 313 }
307 AddChildViewAt(user_card_container_, 0); 314 AddChildViewAt(user_card_container_, 0);
308 } 315 }
309 316
310 void UserView::ToggleUserDropdownWidget() { 317 void UserView::ToggleAddUserMenuOption() {
311 if (user_dropdown_widget_) { 318 if (add_menu_option_) {
312 HideUserDropdownWidget(); 319 RemoveAddUserMenuOption();
313 return; 320 return;
314 } 321 }
315 322
316 // Note: We do not need to install a global event handler to delete this 323 // Note: We do not need to install a global event handler to delete this
317 // item since it will destroyed automatically before the menu / user menu item 324 // item since it will destroyed automatically before the menu / user menu item
318 // gets destroyed.. 325 // gets destroyed..
319 user_dropdown_widget_.reset(new views::Widget); 326 add_menu_option_.reset(new views::Widget);
320 views::Widget::InitParams params; 327 views::Widget::InitParams params;
321 params.type = views::Widget::InitParams::TYPE_MENU; 328 params.type = views::Widget::InitParams::TYPE_MENU;
322 params.keep_on_top = true; 329 params.keep_on_top = true;
323 params.accept_events = true; 330 params.accept_events = true;
324 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; 331 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
325 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; 332 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW;
326 params.name = "AddUserMenuOption"; 333 params.name = "AddUserMenuOption";
327 WmWindow::Get(GetWidget()->GetNativeWindow()) 334 WmWindow::Get(GetWidget()->GetNativeWindow())
328 ->GetRootWindowController() 335 ->GetRootWindowController()
329 ->ConfigureWidgetInitParamsForContainer( 336 ->ConfigureWidgetInitParamsForContainer(
330 user_dropdown_widget_.get(), 337 add_menu_option_.get(), kShellWindowId_DragImageAndTooltipContainer,
331 kShellWindowId_DragImageAndTooltipContainer, &params); 338 &params);
332 user_dropdown_widget_->Init(params); 339 add_menu_option_->Init(params);
333 340
334 const SessionController* const session_controller = 341 const SessionController* const session_controller =
335 Shell::Get()->session_controller(); 342 Shell::Get()->session_controller();
336 const AddUserSessionPolicy add_user_policy = 343 const AddUserSessionPolicy add_user_policy =
337 session_controller->GetAddUserPolicy(); 344 session_controller->GetAddUserPolicy();
338 add_user_enabled_ = add_user_policy == AddUserSessionPolicy::ALLOWED; 345 add_user_enabled_ = add_user_policy == AddUserSessionPolicy::ALLOWED;
339 346
340 // Position the widget on top of the user card view (which is still in the 347 // Position the widget on top of the user card view (which is still in the
341 // system menu). The top half of the widget will be transparent to allow 348 // system menu). The top half of the widget will be transparent to allow
342 // the active user to show through. 349 // the active user to show through.
343 gfx::Rect bounds = user_card_container_->GetBoundsInScreen(); 350 gfx::Rect bounds = user_card_container_->GetBoundsInScreen();
344 bounds.set_width(bounds.width() + kSeparatorWidth); 351 bounds.set_width(bounds.width() + kSeparatorWidth);
345 int row_height = bounds.height(); 352 int row_height = bounds.height();
346 353
347 views::View* container = new UserDropdownWidgetContents( 354 views::View* container = new UserDropdownWidgetContents(
348 base::Bind(&UserView::HideUserDropdownWidget, base::Unretained(this))); 355 base::Bind(&UserView::RemoveAddUserMenuOption, base::Unretained(this)));
349 views::View* add_user_view = CreateAddUserView(add_user_policy);
350 const SkColor bg_color = add_user_view->background()->get_color();
351 container->SetBorder(views::CreatePaddedBorder( 356 container->SetBorder(views::CreatePaddedBorder(
352 views::CreateSolidSidedBorder(0, 0, 0, kSeparatorWidth, bg_color), 357 views::CreateSolidSidedBorder(0, 0, 0, kSeparatorWidth, kBackgroundColor),
353 gfx::Insets(row_height, 0, 0, 0))); 358 gfx::Insets(row_height, 0, 0, 0)));
354
355 // Create the contents aside from the empty window through which the active
356 // user is seen.
357 views::View* user_dropdown_padding = new views::View(); 359 views::View* user_dropdown_padding = new views::View();
358 user_dropdown_padding->SetBorder(views::CreateSolidSidedBorder( 360 user_dropdown_padding->SetBorder(views::CreateSolidSidedBorder(
359 kMenuSeparatorVerticalPadding - kSeparatorWidth, 0, 0, 0, bg_color)); 361 kMenuSeparatorVerticalPadding - kSeparatorWidth, 0, 0, 0,
362 kBackgroundColor));
360 user_dropdown_padding->SetLayoutManager( 363 user_dropdown_padding->SetLayoutManager(
361 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); 364 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0));
362 views::Separator* separator = new views::Separator(); 365 views::Separator* separator = new views::Separator();
363 separator->SetPreferredHeight(kSeparatorWidth); 366 separator->SetPreferredHeight(kSeparatorWidth);
364 separator->SetColor( 367 separator->SetColor(color_utils::GetResultingPaintColor(kMenuSeparatorColor,
365 color_utils::GetResultingPaintColor(kMenuSeparatorColor, bg_color)); 368 kBackgroundColor));
366 const int separator_horizontal_padding = 369 const int separator_horizontal_padding =
367 (kTrayPopupItemMinStartWidth - kTrayItemSize) / 2; 370 (kTrayPopupItemMinStartWidth - kTrayItemSize) / 2;
368 separator->SetBorder( 371 separator->SetBorder(views::CreateSolidSidedBorder(
369 views::CreateSolidSidedBorder(0, separator_horizontal_padding, 0, 372 0, separator_horizontal_padding, 0, separator_horizontal_padding,
370 separator_horizontal_padding, bg_color)); 373 kBackgroundColor));
371 user_dropdown_padding->AddChildView(separator); 374 user_dropdown_padding->AddChildView(separator);
372 375
373 // Add other logged in users.
374 for (int i = 1; i < session_controller->NumberOfLoggedInUsers(); ++i) { 376 for (int i = 1; i < session_controller->NumberOfLoggedInUsers(); ++i) {
375 user_dropdown_padding->AddChildView( 377 user_dropdown_padding->AddChildView(
376 new ButtonFromView(new UserCardView(LoginStatus::USER, i), this, 378 new ButtonFromView(new UserCardView(LoginStatus::USER, i), this,
377 TrayPopupInkDropStyle::INSET_BOUNDS)); 379 TrayPopupInkDropStyle::INSET_BOUNDS));
378 } 380 }
379 381
380 // Add the "add user" option or the "can't add another user" message. 382 user_dropdown_padding->AddChildView(CreateAddUserView(add_user_policy, this));
381 if (add_user_enabled_) {
382 auto* button = new ButtonFromView(add_user_view, this,
383 TrayPopupInkDropStyle::INSET_BOUNDS);
384 button->SetAccessibleName(
385 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_SIGN_IN_ANOTHER_ACCOUNT));
386 user_dropdown_padding->AddChildView(button);
387 } else {
388 user_dropdown_padding->AddChildView(add_user_view);
389 }
390
391 container->AddChildView(user_dropdown_padding); 383 container->AddChildView(user_dropdown_padding);
392 container->SetLayoutManager(new views::FillLayout()); 384 container->SetLayoutManager(new views::FillLayout());
393 user_dropdown_widget_->SetContentsView(container); 385 add_menu_option_->SetContentsView(container);
394 386
395 bounds.set_height(container->GetPreferredSize().height()); 387 bounds.set_height(container->GetPreferredSize().height());
396 user_dropdown_widget_->SetBounds(bounds); 388 add_menu_option_->SetBounds(bounds);
397 389
398 // Suppress the appearance of the collective capture icon while the dropdown 390 // Suppress the appearance of the collective capture icon while the dropdown
399 // is open (the icon will appear in the specific user rows). 391 // is open (the icon will appear in the specific user rows).
400 user_card_view_->SetSuppressCaptureIcon(true); 392 user_card_view_->SetSuppressCaptureIcon(true);
401 393
402 // Show the content. 394 // Show the content.
403 user_dropdown_widget_->SetAlwaysOnTop(true); 395 add_menu_option_->SetAlwaysOnTop(true);
404 user_dropdown_widget_->Show(); 396 add_menu_option_->Show();
405 397
406 // Install a listener to focus changes so that we can remove the card when 398 // Install a listener to focus changes so that we can remove the card when
407 // the focus gets changed. When called through the destruction of the bubble, 399 // the focus gets changed. When called through the destruction of the bubble,
408 // the FocusManager cannot be determined anymore and we remember it here. 400 // the FocusManager cannot be determined anymore and we remember it here.
409 focus_manager_ = user_card_container_->GetFocusManager(); 401 focus_manager_ = user_card_container_->GetFocusManager();
410 focus_manager_->AddFocusChangeListener(this); 402 focus_manager_->AddFocusChangeListener(this);
411 } 403 }
412 404
413 void UserView::HideUserDropdownWidget() { 405 void UserView::RemoveAddUserMenuOption() {
414 if (!user_dropdown_widget_) 406 if (!add_menu_option_)
415 return; 407 return;
416 focus_manager_->RemoveFocusChangeListener(this); 408 focus_manager_->RemoveFocusChangeListener(this);
417 focus_manager_ = nullptr; 409 focus_manager_ = nullptr;
418 if (user_card_container_->GetFocusManager()) 410 if (user_card_container_->GetFocusManager())
419 user_card_container_->GetFocusManager()->ClearFocus(); 411 user_card_container_->GetFocusManager()->ClearFocus();
420 user_card_view_->SetSuppressCaptureIcon(false); 412 user_card_view_->SetSuppressCaptureIcon(false);
421 user_dropdown_widget_.reset(); 413 add_menu_option_.reset();
422 } 414 }
423 415
424 } // namespace tray 416 } // namespace tray
425 } // namespace ash 417 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/user/user_view.h ('k') | chrome/browser/ui/views/autofill/password_generation_popup_view_views.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698