OLD | NEW |
---|---|
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/cloud/user_policy_signin_service.h" | 5 #include "chrome/browser/policy/cloud/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 14 matching lines...) Expand all Loading... | |
25 #include "chrome/common/chrome_notification_types.h" | 25 #include "chrome/common/chrome_notification_types.h" |
26 #include "chrome/common/chrome_switches.h" | 26 #include "chrome/common/chrome_switches.h" |
27 #include "chrome/common/pref_names.h" | 27 #include "chrome/common/pref_names.h" |
28 #include "content/public/browser/notification_details.h" | 28 #include "content/public/browser/notification_details.h" |
29 #include "content/public/browser/notification_source.h" | 29 #include "content/public/browser/notification_source.h" |
30 #include "google_apis/gaia/gaia_constants.h" | 30 #include "google_apis/gaia/gaia_constants.h" |
31 #include "google_apis/gaia/gaia_urls.h" | 31 #include "google_apis/gaia/gaia_urls.h" |
32 #include "google_apis/gaia/oauth2_access_token_consumer.h" | 32 #include "google_apis/gaia/oauth2_access_token_consumer.h" |
33 #include "google_apis/gaia/oauth2_access_token_fetcher.h" | 33 #include "google_apis/gaia/oauth2_access_token_fetcher.h" |
34 | 34 |
35 #if defined(ENABLE_MANAGED_USERS) | |
36 #include "chrome/browser/managed_mode/managed_user_service.h" | |
37 #endif | |
38 | |
35 namespace em = enterprise_management; | 39 namespace em = enterprise_management; |
36 | 40 |
37 namespace { | 41 namespace { |
38 | 42 |
39 const char kServiceScopeGetUserInfo[] = | 43 const char kServiceScopeGetUserInfo[] = |
40 "https://www.googleapis.com/auth/userinfo.email"; | 44 "https://www.googleapis.com/auth/userinfo.email"; |
41 | 45 |
42 // The key under which the hosted-domain value is stored in the UserInfo | 46 // The key under which the hosted-domain value is stored in the UserInfo |
43 // response. | 47 // response. |
44 const char kGetHostedDomainKey[] = "hd"; | 48 const char kGetHostedDomainKey[] = "hd"; |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
357 const content::NotificationDetails& details) { | 361 const content::NotificationDetails& details) { |
358 // If an import process is running, wait for NOTIFICATION_IMPORT_FINISHED | 362 // If an import process is running, wait for NOTIFICATION_IMPORT_FINISHED |
359 // before potentially creating the SigninManager. Its dependencies can access | 363 // before potentially creating the SigninManager. Its dependencies can access |
360 // databases that the import process is also accessing, causing conflicts. | 364 // databases that the import process is also accessing, causing conflicts. |
361 // Note that the profile manager is NULL in unit tests. | 365 // Note that the profile manager is NULL in unit tests. |
362 if (g_browser_process->profile_manager() && | 366 if (g_browser_process->profile_manager() && |
363 g_browser_process->profile_manager()->will_import()) { | 367 g_browser_process->profile_manager()->will_import()) { |
364 return; | 368 return; |
365 } | 369 } |
366 | 370 |
371 #if defined(ENABLE_MANAGED_USERS) | |
372 if (ManagedUserService::ProfileIsManaged(profile_)) { | |
Andrew T Wilson (Slow)
2013/06/20 20:54:44
I would have liked to have seen a comment for what
| |
373 registrar_.RemoveAll(); | |
374 return; | |
375 } | |
376 #endif | |
377 | |
367 // If using a TestingProfile with no SigninManager or UserCloudPolicyManager, | 378 // If using a TestingProfile with no SigninManager or UserCloudPolicyManager, |
368 // skip initialization. | 379 // skip initialization. |
369 if (!GetManager() || !SigninManagerFactory::GetForProfile(profile_)) { | 380 if (!GetManager() || !SigninManagerFactory::GetForProfile(profile_)) { |
370 DVLOG(1) << "Skipping initialization for tests due to missing components."; | 381 DVLOG(1) << "Skipping initialization for tests due to missing components."; |
371 return; | 382 return; |
372 } | 383 } |
373 | 384 |
374 switch (type) { | 385 switch (type) { |
375 case chrome::NOTIFICATION_GOOGLE_SIGNED_OUT: | 386 case chrome::NOTIFICATION_GOOGLE_SIGNED_OUT: |
376 ShutdownUserCloudPolicyManager(); | 387 ShutdownUserCloudPolicyManager(); |
(...skipping 15 matching lines...) Expand all Loading... | |
392 ShutdownUserCloudPolicyManager(); | 403 ShutdownUserCloudPolicyManager(); |
393 else | 404 else |
394 InitializeForSignedInUser(); | 405 InitializeForSignedInUser(); |
395 break; | 406 break; |
396 } | 407 } |
397 case chrome::NOTIFICATION_TOKEN_AVAILABLE: { | 408 case chrome::NOTIFICATION_TOKEN_AVAILABLE: { |
398 const TokenService::TokenAvailableDetails& token_details = | 409 const TokenService::TokenAvailableDetails& token_details = |
399 *(content::Details<const TokenService::TokenAvailableDetails>( | 410 *(content::Details<const TokenService::TokenAvailableDetails>( |
400 details).ptr()); | 411 details).ptr()); |
401 if (token_details.service() == | 412 if (token_details.service() == |
402 GaiaConstants::kGaiaOAuth2LoginRefreshToken) { | 413 GaiaConstants::kGaiaOAuth2LoginRefreshToken) { |
403 SigninManager* signin_manager = | 414 SigninManager* signin_manager = |
404 SigninManagerFactory::GetForProfile(profile_); | 415 SigninManagerFactory::GetForProfile(profile_); |
405 std::string username = signin_manager->GetAuthenticatedUsername(); | 416 std::string username = signin_manager->GetAuthenticatedUsername(); |
406 // Should not have GAIA tokens if the user isn't signed in. | 417 // Should not have GAIA tokens if the user isn't signed in. |
407 DCHECK(!username.empty()); | 418 DCHECK(!username.empty()); |
408 // TokenService now has a refresh token (implying that the user is | 419 // TokenService now has a refresh token (implying that the user is |
409 // signed in) so initialize the UserCloudPolicyManager. | 420 // signed in) so initialize the UserCloudPolicyManager. |
410 InitializeForSignedInUser(); | 421 InitializeForSignedInUser(); |
411 } | 422 } |
412 break; | 423 break; |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
582 // before UserCloudPolicyManager shuts down the CloudPolicyClient. | 593 // before UserCloudPolicyManager shuts down the CloudPolicyClient. |
583 registration_helper_.reset(); | 594 registration_helper_.reset(); |
584 StopObserving(); | 595 StopObserving(); |
585 } | 596 } |
586 | 597 |
587 UserCloudPolicyManager* UserPolicySigninService::GetManager() { | 598 UserCloudPolicyManager* UserPolicySigninService::GetManager() { |
588 return UserCloudPolicyManagerFactory::GetForProfile(profile_); | 599 return UserCloudPolicyManagerFactory::GetForProfile(profile_); |
589 } | 600 } |
590 | 601 |
591 } // namespace policy | 602 } // namespace policy |
OLD | NEW |