| Index: ash/common/system/user/user_view.cc
|
| diff --git a/ash/common/system/user/user_view.cc b/ash/common/system/user/user_view.cc
|
| index ac07e180f01c6076d72e0e7896f57fffbf9f076f..b2f17ddd5299e839c1d577643fdcfcfbd56b67c0 100644
|
| --- a/ash/common/system/user/user_view.cc
|
| +++ b/ash/common/system/user/user_view.cc
|
| @@ -29,7 +29,6 @@
|
| #include "ash/common/wm_window.h"
|
| #include "ash/public/cpp/shell_window_ids.h"
|
| #include "ash/resources/vector_icons/vector_icons.h"
|
| -#include "base/optional.h"
|
| #include "components/signin/core/account_id/account_id.h"
|
| #include "components/user_manager/user_info.h"
|
| #include "grit/ash_resources.h"
|
| @@ -105,39 +104,40 @@ bool IsMultiProfileSupportedAndUserActive() {
|
| }
|
|
|
| // Creates the view shown in the user switcher popup ("AddUserMenuOption").
|
| -views::View* CreateAddUserView(
|
| - base::Optional<SessionStateDelegate::AddUserError> error) {
|
| +views::View* CreateAddUserView(AddUserSessionPolicy policy) {
|
| DCHECK(UseMd());
|
| auto view = new views::View;
|
| auto layout = new views::BoxLayout(
|
| views::BoxLayout::kHorizontal, (kMenuButtonSize - kMenuIconSize) / 2,
|
| kMenuSeparatorVerticalPadding, kTrayPopupPaddingBetweenItems);
|
| layout->set_minimum_cross_axis_size(
|
| - error ? 56 : GetTrayConstant(TRAY_POPUP_ITEM_MIN_HEIGHT));
|
| + policy == AddUserSessionPolicy::ALLOWED
|
| + ? GetTrayConstant(TRAY_POPUP_ITEM_MIN_HEIGHT)
|
| + : 56);
|
| view->SetLayoutManager(layout);
|
| view->set_background(
|
| views::Background::CreateSolidBackground(kBackgroundColor));
|
|
|
| - if (!error) {
|
| - auto icon = new views::ImageView();
|
| - icon->SetImage(
|
| - gfx::CreateVectorIcon(kSystemMenuNewUserIcon, kMenuIconColor));
|
| - view->AddChildView(icon);
|
| - }
|
| + int message_id = 0;
|
| + switch (policy) {
|
| + case AddUserSessionPolicy::ALLOWED: {
|
| + message_id = IDS_ASH_STATUS_TRAY_SIGN_IN_ANOTHER_ACCOUNT;
|
|
|
| - int message_id = IDS_ASH_STATUS_TRAY_SIGN_IN_ANOTHER_ACCOUNT;
|
| - if (error) {
|
| - switch (*error) {
|
| - case SessionStateDelegate::ADD_USER_ERROR_NOT_ALLOWED_PRIMARY_USER:
|
| - message_id = IDS_ASH_STATUS_TRAY_MESSAGE_NOT_ALLOWED_PRIMARY_USER;
|
| - break;
|
| - case SessionStateDelegate::ADD_USER_ERROR_MAXIMUM_USERS_REACHED:
|
| - message_id = IDS_ASH_STATUS_TRAY_MESSAGE_CANNOT_ADD_USER;
|
| - break;
|
| - case SessionStateDelegate::ADD_USER_ERROR_OUT_OF_USERS:
|
| - message_id = IDS_ASH_STATUS_TRAY_MESSAGE_OUT_OF_USERS;
|
| - break;
|
| + auto icon = new views::ImageView();
|
| + icon->SetImage(
|
| + gfx::CreateVectorIcon(kSystemMenuNewUserIcon, kMenuIconColor));
|
| + view->AddChildView(icon);
|
| + break;
|
| }
|
| + case AddUserSessionPolicy::ERROR_NOT_ALLOWED_PRIMARY_USER:
|
| + message_id = IDS_ASH_STATUS_TRAY_MESSAGE_NOT_ALLOWED_PRIMARY_USER;
|
| + break;
|
| + case AddUserSessionPolicy::ERROR_MAXIMUM_USERS_REACHED:
|
| + message_id = IDS_ASH_STATUS_TRAY_MESSAGE_CANNOT_ADD_USER;
|
| + break;
|
| + case AddUserSessionPolicy::ERROR_NO_ELIGIBLE_USERS:
|
| + message_id = IDS_ASH_STATUS_TRAY_MESSAGE_OUT_OF_USERS;
|
| + break;
|
| }
|
|
|
| auto command_label = new views::Label(l10n_util::GetStringUTF16(message_id));
|
| @@ -604,15 +604,13 @@ void UserView::ToggleAddUserMenuOption() {
|
|
|
| const SessionStateDelegate* delegate =
|
| WmShell::Get()->GetSessionStateDelegate();
|
| - SessionStateDelegate::AddUserError add_user_error;
|
| - add_user_enabled_ = delegate->CanAddUserToMultiProfile(&add_user_error);
|
| + const AddUserSessionPolicy add_user_policy =
|
| + delegate->GetAddUserSessionPolicy();
|
| + add_user_enabled_ = add_user_policy == AddUserSessionPolicy::ALLOWED;
|
|
|
| if (UseMd()) {
|
| - base::Optional<SessionStateDelegate::AddUserError> error;
|
| - if (!add_user_enabled_)
|
| - error = add_user_error;
|
| ButtonFromView* button = new ButtonFromView(
|
| - CreateAddUserView(error), add_user_enabled_ ? this : nullptr,
|
| + CreateAddUserView(add_user_policy), add_user_enabled_ ? this : nullptr,
|
| IsActiveUser() ? TrayPopupInkDropStyle::INSET_BOUNDS
|
| : TrayPopupInkDropStyle::FILL_BOUNDS,
|
| false, gfx::Insets());
|
| @@ -680,18 +678,19 @@ void UserView::ToggleAddUserMenuOption() {
|
| } else {
|
| ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
|
| int message_id = 0;
|
| - switch (add_user_error) {
|
| - case SessionStateDelegate::ADD_USER_ERROR_NOT_ALLOWED_PRIMARY_USER:
|
| + switch (add_user_policy) {
|
| + case AddUserSessionPolicy::ERROR_NOT_ALLOWED_PRIMARY_USER:
|
| message_id = IDS_ASH_STATUS_TRAY_MESSAGE_NOT_ALLOWED_PRIMARY_USER;
|
| break;
|
| - case SessionStateDelegate::ADD_USER_ERROR_MAXIMUM_USERS_REACHED:
|
| + case AddUserSessionPolicy::ERROR_MAXIMUM_USERS_REACHED:
|
| message_id = IDS_ASH_STATUS_TRAY_MESSAGE_CANNOT_ADD_USER;
|
| break;
|
| - case SessionStateDelegate::ADD_USER_ERROR_OUT_OF_USERS:
|
| + case AddUserSessionPolicy::ERROR_NO_ELIGIBLE_USERS:
|
| message_id = IDS_ASH_STATUS_TRAY_MESSAGE_OUT_OF_USERS;
|
| break;
|
| default:
|
| - NOTREACHED() << "Unknown adding user error " << add_user_error;
|
| + NOTREACHED() << "Unknown adding user policy "
|
| + << static_cast<int>(add_user_policy);
|
| }
|
|
|
| popup_message_.reset(new PopupMessage(
|
|
|