| 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 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 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 // | 40 // |
| 41 // This class can handle one request at a time, and all calls through an | 41 // This class can handle one request at a time, and all calls through an |
| 42 // instance should be serialized. | 42 // instance should be serialized. |
| 43 class GaiaOAuthFetcher : public net::URLFetcherDelegate { | 43 class GaiaOAuthFetcher : public net::URLFetcherDelegate { |
| 44 public: | 44 public: |
| 45 // Defines steps of OAuth process performed by this class. | 45 // Defines steps of OAuth process performed by this class. |
| 46 typedef enum { | 46 typedef enum { |
| 47 OAUTH1_LOGIN, | 47 OAUTH1_LOGIN, |
| 48 OAUTH1_REQUEST_TOKEN, | 48 OAUTH1_REQUEST_TOKEN, |
| 49 OAUTH1_ALL_ACCESS_TOKEN, | 49 OAUTH1_ALL_ACCESS_TOKEN, |
| 50 OAUTH2_LOGIN, |
| 50 OAUTH2_SERVICE_ACCESS_TOKEN, | 51 OAUTH2_SERVICE_ACCESS_TOKEN, |
| 52 OAUTH2_REVOKE_TOKEN, |
| 51 USER_INFO, | 53 USER_INFO, |
| 52 OAUTH2_REVOKE_TOKEN, | |
| 53 } RequestType; | 54 } RequestType; |
| 54 | 55 |
| 55 GaiaOAuthFetcher(GaiaOAuthConsumer* consumer, | 56 GaiaOAuthFetcher(GaiaOAuthConsumer* consumer, |
| 56 net::URLRequestContextGetter* getter, | 57 net::URLRequestContextGetter* getter, |
| 57 const std::string& service_scope); | 58 const std::string& service_scope); |
| 58 | 59 |
| 59 virtual ~GaiaOAuthFetcher(); | 60 virtual ~GaiaOAuthFetcher(); |
| 60 | 61 |
| 61 // Sets the mask of which OAuth fetch steps should be automatically kicked | 62 // Sets the mask of which OAuth fetch steps should be automatically kicked |
| 62 // of upon successful completition of the previous steps. By default, | 63 // of upon successful completition of the previous steps. By default, |
| 63 // this class will chain all steps in OAuth proccess. | 64 // this class will chain all steps in OAuth proccess. |
| 64 void SetAutoFetchLimit(RequestType limit) { auto_fetch_limit_ = limit; } | 65 void SetAutoFetchLimit(RequestType limit) { auto_fetch_limit_ = limit; } |
| 65 | 66 |
| 66 // Non-UI version of the method above. Initiates Gaia OAuth request token | 67 // Non-UI version of the method above. Initiates Gaia OAuth request token |
| 67 // retrieval. | 68 // retrieval. |
| 68 void StartGetOAuthTokenRequest(); | 69 void StartGetOAuthTokenRequest(); |
| 69 | 70 |
| 70 // Performs account login based on OAuth1 access token and its secret. | 71 // Performs account login based on OAuth1 access token and its secret. |
| 71 void StartOAuthLogin(const char* source, | 72 void StartOAuth1Login(const char* source, |
| 72 const char* service, | 73 const char* service, |
| 73 const std::string& oauth1_access_token, | 74 const std::string& oauth1_access_token, |
| 74 const std::string& oauth1_access_token_secret); | 75 const std::string& oauth1_access_token_secret); |
| 75 | 76 |
| 76 // Obtains an OAuth1 access token and secret | 77 // Obtains an OAuth1 access token and secret |
| 77 // | 78 // |
| 78 // oauth1_request_token is from GetOAuthToken's result. | 79 // oauth1_request_token is from GetOAuthToken's result. |
| 79 virtual void StartOAuthGetAccessToken( | 80 virtual void StartOAuthGetAccessToken( |
| 80 const std::string& oauth1_request_token); | 81 const std::string& oauth1_request_token); |
| 81 | 82 |
| 82 // Obtains an OAuth2 access token using Gaia's OAuth1-to-OAuth2 bridge. | 83 // Obtains an OAuth2 access token using Gaia's OAuth1-to-OAuth2 bridge. |
| 83 // | 84 // |
| 84 // oauth1_access_token and oauth1_access_token_secret are from | 85 // oauth1_access_token and oauth1_access_token_secret are from |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 std::string request_body_; | 224 std::string request_body_; |
| 224 std::string request_headers_; | 225 std::string request_headers_; |
| 225 std::string service_scope_; | 226 std::string service_scope_; |
| 226 bool fetch_pending_; | 227 bool fetch_pending_; |
| 227 RequestType auto_fetch_limit_; | 228 RequestType auto_fetch_limit_; |
| 228 | 229 |
| 229 DISALLOW_COPY_AND_ASSIGN(GaiaOAuthFetcher); | 230 DISALLOW_COPY_AND_ASSIGN(GaiaOAuthFetcher); |
| 230 }; | 231 }; |
| 231 | 232 |
| 232 #endif // CHROME_BROWSER_NET_GAIA_GAIA_OAUTH_FETCHER_H_ | 233 #endif // CHROME_BROWSER_NET_GAIA_GAIA_OAUTH_FETCHER_H_ |
| OLD | NEW |