| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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_CHROMEOS_ARC_ARC_AUTH_CODE_FETCHER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_ARC_ARC_AUTH_CODE_FETCHER_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_ARC_ARC_AUTH_CODE_FETCHER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_ARC_ARC_AUTH_CODE_FETCHER_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 | 21 |
| 22 namespace arc { | 22 namespace arc { |
| 23 | 23 |
| 24 class ArcAuthCodeFetcherDelegate; | 24 class ArcAuthCodeFetcherDelegate; |
| 25 | 25 |
| 26 class ArcAuthCodeFetcher : public OAuth2TokenService::Consumer, | 26 class ArcAuthCodeFetcher : public OAuth2TokenService::Consumer, |
| 27 public net::URLFetcherDelegate { | 27 public net::URLFetcherDelegate { |
| 28 public: | 28 public: |
| 29 ArcAuthCodeFetcher(ArcAuthCodeFetcherDelegate* delegate, | 29 ArcAuthCodeFetcher(ArcAuthCodeFetcherDelegate* delegate, |
| 30 net::URLRequestContextGetter* request_context_getter, | 30 net::URLRequestContextGetter* request_context_getter, |
| 31 Profile* profile, | 31 Profile* profile); |
| 32 const std::string& auth_endpoint); | |
| 33 ~ArcAuthCodeFetcher() override; | 32 ~ArcAuthCodeFetcher() override; |
| 34 | 33 |
| 35 // OAuth2TokenService::Consumer: | 34 // OAuth2TokenService::Consumer: |
| 36 void OnGetTokenSuccess(const OAuth2TokenService::Request* request, | 35 void OnGetTokenSuccess(const OAuth2TokenService::Request* request, |
| 37 const std::string& access_token, | 36 const std::string& access_token, |
| 38 const base::Time& expiration_time) override; | 37 const base::Time& expiration_time) override; |
| 39 void OnGetTokenFailure(const OAuth2TokenService::Request* request, | 38 void OnGetTokenFailure(const OAuth2TokenService::Request* request, |
| 40 const GoogleServiceAuthError& error) override; | 39 const GoogleServiceAuthError& error) override; |
| 41 | 40 |
| 42 // net::URLFetcherDelegate: | 41 // net::URLFetcherDelegate: |
| 43 void OnURLFetchComplete(const net::URLFetcher* source) override; | 42 void OnURLFetchComplete(const net::URLFetcher* source) override; |
| 44 | 43 |
| 45 private: | 44 private: |
| 46 void ResetFetchers(); | 45 void ResetFetchers(); |
| 47 | 46 |
| 48 // Unowned pointers. | 47 // Unowned pointers. |
| 49 ArcAuthCodeFetcherDelegate* const delegate_; | 48 ArcAuthCodeFetcherDelegate* const delegate_; |
| 50 net::URLRequestContextGetter* const request_context_getter_; | 49 net::URLRequestContextGetter* const request_context_getter_; |
| 51 Profile* const profile_; | 50 Profile* const profile_; |
| 52 | 51 |
| 53 // URL to request auth code. | |
| 54 const std::string auth_endpoint_; | |
| 55 | |
| 56 std::unique_ptr<OAuth2TokenService::Request> login_token_request_; | 52 std::unique_ptr<OAuth2TokenService::Request> login_token_request_; |
| 57 std::unique_ptr<net::URLFetcher> auth_code_fetcher_; | 53 std::unique_ptr<net::URLFetcher> auth_code_fetcher_; |
| 58 | 54 |
| 59 DISALLOW_COPY_AND_ASSIGN(ArcAuthCodeFetcher); | 55 DISALLOW_COPY_AND_ASSIGN(ArcAuthCodeFetcher); |
| 60 }; | 56 }; |
| 61 | 57 |
| 62 } // namespace arc | 58 } // namespace arc |
| 63 | 59 |
| 64 #endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_AUTH_CODE_FETCHER_H_ | 60 #endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_AUTH_CODE_FETCHER_H_ |
| OLD | NEW |