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

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

Issue 560033002: Fixed suggesting adding more users into multi-profile session when we don't have more (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 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 481 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 add_menu_option_->Show(); 492 add_menu_option_->Show();
493 493
494 AddUserView* add_user_view = 494 AddUserView* add_user_view =
495 new AddUserView(static_cast<ButtonFromView*>(user_card_view_)); 495 new AddUserView(static_cast<ButtonFromView*>(user_card_view_));
496 496
497 const SessionStateDelegate* delegate = 497 const SessionStateDelegate* delegate =
498 Shell::GetInstance()->session_state_delegate(); 498 Shell::GetInstance()->session_state_delegate();
499 499
500 bool multi_profile_allowed = 500 bool multi_profile_allowed =
501 delegate->IsMultiProfileAllowedByPrimaryUserPolicy(); 501 delegate->IsMultiProfileAllowedByPrimaryUserPolicy();
502 add_user_disabled_ = (delegate->NumberOfLoggedInUsers() >= 502 int admitted_users_to_be_added =
503 delegate->GetMaximumNumberOfLoggedInUsers()) || 503 delegate->GetNumberOfAdmittedForMultiProfileUsers();
504 !multi_profile_allowed; 504 add_user_disabled_ = !multi_profile_allowed ||
505 admitted_users_to_be_added <= 0 ||
dzhioev (left Google) 2014/09/18 07:14:22 Checking for "<= 0" doesn't make sense to me. Can
Roman Sorokin (ftl) 2014/09/22 08:36:06 Done.
506 (delegate->NumberOfLoggedInUsers() >=
507 delegate->GetMaximumNumberOfLoggedInUsers());
505 508
506 ButtonFromView* button = new ButtonFromView( 509 ButtonFromView* button = new ButtonFromView(
507 add_user_view, 510 add_user_view,
508 add_user_disabled_ ? NULL : this, 511 add_user_disabled_ ? NULL : this,
509 !add_user_disabled_, 512 !add_user_disabled_,
510 gfx::Insets(1, 1, 1, 1)); 513 gfx::Insets(1, 1, 1, 1));
511 button->set_request_focus_on_press(false); 514 button->set_request_focus_on_press(false);
512 button->SetAccessibleName( 515 button->SetAccessibleName(
513 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_SIGN_IN_ANOTHER_ACCOUNT)); 516 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_SIGN_IN_ANOTHER_ACCOUNT));
514 button->ForceBorderVisible(true); 517 button->ForceBorderVisible(true);
515 add_menu_option_->SetContentsView(button); 518 add_menu_option_->SetContentsView(button);
516 519
517 if (add_user_disabled_) { 520 if (add_user_disabled_) {
518 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); 521 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
519 int message_id; 522 int message_id;
520 if (!multi_profile_allowed) 523 if (!multi_profile_allowed)
521 message_id = IDS_ASH_STATUS_TRAY_MESSAGE_NOT_ALLOWED_PRIMARY_USER; 524 message_id = IDS_ASH_STATUS_TRAY_MESSAGE_NOT_ALLOWED_PRIMARY_USER;
525 else if (admitted_users_to_be_added <= 0)
526 message_id = IDS_ASH_STATUS_TRAY_MESSAGE_OUT_OF_USERS;
522 else 527 else
523 message_id = IDS_ASH_STATUS_TRAY_MESSAGE_CANNOT_ADD_USER; 528 message_id = IDS_ASH_STATUS_TRAY_MESSAGE_CANNOT_ADD_USER;
524 529
525 popup_message_.reset(new PopupMessage( 530 popup_message_.reset(new PopupMessage(
526 bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_CAPTION_CANNOT_ADD_USER), 531 bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_CAPTION_CANNOT_ADD_USER),
527 bundle.GetLocalizedString(message_id), 532 bundle.GetLocalizedString(message_id),
528 PopupMessage::ICON_WARNING, 533 PopupMessage::ICON_WARNING,
529 add_user_view->anchor(), 534 add_user_view->anchor(),
530 views::BubbleBorder::TOP_LEFT, 535 views::BubbleBorder::TOP_LEFT,
531 gfx::Size(parent()->bounds().width() - kPopupMessageOffset, 0), 536 gfx::Size(parent()->bounds().width() - kPopupMessageOffset, 0),
(...skipping 26 matching lines...) Expand all
558 focus_manager_ = NULL; 563 focus_manager_ = NULL;
559 if (user_card_view_->GetFocusManager()) 564 if (user_card_view_->GetFocusManager())
560 user_card_view_->GetFocusManager()->ClearFocus(); 565 user_card_view_->GetFocusManager()->ClearFocus();
561 popup_message_.reset(); 566 popup_message_.reset();
562 mouse_watcher_.reset(); 567 mouse_watcher_.reset();
563 add_menu_option_.reset(); 568 add_menu_option_.reset();
564 } 569 }
565 570
566 } // namespace tray 571 } // namespace tray
567 } // namespace ash 572 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698