| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 REMOTING_TEST_ACCESS_TOKEN_FETCHER_H_ | 5 #ifndef REMOTING_TEST_ACCESS_TOKEN_FETCHER_H_ |
| 6 #define REMOTING_TEST_ACCESS_TOKEN_FETCHER_H_ | 6 #define REMOTING_TEST_ACCESS_TOKEN_FETCHER_H_ |
| 7 | 7 |
| 8 #include <memory> |
| 8 #include <string> | 9 #include <string> |
| 9 | 10 |
| 10 #include "base/callback.h" | 11 #include "base/callback.h" |
| 11 #include "base/macros.h" | 12 #include "base/macros.h" |
| 12 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/scoped_ptr.h" | |
| 14 #include "google_apis/gaia/gaia_oauth_client.h" | 14 #include "google_apis/gaia/gaia_oauth_client.h" |
| 15 | 15 |
| 16 namespace remoting { | 16 namespace remoting { |
| 17 namespace test { | 17 namespace test { |
| 18 | 18 |
| 19 // Supplied by the client for each request to GAIA and returns valid tokens on | 19 // Supplied by the client for each request to GAIA and returns valid tokens on |
| 20 // success or empty tokens on failure. | 20 // success or empty tokens on failure. |
| 21 typedef base::Callback<void(const std::string& access_token, | 21 typedef base::Callback<void(const std::string& access_token, |
| 22 const std::string& refresh_token)> | 22 const std::string& refresh_token)> |
| 23 AccessTokenCallback; | 23 AccessTokenCallback; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 44 private: | 44 private: |
| 45 // gaia::GaiaOAuthClient::Delegate Interface. | 45 // gaia::GaiaOAuthClient::Delegate Interface. |
| 46 void OnGetTokensResponse(const std::string& refresh_token, | 46 void OnGetTokensResponse(const std::string& refresh_token, |
| 47 const std::string& access_token, | 47 const std::string& access_token, |
| 48 int expires_in_seconds) override; | 48 int expires_in_seconds) override; |
| 49 void OnRefreshTokenResponse(const std::string& access_token, | 49 void OnRefreshTokenResponse(const std::string& access_token, |
| 50 int expires_in_seconds) override; | 50 int expires_in_seconds) override; |
| 51 void OnGetUserEmailResponse(const std::string& user_email) override; | 51 void OnGetUserEmailResponse(const std::string& user_email) override; |
| 52 void OnGetUserIdResponse(const std::string& user_id) override; | 52 void OnGetUserIdResponse(const std::string& user_id) override; |
| 53 void OnGetUserInfoResponse( | 53 void OnGetUserInfoResponse( |
| 54 scoped_ptr<base::DictionaryValue> user_info) override; | 54 std::unique_ptr<base::DictionaryValue> user_info) override; |
| 55 void OnGetTokenInfoResponse( | 55 void OnGetTokenInfoResponse( |
| 56 scoped_ptr<base::DictionaryValue> token_info) override; | 56 std::unique_ptr<base::DictionaryValue> token_info) override; |
| 57 void OnOAuthError() override; | 57 void OnOAuthError() override; |
| 58 void OnNetworkError(int response_code) override; | 58 void OnNetworkError(int response_code) override; |
| 59 | 59 |
| 60 // Updates |auth_client_| with a new GaiaOAuthClient instance. | 60 // Updates |auth_client_| with a new GaiaOAuthClient instance. |
| 61 void CreateNewGaiaOAuthClientInstance(); | 61 void CreateNewGaiaOAuthClientInstance(); |
| 62 | 62 |
| 63 // Validates the retrieved access token. | 63 // Validates the retrieved access token. |
| 64 void ValidateAccessToken(); | 64 void ValidateAccessToken(); |
| 65 | 65 |
| 66 // Caller-supplied callback used to return valid tokens on success or empty | 66 // Caller-supplied callback used to return valid tokens on success or empty |
| 67 // tokens on failure. | 67 // tokens on failure. |
| 68 AccessTokenCallback access_token_callback_; | 68 AccessTokenCallback access_token_callback_; |
| 69 | 69 |
| 70 // Retrieved based on the |refresh_token_|. | 70 // Retrieved based on the |refresh_token_|. |
| 71 std::string access_token_; | 71 std::string access_token_; |
| 72 | 72 |
| 73 // Supplied by the caller or retrieved from a caller-supplied auth token. | 73 // Supplied by the caller or retrieved from a caller-supplied auth token. |
| 74 std::string refresh_token_; | 74 std::string refresh_token_; |
| 75 | 75 |
| 76 // Holds the client id, secret, and redirect url used to make | 76 // Holds the client id, secret, and redirect url used to make |
| 77 // the Gaia service request. | 77 // the Gaia service request. |
| 78 gaia::OAuthClientInfo oauth_client_info_; | 78 gaia::OAuthClientInfo oauth_client_info_; |
| 79 | 79 |
| 80 // Used to make token requests to GAIA. | 80 // Used to make token requests to GAIA. |
| 81 scoped_ptr<gaia::GaiaOAuthClient> auth_client_; | 81 std::unique_ptr<gaia::GaiaOAuthClient> auth_client_; |
| 82 | 82 |
| 83 DISALLOW_COPY_AND_ASSIGN(AccessTokenFetcher); | 83 DISALLOW_COPY_AND_ASSIGN(AccessTokenFetcher); |
| 84 }; | 84 }; |
| 85 | 85 |
| 86 } // namespace test | 86 } // namespace test |
| 87 } // namespace remoting | 87 } // namespace remoting |
| 88 | 88 |
| 89 #endif // REMOTING_TEST_ACCESS_TOKEN_FETCHER_H_ | 89 #endif // REMOTING_TEST_ACCESS_TOKEN_FETCHER_H_ |
| OLD | NEW |