Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(181)

Side by Side Diff: chrome/browser/chromeos/policy/device_local_account.cc

Issue 1019283004: Switch to direct use of OwnerSettingsServiceChromeOS::Set() in tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 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 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 "chrome/browser/chromeos/policy/device_local_account.h" 5 #include "chrome/browser/chromeos/policy/device_local_account.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/strings/string_number_conversions.h" 12 #include "base/strings/string_number_conversions.h"
13 #include "base/strings/string_util.h" 13 #include "base/strings/string_util.h"
14 #include "base/values.h" 14 #include "base/values.h"
15 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos.h"
15 #include "chrome/browser/chromeos/settings/cros_settings.h" 16 #include "chrome/browser/chromeos/settings/cros_settings.h"
16 #include "chromeos/login/user_names.h" 17 #include "chromeos/login/user_names.h"
17 #include "chromeos/settings/cros_settings_names.h" 18 #include "chromeos/settings/cros_settings_names.h"
18 #include "google_apis/gaia/gaia_auth_util.h" 19 #include "google_apis/gaia/gaia_auth_util.h"
19 20
20 namespace policy { 21 namespace policy {
21 22
22 namespace { 23 namespace {
23 24
24 const char kPublicAccountDomainPrefix[] = "public-accounts"; 25 const char kPublicAccountDomainPrefix[] = "public-accounts";
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 return true; 85 return true;
85 } 86 }
86 87
87 // |user_id| is a device-local account but its type is not recognized. 88 // |user_id| is a device-local account but its type is not recognized.
88 NOTREACHED(); 89 NOTREACHED();
89 if (type) 90 if (type)
90 *type = DeviceLocalAccount::TYPE_COUNT; 91 *type = DeviceLocalAccount::TYPE_COUNT;
91 return true; 92 return true;
92 } 93 }
93 94
94 void SetDeviceLocalAccounts( 95 void SetDeviceLocalAccounts(chromeos::OwnerSettingsServiceChromeOS* service,
95 chromeos::CrosSettings* cros_settings, 96 const std::vector<DeviceLocalAccount>& accounts) {
96 const std::vector<DeviceLocalAccount>& accounts) {
97 base::ListValue list; 97 base::ListValue list;
98 for (std::vector<DeviceLocalAccount>::const_iterator it = accounts.begin(); 98 for (std::vector<DeviceLocalAccount>::const_iterator it = accounts.begin();
99 it != accounts.end(); ++it) { 99 it != accounts.end(); ++it) {
100 scoped_ptr<base::DictionaryValue> entry(new base::DictionaryValue); 100 scoped_ptr<base::DictionaryValue> entry(new base::DictionaryValue);
101 entry->SetStringWithoutPathExpansion( 101 entry->SetStringWithoutPathExpansion(
102 chromeos::kAccountsPrefDeviceLocalAccountsKeyId, 102 chromeos::kAccountsPrefDeviceLocalAccountsKeyId,
103 it->account_id); 103 it->account_id);
104 entry->SetIntegerWithoutPathExpansion( 104 entry->SetIntegerWithoutPathExpansion(
105 chromeos::kAccountsPrefDeviceLocalAccountsKeyType, 105 chromeos::kAccountsPrefDeviceLocalAccountsKeyType,
106 it->type); 106 it->type);
107 if (it->type == DeviceLocalAccount::TYPE_KIOSK_APP) { 107 if (it->type == DeviceLocalAccount::TYPE_KIOSK_APP) {
108 entry->SetStringWithoutPathExpansion( 108 entry->SetStringWithoutPathExpansion(
109 chromeos::kAccountsPrefDeviceLocalAccountsKeyKioskAppId, 109 chromeos::kAccountsPrefDeviceLocalAccountsKeyKioskAppId,
110 it->kiosk_app_id); 110 it->kiosk_app_id);
111 if (!it->kiosk_app_update_url.empty()) { 111 if (!it->kiosk_app_update_url.empty()) {
112 entry->SetStringWithoutPathExpansion( 112 entry->SetStringWithoutPathExpansion(
113 chromeos::kAccountsPrefDeviceLocalAccountsKeyKioskAppUpdateURL, 113 chromeos::kAccountsPrefDeviceLocalAccountsKeyKioskAppUpdateURL,
114 it->kiosk_app_update_url); 114 it->kiosk_app_update_url);
115 } 115 }
116 } 116 }
117 list.Append(entry.release()); 117 list.Append(entry.release());
118 } 118 }
119 119
120 cros_settings->Set(chromeos::kAccountsPrefDeviceLocalAccounts, list); 120 service->Set(chromeos::kAccountsPrefDeviceLocalAccounts, list);
121 } 121 }
122 122
123 std::vector<DeviceLocalAccount> GetDeviceLocalAccounts( 123 std::vector<DeviceLocalAccount> GetDeviceLocalAccounts(
124 chromeos::CrosSettings* cros_settings) { 124 chromeos::CrosSettings* cros_settings) {
125 std::vector<DeviceLocalAccount> accounts; 125 std::vector<DeviceLocalAccount> accounts;
126 126
127 const base::ListValue* list = NULL; 127 const base::ListValue* list = NULL;
128 cros_settings->GetList(chromeos::kAccountsPrefDeviceLocalAccounts, &list); 128 cros_settings->GetList(chromeos::kAccountsPrefDeviceLocalAccounts, &list);
129 if (!list) 129 if (!list)
130 return accounts; 130 return accounts;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 accounts.push_back( 180 accounts.push_back(
181 DeviceLocalAccount(static_cast<DeviceLocalAccount::Type>(type), 181 DeviceLocalAccount(static_cast<DeviceLocalAccount::Type>(type),
182 account_id, 182 account_id,
183 kiosk_app_id, 183 kiosk_app_id,
184 kiosk_app_update_url)); 184 kiosk_app_update_url));
185 } 185 }
186 return accounts; 186 return accounts;
187 } 187 }
188 188
189 } // namespace policy 189 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698