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
);
26 AddCallback("recordClickOnLockIcon",
27 &UserBoardScreenHandler::HandleRecordClickOnLockIcon
);
30 void UserBoardScreenHandler::Initialize() {
33 //----------------- Handlers
35 void UserBoardScreenHandler::HandleGetUsers() {
37 model_
->SendUserList();
40 void UserBoardScreenHandler::HandleHardlockPod(const std::string
& user_id
) {
42 model_
->HardLockPod(user_id
);
45 void UserBoardScreenHandler::HandleAttemptUnlock(const std::string
& user_id
) {
47 model_
->AttemptEasyUnlock(user_id
);
50 void UserBoardScreenHandler::HandleRecordClickOnLockIcon(
51 const std::string
& user_id
) {
53 model_
->RecordClickOnLockIcon(user_id
);
56 //----------------- API
58 void UserBoardScreenHandler::SetPublicSessionDisplayName(
59 const std::string
& user_id
,
60 const std::string
& display_name
) {
61 CallJS("login.AccountPickerScreen.setPublicSessionDisplayName", user_id
,
65 void UserBoardScreenHandler::SetPublicSessionLocales(
66 const std::string
& user_id
,
67 scoped_ptr
<base::ListValue
> locales
,
68 const std::string
& default_locale
,
69 bool multiple_recommended_locales
) {
70 CallJS("login.AccountPickerScreen.setPublicSessionLocales", user_id
, *locales
,
71 default_locale
, multiple_recommended_locales
);
74 void UserBoardScreenHandler::ShowBannerMessage(const base::string16
& message
) {
75 CallJS("login.AccountPickerScreen.showBannerMessage", message
);
78 void UserBoardScreenHandler::ShowUserPodCustomIcon(
79 const std::string
& user_id
,
80 const base::DictionaryValue
& icon
) {
81 CallJS("login.AccountPickerScreen.showUserPodCustomIcon", user_id
, icon
);
84 void UserBoardScreenHandler::HideUserPodCustomIcon(const std::string
& user_id
) {
85 CallJS("login.AccountPickerScreen.hideUserPodCustomIcon", user_id
);
88 void UserBoardScreenHandler::SetAuthType(
89 const std::string
& user_id
,
90 proximity_auth::ScreenlockBridge::LockHandler::AuthType auth_type
,
91 const base::string16
& initial_value
) {
92 CallJS("login.AccountPickerScreen.setAuthType", user_id
,
93 static_cast<int>(auth_type
), base::StringValue(initial_value
));
96 void UserBoardScreenHandler::Bind(UserBoardModel
& model
) {
98 BaseScreenHandler::SetBaseScreen(model_
);
101 void UserBoardScreenHandler::Unbind() {
103 BaseScreenHandler::SetBaseScreen(nullptr);
106 } // namespace chromeos