OLD | NEW |
| (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 REMOTING_HOST_GAIA_OAUTH_CLIENT_H_ | |
6 #define REMOTING_HOST_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 } // namespace net | |
16 | |
17 // A helper class to get and refresh OAuth tokens given an authorization code. | |
18 // | |
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 | |
21 // this duplication. | |
22 namespace remoting { | |
23 | |
24 struct OAuthClientInfo { | |
25 std::string client_id; | |
26 std::string client_secret; | |
27 }; | |
28 | |
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 { | |
37 public: | |
38 class Delegate { | |
39 public: | |
40 virtual ~Delegate() { } | |
41 | |
42 // Invoked on a successful response to the RefreshToken request. | |
43 virtual void OnRefreshTokenResponse(const std::string& user_email, | |
44 const std::string& access_token, | |
45 int expires_in_seconds) = 0; | |
46 // Invoked when there is an OAuth error with one of the requests. | |
47 virtual void OnOAuthError() = 0; | |
48 // Invoked when there is a network error or upon receiving an | |
49 // invalid response. | |
50 virtual void OnNetworkError(int response_code) = 0; | |
51 }; | |
52 | |
53 GaiaOAuthClient(const OAuthProviderInfo& provider_info, | |
54 net::URLRequestContextGetter* context_getter); | |
55 ~GaiaOAuthClient(); | |
56 | |
57 void RefreshToken(const OAuthClientInfo& oauth_client_info, | |
58 const std::string& refresh_token, | |
59 Delegate* delegate); | |
60 | |
61 private: | |
62 // The guts of the implementation live in this class. | |
63 class Core; | |
64 scoped_refptr<Core> core_; | |
65 DISALLOW_COPY_AND_ASSIGN(GaiaOAuthClient); | |
66 }; | |
67 | |
68 } // namespace remoting | |
69 | |
70 #endif // CHROME_COMMON_NET_GAIA_GAIA_OAUTH_CLIENT_H_ | |
OLD | NEW |