| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/signin/fake_gaia_cookie_manager_service.h" | 5 #include "chrome/browser/signin/fake_gaia_cookie_manager_service.h" |
| 6 | 6 |
| 7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
| 8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
| 9 #include "chrome/browser/signin/chrome_signin_client_factory.h" | 9 #include "chrome/browser/signin/chrome_signin_client_factory.h" |
| 10 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 10 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 net::URLRequestStatus::SUCCESS); | 54 net::URLRequestStatus::SUCCESS); |
| 55 } | 55 } |
| 56 | 56 |
| 57 void FakeGaiaCookieManagerService::SetListAccountsResponseOneAccount( | 57 void FakeGaiaCookieManagerService::SetListAccountsResponseOneAccount( |
| 58 const char* account) { | 58 const char* account) { |
| 59 DCHECK(url_fetcher_factory_); | 59 DCHECK(url_fetcher_factory_); |
| 60 url_fetcher_factory_->SetFakeResponse( | 60 url_fetcher_factory_->SetFakeResponse( |
| 61 GaiaUrls::GetInstance()->ListAccountsURLWithSource( | 61 GaiaUrls::GetInstance()->ListAccountsURLWithSource( |
| 62 GaiaConstants::kChromeSource), | 62 GaiaConstants::kChromeSource), |
| 63 base::StringPrintf( | 63 base::StringPrintf( |
| 64 "[\"f\", [[\"b\", 0, \"n\", \"%s\", \"p\", 0, 0, 0, 0, 1]]]", | 64 "[\"f\", [[\"b\", 0, \"n\", \"%s\", \"p\", 0, 0, 0, 0, 1, \"22\"]]]", |
| 65 account), | 65 account), |
| 66 net::HTTP_OK, | 66 net::HTTP_OK, |
| 67 net::URLRequestStatus::SUCCESS); | 67 net::URLRequestStatus::SUCCESS); |
| 68 } | 68 } |
| 69 | 69 |
| 70 void FakeGaiaCookieManagerService::SetListAccountsResponseOneAccountWithExpiry( | 70 void FakeGaiaCookieManagerService::SetListAccountsResponseOneAccountWithExpiry( |
| 71 const char* account, bool expired) { | 71 const char* account, bool expired) { |
| 72 DCHECK(url_fetcher_factory_); | 72 DCHECK(url_fetcher_factory_); |
| 73 url_fetcher_factory_->SetFakeResponse( | 73 url_fetcher_factory_->SetFakeResponse( |
| 74 GaiaUrls::GetInstance()->ListAccountsURLWithSource( | 74 GaiaUrls::GetInstance()->ListAccountsURLWithSource( |
| 75 GaiaConstants::kChromeSource), | 75 GaiaConstants::kChromeSource), |
| 76 base::StringPrintf( | 76 base::StringPrintf( |
| 77 "[\"f\", [[\"b\", 0, \"n\", \"%s\", \"p\", 0, 0, 0, 0, %d]]]", | 77 "[\"f\", [[\"b\", 0, \"n\", \"%s\", \"p\", 0, 0, 0, 0, %d, \"22\"]]]", |
| 78 account, expired ? 0 : 1), | 78 account, expired ? 0 : 1), |
| 79 net::HTTP_OK, | 79 net::HTTP_OK, |
| 80 net::URLRequestStatus::SUCCESS); | 80 net::URLRequestStatus::SUCCESS); |
| 81 } | 81 } |
| 82 | 82 |
| 83 void FakeGaiaCookieManagerService::SetListAccountsResponseTwoAccounts( | 83 void FakeGaiaCookieManagerService::SetListAccountsResponseTwoAccounts( |
| 84 const char* account1, const char* account2) { | 84 const char* account1, const char* account2) { |
| 85 DCHECK(url_fetcher_factory_); | 85 DCHECK(url_fetcher_factory_); |
| 86 url_fetcher_factory_->SetFakeResponse( | 86 url_fetcher_factory_->SetFakeResponse( |
| 87 GaiaUrls::GetInstance()->ListAccountsURLWithSource( | 87 GaiaUrls::GetInstance()->ListAccountsURLWithSource( |
| 88 GaiaConstants::kChromeSource), | 88 GaiaConstants::kChromeSource), |
| 89 base::StringPrintf( | 89 base::StringPrintf( |
| 90 "[\"f\", [[\"b\", 0, \"n\", \"%s\", \"p\", 0, 0, 0, 0, 1], " | 90 "[\"f\", [[\"b\", 0, \"n\", \"%s\", \"p\", 0, 0, 0, 0, 1, \"22\"], " |
| 91 "[\"b\", 0, \"n\", \"%s\", \"p\", 0, 0, 0, 0, 1]]]", | 91 "[\"b\", 0, \"n\", \"%s\", \"p\", 0, 0, 0, 0, 1, \"24\"]]]", |
| 92 account1, account2), | 92 account1, account2), |
| 93 net::HTTP_OK, | 93 net::HTTP_OK, |
| 94 net::URLRequestStatus::SUCCESS); | 94 net::URLRequestStatus::SUCCESS); |
| 95 } | 95 } |
| 96 | 96 |
| 97 void FakeGaiaCookieManagerService::SetListAccountsResponseTwoAccountsWithExpiry( | 97 void FakeGaiaCookieManagerService::SetListAccountsResponseTwoAccountsWithExpiry( |
| 98 const char* account1, bool account1_expired, | 98 const char* account1, bool account1_expired, |
| 99 const char* account2, bool account2_expired) { | 99 const char* account2, bool account2_expired) { |
| 100 DCHECK(url_fetcher_factory_); | 100 DCHECK(url_fetcher_factory_); |
| 101 url_fetcher_factory_->SetFakeResponse( | 101 url_fetcher_factory_->SetFakeResponse( |
| 102 GaiaUrls::GetInstance()->ListAccountsURLWithSource( | 102 GaiaUrls::GetInstance()->ListAccountsURLWithSource( |
| 103 GaiaConstants::kChromeSource), | 103 GaiaConstants::kChromeSource), |
| 104 base::StringPrintf( | 104 base::StringPrintf( |
| 105 "[\"f\", [[\"b\", 0, \"n\", \"%s\", \"p\", 0, 0, 0, 0, %d], " | 105 "[\"f\", [[\"b\", 0, \"n\", \"%s\", \"p\", 0, 0, 0, 0, %d, \"28\"], " |
| 106 "[\"b\", 0, \"n\", \"%s\", \"p\", 0, 0, 0, 0, %d]]]", | 106 "[\"b\", 0, \"n\", \"%s\", \"p\", 0, 0, 0, 0, %d, \"29\"]]]", |
| 107 account1, account1_expired ? 0 : 1, | 107 account1, account1_expired ? 0 : 1, |
| 108 account2, account2_expired ? 0 : 1), | 108 account2, account2_expired ? 0 : 1), |
| 109 net::HTTP_OK, | 109 net::HTTP_OK, |
| 110 net::URLRequestStatus::SUCCESS); | 110 net::URLRequestStatus::SUCCESS); |
| 111 } | 111 } |
| 112 | 112 |
| 113 // static | 113 // static |
| 114 KeyedService* FakeGaiaCookieManagerService::Build( | 114 KeyedService* FakeGaiaCookieManagerService::Build( |
| 115 content::BrowserContext* context) { | 115 content::BrowserContext* context) { |
| 116 Profile* profile = Profile::FromBrowserContext(context); | 116 Profile* profile = Profile::FromBrowserContext(context); |
| 117 FakeGaiaCookieManagerService* service = new FakeGaiaCookieManagerService( | 117 FakeGaiaCookieManagerService* service = new FakeGaiaCookieManagerService( |
| 118 ProfileOAuth2TokenServiceFactory::GetForProfile(profile), | 118 ProfileOAuth2TokenServiceFactory::GetForProfile(profile), |
| 119 GaiaConstants::kChromeSource, | 119 GaiaConstants::kChromeSource, |
| 120 ChromeSigninClientFactory::GetForProfile(profile)); | 120 ChromeSigninClientFactory::GetForProfile(profile)); |
| 121 return service; | 121 return service; |
| 122 } | 122 } |
| OLD | NEW |