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

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

Issue 11649055: OAuth2 sign-in flow for ChromeOS (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: clang fix Created 7 years, 11 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // The TokenService will supply authentication tokens for any service that 5 // The TokenService will supply authentication tokens for any service that
6 // needs it, such as sync. Whenever the user logs in, a controller watching 6 // needs it, such as sync. Whenever the user logs in, a controller watching
7 // the token service is expected either to call ClientLogin to derive a new 7 // the token service is expected either to call ClientLogin to derive a new
8 // SID and LSID, or to use GAIA OAuth requests to derive an OAuth1 access 8 // SID and LSID, or to use GAIA OAuth requests to derive an OAuth1 access
9 // token for the OAuthLogin scope. Whenever such credentials are available, 9 // token for the OAuthLogin scope. Whenever such credentials are available,
10 // the TokenService should be updated with new credentials. The controller 10 // the TokenService should be updated with new credentials. The controller
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 144
145 // Clear all DB stored tokens for the current profile. Tokens may still be 145 // Clear all DB stored tokens for the current profile. Tokens may still be
146 // available in memory. If a DB load is pending it may still be serviced. 146 // available in memory. If a DB load is pending it may still be serviced.
147 void EraseTokensFromDB(); 147 void EraseTokensFromDB();
148 148
149 // Returns true if tokens have been loaded from the DB. Set when 149 // Returns true if tokens have been loaded from the DB. Set when
150 // LoadTokensFromDB() completes, unset when ResetCredentialsInMemory() is 150 // LoadTokensFromDB() completes, unset when ResetCredentialsInMemory() is
151 // called. 151 // called.
152 bool TokensLoadedFromDB() const; 152 bool TokensLoadedFromDB() const;
153 153
154 // Returns true if the token service has all credentials needed to fetch 154 // Returns true if the token service has either GAIA credentials or OAuth2
155 // tokens. 155 // tokens needed to fetch other service tokens.
156 virtual bool AreCredentialsValid() const; 156 virtual bool AreCredentialsValid() const;
157 157
158 // Tokens will be fetched for all services(sync, talk) in the background. 158 // Tokens will be fetched for all services(sync, talk) in the background.
159 // Results come back via event channel. Services can also poll before events 159 // Results come back via event channel. Services can also poll before events
160 // are issued. 160 // are issued.
161 void StartFetchingTokens(); 161 void StartFetchingTokens();
162 virtual bool HasTokenForService(const char* service) const; 162 virtual bool HasTokenForService(const char* service) const;
163 const std::string& GetTokenForService(const char* const service) const; 163 const std::string& GetTokenForService(const char* const service) const;
164 164
165 // OAuth login token is an all-powerful token that allows creating OAuth2 165 // OAuth login token is an all-powerful token that allows creating OAuth2
166 // tokens for any other scope (i.e. down-scoping). 166 // tokens for any other scope (i.e. down-scoping).
167 // Typical use is to create an OAuth2 token for appropriate scope and then 167 // Typical use is to create an OAuth2 token for appropriate scope and then
168 // use that token to call a Google API. 168 // use that token to call a Google API.
169 virtual bool HasOAuthLoginToken() const; 169 virtual bool HasOAuthLoginToken() const;
170 virtual bool HasOAuthLoginAccessToken() const;
170 virtual const std::string& GetOAuth2LoginRefreshToken() const; 171 virtual const std::string& GetOAuth2LoginRefreshToken() const;
171 const std::string& GetOAuth2LoginAccessToken() const; 172 const std::string& GetOAuth2LoginAccessToken() const;
172 173
173 // For tests only. Doesn't save to the WebDB. 174 // For tests only. Doesn't save to the WebDB.
174 void IssueAuthTokenForTest(const std::string& service, 175 void IssueAuthTokenForTest(const std::string& service,
175 const std::string& auth_token); 176 const std::string& auth_token);
176 177
177 // GaiaAuthConsumer implementation. 178 // GaiaAuthConsumer implementation.
178 virtual void OnIssueAuthTokenSuccess(const std::string& service, 179 virtual void OnIssueAuthTokenSuccess(const std::string& service,
179 const std::string& auth_token) OVERRIDE; 180 const std::string& auth_token) OVERRIDE;
180 virtual void OnIssueAuthTokenFailure( 181 virtual void OnIssueAuthTokenFailure(
181 const std::string& service, 182 const std::string& service,
182 const GoogleServiceAuthError& error) OVERRIDE; 183 const GoogleServiceAuthError& error) OVERRIDE;
183 virtual void OnClientOAuthSuccess(const ClientOAuthResult& result) OVERRIDE; 184 virtual void OnClientOAuthSuccess(const ClientOAuthResult& result) OVERRIDE;
184 virtual void OnClientOAuthFailure( 185 virtual void OnClientOAuthFailure(
185 const GoogleServiceAuthError& error) OVERRIDE; 186 const GoogleServiceAuthError& error) OVERRIDE;
186 187
187 // WebDataServiceConsumer implementation. 188 // WebDataServiceConsumer implementation.
188 virtual void OnWebDataServiceRequestDone( 189 virtual void OnWebDataServiceRequestDone(
189 WebDataService::Handle h, 190 WebDataService::Handle h,
190 const WDTypedResult* result) OVERRIDE; 191 const WDTypedResult* result) OVERRIDE;
191 192
192 protected: 193 protected:
194 // Saves OAuth2 credentials.
195 void SaveOAuth2Credentials(const ClientOAuthResult& result);
196
193 void set_tokens_loaded(bool loaded) { 197 void set_tokens_loaded(bool loaded) {
194 tokens_loaded_ = loaded; 198 tokens_loaded_ = loaded;
195 } 199 }
196 200
197 private: 201 private:
198 202
199 // Gets the list of all service names for which tokens will be retrieved. 203 // Gets the list of all service names for which tokens will be retrieved.
200 // This method is meant only for tests. 204 // This method is meant only for tests.
201 static void GetServiceNamesForTesting(std::vector<std::string>* names); 205 static void GetServiceNamesForTesting(std::vector<std::string>* names);
202 206
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 257
254 friend class TokenServiceTest; 258 friend class TokenServiceTest;
255 FRIEND_TEST_ALL_PREFIXES(TokenServiceTest, LoadTokensIntoMemoryBasic); 259 FRIEND_TEST_ALL_PREFIXES(TokenServiceTest, LoadTokensIntoMemoryBasic);
256 FRIEND_TEST_ALL_PREFIXES(TokenServiceTest, LoadTokensIntoMemoryAdvanced); 260 FRIEND_TEST_ALL_PREFIXES(TokenServiceTest, LoadTokensIntoMemoryAdvanced);
257 FRIEND_TEST_ALL_PREFIXES(TokenServiceTest, FullIntegrationNewServicesAdded); 261 FRIEND_TEST_ALL_PREFIXES(TokenServiceTest, FullIntegrationNewServicesAdded);
258 262
259 DISALLOW_COPY_AND_ASSIGN(TokenService); 263 DISALLOW_COPY_AND_ASSIGN(TokenService);
260 }; 264 };
261 265
262 #endif // CHROME_BROWSER_SIGNIN_TOKEN_SERVICE_H_ 266 #endif // CHROME_BROWSER_SIGNIN_TOKEN_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698