Chromium Code Reviews| 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/gaia_cookie_manager_service.h" | 5 #include "components/signin/core/browser/gaia_cookie_manager_service.h" |
| 6 | 6 |
| 7 #include <queue> | 7 #include <queue> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 302 base::Bind(&GaiaCookieManagerService::OnCookieChanged, | 302 base::Bind(&GaiaCookieManagerService::OnCookieChanged, |
| 303 base::Unretained(this))); | 303 base::Unretained(this))); |
| 304 } | 304 } |
| 305 | 305 |
| 306 void GaiaCookieManagerService::Shutdown() { | 306 void GaiaCookieManagerService::Shutdown() { |
| 307 cookie_changed_subscription_.reset(); | 307 cookie_changed_subscription_.reset(); |
| 308 } | 308 } |
| 309 | 309 |
| 310 void GaiaCookieManagerService::AddAccountToCookie( | 310 void GaiaCookieManagerService::AddAccountToCookie( |
| 311 const std::string& account_id) { | 311 const std::string& account_id) { |
| 312 AddAccountToCookieWithToken(account_id, std::string()); | |
| 313 } | |
| 314 | |
| 315 void GaiaCookieManagerService::AddAccountToCookieWithToken( | |
| 316 const std::string& account_id, const std::string& oauth2_token) { | |
|
Roger Tawa OOO till Jul 10th
2015/05/07 18:44:50
oauth2_token is not very clear. Is this an access
Mike Lerman
2015/05/12 20:51:44
Done.
| |
| 312 if (!signin_client_->AreSigninCookiesAllowed()) { | 317 if (!signin_client_->AreSigninCookiesAllowed()) { |
| 313 SignalComplete(account_id, | 318 SignalComplete(account_id, |
| 314 GoogleServiceAuthError(GoogleServiceAuthError::REQUEST_CANCELED)); | 319 GoogleServiceAuthError(GoogleServiceAuthError::REQUEST_CANCELED)); |
| 315 return; | 320 return; |
| 316 } | 321 } |
| 317 | 322 |
| 318 DCHECK(!account_id.empty()); | 323 DCHECK(!account_id.empty()); |
| 319 VLOG(1) << "GaiaCookieManagerService::AddAccountToCookie: " << account_id; | 324 VLOG(1) << "GaiaCookieManagerService::AddAccountToCookie: " << account_id; |
| 320 requests_.push_back(GaiaCookieRequest::CreateAddAccountRequest(account_id)); | 325 requests_.push_back(GaiaCookieRequest::CreateAddAccountRequest(account_id)); |
| 321 if (requests_.size() == 1) | 326 if (requests_.size() == 1) { |
| 322 StartFetchingUbertoken(); | 327 StartFetchingUbertoken(oauth2_token); |
| 328 } | |
| 323 } | 329 } |
| 324 | 330 |
| 325 bool GaiaCookieManagerService::ListAccounts( | 331 bool GaiaCookieManagerService::ListAccounts( |
| 326 std::vector<std::pair<std::string,bool> >* accounts) { | 332 std::vector<std::pair<std::string,bool> >* accounts) { |
| 327 DCHECK(accounts); | 333 DCHECK(accounts); |
| 328 accounts->clear(); | 334 accounts->clear(); |
| 329 | 335 |
| 330 // There is a fetch currently executing (the results being provided in the | 336 // There is a fetch currently executing (the results being provided in the |
| 331 // parameter don't align with the fetches that have been started), or the list | 337 // parameter don't align with the fetches that have been started), or the list |
| 332 // of accounts haven't been fetched even once. | 338 // of accounts haven't been fetched even once. |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 559 FROM_HERE, fetcher_backoff_.GetTimeUntilRelease(), this, | 565 FROM_HERE, fetcher_backoff_.GetTimeUntilRelease(), this, |
| 560 &GaiaCookieManagerService::StartFetchingListAccounts); | 566 &GaiaCookieManagerService::StartFetchingListAccounts); |
| 561 return; | 567 return; |
| 562 } | 568 } |
| 563 | 569 |
| 564 FOR_EACH_OBSERVER(Observer, observer_list_, | 570 FOR_EACH_OBSERVER(Observer, observer_list_, |
| 565 OnGaiaAccountsInCookieUpdated(listed_accounts_, error)); | 571 OnGaiaAccountsInCookieUpdated(listed_accounts_, error)); |
| 566 HandleNextRequest(); | 572 HandleNextRequest(); |
| 567 } | 573 } |
| 568 | 574 |
| 569 void GaiaCookieManagerService::StartFetchingUbertoken() { | 575 void GaiaCookieManagerService::StartFetchingUbertoken( |
| 576 const std::string& access_token) { | |
| 570 VLOG(1) << "GaiaCookieManagerService::StartFetching account_id=" | 577 VLOG(1) << "GaiaCookieManagerService::StartFetching account_id=" |
| 571 << requests_.front().account_id(); | 578 << requests_.front().account_id(); |
| 572 uber_token_fetcher_.reset( | 579 uber_token_fetcher_.reset( |
| 573 new UbertokenFetcher(token_service_, this, source_, | 580 new UbertokenFetcher(token_service_, this, source_, |
| 574 signin_client_->GetURLRequestContext())); | 581 signin_client_->GetURLRequestContext())); |
| 575 uber_token_fetcher_->StartFetchingToken(requests_.front().account_id()); | 582 if (access_token.empty()) |
| 583 uber_token_fetcher_->StartFetchingToken(requests_.front().account_id()); | |
| 584 else | |
| 585 uber_token_fetcher_->OnGetTokenSuccess(nullptr, access_token, base::Time()); | |
|
Roger Tawa OOO till Jul 10th
2015/05/07 18:44:50
Would be better to add access_token arg to StartFe
Mike Lerman
2015/05/12 20:51:44
Done.
| |
| 576 } | 586 } |
| 577 | 587 |
| 578 void GaiaCookieManagerService::StartFetchingMergeSession() { | 588 void GaiaCookieManagerService::StartFetchingMergeSession() { |
| 579 DCHECK(!uber_token_.empty()); | 589 DCHECK(!uber_token_.empty()); |
| 580 gaia_auth_fetcher_.reset( | 590 gaia_auth_fetcher_.reset( |
| 581 new GaiaAuthFetcher(this, source_, | 591 new GaiaAuthFetcher(this, source_, |
| 582 signin_client_->GetURLRequestContext())); | 592 signin_client_->GetURLRequestContext())); |
| 583 | 593 |
| 584 gaia_auth_fetcher_->StartMergeSession(uber_token_, | 594 gaia_auth_fetcher_->StartMergeSession(uber_token_, |
| 585 external_cc_result_fetcher_.GetExternalCcResult()); | 595 external_cc_result_fetcher_.GetExternalCcResult()); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 628 } | 638 } |
| 629 | 639 |
| 630 gaia_auth_fetcher_.reset(); | 640 gaia_auth_fetcher_.reset(); |
| 631 fetcher_retries_ = 0; | 641 fetcher_retries_ = 0; |
| 632 if (requests_.empty()) { | 642 if (requests_.empty()) { |
| 633 VLOG(1) << "GaiaCookieManagerService::HandleNextRequest: no more"; | 643 VLOG(1) << "GaiaCookieManagerService::HandleNextRequest: no more"; |
| 634 uber_token_fetcher_.reset(); | 644 uber_token_fetcher_.reset(); |
| 635 } else { | 645 } else { |
| 636 switch (requests_.front().request_type()) { | 646 switch (requests_.front().request_type()) { |
| 637 case GaiaCookieRequestType::ADD_ACCOUNT: | 647 case GaiaCookieRequestType::ADD_ACCOUNT: |
| 638 StartFetchingUbertoken(); | 648 StartFetchingUbertoken(std::string()); |
| 639 break; | 649 break; |
| 640 case GaiaCookieRequestType::LOG_OUT: | 650 case GaiaCookieRequestType::LOG_OUT: |
| 641 StartLogOutUrlFetch(); | 651 StartLogOutUrlFetch(); |
| 642 break; | 652 break; |
| 643 case GaiaCookieRequestType::LIST_ACCOUNTS: | 653 case GaiaCookieRequestType::LIST_ACCOUNTS: |
| 644 uber_token_fetcher_.reset(); | 654 uber_token_fetcher_.reset(); |
| 645 StartFetchingListAccounts(); | 655 StartFetchingListAccounts(); |
| 646 break; | 656 break; |
| 647 }; | 657 }; |
| 648 } | 658 } |
| 649 } | 659 } |
| OLD | NEW |