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

Side by Side Diff: components/policy/core/common/cloud/user_info_fetcher.h

Issue 257773002: Use new people.get api instead of oauth2/v1/userinfo. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix user image manager tests Created 6 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
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 COMPONENTS_POLICY_CORE_COMMON_CLOUD_USER_INFO_FETCHER_H_ 5 #ifndef COMPONENTS_POLICY_CORE_COMMON_CLOUD_USER_INFO_FETCHER_H_
6 #define COMPONENTS_POLICY_CORE_COMMON_CLOUD_USER_INFO_FETCHER_H_ 6 #define COMPONENTS_POLICY_CORE_COMMON_CLOUD_USER_INFO_FETCHER_H_
7 7
8 #include <string> 8 #include <string>
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "components/policy/policy_export.h" 10 #include "components/policy/policy_export.h"
11 #include "google_apis/gaia/gaia_oauth_client.h"
11 #include "net/url_request/url_fetcher_delegate.h" 12 #include "net/url_request/url_fetcher_delegate.h"
12 13
13 class GoogleServiceAuthError; 14 class GoogleServiceAuthError;
14 15
15 namespace base { 16 namespace base {
16 class DictionaryValue; 17 class DictionaryValue;
17 } 18 }
18 19
19 namespace net { 20 namespace net {
20 class URLFetcher; 21 class URLFetcher;
21 class URLRequestContextGetter; 22 class URLRequestContextGetter;
22 } 23 }
23 24
24 namespace policy { 25 namespace policy {
25 26
26 // Class that makes a UserInfo request, parses the response, and notifies 27 // Class that makes a UserInfo request, parses the response, and notifies
27 // a provided Delegate when the request is complete. 28 // a provided Delegate when the request is complete.
28 class POLICY_EXPORT UserInfoFetcher : public net::URLFetcherDelegate { 29 class POLICY_EXPORT UserInfoFetcher {
29 public: 30 public:
30 class POLICY_EXPORT Delegate { 31 class POLICY_EXPORT Delegate {
31 public: 32 public:
32 // Invoked when the UserInfo request has succeeded, passing the parsed 33 // Invoked when the UserInfo request has succeeded, passing the parsed
33 // response in |response|. Delegate may free the UserInfoFetcher in this 34 // response in |response|. Delegate may free the UserInfoFetcher in this
34 // callback. 35 // callback.
35 virtual void OnGetUserInfoSuccess( 36 virtual void OnGetUserInfoSuccess(
36 const base::DictionaryValue* response) = 0; 37 const base::DictionaryValue* response) = 0;
37 38
38 // Invoked when the UserInfo request has failed, passing the associated 39 // Invoked when the UserInfo request has failed, passing the associated
39 // error in |error|. Delegate may free the UserInfoFetcher in this 40 // error in |error|. Delegate may free the UserInfoFetcher in this
40 // callback. 41 // callback.
41 virtual void OnGetUserInfoFailure(const GoogleServiceAuthError& error) = 0; 42 virtual void OnGetUserInfoFailure(const GoogleServiceAuthError& error) = 0;
42 }; 43 };
43 44
44 // Create a new UserInfoFetcher. |context| can be NULL for unit tests. 45 // Create a new UserInfoFetcher. |context| can be NULL for unit tests.
45 UserInfoFetcher(Delegate* delegate, net::URLRequestContextGetter* context); 46 UserInfoFetcher(Delegate* delegate, net::URLRequestContextGetter* context);
46 virtual ~UserInfoFetcher(); 47 virtual ~UserInfoFetcher();
47 48
48 // Starts the UserInfo request, using the passed OAuth2 |access_token|. 49 // Starts the UserInfo request, using the passed OAuth2 |access_token|.
49 void Start(const std::string& access_token); 50 void Start(const std::string& access_token);
50 51
51 // net::URLFetcherDelegate implementation. 52 private:
52 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; 53 class GaiaDelegate : public gaia::GaiaOAuthClient::Delegate {
54 public:
55 explicit GaiaDelegate(UserInfoFetcher::Delegate* delegate);
53 56
54 private: 57 private:
55 Delegate* delegate_; 58 // gaia::GaiaOAuthClient::Delegate implementation.
56 net::URLRequestContextGetter* context_; 59 virtual void OnGetUserInfoResponse(
57 scoped_ptr<net::URLFetcher> url_fetcher_; 60 scoped_ptr<base::DictionaryValue> user_info) OVERRIDE;
61 virtual void OnOAuthError() OVERRIDE;
62 virtual void OnNetworkError(int response_code) OVERRIDE;
63
64 UserInfoFetcher::Delegate* delegate_;
65
66 DISALLOW_COPY_AND_ASSIGN(GaiaDelegate);
67 };
68
69 GaiaDelegate delegate_;
70 gaia::GaiaOAuthClient gaia_client_;
58 71
59 DISALLOW_COPY_AND_ASSIGN(UserInfoFetcher); 72 DISALLOW_COPY_AND_ASSIGN(UserInfoFetcher);
60 }; 73 };
61 74
62 } // namespace policy 75 } // namespace policy
63 76
64 #endif // COMPONENTS_POLICY_CORE_COMMON_CLOUD_USER_INFO_FETCHER_H_ 77 #endif // COMPONENTS_POLICY_CORE_COMMON_CLOUD_USER_INFO_FETCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698