OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/signin/core/browser/signin_manager.h" | 5 #include "components/signin/core/browser/signin_manager.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 } | 349 } |
350 | 350 |
351 const std::string& SigninManager::GetUsernameForAuthInProgress() const { | 351 const std::string& SigninManager::GetUsernameForAuthInProgress() const { |
352 return possibly_invalid_username_; | 352 return possibly_invalid_username_; |
353 } | 353 } |
354 | 354 |
355 void SigninManager::DisableOneClickSignIn(PrefService* prefs) { | 355 void SigninManager::DisableOneClickSignIn(PrefService* prefs) { |
356 prefs->SetBoolean(prefs::kReverseAutologinEnabled, false); | 356 prefs->SetBoolean(prefs::kReverseAutologinEnabled, false); |
357 } | 357 } |
358 | 358 |
| 359 void SigninManager::MergeSigninCredentialIntoCookieJar() { |
| 360 if (!client_->ShouldMergeSigninCredentialsIntoCookieJar()) |
| 361 return; |
| 362 |
| 363 if (!IsAuthenticated()) |
| 364 return; |
| 365 |
| 366 // Don't execute 2 MergeSessionHelpers. New account takes priority. |
| 367 if (merge_session_helper_.get() && merge_session_helper_->is_running()) |
| 368 merge_session_helper_->CancelAll(); |
| 369 |
| 370 merge_session_helper_.reset(new MergeSessionHelper( |
| 371 token_service_, GaiaConstants::kChromeSource, |
| 372 client_->GetURLRequestContext(), NULL)); |
| 373 |
| 374 merge_session_helper_->LogIn(GetAuthenticatedAccountId()); |
| 375 } |
| 376 |
359 void SigninManager::CompletePendingSignin() { | 377 void SigninManager::CompletePendingSignin() { |
360 DCHECK(!possibly_invalid_username_.empty()); | 378 DCHECK(!possibly_invalid_username_.empty()); |
361 OnSignedIn(possibly_invalid_username_); | 379 OnSignedIn(possibly_invalid_username_); |
362 | 380 |
363 if (client_->ShouldMergeSigninCredentialsIntoCookieJar()) { | |
364 merge_session_helper_.reset(new MergeSessionHelper( | |
365 token_service_, GaiaConstants::kChromeSource, | |
366 client_->GetURLRequestContext(), NULL)); | |
367 } | |
368 | |
369 DCHECK(!temp_refresh_token_.empty()); | 381 DCHECK(!temp_refresh_token_.empty()); |
370 DCHECK(IsAuthenticated()); | 382 DCHECK(IsAuthenticated()); |
371 std::string account_id = GetAuthenticatedAccountId(); | 383 token_service_->UpdateCredentials(GetAuthenticatedAccountId(), |
372 token_service_->UpdateCredentials(account_id, temp_refresh_token_); | 384 temp_refresh_token_); |
373 temp_refresh_token_.clear(); | 385 temp_refresh_token_.clear(); |
374 | 386 |
375 if (client_->ShouldMergeSigninCredentialsIntoCookieJar()) | 387 MergeSigninCredentialIntoCookieJar(); |
376 merge_session_helper_->LogIn(account_id); | |
377 } | 388 } |
378 | 389 |
379 void SigninManager::OnExternalSigninCompleted(const std::string& username) { | 390 void SigninManager::OnExternalSigninCompleted(const std::string& username) { |
380 OnSignedIn(username); | 391 OnSignedIn(username); |
381 } | 392 } |
382 | 393 |
383 void SigninManager::OnSignedIn(const std::string& username) { | 394 void SigninManager::OnSignedIn(const std::string& username) { |
384 client_->GetPrefs()->SetInt64(prefs::kSignedInTime, | 395 client_->GetPrefs()->SetInt64(prefs::kSignedInTime, |
385 base::Time::Now().ToInternalValue()); | 396 base::Time::Now().ToInternalValue()); |
386 SetAuthenticatedUsername(username); | 397 SetAuthenticatedUsername(username); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 void SigninManager::OnAccountUpdateFailed(const std::string& account_id) { | 436 void SigninManager::OnAccountUpdateFailed(const std::string& account_id) { |
426 user_info_fetched_by_account_tracker_ = true; | 437 user_info_fetched_by_account_tracker_ = true; |
427 PostSignedIn(); | 438 PostSignedIn(); |
428 } | 439 } |
429 | 440 |
430 void SigninManager::ProhibitSignout(bool prohibit_signout) { | 441 void SigninManager::ProhibitSignout(bool prohibit_signout) { |
431 prohibit_signout_ = prohibit_signout; | 442 prohibit_signout_ = prohibit_signout; |
432 } | 443 } |
433 | 444 |
434 bool SigninManager::IsSignoutProhibited() const { return prohibit_signout_; } | 445 bool SigninManager::IsSignoutProhibited() const { return prohibit_signout_; } |
OLD | NEW |