OLD | NEW |
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 CHROME_BROWSER_POLICY_USER_INFO_FETCHER_H_ | 5 #ifndef CHROME_BROWSER_POLICY_USER_INFO_FETCHER_H_ |
6 #define CHROME_BROWSER_POLICY_USER_INFO_FETCHER_H_ | 6 #define CHROME_BROWSER_POLICY_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 "net/url_request/url_fetcher_delegate.h" | 10 #include "net/url_request/url_fetcher_delegate.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 // Invoked when the UserInfo request has succeeded, passing the parsed | 31 // Invoked when the UserInfo request has succeeded, passing the parsed |
32 // response in |response|. Delegate may free the UserInfoFetcher in this | 32 // response in |response|. Delegate may free the UserInfoFetcher in this |
33 // callback. | 33 // callback. |
34 virtual void OnGetUserInfoSuccess( | 34 virtual void OnGetUserInfoSuccess( |
35 const base::DictionaryValue* response) = 0; | 35 const base::DictionaryValue* response) = 0; |
36 | 36 |
37 // Invoked when the UserInfo request has failed, passing the associated | 37 // Invoked when the UserInfo request has failed, passing the associated |
38 // error in |error|. Delegate may free the UserInfoFetcher in this | 38 // error in |error|. Delegate may free the UserInfoFetcher in this |
39 // callback. | 39 // callback. |
40 virtual void OnGetUserInfoFailure(const GoogleServiceAuthError& error) = 0; | 40 virtual void OnGetUserInfoFailure(const GoogleServiceAuthError& error) = 0; |
| 41 |
| 42 protected: |
| 43 virtual ~Delegate() { } |
41 }; | 44 }; |
42 | 45 |
43 // Create a new UserInfoFetcher. |context| can be NULL for unit tests. | 46 // Create a new UserInfoFetcher. |context| can be NULL for unit tests. |
44 UserInfoFetcher(Delegate* delegate, net::URLRequestContextGetter* context); | 47 UserInfoFetcher(Delegate* delegate, net::URLRequestContextGetter* context); |
45 virtual ~UserInfoFetcher(); | 48 virtual ~UserInfoFetcher(); |
46 | 49 |
47 // Starts the UserInfo request, using the passed OAuth2 |access_token|. | 50 // Starts the UserInfo request, using the passed OAuth2 |access_token|. |
48 void Start(const std::string& access_token); | 51 void Start(const std::string& access_token); |
49 | 52 |
50 // net::URLFetcherDelegate implementation. | 53 // net::URLFetcherDelegate implementation. |
51 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; | 54 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; |
52 | 55 |
53 private: | 56 private: |
54 Delegate* delegate_; | 57 Delegate* delegate_; |
55 net::URLRequestContextGetter* context_; | 58 net::URLRequestContextGetter* context_; |
56 scoped_ptr<net::URLFetcher> url_fetcher_; | 59 scoped_ptr<net::URLFetcher> url_fetcher_; |
57 | 60 |
58 DISALLOW_COPY_AND_ASSIGN(UserInfoFetcher); | 61 DISALLOW_COPY_AND_ASSIGN(UserInfoFetcher); |
59 }; | 62 }; |
60 | 63 |
61 } // namespace policy | 64 } // namespace policy |
62 | 65 |
63 #endif // CHROME_BROWSER_POLICY_USER_INFO_FETCHER_H_ | 66 #endif // CHROME_BROWSER_POLICY_USER_INFO_FETCHER_H_ |
OLD | NEW |