| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_NET_GAIA_GAIA_OAUTH_FETCHER_H_ | 5 #ifndef CHROME_BROWSER_NET_GAIA_GAIA_OAUTH_FETCHER_H_ |
| 6 #define CHROME_BROWSER_NET_GAIA_GAIA_OAUTH_FETCHER_H_ | 6 #define CHROME_BROWSER_NET_GAIA_GAIA_OAUTH_FETCHER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 const std::string& oauth1_access_token, | 99 const std::string& oauth1_access_token, |
| 100 const std::string& oauth1_access_token_secret, | 100 const std::string& oauth1_access_token_secret, |
| 101 const std::string& wrap_token_duration, | 101 const std::string& wrap_token_duration, |
| 102 const std::string& service_scope); | 102 const std::string& service_scope); |
| 103 | 103 |
| 104 // Obtains user information related to an OAuth2 access token | 104 // Obtains user information related to an OAuth2 access token |
| 105 // | 105 // |
| 106 // oauth2_access_token is from OAuthWrapBridge's result. | 106 // oauth2_access_token is from OAuthWrapBridge's result. |
| 107 virtual void StartUserInfo(const std::string& oauth2_access_token); | 107 virtual void StartUserInfo(const std::string& oauth2_access_token); |
| 108 | 108 |
| 109 // Starts a request for revoking the given OAuth access token (as requested by | |
| 110 // StartOAuthGetAccessToken). | |
| 111 virtual void StartOAuthRevokeAccessToken(const std::string& token, | |
| 112 const std::string& secret); | |
| 113 | |
| 114 // Starts a request for revoking the given OAuth Bearer token (as requested by | |
| 115 // StartOAuthWrapBridge). | |
| 116 virtual void StartOAuthRevokeWrapToken(const std::string& token); | |
| 117 | |
| 118 // NotificationObserver implementation. | 109 // NotificationObserver implementation. |
| 119 virtual void Observe(int type, | 110 virtual void Observe(int type, |
| 120 const NotificationSource& source, | 111 const NotificationSource& source, |
| 121 const NotificationDetails& details) OVERRIDE; | 112 const NotificationDetails& details) OVERRIDE; |
| 122 | 113 |
| 123 // Called when a cookie, e. g. oauth_token, changes | 114 // Called when a cookie, e. g. oauth_token, changes |
| 124 virtual void OnCookieChanged(Profile* profile, | 115 virtual void OnCookieChanged(Profile* profile, |
| 125 ChromeCookieDetails* cookie_details); | 116 ChromeCookieDetails* cookie_details); |
| 126 | 117 |
| 127 // Called when a cookie, e. g. oauth_token, changes | 118 // Called when a cookie, e. g. oauth_token, changes |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 // Process the results of a OAuthGetAccessToken fetch. | 151 // Process the results of a OAuthGetAccessToken fetch. |
| 161 virtual void OnOAuthGetAccessTokenFetched(const std::string& data, | 152 virtual void OnOAuthGetAccessTokenFetched(const std::string& data, |
| 162 const net::URLRequestStatus& status, | 153 const net::URLRequestStatus& status, |
| 163 int response_code); | 154 int response_code); |
| 164 | 155 |
| 165 // Process the results of a OAuthWrapBridge fetch. | 156 // Process the results of a OAuthWrapBridge fetch. |
| 166 virtual void OnOAuthWrapBridgeFetched(const std::string& data, | 157 virtual void OnOAuthWrapBridgeFetched(const std::string& data, |
| 167 const net::URLRequestStatus& status, | 158 const net::URLRequestStatus& status, |
| 168 int response_code); | 159 int response_code); |
| 169 | 160 |
| 170 // Process the results of a token revocation fetch. | |
| 171 virtual void OnOAuthRevokeTokenFetched(const std::string& data, | |
| 172 const net::URLRequestStatus& status, | |
| 173 int response_code); | |
| 174 | |
| 175 // Process the results of a userinfo fetch. | 161 // Process the results of a userinfo fetch. |
| 176 virtual void OnUserInfoFetched(const std::string& data, | 162 virtual void OnUserInfoFetched(const std::string& data, |
| 177 const net::URLRequestStatus& status, | 163 const net::URLRequestStatus& status, |
| 178 int response_code); | 164 int response_code); |
| 179 | 165 |
| 180 // Tokenize the results of a GetOAuthToken fetch. | 166 // Tokenize the results of a GetOAuthToken fetch. |
| 181 static void ParseGetOAuthTokenResponse(const std::string& data, | 167 static void ParseGetOAuthTokenResponse(const std::string& data, |
| 182 std::string* token); | 168 std::string* token); |
| 183 | 169 |
| 184 // Tokenize the results of a OAuthLogin fetch. | 170 // Tokenize the results of a OAuthLogin fetch. |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 const std::string& oauth1_access_token, | 207 const std::string& oauth1_access_token, |
| 222 const std::string& oauth1_access_token_secret); | 208 const std::string& oauth1_access_token_secret); |
| 223 | 209 |
| 224 // Given parameters, create a OAuthWrapBridge request body. | 210 // Given parameters, create a OAuthWrapBridge request body. |
| 225 static std::string MakeOAuthWrapBridgeBody( | 211 static std::string MakeOAuthWrapBridgeBody( |
| 226 const std::string& oauth1_access_token, | 212 const std::string& oauth1_access_token, |
| 227 const std::string& oauth1_access_token_secret, | 213 const std::string& oauth1_access_token_secret, |
| 228 const std::string& wrap_token_duration, | 214 const std::string& wrap_token_duration, |
| 229 const std::string& oauth2_service_scope); | 215 const std::string& oauth2_service_scope); |
| 230 | 216 |
| 217 // Given parameters, create a userinfo request body. |
| 218 static std::string MakeUserInfoBody(const std::string& oauth2_access_token); |
| 219 |
| 231 // Create a fetcher useable for making any Gaia OAuth request. | 220 // Create a fetcher useable for making any Gaia OAuth request. |
| 232 static URLFetcher* CreateGaiaFetcher(net::URLRequestContextGetter* getter, | 221 static URLFetcher* CreateGaiaFetcher(net::URLRequestContextGetter* getter, |
| 233 const GURL& gaia_gurl_, | 222 const GURL& gaia_gurl_, |
| 234 const std::string& body, | 223 const std::string& body, |
| 235 const std::string& headers, | 224 const std::string& headers, |
| 236 bool send_cookies, | 225 bool send_cookies, |
| 237 URLFetcher::Delegate* delegate); | 226 URLFetcher::Delegate* delegate); |
| 238 | 227 |
| 239 bool ShouldAutoFetch(AutoFetchLimit fetch_step); | 228 bool ShouldAutoFetch(AutoFetchLimit fetch_step); |
| 240 | 229 |
| 241 // These fields are common to GaiaOAuthFetcher, same every request | 230 // These fields are common to GaiaOAuthFetcher, same every request |
| 242 GaiaOAuthConsumer* const consumer_; | 231 GaiaOAuthConsumer* const consumer_; |
| 243 net::URLRequestContextGetter* const getter_; | 232 net::URLRequestContextGetter* const getter_; |
| 244 Profile* profile_; | 233 Profile* profile_; |
| 245 Browser* popup_; | 234 Browser* popup_; |
| 246 NotificationRegistrar registrar_; | 235 NotificationRegistrar registrar_; |
| 247 | 236 |
| 248 // While a fetch is going on: | 237 // While a fetch is going on: |
| 249 scoped_ptr<URLFetcher> fetcher_; | 238 scoped_ptr<URLFetcher> fetcher_; |
| 250 std::string request_body_; | 239 std::string request_body_; |
| 251 std::string request_headers_; | 240 std::string request_headers_; |
| 252 std::string service_scope_; | 241 std::string service_scope_; |
| 253 bool fetch_pending_; | 242 bool fetch_pending_; |
| 254 AutoFetchLimit auto_fetch_limit_; | 243 AutoFetchLimit auto_fetch_limit_; |
| 255 | 244 |
| 256 DISALLOW_COPY_AND_ASSIGN(GaiaOAuthFetcher); | 245 DISALLOW_COPY_AND_ASSIGN(GaiaOAuthFetcher); |
| 257 }; | 246 }; |
| 258 | 247 |
| 259 #endif // CHROME_BROWSER_NET_GAIA_GAIA_OAUTH_FETCHER_H_ | 248 #endif // CHROME_BROWSER_NET_GAIA_GAIA_OAUTH_FETCHER_H_ |
| OLD | NEW |