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 GOOGLE_APIS_GAIA_OAUTH2_ACCESS_TOKEN_FETCHER_H_ | 5 #ifndef GOOGLE_APIS_GAIA_OAUTH2_ACCESS_TOKEN_FETCHER_H_ |
6 #define GOOGLE_APIS_GAIA_OAUTH2_ACCESS_TOKEN_FETCHER_H_ | 6 #define GOOGLE_APIS_GAIA_OAUTH2_ACCESS_TOKEN_FETCHER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 const base::Time& expiration_time); | 83 const base::Time& expiration_time); |
84 void OnGetTokenFailure(const GoogleServiceAuthError& error); | 84 void OnGetTokenFailure(const GoogleServiceAuthError& error); |
85 | 85 |
86 // Other helpers. | 86 // Other helpers. |
87 static GURL MakeGetAccessTokenUrl(); | 87 static GURL MakeGetAccessTokenUrl(); |
88 static std::string MakeGetAccessTokenBody( | 88 static std::string MakeGetAccessTokenBody( |
89 const std::string& client_id, | 89 const std::string& client_id, |
90 const std::string& client_secret, | 90 const std::string& client_secret, |
91 const std::string& refresh_token, | 91 const std::string& refresh_token, |
92 const std::vector<std::string>& scopes); | 92 const std::vector<std::string>& scopes); |
93 static bool ParseGetAccessTokenResponse(const net::URLFetcher* source, | 93 |
94 std::string* access_token, | 94 static bool ParseGetAccessTokenSuccessResponse( |
95 int* expires_in); | 95 const net::URLFetcher* source, |
| 96 std::string* access_token, |
| 97 int* expires_in); |
| 98 |
| 99 static bool ParseGetAccessTokenFailureResponse( |
| 100 const net::URLFetcher* source, |
| 101 std::string* error); |
96 | 102 |
97 // State that is set during construction. | 103 // State that is set during construction. |
98 OAuth2AccessTokenConsumer* const consumer_; | 104 OAuth2AccessTokenConsumer* const consumer_; |
99 net::URLRequestContextGetter* const getter_; | 105 net::URLRequestContextGetter* const getter_; |
100 State state_; | 106 State state_; |
101 | 107 |
102 // While a fetch is in progress. | 108 // While a fetch is in progress. |
103 scoped_ptr<net::URLFetcher> fetcher_; | 109 scoped_ptr<net::URLFetcher> fetcher_; |
104 std::string client_id_; | 110 std::string client_id_; |
105 std::string client_secret_; | 111 std::string client_secret_; |
106 std::string refresh_token_; | 112 std::string refresh_token_; |
107 std::vector<std::string> scopes_; | 113 std::vector<std::string> scopes_; |
108 | 114 |
109 friend class OAuth2AccessTokenFetcherTest; | 115 friend class OAuth2AccessTokenFetcherTest; |
110 FRIEND_TEST_ALL_PREFIXES(OAuth2AccessTokenFetcherTest, | 116 FRIEND_TEST_ALL_PREFIXES(OAuth2AccessTokenFetcherTest, |
111 ParseGetAccessTokenResponse); | 117 ParseGetAccessTokenResponse); |
112 FRIEND_TEST_ALL_PREFIXES(OAuth2AccessTokenFetcherTest, | 118 FRIEND_TEST_ALL_PREFIXES(OAuth2AccessTokenFetcherTest, |
113 MakeGetAccessTokenBody); | 119 MakeGetAccessTokenBody); |
114 | 120 |
115 DISALLOW_COPY_AND_ASSIGN(OAuth2AccessTokenFetcher); | 121 DISALLOW_COPY_AND_ASSIGN(OAuth2AccessTokenFetcher); |
116 }; | 122 }; |
117 | 123 |
118 #endif // GOOGLE_APIS_GAIA_OAUTH2_ACCESS_TOKEN_FETCHER_H_ | 124 #endif // GOOGLE_APIS_GAIA_OAUTH2_ACCESS_TOKEN_FETCHER_H_ |
OLD | NEW |