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/ui/sync/one_click_signin_sync_starter.h" | 5 #include "chrome/browser/ui/sync/one_click_signin_sync_starter.h" |
6 | 6 |
7 #include "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 // will not be able to complete sucessfully. | 146 // will not be able to complete sucessfully. |
147 sync_driver::SyncPrefs sync_prefs(profile_->GetPrefs()); | 147 sync_driver::SyncPrefs sync_prefs(profile_->GetPrefs()); |
148 sync_prefs.SetStartSuppressed(false); | 148 sync_prefs.SetStartSuppressed(false); |
149 } | 149 } |
150 | 150 |
151 void OneClickSigninSyncStarter::ConfirmSignin(const std::string& oauth_token) { | 151 void OneClickSigninSyncStarter::ConfirmSignin(const std::string& oauth_token) { |
152 DCHECK(!oauth_token.empty()); | 152 DCHECK(!oauth_token.empty()); |
153 SigninManager* signin = SigninManagerFactory::GetForProfile(profile_); | 153 SigninManager* signin = SigninManagerFactory::GetForProfile(profile_); |
154 // If this is a new signin (no authenticated username yet) try loading | 154 // If this is a new signin (no authenticated username yet) try loading |
155 // policy for this user now, before any signed in services are initialized. | 155 // policy for this user now, before any signed in services are initialized. |
156 if (signin->GetAuthenticatedUsername().empty()) { | 156 if (!signin->IsAuthenticated()) { |
157 #if defined(ENABLE_CONFIGURATION_POLICY) | 157 #if defined(ENABLE_CONFIGURATION_POLICY) |
158 policy::UserPolicySigninService* policy_service = | 158 policy::UserPolicySigninService* policy_service = |
159 policy::UserPolicySigninServiceFactory::GetForProfile(profile_); | 159 policy::UserPolicySigninServiceFactory::GetForProfile(profile_); |
160 policy_service->RegisterForPolicy( | 160 policy_service->RegisterForPolicy( |
161 signin->GetUsernameForAuthInProgress(), | 161 signin->GetUsernameForAuthInProgress(), |
162 oauth_token, | 162 oauth_token, |
163 base::Bind(&OneClickSigninSyncStarter::OnRegisteredForPolicy, | 163 base::Bind(&OneClickSigninSyncStarter::OnRegisteredForPolicy, |
164 weak_pointer_factory_.GetWeakPtr())); | 164 weak_pointer_factory_.GetWeakPtr())); |
165 return; | 165 return; |
166 #else | 166 #else |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 case Profile::CREATE_STATUS_CREATED: { | 295 case Profile::CREATE_STATUS_CREATED: { |
296 break; | 296 break; |
297 } | 297 } |
298 case Profile::CREATE_STATUS_INITIALIZED: { | 298 case Profile::CREATE_STATUS_INITIALIZED: { |
299 // Wait until the profile is initialized before we transfer credentials. | 299 // Wait until the profile is initialized before we transfer credentials. |
300 SigninManager* old_signin_manager = | 300 SigninManager* old_signin_manager = |
301 SigninManagerFactory::GetForProfile(profile_); | 301 SigninManagerFactory::GetForProfile(profile_); |
302 SigninManager* new_signin_manager = | 302 SigninManager* new_signin_manager = |
303 SigninManagerFactory::GetForProfile(new_profile); | 303 SigninManagerFactory::GetForProfile(new_profile); |
304 DCHECK(!old_signin_manager->GetUsernameForAuthInProgress().empty()); | 304 DCHECK(!old_signin_manager->GetUsernameForAuthInProgress().empty()); |
305 DCHECK(old_signin_manager->GetAuthenticatedUsername().empty()); | 305 DCHECK(!old_signin_manager->IsAuthenticated()); |
306 DCHECK(new_signin_manager->GetAuthenticatedUsername().empty()); | 306 DCHECK(!new_signin_manager->IsAuthenticated()); |
307 DCHECK(!dm_token_.empty()); | 307 DCHECK(!dm_token_.empty()); |
308 DCHECK(!client_id_.empty()); | 308 DCHECK(!client_id_.empty()); |
309 | 309 |
310 // Copy credentials from the old profile to the just-created profile, | 310 // Copy credentials from the old profile to the just-created profile, |
311 // and switch over to tracking that profile. | 311 // and switch over to tracking that profile. |
312 new_signin_manager->CopyCredentialsFrom(*old_signin_manager); | 312 new_signin_manager->CopyCredentialsFrom(*old_signin_manager); |
313 FinishProfileSyncServiceSetup(); | 313 FinishProfileSyncServiceSetup(); |
314 Initialize(new_profile, NULL); | 314 Initialize(new_profile, NULL); |
315 DCHECK_EQ(profile_, new_profile); | 315 DCHECK_EQ(profile_, new_profile); |
316 | 316 |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
610 false /* user_gesture */); | 610 false /* user_gesture */); |
611 } | 611 } |
612 | 612 |
613 void OneClickSigninSyncStarter::LoadContinueUrl() { | 613 void OneClickSigninSyncStarter::LoadContinueUrl() { |
614 web_contents()->GetController().LoadURL( | 614 web_contents()->GetController().LoadURL( |
615 continue_url_, | 615 continue_url_, |
616 content::Referrer(), | 616 content::Referrer(), |
617 content::PAGE_TRANSITION_AUTO_TOPLEVEL, | 617 content::PAGE_TRANSITION_AUTO_TOPLEVEL, |
618 std::string()); | 618 std::string()); |
619 } | 619 } |
OLD | NEW |