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

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

Issue 2661153003: Moving oauth code from host to base to allow code sharing between host and client. (Closed)
Patch Set: Merge branch 'master' into auth_token Created 3 years, 10 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 | « remoting/host/setup/BUILD.gn ('k') | remoting/host/setup/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 2013 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_SETUP_GAIA_OAUTH_CLIENT_H_
6 #define REMOTING_HOST_SETUP_GAIA_OAUTH_CLIENT_H_
7
8 #include <queue>
9
10 #include "base/macros.h"
11 #include "base/memory/ref_counted.h"
12 #include "google_apis/gaia/gaia_oauth_client.h"
13 #include "net/url_request/url_request_context_getter.h"
14
15 #include "remoting/host/setup/oauth_client.h"
16
17 namespace remoting {
18
19 // A wrapper around gaia::GaiaOAuthClient that provides a more
20 // convenient interface, with queueing of requests and a callback
21 // rather than a delegate.
22 class GaiaOAuthClient : public OAuthClient,
23 public gaia::GaiaOAuthClient::Delegate {
24 public:
25 GaiaOAuthClient(
26 scoped_refptr<net::URLRequestContextGetter> url_request_context_getter);
27
28 ~GaiaOAuthClient() override;
29
30 // Redeems |auth_code| using |oauth_client_info| to obtain |refresh_token| and
31 // |access_token|, then uses the userinfo endpoint to obtain |user_email|.
32 // Calls CompletionCallback with |user_email| and |refresh_token| when done,
33 // or with empty strings on error.
34 // If a request is received while another one is being processed, it is
35 // enqueued and processed after the first one is finished.
36 void GetCredentialsFromAuthCode(
37 const gaia::OAuthClientInfo& oauth_client_info,
38 const std::string& auth_code,
39 bool need_user_email,
40 CompletionCallback on_done) override;
41
42 // gaia::GaiaOAuthClient::Delegate
43 void OnGetTokensResponse(const std::string& refresh_token,
44 const std::string& access_token,
45 int expires_in_seconds) override;
46 void OnRefreshTokenResponse(const std::string& access_token,
47 int expires_in_seconds) override;
48 void OnGetUserEmailResponse(const std::string& user_email) override;
49
50 void OnOAuthError() override;
51 void OnNetworkError(int response_code) override;
52
53 private:
54 struct Request {
55 Request(const gaia::OAuthClientInfo& oauth_client_info,
56 const std::string& auth_code,
57 bool need_user_email,
58 CompletionCallback on_done);
59 Request(const Request& other);
60 virtual ~Request();
61 gaia::OAuthClientInfo oauth_client_info;
62 std::string auth_code;
63 bool need_user_email;
64 CompletionCallback on_done;
65 };
66
67 void SendResponse(const std::string& user_email,
68 const std::string& refresh_token);
69
70 std::queue<Request> pending_requests_;
71 gaia::GaiaOAuthClient gaia_oauth_client_;
72 std::string refresh_token_;
73 bool need_user_email_;
74 CompletionCallback on_done_;
75
76 DISALLOW_COPY_AND_ASSIGN(GaiaOAuthClient);
77 };
78
79 } // namespace remoting
80
81 #endif // REMOTING_HOST_SETUP_GAIA_OAUTH_CLIENT_H_
OLDNEW
« no previous file with comments | « remoting/host/setup/BUILD.gn ('k') | remoting/host/setup/gaia_oauth_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698