| OLD | NEW |
| 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 Loading... |
| 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 SessionStateDelegate::PrimaryUserPolicy primary_user_policy = |
| 497 delegate->GetMaximumNumberOfLoggedInUsers(); | 497 delegate->GetPrimaryUserPolicy(); |
| 498 add_user_disabled_ = |
| 499 (delegate->NumberOfLoggedInUsers() >= |
| 500 delegate->GetMaximumNumberOfLoggedInUsers()) || |
| 501 (primary_user_policy != SessionStateDelegate::PRIMARY_USER_POLICY_ALLOW); |
| 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; |
| 517 switch (primary_user_policy) { |
| 518 case SessionStateDelegate::PRIMARY_USER_POLICY_FORBIDS: |
| 519 case SessionStateDelegate::PRIMARY_USER_POLICY_CERT_TAINTED: |
| 520 messageId = IDS_ASH_STATUS_TRAY_MESSAGE_NOT_ALLOWED_PRIMARY_USER; |
| 521 break; |
| 522 default: |
| 523 messageId = IDS_ASH_STATUS_TRAY_MESSAGE_CANNOT_ADD_USER; |
| 524 } |
| 525 |
| 511 popup_message_.reset(new PopupMessage( | 526 popup_message_.reset(new PopupMessage( |
| 512 bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_CAPTION_CANNOT_ADD_USER), | 527 bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_CAPTION_CANNOT_ADD_USER), |
| 513 bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_MESSAGE_CANNOT_ADD_USER), | 528 bundle.GetLocalizedString(messageId), |
| 514 PopupMessage::ICON_WARNING, | 529 PopupMessage::ICON_WARNING, |
| 515 add_user_view->anchor(), | 530 add_user_view->anchor(), |
| 516 views::BubbleBorder::TOP_LEFT, | 531 views::BubbleBorder::TOP_LEFT, |
| 517 gfx::Size(parent()->bounds().width() - kPopupMessageOffset, 0), | 532 gfx::Size(parent()->bounds().width() - kPopupMessageOffset, 0), |
| 518 2 * kPopupMessageOffset)); | 533 2 * kPopupMessageOffset)); |
| 519 } else { | 534 } else { |
| 520 // We activate the entry automatically if invoked with focus. | 535 // We activate the entry automatically if invoked with focus. |
| 521 if (user_card_view_->HasFocus()) { | 536 if (user_card_view_->HasFocus()) { |
| 522 button->GetFocusManager()->SetFocusedView(button); | 537 button->GetFocusManager()->SetFocusedView(button); |
| 523 user_card_view_->GetFocusManager()->SetFocusedView(button); | 538 user_card_view_->GetFocusManager()->SetFocusedView(button); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 544 focus_manager_ = NULL; | 559 focus_manager_ = NULL; |
| 545 if (user_card_view_->GetFocusManager()) | 560 if (user_card_view_->GetFocusManager()) |
| 546 user_card_view_->GetFocusManager()->ClearFocus(); | 561 user_card_view_->GetFocusManager()->ClearFocus(); |
| 547 popup_message_.reset(); | 562 popup_message_.reset(); |
| 548 mouse_watcher_.reset(); | 563 mouse_watcher_.reset(); |
| 549 add_menu_option_.reset(); | 564 add_menu_option_.reset(); |
| 550 } | 565 } |
| 551 | 566 |
| 552 } // namespace tray | 567 } // namespace tray |
| 553 } // namespace ash | 568 } // namespace ash |
| OLD | NEW |