fake_oauth2_token_service.h revision a1401311d1ab56c4ed0a474bd38c108f75cb0cd9
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 3// found in the LICENSE file. 4 5#ifndef GOOGLE_APIS_GAIA_FAKE_OAUTH2_TOKEN_SERVICE_H_ 6#define GOOGLE_APIS_GAIA_FAKE_OAUTH2_TOKEN_SERVICE_H_ 7 8#include <set> 9#include <string> 10 11#include "base/compiler_specific.h" 12#include "google_apis/gaia/oauth2_token_service.h" 13 14namespace net { 15class URLRequestContextGetter; 16} 17 18// Do-nothing implementation of OAuth2TokenService. 19class FakeOAuth2TokenService : public OAuth2TokenService { 20 public: 21 FakeOAuth2TokenService(); 22 virtual ~FakeOAuth2TokenService(); 23 24 void AddAccount(const std::string& account_id); 25 26 void set_request_context(net::URLRequestContextGetter* request_context) { 27 request_context_ = request_context; 28 } 29 30 protected: 31 // OAuth2TokenService overrides. 32 virtual void FetchOAuth2Token(RequestImpl* request, 33 const std::string& account_id, 34 net::URLRequestContextGetter* getter, 35 const std::string& client_id, 36 const std::string& client_secret, 37 const ScopeSet& scopes) OVERRIDE; 38 39 virtual void InvalidateOAuth2Token(const std::string& account_id, 40 const std::string& client_id, 41 const ScopeSet& scopes, 42 const std::string& access_token) OVERRIDE; 43 44 virtual bool RefreshTokenIsAvailable(const std::string& account_id) const 45 OVERRIDE; 46 47 private: 48 // OAuth2TokenService overrides. 49 virtual net::URLRequestContextGetter* GetRequestContext() OVERRIDE; 50 51 virtual OAuth2AccessTokenFetcher* CreateAccessTokenFetcher( 52 const std::string& account_id, 53 net::URLRequestContextGetter* getter, 54 OAuth2AccessTokenConsumer* consumer) OVERRIDE; 55 56 std::set<std::string> account_ids_; 57 net::URLRequestContextGetter* request_context_; // weak 58 59 DISALLOW_COPY_AND_ASSIGN(FakeOAuth2TokenService); 60}; 61 62#endif // GOOGLE_APIS_GAIA_FAKE_OAUTH2_TOKEN_SERVICE_H_ 63