Index: chrome/browser/ui/sync/one_click_signin_sync_starter.cc |
diff --git a/chrome/browser/ui/sync/one_click_signin_sync_starter.cc b/chrome/browser/ui/sync/one_click_signin_sync_starter.cc |
index 3373b310b69707e0752c9970dd36fda9766a6c5b..14b9626140883f234d429a0c11ea093650c61bfc 100644 |
--- a/chrome/browser/ui/sync/one_click_signin_sync_starter.cc |
+++ b/chrome/browser/ui/sync/one_click_signin_sync_starter.cc |
@@ -37,6 +37,7 @@ |
#include "components/prefs/pref_service.h" |
#include "components/signin/core/browser/signin_manager.h" |
#include "components/signin/core/browser/signin_metrics.h" |
+#include "components/signin/core/common/profile_management_switches.h" |
#include "components/sync/base/sync_prefs.h" |
#include "net/base/url_util.h" |
#include "net/url_request/url_request_context_getter.h" |
@@ -98,6 +99,7 @@ OneClickSigninSyncStarter::OneClickSigninSyncStarter( |
BrowserList::AddObserver(this); |
Initialize(profile, browser); |
+ DCHECK(!refresh_token.empty() || switches::IsAccountConsistencyDiceEnabled()); |
SigninManagerFactory::GetForProfile(profile_)->StartSignInWithRefreshToken( |
refresh_token, gaia_id, email, password, |
base::Bind(&OneClickSigninSyncStarter::ConfirmSignin, |
@@ -141,7 +143,6 @@ void OneClickSigninSyncStarter::Initialize(Profile* profile, Browser* browser) { |
void OneClickSigninSyncStarter::ConfirmSignin(ProfileMode profile_mode, |
const std::string& oauth_token) { |
- DCHECK(!oauth_token.empty()); |
SigninManager* signin = SigninManagerFactory::GetForProfile(profile_); |
if (signin->IsAuthenticated()) { |
// The user is already signed in - just tell SigninManager to continue |
@@ -158,10 +159,19 @@ void OneClickSigninSyncStarter::ConfirmSignin(ProfileMode profile_mode, |
// initialized. |
policy::UserPolicySigninService* policy_service = |
policy::UserPolicySigninServiceFactory::GetForProfile(profile_); |
- policy_service->RegisterForPolicy( |
- signin->GetUsernameForAuthInProgress(), oauth_token, |
- base::Bind(&OneClickSigninSyncStarter::OnRegisteredForPolicy, |
- weak_pointer_factory_.GetWeakPtr())); |
+ if (oauth_token.empty()) { |
+ DCHECK(switches::IsAccountConsistencyDiceEnabled()); |
+ policy_service->RegisterForPolicyWithAccountId( |
+ signin->GetUsernameForAuthInProgress(), |
+ signin->GetAccountIdForAuthInProgress(), |
+ base::Bind(&OneClickSigninSyncStarter::OnRegisteredForPolicy, |
+ weak_pointer_factory_.GetWeakPtr())); |
+ } else { |
+ policy_service->RegisterForPolicyWithLoginToken( |
+ signin->GetUsernameForAuthInProgress(), oauth_token, |
+ base::Bind(&OneClickSigninSyncStarter::OnRegisteredForPolicy, |
+ weak_pointer_factory_.GetWeakPtr())); |
+ } |
break; |
} |
case NEW_PROFILE: |