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

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

Issue 12692006: Merge 186990 (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1410/src/
Patch Set: Created 7 years, 9 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/user_policy_signin_service.h" 5 #include "chrome/browser/policy/user_policy_signin_service.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 // TokenService should not yet have loaded its tokens since this happens in 241 // TokenService should not yet have loaded its tokens since this happens in
242 // the background after PKS initialization - so this service should always be 242 // the background after PKS initialization - so this service should always be
243 // created before the oauth token is available. 243 // created before the oauth token is available.
244 DCHECK(!TokenServiceFactory::GetForProfile(profile_)->HasOAuthLoginToken()); 244 DCHECK(!TokenServiceFactory::GetForProfile(profile_)->HasOAuthLoginToken());
245 245
246 // Register a listener to be called back once the current profile has finished 246 // Register a listener to be called back once the current profile has finished
247 // initializing, so we can startup the UserCloudPolicyManager. 247 // initializing, so we can startup the UserCloudPolicyManager.
248 registrar_.Add(this, 248 registrar_.Add(this,
249 chrome::NOTIFICATION_PROFILE_ADDED, 249 chrome::NOTIFICATION_PROFILE_ADDED,
250 content::Source<Profile>(profile)); 250 content::Source<Profile>(profile));
251
252 // Register a listener for the import finished notification in a first run
253 // scenario, which indicates the profile is ready to be further initialized.
254 registrar_.Add(this,
255 chrome::NOTIFICATION_IMPORT_FINISHED,
256 content::Source<Profile>(profile));
251 } 257 }
252 258
253 UserPolicySigninService::~UserPolicySigninService() {} 259 UserPolicySigninService::~UserPolicySigninService() {}
254 260
255 void UserPolicySigninService::RegisterPolicyClient( 261 void UserPolicySigninService::RegisterPolicyClient(
256 const std::string& username, 262 const std::string& username,
257 const std::string& oauth2_refresh_token, 263 const std::string& oauth2_refresh_token,
258 const PolicyRegistrationCallback& callback) { 264 const PolicyRegistrationCallback& callback) {
259 DCHECK(!username.empty()); 265 DCHECK(!username.empty());
260 DCHECK(!oauth2_refresh_token.empty()); 266 DCHECK(!oauth2_refresh_token.empty());
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 // Manager should be fully initialized by now. 341 // Manager should be fully initialized by now.
336 DCHECK(manager); 342 DCHECK(manager);
337 DCHECK(manager->core()->service()); 343 DCHECK(manager->core()->service());
338 manager->core()->service()->AddObserver(this); 344 manager->core()->service()->AddObserver(this);
339 } 345 }
340 346
341 void UserPolicySigninService::Observe( 347 void UserPolicySigninService::Observe(
342 int type, 348 int type,
343 const content::NotificationSource& source, 349 const content::NotificationSource& source,
344 const content::NotificationDetails& details) { 350 const content::NotificationDetails& details) {
351 // If an import process is running, wait for NOTIFICATION_IMPORT_FINISHED
352 // before potentially creating the SigninManager. Its dependencies can access
353 // databases that the import process is also accessing, causing conflicts.
354 // Note that the profile manager is NULL in unit tests.
355 if (g_browser_process->profile_manager() &&
356 g_browser_process->profile_manager()->will_import()) {
357 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_ADDED, type);
358 return;
359 }
360
345 // If using a TestingProfile with no SigninManager or UserCloudPolicyManager, 361 // If using a TestingProfile with no SigninManager or UserCloudPolicyManager,
346 // skip initialization. 362 // skip initialization.
347 if (!GetManager() || !SigninManagerFactory::GetForProfile(profile_)) { 363 if (!GetManager() || !SigninManagerFactory::GetForProfile(profile_)) {
348 DVLOG(1) << "Skipping initialization for tests due to missing components."; 364 DVLOG(1) << "Skipping initialization for tests due to missing components.";
349 return; 365 return;
350 } 366 }
351 367
352 switch (type) { 368 switch (type) {
353 case chrome::NOTIFICATION_GOOGLE_SIGNED_OUT: 369 case chrome::NOTIFICATION_GOOGLE_SIGNED_OUT:
354 ShutdownUserCloudPolicyManager(); 370 ShutdownUserCloudPolicyManager();
355 break; 371 break;
372 case chrome::NOTIFICATION_IMPORT_FINISHED:
356 case chrome::NOTIFICATION_PROFILE_ADDED: { 373 case chrome::NOTIFICATION_PROFILE_ADDED: {
357 // A new profile has been loaded - if it's signed in, then initialize the 374 // A new profile has been loaded - if it's signed in, then initialize the
358 // UCPM, otherwise shut down the UCPM (which deletes any cached policy 375 // UCPM, otherwise shut down the UCPM (which deletes any cached policy
359 // data). This must be done here instead of at constructor time because 376 // data). This must be done here instead of at constructor time because
360 // the Profile is not fully initialized when this object is constructed 377 // the Profile is not fully initialized when this object is constructed
361 // (DoFinalInit() has not yet been called, so ProfileIOData and 378 // (DoFinalInit() has not yet been called, so ProfileIOData and
362 // SSLConfigServiceManager have not been created yet). 379 // SSLConfigServiceManager have not been created yet).
363 // TODO(atwilson): Switch to using a timer instead, to avoid contention 380 // TODO(atwilson): Switch to using a timer instead, to avoid contention
364 // with other services at startup (http://crbug.com/165468). 381 // with other services at startup (http://crbug.com/165468).
365 SigninManager* signin_manager = 382 SigninManager* signin_manager =
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 // before UserCloudPolicyManager shuts down the CloudPolicyClient. 540 // before UserCloudPolicyManager shuts down the CloudPolicyClient.
524 registration_helper_.reset(); 541 registration_helper_.reset();
525 StopObserving(); 542 StopObserving();
526 } 543 }
527 544
528 UserCloudPolicyManager* UserPolicySigninService::GetManager() { 545 UserCloudPolicyManager* UserPolicySigninService::GetManager() {
529 return UserCloudPolicyManagerFactory::GetForProfile(profile_); 546 return UserCloudPolicyManagerFactory::GetForProfile(profile_);
530 } 547 }
531 548
532 } // namespace policy 549 } // namespace policy
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698