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/signin/signin_manager.h" | 5 #include "chrome/browser/signin/signin_manager.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
(...skipping 10 matching lines...) Expand all Loading... | |
21 #include "chrome/browser/profiles/profile_manager.h" | 21 #include "chrome/browser/profiles/profile_manager.h" |
22 #include "chrome/browser/signin/about_signin_internals.h" | 22 #include "chrome/browser/signin/about_signin_internals.h" |
23 #include "chrome/browser/signin/about_signin_internals_factory.h" | 23 #include "chrome/browser/signin/about_signin_internals_factory.h" |
24 #include "chrome/browser/signin/signin_global_error.h" | 24 #include "chrome/browser/signin/signin_global_error.h" |
25 #include "chrome/browser/signin/signin_internals_util.h" | 25 #include "chrome/browser/signin/signin_internals_util.h" |
26 #include "chrome/browser/signin/signin_manager_factory.h" | 26 #include "chrome/browser/signin/signin_manager_factory.h" |
27 #include "chrome/browser/signin/token_service.h" | 27 #include "chrome/browser/signin/token_service.h" |
28 #include "chrome/browser/signin/token_service_factory.h" | 28 #include "chrome/browser/signin/token_service_factory.h" |
29 #include "chrome/browser/sync/profile_sync_service.h" | 29 #include "chrome/browser/sync/profile_sync_service.h" |
30 #include "chrome/browser/sync/sync_prefs.h" | 30 #include "chrome/browser/sync/sync_prefs.h" |
31 #include "chrome/browser/ui/global_error/global_error_service.h" | |
32 #include "chrome/browser/ui/global_error/global_error_service_factory.h" | 31 #include "chrome/browser/ui/global_error/global_error_service_factory.h" |
32 #include "chrome/browser/ui/host_desktop.h" | |
33 #include "chrome/browser/ui/webui/signin/profile_signin_confirmation_dialog.h" | |
33 #include "chrome/common/chrome_notification_types.h" | 34 #include "chrome/common/chrome_notification_types.h" |
34 #include "chrome/common/chrome_switches.h" | 35 #include "chrome/common/chrome_switches.h" |
35 #include "chrome/common/pref_names.h" | 36 #include "chrome/common/pref_names.h" |
36 #include "content/public/browser/browser_thread.h" | 37 #include "content/public/browser/browser_thread.h" |
37 #include "content/public/browser/notification_service.h" | 38 #include "content/public/browser/notification_service.h" |
38 #include "google_apis/gaia/gaia_auth_fetcher.h" | 39 #include "google_apis/gaia/gaia_auth_fetcher.h" |
39 #include "google_apis/gaia/gaia_auth_util.h" | 40 #include "google_apis/gaia/gaia_auth_util.h" |
40 #include "google_apis/gaia/gaia_constants.h" | 41 #include "google_apis/gaia/gaia_constants.h" |
41 #include "google_apis/gaia/gaia_urls.h" | 42 #include "google_apis/gaia/gaia_urls.h" |
42 #include "net/cookies/cookie_monster.h" | 43 #include "net/cookies/cookie_monster.h" |
(...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
715 CompleteSigninAfterPolicyLoad(); | 716 CompleteSigninAfterPolicyLoad(); |
716 return; | 717 return; |
717 } | 718 } |
718 | 719 |
719 // Stash away a copy of our CloudPolicyClient (should not already have one). | 720 // Stash away a copy of our CloudPolicyClient (should not already have one). |
720 DCHECK(!policy_client_); | 721 DCHECK(!policy_client_); |
721 policy_client_.swap(client); | 722 policy_client_.swap(client); |
722 | 723 |
723 DVLOG(1) << "Policy registration succeeded: dm_token=" | 724 DVLOG(1) << "Policy registration succeeded: dm_token=" |
724 << policy_client_->dm_token(); | 725 << policy_client_->dm_token(); |
725 // TODO(dconnelly): Prompt user for whether they want to create a new profile | 726 |
726 // or not (http://crbug.com/171236), and either call SignOut() if they cancel, | 727 // Allow user to create a new profile before continuing with sign-in. |
727 // TransferCredentialsToNewProfile() to create a new profile, or | 728 ProfileSigninConfirmationDialog::ShowDialog( |
728 // LoadPolicyWithCachedClient() if they want to sign in for the current | 729 possibly_invalid_username_, |
729 // profile. | 730 base::Bind(&SigninManager::SignOut, |
730 // For now, just call LoadPolicyWithCachedClient() to immediately load policy | 731 weak_pointer_factory_.GetWeakPtr()), |
731 // into the current profile and finish signing in. | 732 base::Bind(&SigninManager::TransferCredentialsToNewProfile, |
732 LoadPolicyWithCachedClient(policy_client_.Pass()); | 733 weak_pointer_factory_.GetWeakPtr()), |
734 base::Bind(&SigninManager::LoadPolicyWithCachedClient, | |
735 weak_pointer_factory_.GetWeakPtr(), | |
736 base::Passed(policy_client_.Pass()))); | |
Andrew T Wilson (Slow)
2013/02/10 20:47:26
So, this is the root of the DCHECK you are hitting
dconnelly
2013/02/11 09:35:16
Done.
| |
733 } | 737 } |
734 | 738 |
735 void SigninManager::LoadPolicyWithCachedClient( | 739 void SigninManager::LoadPolicyWithCachedClient( |
736 scoped_ptr<policy::CloudPolicyClient> client) { | 740 scoped_ptr<policy::CloudPolicyClient> client) { |
737 DCHECK(client); | 741 DCHECK(client); |
738 policy::UserPolicySigninService* policy_service = | 742 policy::UserPolicySigninService* policy_service = |
739 policy::UserPolicySigninServiceFactory::GetForProfile(profile_); | 743 policy::UserPolicySigninServiceFactory::GetForProfile(profile_); |
740 policy_service->FetchPolicyForSignedInUser( | 744 policy_service->FetchPolicyForSignedInUser( |
741 client.Pass(), | 745 client.Pass(), |
742 base::Bind(&SigninManager::OnPolicyFetchComplete, | 746 base::Bind(&SigninManager::OnPolicyFetchComplete, |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
780 // Wait until the profile is initialized before we transfer credentials. | 784 // Wait until the profile is initialized before we transfer credentials. |
781 if (status == Profile::CREATE_STATUS_INITIALIZED) { | 785 if (status == Profile::CREATE_STATUS_INITIALIZED) { |
782 DCHECK(!possibly_invalid_username_.empty()); | 786 DCHECK(!possibly_invalid_username_.empty()); |
783 DCHECK(policy_client_); | 787 DCHECK(policy_client_); |
784 // Sign in to the just-created profile and fetch policy for it. | 788 // Sign in to the just-created profile and fetch policy for it. |
785 SigninManager* signin_manager = | 789 SigninManager* signin_manager = |
786 SigninManagerFactory::GetForProfile(profile); | 790 SigninManagerFactory::GetForProfile(profile); |
787 DCHECK(signin_manager); | 791 DCHECK(signin_manager); |
788 signin_manager->possibly_invalid_username_ = possibly_invalid_username_; | 792 signin_manager->possibly_invalid_username_ = possibly_invalid_username_; |
789 signin_manager->last_result_ = last_result_; | 793 signin_manager->last_result_ = last_result_; |
790 signin_manager->temp_oauth_login_tokens_ = temp_oauth_login_tokens_; | 794 signin_manager->temp_oauth_login_tokens_ = temp_oauth_login_tokens_; |
Andrew T Wilson (Slow)
2013/02/10 20:47:26
So, when you change LoadPolicyWithCachedClient() t
dconnelly
2013/02/11 09:35:16
Done.
| |
791 signin_manager->LoadPolicyWithCachedClient(policy_client_.Pass()); | 795 signin_manager->LoadPolicyWithCachedClient(policy_client_.Pass()); |
792 // Allow sync to start up if it is not overridden by policy. | 796 // Allow sync to start up if it is not overridden by policy. |
793 browser_sync::SyncPrefs prefs(profile->GetPrefs()); | 797 browser_sync::SyncPrefs prefs(profile->GetPrefs()); |
794 prefs.SetSyncSetupCompleted(); | 798 prefs.SetSyncSetupCompleted(); |
795 | 799 |
796 // We've transferred our credentials to the new profile - sign out. | 800 // We've transferred our credentials to the new profile - sign out. |
797 SignOut(); | 801 SignOut(); |
798 } | 802 } |
799 } | 803 } |
800 #endif | 804 #endif |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
916 NotifySigninValueChanged(field, value)); | 920 NotifySigninValueChanged(field, value)); |
917 } | 921 } |
918 | 922 |
919 void SigninManager::NotifyDiagnosticsObservers( | 923 void SigninManager::NotifyDiagnosticsObservers( |
920 const TimedSigninStatusField& field, | 924 const TimedSigninStatusField& field, |
921 const std::string& value) { | 925 const std::string& value) { |
922 FOR_EACH_OBSERVER(SigninDiagnosticsObserver, | 926 FOR_EACH_OBSERVER(SigninDiagnosticsObserver, |
923 signin_diagnostics_observers_, | 927 signin_diagnostics_observers_, |
924 NotifySigninValueChanged(field, value)); | 928 NotifySigninValueChanged(field, value)); |
925 } | 929 } |
OLD | NEW |