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

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

Issue 374853002: Providing more information on why certain users can't be added to multi-profile (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Minor fix Created 6 years, 4 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 475 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 486
487 // Show the content. 487 // Show the content.
488 add_menu_option_->SetAlwaysOnTop(true); 488 add_menu_option_->SetAlwaysOnTop(true);
489 add_menu_option_->Show(); 489 add_menu_option_->Show();
490 490
491 AddUserView* add_user_view = 491 AddUserView* add_user_view =
492 new AddUserView(static_cast<ButtonFromView*>(user_card_view_)); 492 new AddUserView(static_cast<ButtonFromView*>(user_card_view_));
493 493
494 const SessionStateDelegate* delegate = 494 const SessionStateDelegate* delegate =
495 Shell::GetInstance()->session_state_delegate(); 495 Shell::GetInstance()->session_state_delegate();
496 add_user_disabled_ = delegate->NumberOfLoggedInUsers() >= 496
497 delegate->GetMaximumNumberOfLoggedInUsers(); 497 bool IsMultiProfileAllowed =
James Cook 2014/08/11 17:01:34 is_multi_profile_allowed (or just multi_profile_al
Roman Sorokin (ftl) 2014/08/11 17:41:45 Done.
498 delegate->IsMultiProfileAllowedByPrimaryUserPolicy();
499 add_user_disabled_ = (delegate->NumberOfLoggedInUsers() >=
500 delegate->GetMaximumNumberOfLoggedInUsers()) ||
501 !IsMultiProfileAllowed;
502
498 ButtonFromView* button = new ButtonFromView( 503 ButtonFromView* button = new ButtonFromView(
499 add_user_view, 504 add_user_view,
500 add_user_disabled_ ? NULL : this, 505 add_user_disabled_ ? NULL : this,
501 !add_user_disabled_, 506 !add_user_disabled_,
502 gfx::Insets(1, 1, 1, 1)); 507 gfx::Insets(1, 1, 1, 1));
503 button->set_request_focus_on_press(false); 508 button->set_request_focus_on_press(false);
504 button->SetAccessibleName( 509 button->SetAccessibleName(
505 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_SIGN_IN_ANOTHER_ACCOUNT)); 510 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_SIGN_IN_ANOTHER_ACCOUNT));
506 button->ForceBorderVisible(true); 511 button->ForceBorderVisible(true);
507 add_menu_option_->SetContentsView(button); 512 add_menu_option_->SetContentsView(button);
508 513
509 if (add_user_disabled_) { 514 if (add_user_disabled_) {
510 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); 515 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
516 int messageId;
James Cook 2014/08/11 17:01:34 message_id
Roman Sorokin (ftl) 2014/08/11 17:41:44 Done.
517 if (!IsMultiProfileAllowed)
518 messageId = IDS_ASH_STATUS_TRAY_MESSAGE_NOT_ALLOWED_PRIMARY_USER;
519 else
520 messageId = IDS_ASH_STATUS_TRAY_MESSAGE_CANNOT_ADD_USER;
521
511 popup_message_.reset(new PopupMessage( 522 popup_message_.reset(new PopupMessage(
512 bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_CAPTION_CANNOT_ADD_USER), 523 bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_CAPTION_CANNOT_ADD_USER),
513 bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_MESSAGE_CANNOT_ADD_USER), 524 bundle.GetLocalizedString(messageId),
514 PopupMessage::ICON_WARNING, 525 PopupMessage::ICON_WARNING,
515 add_user_view->anchor(), 526 add_user_view->anchor(),
516 views::BubbleBorder::TOP_LEFT, 527 views::BubbleBorder::TOP_LEFT,
517 gfx::Size(parent()->bounds().width() - kPopupMessageOffset, 0), 528 gfx::Size(parent()->bounds().width() - kPopupMessageOffset, 0),
518 2 * kPopupMessageOffset)); 529 2 * kPopupMessageOffset));
519 } else { 530 } else {
520 // We activate the entry automatically if invoked with focus. 531 // We activate the entry automatically if invoked with focus.
521 if (user_card_view_->HasFocus()) { 532 if (user_card_view_->HasFocus()) {
522 button->GetFocusManager()->SetFocusedView(button); 533 button->GetFocusManager()->SetFocusedView(button);
523 user_card_view_->GetFocusManager()->SetFocusedView(button); 534 user_card_view_->GetFocusManager()->SetFocusedView(button);
(...skipping 20 matching lines...) Expand all
544 focus_manager_ = NULL; 555 focus_manager_ = NULL;
545 if (user_card_view_->GetFocusManager()) 556 if (user_card_view_->GetFocusManager())
546 user_card_view_->GetFocusManager()->ClearFocus(); 557 user_card_view_->GetFocusManager()->ClearFocus();
547 popup_message_.reset(); 558 popup_message_.reset();
548 mouse_watcher_.reset(); 559 mouse_watcher_.reset();
549 add_menu_option_.reset(); 560 add_menu_option_.reset();
550 } 561 }
551 562
552 } // namespace tray 563 } // namespace tray
553 } // namespace ash 564 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698