1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/ui/webui/chromeos/login/user_board_screen_handler.h"
7 #include "chrome/browser/chromeos/login/ui/models/user_board_model.h"
8 #include "components/login/localized_values_builder.h"
12 UserBoardScreenHandler::UserBoardScreenHandler() : model_(nullptr) {
15 UserBoardScreenHandler::~UserBoardScreenHandler() {
18 void UserBoardScreenHandler::DeclareLocalizedValues(
19 ::login::LocalizedValuesBuilder
* builder
) {
22 void UserBoardScreenHandler::RegisterMessages() {
23 AddCallback("getUsers", &UserBoardScreenHandler::HandleGetUsers
);
24 AddCallback("attemptUnlock", &UserBoardScreenHandler::HandleAttemptUnlock
);
25 AddCallback("hardlockPod", &UserBoardScreenHandler::HandleHardlockPod
);
28 void UserBoardScreenHandler::Initialize() {
31 //----------------- Handlers
33 void UserBoardScreenHandler::HandleGetUsers() {
35 model_
->SendUserList();
38 void UserBoardScreenHandler::HandleHardlockPod(const std::string
& user_id
) {
40 model_
->HardLockPod(user_id
);
43 void UserBoardScreenHandler::HandleAttemptUnlock(const std::string
& user_id
) {
45 model_
->AttemptEasyUnlock(user_id
);
48 //----------------- API
50 void UserBoardScreenHandler::SetPublicSessionDisplayName(
51 const std::string
& user_id
,
52 const std::string
& display_name
) {
53 CallJS("login.AccountPickerScreen.setPublicSessionDisplayName", user_id
,
57 void UserBoardScreenHandler::SetPublicSessionLocales(
58 const std::string
& user_id
,
59 scoped_ptr
<base::ListValue
> locales
,
60 const std::string
& default_locale
,
61 bool multiple_recommended_locales
) {
62 CallJS("login.AccountPickerScreen.setPublicSessionLocales", user_id
, *locales
,
63 default_locale
, multiple_recommended_locales
);
66 void UserBoardScreenHandler::ShowBannerMessage(const base::string16
& message
) {
67 CallJS("login.AccountPickerScreen.showBannerMessage", message
);
70 void UserBoardScreenHandler::ShowUserPodCustomIcon(
71 const std::string
& user_id
,
72 const base::DictionaryValue
& icon
) {
73 CallJS("login.AccountPickerScreen.showUserPodCustomIcon", user_id
, icon
);
76 void UserBoardScreenHandler::HideUserPodCustomIcon(const std::string
& user_id
) {
77 CallJS("login.AccountPickerScreen.hideUserPodCustomIcon", user_id
);
80 void UserBoardScreenHandler::SetAuthType(
81 const std::string
& user_id
,
82 ScreenlockBridge::LockHandler::AuthType auth_type
,
83 const base::string16
& initial_value
) {
84 CallJS("login.AccountPickerScreen.setAuthType", user_id
,
85 static_cast<int>(auth_type
), base::StringValue(initial_value
));
88 void UserBoardScreenHandler::Bind(UserBoardModel
& model
) {
90 BaseScreenHandler::SetBaseScreen(model_
);
93 void UserBoardScreenHandler::Unbind() {
95 BaseScreenHandler::SetBaseScreen(nullptr);
98 } // namespace chromeos