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

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: Rebasing to include the update to ProfileSyncService: r224220 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 <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 #if defined(OS_ANDROID) 45 #if defined(OS_ANDROID)
46 : public AndroidProfileOAuth2TokenService { 46 : public AndroidProfileOAuth2TokenService {
47 #else 47 #else
48 : public ProfileOAuth2TokenService { 48 : public ProfileOAuth2TokenService {
49 #endif 49 #endif
50 public: 50 public:
51 struct PendingRequest { 51 struct PendingRequest {
52 PendingRequest(); 52 PendingRequest();
53 ~PendingRequest(); 53 ~PendingRequest();
54 54
55 std::string account_id;
55 std::string client_id; 56 std::string client_id;
56 std::string client_secret; 57 std::string client_secret;
57 ScopeSet scopes; 58 ScopeSet scopes;
58 base::WeakPtr<RequestImpl> request; 59 base::WeakPtr<RequestImpl> request;
59 }; 60 };
60 61
61 FakeProfileOAuth2TokenService(); 62 FakeProfileOAuth2TokenService();
62 virtual ~FakeProfileOAuth2TokenService(); 63 virtual ~FakeProfileOAuth2TokenService();
63 64
65 // Overriden to make sure it works on Android.
66 virtual bool RefreshTokenIsAvailable(
67 const std::string& account_id) OVERRIDE;
68
64 // Sets the current refresh token. If |token| is non-empty, this will invoke 69 // Sets the current refresh token. If |token| is non-empty, this will invoke
65 // OnRefreshTokenAvailable() on all Observers, otherwise this will invoke 70 // OnRefreshTokenAvailable() on all Observers, otherwise this will invoke
66 // OnRefreshTokenRevoked(). 71 // OnRefreshTokenRevoked().
67 void IssueRefreshToken(const std::string& token); 72 void IssueRefreshToken(const std::string& token);
68 73
69 // Gets a list of active requests (can be used by tests to validate that the 74 // Gets a list of active requests (can be used by tests to validate that the
70 // correct request has been issued). 75 // correct request has been issued).
71 std::vector<PendingRequest> GetPendingRequests(); 76 std::vector<PendingRequest> GetPendingRequests();
72 77
73 // Helper routines to issue tokens for pending requests. 78 // Helper routines to issue tokens for pending requests.
79 // TODO(fgorski): Add account IDs as parameters.
74 void IssueTokenForScope(const ScopeSet& scopes, 80 void IssueTokenForScope(const ScopeSet& scopes,
75 const std::string& access_token, 81 const std::string& access_token,
76 const base::Time& expiration); 82 const base::Time& expiration);
77 83
78 void IssueErrorForScope(const ScopeSet& scopes, 84 void IssueErrorForScope(const ScopeSet& scopes,
79 const GoogleServiceAuthError& error); 85 const GoogleServiceAuthError& error);
80 86
81 void IssueTokenForAllPendingRequests(const std::string& access_token, 87 void IssueTokenForAllPendingRequests(const std::string& access_token,
82 const base::Time& expiration); 88 const base::Time& expiration);
83 89
84 void IssueErrorForAllPendingRequests(const GoogleServiceAuthError& error); 90 void IssueErrorForAllPendingRequests(const GoogleServiceAuthError& error);
85 91
86 // Helper function to be used with 92 // Helper function to be used with
87 // BrowserContextKeyedService::SetTestingFactory(). 93 // BrowserContextKeyedService::SetTestingFactory().
88 static BrowserContextKeyedService* Build(content::BrowserContext* profile); 94 static BrowserContextKeyedService* Build(content::BrowserContext* profile);
89 95
90 protected: 96 protected:
91 // OAuth2TokenService overrides. 97 // OAuth2TokenService overrides.
92 virtual void FetchOAuth2Token(RequestImpl* request, 98 virtual void FetchOAuth2Token(RequestImpl* request,
99 const std::string& account_id,
93 net::URLRequestContextGetter* getter, 100 net::URLRequestContextGetter* getter,
94 const std::string& client_id, 101 const std::string& client_id,
95 const std::string& client_secret, 102 const std::string& client_secret,
96 const ScopeSet& scopes) OVERRIDE; 103 const ScopeSet& scopes) OVERRIDE;
97 104
98 virtual std::string GetRefreshToken() OVERRIDE; 105 virtual std::string GetRefreshToken(const std::string& account_id) OVERRIDE;
99 106
100 virtual net::URLRequestContextGetter* GetRequestContext() OVERRIDE; 107 virtual net::URLRequestContextGetter* GetRequestContext() OVERRIDE;
101 108
102 private: 109 private:
103 // Helper function to complete pending requests - if |all_scopes| is true, 110 // Helper function to complete pending requests - if |all_scopes| is true,
104 // then all pending requests are completed, otherwise, only those requests 111 // then all pending requests are completed, otherwise, only those requests
105 // matching |scopes| are completed. 112 // matching |scopes| are completed.
106 void CompleteRequests(bool all_scopes, 113 void CompleteRequests(bool all_scopes,
107 const ScopeSet& scopes, 114 const ScopeSet& scopes,
108 const GoogleServiceAuthError& error, 115 const GoogleServiceAuthError& error,
109 const std::string& access_token, 116 const std::string& access_token,
110 const base::Time& expiration); 117 const base::Time& expiration);
111 118
112 std::vector<PendingRequest> pending_requests_; 119 std::vector<PendingRequest> pending_requests_;
113 std::string refresh_token_; 120 std::string refresh_token_;
114 121
115 DISALLOW_COPY_AND_ASSIGN(FakeProfileOAuth2TokenService); 122 DISALLOW_COPY_AND_ASSIGN(FakeProfileOAuth2TokenService);
116 }; 123 };
117 124
118 #endif // CHROME_BROWSER_SIGNIN_FAKE_PROFILE_OAUTH2_TOKEN_SERVICE_H_ 125 #endif // CHROME_BROWSER_SIGNIN_FAKE_PROFILE_OAUTH2_TOKEN_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698