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

Side by Side Diff: chrome/browser/policy/browser_policy_connector.cc

Issue 9404011: Explicitly wait for user policy before completing login. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/policy/browser_policy_connector.h" 5 #include "chrome/browser/policy/browser_policy_connector.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/file_path.h" 9 #include "base/file_path.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 } 251 }
252 #if defined(OS_CHROMEOS) 252 #if defined(OS_CHROMEOS)
253 if (device_cloud_policy_subsystem_.get()) { 253 if (device_cloud_policy_subsystem_.get()) {
254 device_cloud_policy_subsystem_-> 254 device_cloud_policy_subsystem_->
255 ScheduleServiceInitialization(delay_milliseconds); 255 ScheduleServiceInitialization(delay_milliseconds);
256 } 256 }
257 #endif 257 #endif
258 } 258 }
259 void BrowserPolicyConnector::InitializeUserPolicy( 259 void BrowserPolicyConnector::InitializeUserPolicy(
260 const std::string& user_name, 260 const std::string& user_name,
261 bool wait_for_policy_fetch) { 261 bool wait_for_policy_fetch,
262 const base::Closure& callback) {
262 // Throw away the old backend. 263 // Throw away the old backend.
263 user_cloud_policy_subsystem_.reset(); 264 user_cloud_policy_subsystem_.reset();
264 user_policy_token_cache_.reset(); 265 user_policy_token_cache_.reset();
265 user_data_store_.reset(); 266 user_data_store_.reset();
266 token_service_ = NULL; 267 token_service_ = NULL;
267 registrar_.RemoveAll(); 268 registrar_.RemoveAll();
268 269
269 CommandLine* command_line = CommandLine::ForCurrentProcess(); 270 CommandLine* command_line = CommandLine::ForCurrentProcess();
270 271
271 FilePath policy_dir; 272 FilePath policy_dir;
272 PathService::Get(chrome::DIR_USER_DATA, &policy_dir); 273 PathService::Get(chrome::DIR_USER_DATA, &policy_dir);
273 #if defined(OS_CHROMEOS) 274 #if defined(OS_CHROMEOS)
274 policy_dir = policy_dir.Append( 275 policy_dir = policy_dir.Append(
275 command_line->GetSwitchValuePath(switches::kLoginProfile)); 276 command_line->GetSwitchValuePath(switches::kLoginProfile));
276 #endif 277 #endif
277 278
278 if (command_line->HasSwitch(switches::kDeviceManagementUrl)) { 279 if (command_line->HasSwitch(switches::kDeviceManagementUrl)) {
279 FilePath policy_cache_dir = policy_dir.Append(kPolicyDir); 280 FilePath policy_cache_dir = policy_dir.Append(kPolicyDir);
280 281
281 UserPolicyCache* user_policy_cache = 282 UserPolicyCache* user_policy_cache =
282 new UserPolicyCache(policy_cache_dir.Append(kPolicyCacheFile), 283 new UserPolicyCache(policy_cache_dir.Append(kPolicyCacheFile),
283 wait_for_policy_fetch); 284 wait_for_policy_fetch,
285 callback);
284 user_data_store_.reset(CloudPolicyDataStore::CreateForUserPolicies()); 286 user_data_store_.reset(CloudPolicyDataStore::CreateForUserPolicies());
285 user_policy_token_cache_.reset( 287 user_policy_token_cache_.reset(
286 new UserPolicyTokenCache(user_data_store_.get(), 288 new UserPolicyTokenCache(user_data_store_.get(),
287 policy_cache_dir.Append(kTokenCacheFile))); 289 policy_cache_dir.Append(kTokenCacheFile)));
288 290
289 // Prepending user caches meaning they will take precedence of device policy 291 // Prepending user caches meaning they will take precedence of device policy
290 // caches. 292 // caches.
291 managed_cloud_provider_->PrependCache(user_policy_cache); 293 managed_cloud_provider_->PrependCache(user_policy_cache);
292 recommended_cloud_provider_->PrependCache(user_policy_cache); 294 recommended_cloud_provider_->PrependCache(user_policy_cache);
293 user_cloud_policy_subsystem_.reset(new CloudPolicySubsystem( 295 user_cloud_policy_subsystem_.reset(new CloudPolicySubsystem(
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 config_dir_path.Append(FILE_PATH_LITERAL("recommended"))); 512 config_dir_path.Append(FILE_PATH_LITERAL("recommended")));
511 } else { 513 } else {
512 return NULL; 514 return NULL;
513 } 515 }
514 #else 516 #else
515 return NULL; 517 return NULL;
516 #endif 518 #endif
517 } 519 }
518 520
519 } // namespace policy 521 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698