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

Side by Side Diff: chrome/common/net/gaia/gaia_oauth_client.h

Issue 10928017: Moving google_apis and GaiaClient to src/google_apis. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to head Created 8 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 | Annotate | Revision Log
« no previous file with comments | « chrome/common/net/gaia/gaia_constants.cc ('k') | chrome/common/net/gaia/gaia_oauth_client.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_COMMON_NET_GAIA_GAIA_OAUTH_CLIENT_H_
6 #define CHROME_COMMON_NET_GAIA_GAIA_OAUTH_CLIENT_H_
7
8 #include <string>
9
10 #include "base/memory/ref_counted.h"
11 #include "base/message_loop_proxy.h"
12
13 namespace net {
14 class URLRequestContextGetter;
15 }
16
17 // A helper class to get and refresh OAuth tokens given an authorization code.
18 namespace gaia {
19
20 static const char kGaiaOAuth2Url[] =
21 "https://accounts.google.com/o/oauth2/token";
22
23 struct OAuthClientInfo {
24 std::string client_id;
25 std::string client_secret;
26 };
27
28 class GaiaOAuthClient {
29 public:
30 class Delegate {
31 public:
32 // Invoked on a successful response to the GetTokensFromAuthCode request.
33 virtual void OnGetTokensResponse(const std::string& refresh_token,
34 const std::string& access_token,
35 int expires_in_seconds) = 0;
36 // Invoked on a successful response to the RefreshToken request.
37 virtual void OnRefreshTokenResponse(const std::string& access_token,
38 int expires_in_seconds) = 0;
39 // Invoked when there is an OAuth error with one of the requests.
40 virtual void OnOAuthError() = 0;
41 // Invoked when there is a network error or upon receiving an invalid
42 // response. This is invoked when the maximum number of retries have been
43 // exhausted. If max_retries is -1, this is never invoked.
44 virtual void OnNetworkError(int response_code) = 0;
45
46 protected:
47 virtual ~Delegate() {}
48 };
49 GaiaOAuthClient(const std::string& gaia_url,
50 net::URLRequestContextGetter* context_getter);
51 ~GaiaOAuthClient();
52
53 // In the below methods, |max_retries| specifies the maximum number of times
54 // we should retry on a network error in invalid response. This does not
55 // apply in the case of an OAuth error (i.e. there was something wrong with
56 // the input arguments). Setting |max_retries| to -1 implies infinite retries.
57 void GetTokensFromAuthCode(const OAuthClientInfo& oauth_client_info,
58 const std::string& auth_code,
59 int max_retries,
60 Delegate* delegate);
61 void RefreshToken(const OAuthClientInfo& oauth_client_info,
62 const std::string& refresh_token,
63 int max_retries,
64 Delegate* delegate);
65
66 private:
67 // The guts of the implementation live in this class.
68 class Core;
69 scoped_refptr<Core> core_;
70 DISALLOW_COPY_AND_ASSIGN(GaiaOAuthClient);
71 };
72 }
73
74 #endif // CHROME_COMMON_NET_GAIA_GAIA_OAUTH_CLIENT_H_
OLDNEW
« no previous file with comments | « chrome/common/net/gaia/gaia_constants.cc ('k') | chrome/common/net/gaia/gaia_oauth_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698