| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <queue> | 9 #include <queue> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 } else if (std::find_if(requests_.begin(), requests_.end(), | 371 } else if (std::find_if(requests_.begin(), requests_.end(), |
| 372 [](const GaiaCookieRequest& request) { | 372 [](const GaiaCookieRequest& request) { |
| 373 return request.request_type() == LIST_ACCOUNTS; | 373 return request.request_type() == LIST_ACCOUNTS; |
| 374 }) == requests_.end()) { | 374 }) == requests_.end()) { |
| 375 requests_.push_back(GaiaCookieRequest::CreateListAccountsRequest()); | 375 requests_.push_back(GaiaCookieRequest::CreateListAccountsRequest()); |
| 376 } | 376 } |
| 377 } | 377 } |
| 378 | 378 |
| 379 void GaiaCookieManagerService::ForceOnCookieChangedProcessing() { | 379 void GaiaCookieManagerService::ForceOnCookieChangedProcessing() { |
| 380 GURL google_url = GaiaUrls::GetInstance()->google_url(); | 380 GURL google_url = GaiaUrls::GetInstance()->google_url(); |
| 381 net::CanonicalCookie cookie( | 381 std::unique_ptr<net::CanonicalCookie> cookie(net::CanonicalCookie::Create( |
| 382 google_url, kGaiaCookieName, "", google_url.host(), "", base::Time(), | 382 google_url, kGaiaCookieName, std::string(), "." + google_url.host(), |
| 383 base::Time(), base::Time(), false, false, | 383 std::string(), base::Time(), base::Time(), false, false, |
| 384 net::CookieSameSite::DEFAULT_MODE, net::COOKIE_PRIORITY_DEFAULT); | 384 net::CookieSameSite::DEFAULT_MODE, false, net::COOKIE_PRIORITY_DEFAULT)); |
| 385 OnCookieChanged(cookie, true); | 385 OnCookieChanged(*cookie, true); |
| 386 } | 386 } |
| 387 | 387 |
| 388 void GaiaCookieManagerService::LogOutAllAccounts() { | 388 void GaiaCookieManagerService::LogOutAllAccounts() { |
| 389 VLOG(1) << "GaiaCookieManagerService::LogOutAllAccounts"; | 389 VLOG(1) << "GaiaCookieManagerService::LogOutAllAccounts"; |
| 390 | 390 |
| 391 bool log_out_queued = false; | 391 bool log_out_queued = false; |
| 392 if (!requests_.empty()) { | 392 if (!requests_.empty()) { |
| 393 // Track requests to keep; all other unstarted requests will be removed. | 393 // Track requests to keep; all other unstarted requests will be removed. |
| 394 std::vector<GaiaCookieRequest> requests_to_keep; | 394 std::vector<GaiaCookieRequest> requests_to_keep; |
| 395 | 395 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 447 gaia_auth_fetcher_.reset(); | 447 gaia_auth_fetcher_.reset(); |
| 448 uber_token_fetcher_.reset(); | 448 uber_token_fetcher_.reset(); |
| 449 requests_.clear(); | 449 requests_.clear(); |
| 450 fetcher_timer_.Stop(); | 450 fetcher_timer_.Stop(); |
| 451 } | 451 } |
| 452 | 452 |
| 453 void GaiaCookieManagerService::OnCookieChanged( | 453 void GaiaCookieManagerService::OnCookieChanged( |
| 454 const net::CanonicalCookie& cookie, | 454 const net::CanonicalCookie& cookie, |
| 455 bool removed) { | 455 bool removed) { |
| 456 DCHECK_EQ(kGaiaCookieName, cookie.Name()); | 456 DCHECK_EQ(kGaiaCookieName, cookie.Name()); |
| 457 DCHECK_EQ(GaiaUrls::GetInstance()->google_url().host(), cookie.Domain()); | 457 DCHECK(cookie.IsDomainMatch(GaiaUrls::GetInstance()->google_url().host())); |
| 458 list_accounts_stale_ = true; | 458 list_accounts_stale_ = true; |
| 459 // Ignore changes to the cookie while requests are pending. These changes | 459 // Ignore changes to the cookie while requests are pending. These changes |
| 460 // are caused by the service itself as it adds accounts. A side effects is | 460 // are caused by the service itself as it adds accounts. A side effects is |
| 461 // that any changes to the gaia cookie outside of this class, while requests | 461 // that any changes to the gaia cookie outside of this class, while requests |
| 462 // are pending, will be lost. However, trying to process these changes could | 462 // are pending, will be lost. However, trying to process these changes could |
| 463 // cause an endless loop (see crbug.com/516070). | 463 // cause an endless loop (see crbug.com/516070). |
| 464 if (requests_.empty()) { | 464 if (requests_.empty()) { |
| 465 requests_.push_back(GaiaCookieRequest::CreateListAccountsRequest()); | 465 requests_.push_back(GaiaCookieRequest::CreateListAccountsRequest()); |
| 466 fetcher_retries_ = 0; | 466 fetcher_retries_ = 0; |
| 467 signin_client_->DelayNetworkCall( | 467 signin_client_->DelayNetworkCall( |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 715 break; | 715 break; |
| 716 case GaiaCookieRequestType::LIST_ACCOUNTS: | 716 case GaiaCookieRequestType::LIST_ACCOUNTS: |
| 717 uber_token_fetcher_.reset(); | 717 uber_token_fetcher_.reset(); |
| 718 signin_client_->DelayNetworkCall( | 718 signin_client_->DelayNetworkCall( |
| 719 base::Bind(&GaiaCookieManagerService::StartFetchingListAccounts, | 719 base::Bind(&GaiaCookieManagerService::StartFetchingListAccounts, |
| 720 base::Unretained(this))); | 720 base::Unretained(this))); |
| 721 break; | 721 break; |
| 722 }; | 722 }; |
| 723 } | 723 } |
| 724 } | 724 } |
| OLD | NEW |