OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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 CHROME_BROWSER_CHROMEOS_ARC_ARC_AUTH_CODE_FETCHER_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_ARC_ARC_AUTH_CODE_FETCHER_H_ |
| 7 |
| 8 #include <memory> |
| 9 #include <string> |
| 10 |
| 11 #include "base/macros.h" |
| 12 #include "google_apis/gaia/oauth2_token_service.h" |
| 13 #include "net/url_request/url_fetcher_delegate.h" |
| 14 |
| 15 class Profile; |
| 16 |
| 17 namespace net { |
| 18 class URLFetcher; |
| 19 class URLRequestContextGetter; |
| 20 } |
| 21 |
| 22 namespace arc { |
| 23 |
| 24 class ArcAuthCodeFetcherDelegate; |
| 25 |
| 26 class ArcAuthCodeFetcher : public OAuth2TokenService::Consumer, |
| 27 public net::URLFetcherDelegate { |
| 28 public: |
| 29 ArcAuthCodeFetcher(ArcAuthCodeFetcherDelegate* delegate, |
| 30 net::URLRequestContextGetter* request_context_getter, |
| 31 Profile* profile, |
| 32 const std::string& auth_endpoint); |
| 33 ~ArcAuthCodeFetcher() override; |
| 34 |
| 35 // OAuth2TokenService::Consumer: |
| 36 void OnGetTokenSuccess(const OAuth2TokenService::Request* request, |
| 37 const std::string& access_token, |
| 38 const base::Time& expiration_time) override; |
| 39 void OnGetTokenFailure(const OAuth2TokenService::Request* request, |
| 40 const GoogleServiceAuthError& error) override; |
| 41 |
| 42 // net::URLFetcherDelegate: |
| 43 void OnURLFetchComplete(const net::URLFetcher* source) override; |
| 44 |
| 45 private: |
| 46 void ResetFetchers(); |
| 47 |
| 48 // Unowned pointers. |
| 49 ArcAuthCodeFetcherDelegate* const delegate_; |
| 50 net::URLRequestContextGetter* const request_context_getter_; |
| 51 Profile* const profile_; |
| 52 |
| 53 // URL to request auth code. |
| 54 const std::string auth_endpoint_; |
| 55 |
| 56 std::unique_ptr<OAuth2TokenService::Request> login_token_request_; |
| 57 std::unique_ptr<net::URLFetcher> auth_code_fetcher_; |
| 58 |
| 59 DISALLOW_COPY_AND_ASSIGN(ArcAuthCodeFetcher); |
| 60 }; |
| 61 |
| 62 } // namespace arc |
| 63 |
| 64 #endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_AUTH_CODE_FETCHER_H_ |
OLD | NEW |