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

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: 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
(...skipping 17 matching lines...) Expand all
183 virtual void OnClientOAuthSuccess(const ClientOAuthResult& result) OVERRIDE; 183 virtual void OnClientOAuthSuccess(const ClientOAuthResult& result) OVERRIDE;
184 virtual void OnClientOAuthFailure( 184 virtual void OnClientOAuthFailure(
185 const GoogleServiceAuthError& error) OVERRIDE; 185 const GoogleServiceAuthError& error) OVERRIDE;
186 186
187 // WebDataServiceConsumer implementation. 187 // WebDataServiceConsumer implementation.
188 virtual void OnWebDataServiceRequestDone( 188 virtual void OnWebDataServiceRequestDone(
189 WebDataService::Handle h, 189 WebDataService::Handle h,
190 const WDTypedResult* result) OVERRIDE; 190 const WDTypedResult* result) OVERRIDE;
191 191
192 protected: 192 protected:
193 // Saves OAuth2 credentials.
194 void SaveOAuth2Credentials(const ClientOAuthResult& result);
195
193 void set_tokens_loaded(bool loaded) { 196 void set_tokens_loaded(bool loaded) {
194 tokens_loaded_ = loaded; 197 tokens_loaded_ = loaded;
195 } 198 }
196 199
197 private: 200 private:
198 201
199 // Gets the list of all service names for which tokens will be retrieved. 202 // Gets the list of all service names for which tokens will be retrieved.
200 // This method is meant only for tests. 203 // This method is meant only for tests.
201 static void GetServiceNamesForTesting(std::vector<std::string>* names); 204 static void GetServiceNamesForTesting(std::vector<std::string>* names);
202 205
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 256
254 friend class TokenServiceTest; 257 friend class TokenServiceTest;
255 FRIEND_TEST_ALL_PREFIXES(TokenServiceTest, LoadTokensIntoMemoryBasic); 258 FRIEND_TEST_ALL_PREFIXES(TokenServiceTest, LoadTokensIntoMemoryBasic);
256 FRIEND_TEST_ALL_PREFIXES(TokenServiceTest, LoadTokensIntoMemoryAdvanced); 259 FRIEND_TEST_ALL_PREFIXES(TokenServiceTest, LoadTokensIntoMemoryAdvanced);
257 FRIEND_TEST_ALL_PREFIXES(TokenServiceTest, FullIntegrationNewServicesAdded); 260 FRIEND_TEST_ALL_PREFIXES(TokenServiceTest, FullIntegrationNewServicesAdded);
258 261
259 DISALLOW_COPY_AND_ASSIGN(TokenService); 262 DISALLOW_COPY_AND_ASSIGN(TokenService);
260 }; 263 };
261 264
262 #endif // CHROME_BROWSER_SIGNIN_TOKEN_SERVICE_H_ 265 #endif // CHROME_BROWSER_SIGNIN_TOKEN_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698