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

Side by Side Diff: chrome/browser/net/gaia/token_service.h

Issue 3024002: Add IssueAuthToken support to the TokenService. (Closed)
Patch Set: Code review fixes Created 10 years, 5 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
« no previous file with comments | « chrome/browser/chromeos/login/login_utils.cc ('k') | chrome/browser/net/gaia/token_service.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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. One such service is Sync. 6 // needs it, such as sync.
7 // For the time being, the Token Service just supplies the LSID from the
8 // ChromiumOS login. In the future, it'll have a bit more logic and supply
9 // only AuthTokens from Gaia, and not LSIDs.
10 7
11 #ifndef CHROME_BROWSER_NET_GAIA_TOKEN_SERVICE_H_ 8 #ifndef CHROME_BROWSER_NET_GAIA_TOKEN_SERVICE_H_
12 #define CHROME_BROWSER_NET_GAIA_TOKEN_SERVICE_H_ 9 #define CHROME_BROWSER_NET_GAIA_TOKEN_SERVICE_H_
13 10
11 #include <map>
12 #include <string>
13 #include "base/scoped_ptr.h"
14 #include "chrome/common/net/gaia/gaia_auth_consumer.h" 14 #include "chrome/common/net/gaia/gaia_auth_consumer.h"
15 #include "chrome/common/net/gaia/gaia_authenticator2.h"
16 #include "chrome/test/testing_profile.h"
15 17
16 class TokenService { 18 class URLRequestContextGetter;
19
20 // The TokenService is a Profile member, so all calls are expected
21 // from the UI thread.
22 class TokenService : public GaiaAuthConsumer {
17 public: 23 public:
18 void SetClientLoginResult( 24 TokenService() {}
19 const GaiaAuthConsumer::ClientLoginResult& credentials);
20 25
21 bool HasLsid(); 26 // Notification classes
22 const std::string& GetLsid(); 27 class TokenAvailableDetails {
28 public:
29 TokenAvailableDetails() {}
30 TokenAvailableDetails(const std::string& service,
31 const std::string& token)
32 : service_(service), token_(token) {}
33 const std::string& service() const { return service_; }
34 const std::string& token() const { return token_; }
35 private:
36 std::string service_;
37 std::string token_;
38 };
23 39
24 // TODO(chron): Token broadcast will require removing a lot of auth code 40 class TokenRequestFailedDetails {
25 // from sync. For the time being we'll start with LSID passing. 41 public:
42 TokenRequestFailedDetails() {}
43 TokenRequestFailedDetails(const std::string& service,
44 const GaiaAuthError& error)
45 : service_(service), error_(error) {}
46 const std::string& service() const { return service_; }
47 const GaiaAuthError& error() const { return error_; }
48 private:
49 std::string service_;
50 GaiaAuthError error_;
51 };
52
53 // Initialize this token service with a request source
54 // (usually from a GaiaAuthConsumer constant), a getter and
55 // results from ClientLogin.
56 void Initialize(
57 const char* const source,
58 URLRequestContextGetter* getter,
59 const GaiaAuthConsumer::ClientLoginResult& credentials);
60
61 // For legacy services with their own auth routines, they can just read
62 // the LSID out directly. Deprecated.
63 const bool HasLsid() const;
64 const std::string& GetLsid() const;
65
66 // On login, StartFetchingTokens() should be called to kick off token
67 // fetching.
68 // Tokens will be fetched for all services(sync, talk) in the background.
69 // Results come back via event channel. Services can also poll.
70 void StartFetchingTokens();
71 const bool HasTokenForService(const char* const service) const;
72 const std::string& GetTokenForService(const char* const service) const;
73
74 // Callbacks from the fetchers.
75 void OnIssueAuthTokenSuccess(const std::string& service,
76 const std::string& auth_token);
77 void OnIssueAuthTokenFailure(const std::string& service,
78 const GaiaAuthError& error);
26 79
27 private: 80 private:
81 // Did we get a proper LSID?
82 const bool AreCredentialsValid() const;
83
84 // Gaia request source for Gaia accounting.
85 std::string source_;
86 // Credentials from ClientLogin for Issuing auth tokens.
28 GaiaAuthConsumer::ClientLoginResult credentials_; 87 GaiaAuthConsumer::ClientLoginResult credentials_;
88 scoped_ptr<GaiaAuthenticator2> sync_token_fetcher_;
89 scoped_ptr<GaiaAuthenticator2> talk_token_fetcher_;
90 // Map from service to token.
91 std::map<std::string, std::string> token_map_;
92
93 DISALLOW_COPY_AND_ASSIGN(TokenService);
29 }; 94 };
30 95
31 #endif // CHROME_BROWSER_NET_GAIA_TOKEN_SERVICE_H_ 96 #endif // CHROME_BROWSER_NET_GAIA_TOKEN_SERVICE_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/login_utils.cc ('k') | chrome/browser/net/gaia/token_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698