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

Side by Side Diff: remoting/host/gaia_oauth_client.h

Issue 10388226: This broke M20 build. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 7 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 | « no previous file | remoting/host/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
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 #ifndef REMOTING_HOST_GAIA_OAUTH_CLIENT_H_ 5 #ifndef REMOTING_HOST_GAIA_OAUTH_CLIENT_H_
6 #define REMOTING_HOST_GAIA_OAUTH_CLIENT_H_ 6 #define REMOTING_HOST_GAIA_OAUTH_CLIENT_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "base/message_loop_proxy.h" 11 #include "base/message_loop_proxy.h"
12 12
13 namespace net { 13 namespace net {
14 class URLRequestContextGetter; 14 class URLRequestContextGetter;
15 } // namespace net 15 } // namespace net
16 16
17 // A helper class to get and refresh OAuth tokens given an authorization code. 17 // A helper class to get and refresh OAuth tokens given an authorization code.
18 // 18 //
19 // TODO(jamiewalch): This is copied from chrome/common/net to avoid a dependency 19 // TODO(jamiewalch): This is copied from chrome/common/net to avoid a dependency
20 // on chrome. It would be better for this class to be moved into net to avoid 20 // on chrome. It would be better for this class to be moved into net to avoid
21 // this duplication. 21 // this duplication.
22 namespace remoting { 22 namespace remoting {
23 23
24 // TODO(jamiewalch): Make this configurable if we ever support other providers.
25 static const char kGaiaOAuth2Url[] =
26 "https://accounts.google.com/o/oauth2/token";
27
24 struct OAuthClientInfo { 28 struct OAuthClientInfo {
25 std::string client_id; 29 std::string client_id;
26 std::string client_secret; 30 std::string client_secret;
27 }; 31 };
28 32
29 struct OAuthProviderInfo {
30 static OAuthProviderInfo GetDefault();
31
32 std::string access_token_url;
33 std::string user_info_url;
34 };
35
36 class GaiaOAuthClient { 33 class GaiaOAuthClient {
37 public: 34 public:
38 class Delegate { 35 class Delegate {
39 public: 36 public:
40 virtual ~Delegate() { } 37 virtual ~Delegate() { }
41 38
42 // Invoked on a successful response to the RefreshToken request. 39 // Invoked on a successful response to the RefreshToken request.
43 virtual void OnRefreshTokenResponse(const std::string& user_email, 40 virtual void OnRefreshTokenResponse(const std::string& access_token,
44 const std::string& access_token,
45 int expires_in_seconds) = 0; 41 int expires_in_seconds) = 0;
46 // Invoked when there is an OAuth error with one of the requests. 42 // Invoked when there is an OAuth error with one of the requests.
47 virtual void OnOAuthError() = 0; 43 virtual void OnOAuthError() = 0;
48 // Invoked when there is a network error or upon receiving an 44 // Invoked when there is a network error or upon receiving an
49 // invalid response. 45 // invalid response.
50 virtual void OnNetworkError(int response_code) = 0; 46 virtual void OnNetworkError(int response_code) = 0;
51 }; 47 };
52 48 GaiaOAuthClient(const std::string& gaia_url,
53 GaiaOAuthClient(const OAuthProviderInfo& provider_info,
54 net::URLRequestContextGetter* context_getter); 49 net::URLRequestContextGetter* context_getter);
55 ~GaiaOAuthClient(); 50 ~GaiaOAuthClient();
56 51
57 void RefreshToken(const OAuthClientInfo& oauth_client_info, 52 void RefreshToken(const OAuthClientInfo& oauth_client_info,
58 const std::string& refresh_token, 53 const std::string& refresh_token,
59 Delegate* delegate); 54 Delegate* delegate);
60 55
61 private: 56 private:
62 // The guts of the implementation live in this class. 57 // The guts of the implementation live in this class.
63 class Core; 58 class Core;
64 scoped_refptr<Core> core_; 59 scoped_refptr<Core> core_;
65 DISALLOW_COPY_AND_ASSIGN(GaiaOAuthClient); 60 DISALLOW_COPY_AND_ASSIGN(GaiaOAuthClient);
66 }; 61 };
67 62
68 } // namespace remoting 63 } // namespace remoting
69 64
70 #endif // CHROME_COMMON_NET_GAIA_GAIA_OAUTH_CLIENT_H_ 65 #endif // CHROME_COMMON_NET_GAIA_GAIA_OAUTH_CLIENT_H_
OLDNEW
« no previous file with comments | « no previous file | remoting/host/gaia_oauth_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698