1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/chromeos/dom_ui/accounts_options_handler.h"
#include "app/l10n_util.h"
#include "base/json/json_reader.h"
#include "base/scoped_ptr.h"
#include "base/utf_string_conversions.h"
#include "base/values.h"
#include "chrome/browser/chromeos/cros_settings_provider_user.h"
#include "chrome/browser/chromeos/login/user_manager.h"
#include "grit/generated_resources.h"
namespace chromeos {
AccountsOptionsHandler::AccountsOptionsHandler()
: CrosOptionsPageUIHandler(new UserCrosSettingsProvider()) {
}
AccountsOptionsHandler::~AccountsOptionsHandler() {
}
void AccountsOptionsHandler::RegisterMessages() {
DCHECK(dom_ui_);
dom_ui_->RegisterMessageCallback("whitelistUser",
NewCallback(this, &AccountsOptionsHandler::WhitelistUser));
dom_ui_->RegisterMessageCallback("unwhitelistUser",
NewCallback(this, &AccountsOptionsHandler::UnwhitelistUser));
}
void AccountsOptionsHandler::GetLocalizedValues(
DictionaryValue* localized_strings) {
DCHECK(localized_strings);
localized_strings->SetString("accountsPage", l10n_util::GetStringUTF16(
IDS_OPTIONS_ACCOUNTS_TAB_LABEL));
localized_strings->SetString("allow_BWSI", l10n_util::GetStringUTF16(
IDS_OPTIONS_ACCOUNTS_ALLOW_BWSI_DESCRIPTION));
localized_strings->SetString("allow_guest",l10n_util::GetStringUTF16(
IDS_OPTIONS_ACCOUNTS_ALLOW_GUEST_DESCRIPTION));
localized_strings->SetString("show_user_on_signin",l10n_util::GetStringUTF16(
IDS_OPTIONS_ACCOUNTS_SHOW_USER_NAMES_ON_SINGIN_DESCRIPTION));
localized_strings->SetString("username_edit_hint",l10n_util::GetStringUTF16(
IDS_OPTIONS_ACCOUNTS_USERNAME_EDIT_HINT));
localized_strings->SetString("username_format",l10n_util::GetStringUTF16(
IDS_OPTIONS_ACCOUNTS_USERNAME_FORMAT));
localized_strings->SetString("add_users",l10n_util::GetStringUTF16(
IDS_OPTIONS_ACCOUNTS_ADD_USERS));
localized_strings->SetString("current_user_is_owner",
UserManager::Get()->current_user_is_owner() ?
ASCIIToUTF16("true") : ASCIIToUTF16("false"));
}
UserCrosSettingsProvider* AccountsOptionsHandler::users_settings() const {
return static_cast<UserCrosSettingsProvider*>(settings_provider_.get());
}
void AccountsOptionsHandler::WhitelistUser(const ListValue* args) {
std::string email;
if (!args->GetString(0, &email)) {
return;
}
users_settings()->WhitelistUser(email);
}
void AccountsOptionsHandler::UnwhitelistUser(const ListValue* args) {
std::string email;
if (!args->GetString(0, &email)) {
return;
}
users_settings()->UnwhitelistUser(email);
}
} // namespace chromeos
|