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
|
// 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/cros_settings_provider_user.h"
#include "base/logging.h"
#include "base/string_util.h"
#include "base/values.h"
#include "chrome/browser/chromeos/cros_settings_names.h"
#include "chrome/browser/chromeos/login/user_manager.h"
namespace {
Value* CreateSettingsBooleanValue(bool value, bool managed) {
DictionaryValue* dict = new DictionaryValue;
dict->Set("value", Value::CreateBooleanValue(value));
dict->Set("managed", Value::CreateBooleanValue(managed));
return dict;
}
} // namespace
namespace chromeos {
UserCrosSettingsProvider::UserCrosSettingsProvider()
: dict_(new DictionaryValue) {
bool is_owner = UserManager::Get()->current_user_is_owner();
Set(kAccountsPrefAllowBWSI, CreateSettingsBooleanValue(true, !is_owner));
Set(kAccountsPrefAllowGuest, CreateSettingsBooleanValue(true, !is_owner));
Set(kAccountsPrefShowUserNamesOnSignIn,
CreateSettingsBooleanValue(true, !is_owner));
ListValue* user_list = new ListValue;
DictionaryValue* mock_user = new DictionaryValue;
mock_user->SetString("email", "mock_user_1@gmail.com");
mock_user->SetString("name", "Mock User One");
mock_user->SetBoolean("owner", true);
user_list->Append(mock_user);
mock_user = new DictionaryValue;
mock_user->SetString("email", "mock_user_2@gmail.com");
mock_user->SetString("name", "Mock User Two");
mock_user->SetBoolean("owner", false);
user_list->Append(mock_user);
Set(kAccountsPrefUsers, user_list);
}
void UserCrosSettingsProvider::Set(const std::string& path, Value* in_value) {
dict_->Set(path, in_value);
}
bool UserCrosSettingsProvider::Get(const std::string& path,
Value** out_value) const {
return dict_->Get(path, out_value);
}
bool UserCrosSettingsProvider::HandlesSetting(const std::string& path) {
return ::StartsWithASCII(path, "cros.accounts.", true);
}
} // namespace chromeos
|