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

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

Issue 1165323004: We should use UserID object to identify users instead of username. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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/user_cloud_policy_manager_factory_chrom eos.h" 5 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_factory_chrom eos.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 const user_manager::User* user = 129 const user_manager::User* user =
130 chromeos::ProfileHelper::Get()->GetUserByProfile(profile); 130 chromeos::ProfileHelper::Get()->GetUserByProfile(profile);
131 CHECK(user); 131 CHECK(user);
132 132
133 // User policy exists for enterprise accounts only: 133 // User policy exists for enterprise accounts only:
134 // - For regular enterprise users (those who have a GAIA account), a 134 // - For regular enterprise users (those who have a GAIA account), a
135 // |UserCloudPolicyManagerChromeOS| is created here. 135 // |UserCloudPolicyManagerChromeOS| is created here.
136 // - For device-local accounts, policy is provided by 136 // - For device-local accounts, policy is provided by
137 // |DeviceLocalAccountPolicyService|. 137 // |DeviceLocalAccountPolicyService|.
138 // All other user types do not have user policy. 138 // All other user types do not have user policy.
139 const std::string& username = user->email(); 139 const user_manager::UserID& user_id = user->GetUserID();
140 if (!user->HasGaiaAccount() || 140 if (!user->HasGaiaAccount() ||
141 user->IsSupervised() || 141 user->IsSupervised() ||
142 BrowserPolicyConnector::IsNonEnterpriseUser(username)) { 142 BrowserPolicyConnector::IsNonEnterpriseUser(user_id)) {
143 return scoped_ptr<UserCloudPolicyManagerChromeOS>(); 143 return scoped_ptr<UserCloudPolicyManagerChromeOS>();
144 } 144 }
145 145
146 policy::BrowserPolicyConnectorChromeOS* connector = 146 policy::BrowserPolicyConnectorChromeOS* connector =
147 g_browser_process->platform_part()->browser_policy_connector_chromeos(); 147 g_browser_process->platform_part()->browser_policy_connector_chromeos();
148 UserAffiliation affiliation = connector->GetUserAffiliation(username); 148 UserAffiliation affiliation = connector->GetUserAffiliation(user_id);
149 const bool is_affiliated_user = affiliation == USER_AFFILIATION_MANAGED; 149 const bool is_affiliated_user = affiliation == USER_AFFILIATION_MANAGED;
150 const bool is_browser_restart = 150 const bool is_browser_restart =
151 command_line->HasSwitch(chromeos::switches::kLoginUser); 151 command_line->HasSwitch(chromeos::switches::kLoginUser);
152 const bool wait_for_initial_policy = 152 const bool wait_for_initial_policy =
153 !is_browser_restart && 153 !is_browser_restart &&
154 (user_manager::UserManager::Get()->IsCurrentUserNew() || 154 (user_manager::UserManager::Get()->IsCurrentUserNew() ||
155 is_affiliated_user); 155 is_affiliated_user);
156 156
157 const base::TimeDelta initial_policy_fetch_timeout = 157 const base::TimeDelta initial_policy_fetch_timeout =
158 user_manager::UserManager::Get()->IsCurrentUserNew() 158 user_manager::UserManager::Get()->IsCurrentUserNew()
(...skipping 14 matching lines...) Expand all
173 const base::FilePath external_data_dir = 173 const base::FilePath external_data_dir =
174 profile_dir.Append(kPolicy).Append(kPolicyExternalDataDir); 174 profile_dir.Append(kPolicy).Append(kPolicyExternalDataDir);
175 base::FilePath policy_key_dir; 175 base::FilePath policy_key_dir;
176 CHECK(PathService::Get(chromeos::DIR_USER_POLICY_KEYS, &policy_key_dir)); 176 CHECK(PathService::Get(chromeos::DIR_USER_POLICY_KEYS, &policy_key_dir));
177 177
178 scoped_ptr<UserCloudPolicyStoreChromeOS> store( 178 scoped_ptr<UserCloudPolicyStoreChromeOS> store(
179 new UserCloudPolicyStoreChromeOS( 179 new UserCloudPolicyStoreChromeOS(
180 chromeos::DBusThreadManager::Get()->GetCryptohomeClient(), 180 chromeos::DBusThreadManager::Get()->GetCryptohomeClient(),
181 chromeos::DBusThreadManager::Get()->GetSessionManagerClient(), 181 chromeos::DBusThreadManager::Get()->GetSessionManagerClient(),
182 background_task_runner, 182 background_task_runner,
183 username, policy_key_dir, token_cache_file, policy_cache_file)); 183 user_id, policy_key_dir, token_cache_file, policy_cache_file));
184 184
185 scoped_refptr<base::SequencedTaskRunner> backend_task_runner = 185 scoped_refptr<base::SequencedTaskRunner> backend_task_runner =
186 content::BrowserThread::GetBlockingPool()->GetSequencedTaskRunner( 186 content::BrowserThread::GetBlockingPool()->GetSequencedTaskRunner(
187 content::BrowserThread::GetBlockingPool()->GetSequenceToken()); 187 content::BrowserThread::GetBlockingPool()->GetSequenceToken());
188 scoped_refptr<base::SequencedTaskRunner> io_task_runner = 188 scoped_refptr<base::SequencedTaskRunner> io_task_runner =
189 content::BrowserThread::GetMessageLoopProxyForThread( 189 content::BrowserThread::GetMessageLoopProxyForThread(
190 content::BrowserThread::IO); 190 content::BrowserThread::IO);
191 scoped_ptr<CloudExternalDataManager> external_data_manager( 191 scoped_ptr<CloudExternalDataManager> external_data_manager(
192 new UserCloudExternalDataManager(base::Bind(&GetChromePolicyDetails), 192 new UserCloudExternalDataManager(base::Bind(&GetChromePolicyDetails),
193 backend_task_runner, 193 backend_task_runner,
194 io_task_runner, 194 io_task_runner,
195 external_data_dir, 195 external_data_dir,
196 store.get())); 196 store.get()));
197 if (force_immediate_load) 197 if (force_immediate_load)
198 store->LoadImmediately(); 198 store->LoadImmediately();
199 199
200 scoped_refptr<base::SequencedTaskRunner> file_task_runner = 200 scoped_refptr<base::SequencedTaskRunner> file_task_runner =
201 content::BrowserThread::GetMessageLoopProxyForThread( 201 content::BrowserThread::GetMessageLoopProxyForThread(
202 content::BrowserThread::FILE); 202 content::BrowserThread::FILE);
203 203
204 scoped_ptr<UserCloudPolicyManagerChromeOS> manager( 204 scoped_ptr<UserCloudPolicyManagerChromeOS> manager(
205 new UserCloudPolicyManagerChromeOS( 205 new UserCloudPolicyManagerChromeOS(
206 store.Pass(), external_data_manager.Pass(), 206 store.Pass(), external_data_manager.Pass(),
207 component_policy_cache_dir, wait_for_initial_policy, 207 component_policy_cache_dir, wait_for_initial_policy,
208 initial_policy_fetch_timeout, base::ThreadTaskRunnerHandle::Get(), 208 initial_policy_fetch_timeout, base::ThreadTaskRunnerHandle::Get(),
209 file_task_runner, io_task_runner)); 209 file_task_runner, io_task_runner));
210 210
211 bool wildcard_match = false; 211 bool wildcard_match = false;
212 if (connector->IsEnterpriseManaged() && 212 if (connector->IsEnterpriseManaged() &&
213 chromeos::CrosSettings::IsWhitelisted(username, &wildcard_match) && 213 chromeos::CrosSettings::IsWhitelisted(user_id, &wildcard_match) &&
214 wildcard_match && !connector->IsNonEnterpriseUser(username)) { 214 wildcard_match && !connector->IsNonEnterpriseUser(user_id)) {
215 manager->EnableWildcardLoginCheck(username); 215 manager->EnableWildcardLoginCheck(user_id);
216 } 216 }
217 217
218 manager->Init( 218 manager->Init(
219 SchemaRegistryServiceFactory::GetForContext(profile)->registry()); 219 SchemaRegistryServiceFactory::GetForContext(profile)->registry());
220 manager->Connect(g_browser_process->local_state(), 220 manager->Connect(g_browser_process->local_state(),
221 device_management_service, 221 device_management_service,
222 g_browser_process->system_request_context(), 222 g_browser_process->system_request_context(),
223 affiliation); 223 affiliation);
224 224
225 DCHECK(managers_.find(profile) == managers_.end()); 225 DCHECK(managers_.find(profile) == managers_.end());
(...skipping 23 matching lines...) Expand all
249 249
250 bool UserCloudPolicyManagerFactoryChromeOS::HasTestingFactory( 250 bool UserCloudPolicyManagerFactoryChromeOS::HasTestingFactory(
251 content::BrowserContext* context) { 251 content::BrowserContext* context) {
252 return false; 252 return false;
253 } 253 }
254 254
255 void UserCloudPolicyManagerFactoryChromeOS::CreateServiceNow( 255 void UserCloudPolicyManagerFactoryChromeOS::CreateServiceNow(
256 content::BrowserContext* context) {} 256 content::BrowserContext* context) {}
257 257
258 } // namespace policy 258 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698