| Index: chrome/browser/signin/fake_profile_oauth2_token_service_delegate.cc
|
| diff --git a/chrome/browser/signin/fake_profile_oauth2_token_service_delegate.cc b/chrome/browser/signin/fake_profile_oauth2_token_service_delegate.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..7e53eb531d551a0548982638063479472eef02e6
|
| --- /dev/null
|
| +++ b/chrome/browser/signin/fake_profile_oauth2_token_service_delegate.cc
|
| @@ -0,0 +1,93 @@
|
| +// Copyright 2015 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "chrome/browser/signin/fake_profile_oauth2_token_service_delegate.h"
|
| +
|
| +FakeProfileOAuth2TokenServiceDelegate::FakeProfileOAuth2TokenServiceDelegate() {
|
| +}
|
| +
|
| +FakeProfileOAuth2TokenServiceDelegate::
|
| + ~FakeProfileOAuth2TokenServiceDelegate() {
|
| +}
|
| +
|
| +OAuth2AccessTokenFetcher*
|
| +FakeProfileOAuth2TokenServiceDelegate::CreateAccessTokenFetcher(
|
| + const std::string& account_id,
|
| + net::URLRequestContextGetter* getter,
|
| + OAuth2AccessTokenConsumer* consumer) {
|
| + NOTREACHED();
|
| + return NULL;
|
| +}
|
| +
|
| +bool FakeProfileOAuth2TokenServiceDelegate::RefreshTokenIsAvailable(
|
| + const std::string& account_id) const {
|
| + return !GetRefreshToken(account_id).empty();
|
| +}
|
| +
|
| +std::string FakeProfileOAuth2TokenServiceDelegate::GetRefreshToken(
|
| + const std::string& account_id) const {
|
| + std::map<std::string, std::string>::const_iterator it =
|
| + refresh_tokens_.find(account_id);
|
| + if (it != refresh_tokens_.end())
|
| + return it->second;
|
| + return std::string();
|
| +}
|
| +
|
| +void FakeProfileOAuth2TokenServiceDelegate::UpdateAuthError(
|
| + const std::string& account_id,
|
| + const GoogleServiceAuthError& error) {
|
| +}
|
| +
|
| +std::vector<std::string> FakeProfileOAuth2TokenServiceDelegate::GetAccounts() {
|
| + std::vector<std::string> account_ids;
|
| + for (std::map<std::string, std::string>::const_iterator iter =
|
| + refresh_tokens_.begin();
|
| + iter != refresh_tokens_.end(); ++iter) {
|
| + account_ids.push_back(iter->first);
|
| + }
|
| + return account_ids;
|
| +}
|
| +
|
| +void FakeProfileOAuth2TokenServiceDelegate::RevokeAllCredentials() {
|
| +}
|
| +
|
| +void FakeProfileOAuth2TokenServiceDelegate::LoadCredentials(
|
| + const std::string& primary_account_id) {
|
| + // Empty implementation as FakeProfileOAuth2TokenService does not have any
|
| + // credentials to load.
|
| +}
|
| +
|
| +void FakeProfileOAuth2TokenServiceDelegate::UpdateCredentials(
|
| + const std::string& account_id,
|
| + const std::string& refresh_token) {
|
| + IssueRefreshTokenForUser(account_id, refresh_token);
|
| +}
|
| +
|
| +void FakeProfileOAuth2TokenServiceDelegate::IssueRefreshTokenForUser(
|
| + const std::string& account_id,
|
| + const std::string& token) {
|
| + ScopedBatchChange batch(this);
|
| + if (token.empty()) {
|
| + refresh_tokens_.erase(account_id);
|
| + FireRefreshTokenRevoked(account_id);
|
| + } else {
|
| + refresh_tokens_[account_id] = token;
|
| + FireRefreshTokenAvailable(account_id);
|
| + // TODO(atwilson): Maybe we should also call FireRefreshTokensLoaded() here?
|
| + }
|
| +}
|
| +
|
| +net::URLRequestContextGetter*
|
| +FakeProfileOAuth2TokenServiceDelegate::GetRequestContext() const {
|
| + return NULL;
|
| +}
|
| +
|
| +void FakeProfileOAuth2TokenServiceDelegate::IssueRefreshToken(
|
| + const std::string& token) {
|
| + IssueRefreshTokenForUser("account_id", token);
|
| +}
|
| +
|
| +void FakeProfileOAuth2TokenServiceDelegate::IssueAllRefreshTokensLoaded() {
|
| + FireRefreshTokensLoaded();
|
| +}
|
|
|