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

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: Minor fix Created 6 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
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->GetNumberOfUsersAdmittedForMultiProfile();
504 !multi_profile_allowed; 504 DCHECK(admitted_users_to_be_added >= 0);
505 add_user_disabled_ = !multi_profile_allowed ||
James Cook 2014/09/22 19:52:23 Please change this to add_user_enabled_ and invert
Roman Sorokin (ftl) 2014/09/23 15:42:37 Done.
506 admitted_users_to_be_added == 0 ||
507 (delegate->NumberOfLoggedInUsers() >=
508 delegate->GetMaximumNumberOfLoggedInUsers());
James Cook 2014/09/22 19:52:23 Given that all the data to decide whether or not a
Roman Sorokin (ftl) 2014/09/23 15:42:37 Done.
505 509
506 ButtonFromView* button = new ButtonFromView( 510 ButtonFromView* button = new ButtonFromView(
507 add_user_view, 511 add_user_view,
508 add_user_disabled_ ? NULL : this, 512 add_user_disabled_ ? NULL : this,
509 !add_user_disabled_, 513 !add_user_disabled_,
510 gfx::Insets(1, 1, 1, 1)); 514 gfx::Insets(1, 1, 1, 1));
511 button->set_request_focus_on_press(false); 515 button->set_request_focus_on_press(false);
512 button->SetAccessibleName( 516 button->SetAccessibleName(
513 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_SIGN_IN_ANOTHER_ACCOUNT)); 517 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_SIGN_IN_ANOTHER_ACCOUNT));
514 button->ForceBorderVisible(true); 518 button->ForceBorderVisible(true);
515 add_menu_option_->SetContentsView(button); 519 add_menu_option_->SetContentsView(button);
516 520
517 if (add_user_disabled_) { 521 if (add_user_disabled_) {
518 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); 522 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
519 int message_id; 523 int message_id;
520 if (!multi_profile_allowed) 524 if (!multi_profile_allowed)
521 message_id = IDS_ASH_STATUS_TRAY_MESSAGE_NOT_ALLOWED_PRIMARY_USER; 525 message_id = IDS_ASH_STATUS_TRAY_MESSAGE_NOT_ALLOWED_PRIMARY_USER;
526 else if (admitted_users_to_be_added == 0)
527 message_id = IDS_ASH_STATUS_TRAY_MESSAGE_OUT_OF_USERS;
522 else 528 else
523 message_id = IDS_ASH_STATUS_TRAY_MESSAGE_CANNOT_ADD_USER; 529 message_id = IDS_ASH_STATUS_TRAY_MESSAGE_CANNOT_ADD_USER;
524 530
525 popup_message_.reset(new PopupMessage( 531 popup_message_.reset(new PopupMessage(
526 bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_CAPTION_CANNOT_ADD_USER), 532 bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_CAPTION_CANNOT_ADD_USER),
527 bundle.GetLocalizedString(message_id), 533 bundle.GetLocalizedString(message_id),
528 PopupMessage::ICON_WARNING, 534 PopupMessage::ICON_WARNING,
529 add_user_view->anchor(), 535 add_user_view->anchor(),
530 views::BubbleBorder::TOP_LEFT, 536 views::BubbleBorder::TOP_LEFT,
531 gfx::Size(parent()->bounds().width() - kPopupMessageOffset, 0), 537 gfx::Size(parent()->bounds().width() - kPopupMessageOffset, 0),
(...skipping 26 matching lines...) Expand all
558 focus_manager_ = NULL; 564 focus_manager_ = NULL;
559 if (user_card_view_->GetFocusManager()) 565 if (user_card_view_->GetFocusManager())
560 user_card_view_->GetFocusManager()->ClearFocus(); 566 user_card_view_->GetFocusManager()->ClearFocus();
561 popup_message_.reset(); 567 popup_message_.reset();
562 mouse_watcher_.reset(); 568 mouse_watcher_.reset();
563 add_menu_option_.reset(); 569 add_menu_option_.reset();
564 } 570 }
565 571
566 } // namespace tray 572 } // namespace tray
567 } // namespace ash 573 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698