Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(287)

Side by Side Diff: chrome/browser/signin/fake_profile_oauth2_token_service.h

Issue 23382008: Making OAuth2TokenService multi-login aware, updating callers, minor fixes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updates to AndroidPO2TS and removing the DCHECK(signin_manager) from GetPrimaryAccountId Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #ifndef CHROME_BROWSER_SIGNIN_FAKE_PROFILE_OAUTH2_TOKEN_SERVICE_H_ 5 #ifndef CHROME_BROWSER_SIGNIN_FAKE_PROFILE_OAUTH2_TOKEN_SERVICE_H_
6 #define CHROME_BROWSER_SIGNIN_FAKE_PROFILE_OAUTH2_TOKEN_SERVICE_H_ 6 #define CHROME_BROWSER_SIGNIN_FAKE_PROFILE_OAUTH2_TOKEN_SERVICE_H_
7 7
8 #include "chrome/browser/signin/profile_oauth2_token_service.h" 8 #include "chrome/browser/signin/profile_oauth2_token_service.h"
9 9
10 #include <string> 10 #include <string>
(...skipping 25 matching lines...) Expand all
36 // ... 36 // ...
37 // // ...or make them fail... 37 // // ...or make them fail...
38 // IssueErrorForScope(scopes, GoogleServiceAuthError(INVALID_GAIA_CREDENTIALS)); 38 // IssueErrorForScope(scopes, GoogleServiceAuthError(INVALID_GAIA_CREDENTIALS));
39 // 39 //
40 class FakeProfileOAuth2TokenService : public ProfileOAuth2TokenService { 40 class FakeProfileOAuth2TokenService : public ProfileOAuth2TokenService {
41 public: 41 public:
42 struct PendingRequest { 42 struct PendingRequest {
43 PendingRequest(); 43 PendingRequest();
44 ~PendingRequest(); 44 ~PendingRequest();
45 45
46 std::string account_id;
46 std::string client_id; 47 std::string client_id;
47 std::string client_secret; 48 std::string client_secret;
48 ScopeSet scopes; 49 ScopeSet scopes;
49 base::WeakPtr<RequestImpl> request; 50 base::WeakPtr<RequestImpl> request;
50 }; 51 };
51 52
52 FakeProfileOAuth2TokenService(); 53 FakeProfileOAuth2TokenService();
53 virtual ~FakeProfileOAuth2TokenService(); 54 virtual ~FakeProfileOAuth2TokenService();
54 55
55 // Sets the current refresh token. If |token| is non-empty, this will invoke 56 // Sets the current refresh token. If |token| is non-empty, this will invoke
56 // OnRefreshTokenAvailable() on all Observers, otherwise this will invoke 57 // OnRefreshTokenAvailable() on all Observers, otherwise this will invoke
57 // OnRefreshTokenRevoked(). 58 // OnRefreshTokenRevoked().
58 void IssueRefreshToken(const std::string& token); 59 void IssueRefreshToken(const std::string& token);
59 60
60 // Gets a list of active requests (can be used by tests to validate that the 61 // Gets a list of active requests (can be used by tests to validate that the
61 // correct request has been issued). 62 // correct request has been issued).
62 std::vector<PendingRequest> GetPendingRequests(); 63 std::vector<PendingRequest> GetPendingRequests();
63 64
64 // Helper routines to issue tokens for pending requests. 65 // Helper routines to issue tokens for pending requests.
65 void IssueTokenForScope(const ScopeSet& scopes, 66 void IssueTokenForScope(const ScopeSet& scopes,
Andrew T Wilson (Slow) 2013/09/03 14:04:24 May need to add a username for all of these IssueX
fgorski 2013/09/03 20:50:40 Added a TODO, will not change that as part of this
66 const std::string& access_token, 67 const std::string& access_token,
67 const base::Time& expiration); 68 const base::Time& expiration);
68 69
69 void IssueErrorForScope(const ScopeSet& scopes, 70 void IssueErrorForScope(const ScopeSet& scopes,
70 const GoogleServiceAuthError& error); 71 const GoogleServiceAuthError& error);
71 72
72 void IssueTokenForAllPendingRequests(const std::string& access_token, 73 void IssueTokenForAllPendingRequests(const std::string& access_token,
73 const base::Time& expiration); 74 const base::Time& expiration);
74 75
75 void IssueErrorForAllPendingRequests(const GoogleServiceAuthError& error); 76 void IssueErrorForAllPendingRequests(const GoogleServiceAuthError& error);
76 77
78 virtual void Initialize(Profile* profile) OVERRIDE;
77 virtual void Shutdown() OVERRIDE; 79 virtual void Shutdown() OVERRIDE;
78 80
79 // Helper function to be used with 81 // Helper function to be used with
80 // BrowserContextKeyedService::SetTestingFactory(). 82 // BrowserContextKeyedService::SetTestingFactory().
81 static BrowserContextKeyedService* Build(content::BrowserContext* profile); 83 static BrowserContextKeyedService* Build(content::BrowserContext* profile);
82 84
83 protected: 85 protected:
84 // OAuth2TokenService overrides. 86 // OAuth2TokenService overrides.
85 virtual void FetchOAuth2Token(RequestImpl* request, 87 virtual void FetchOAuth2Token(RequestImpl* request,
88 const std::string& account_id,
86 net::URLRequestContextGetter* getter, 89 net::URLRequestContextGetter* getter,
87 const std::string& client_id, 90 const std::string& client_id,
88 const std::string& client_secret, 91 const std::string& client_secret,
89 const ScopeSet& scopes) OVERRIDE; 92 const ScopeSet& scopes) OVERRIDE;
90 93
91 virtual std::string GetRefreshToken() OVERRIDE; 94 virtual std::string GetRefreshToken(const std::string& account_id) OVERRIDE;
92 95
93 virtual net::URLRequestContextGetter* GetRequestContext() OVERRIDE; 96 virtual net::URLRequestContextGetter* GetRequestContext() OVERRIDE;
94 97
95 private: 98 private:
96 // Helper function to complete pending requests - if |all_scopes| is true, 99 // Helper function to complete pending requests - if |all_scopes| is true,
97 // then all pending requests are completed, otherwise, only those requests 100 // then all pending requests are completed, otherwise, only those requests
98 // matching |scopes| are completed. 101 // matching |scopes| are completed.
99 void CompleteRequests(bool all_scopes, 102 void CompleteRequests(bool all_scopes,
100 const ScopeSet& scopes, 103 const ScopeSet& scopes,
101 const GoogleServiceAuthError& error, 104 const GoogleServiceAuthError& error,
102 const std::string& access_token, 105 const std::string& access_token,
103 const base::Time& expiration); 106 const base::Time& expiration);
104 107
105 std::vector<PendingRequest> pending_requests_; 108 std::vector<PendingRequest> pending_requests_;
106 std::string refresh_token_; 109 std::string refresh_token_;
110 bool is_initialized_;
107 111
108 DISALLOW_COPY_AND_ASSIGN(FakeProfileOAuth2TokenService); 112 DISALLOW_COPY_AND_ASSIGN(FakeProfileOAuth2TokenService);
109 }; 113 };
110 114
111 #endif // CHROME_BROWSER_SIGNIN_FAKE_PROFILE_OAUTH2_TOKEN_SERVICE_H_ 115 #endif // CHROME_BROWSER_SIGNIN_FAKE_PROFILE_OAUTH2_TOKEN_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698