| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 OAUTH1_REQUEST_TOKEN, | 46 OAUTH1_REQUEST_TOKEN, |
| 47 OAUTH1_ALL_ACCESS_TOKEN, | 47 OAUTH1_ALL_ACCESS_TOKEN, |
| 48 OAUTH2_SERVICE_ACCESS_TOKEN, | 48 OAUTH2_SERVICE_ACCESS_TOKEN, |
| 49 USER_INFO, | 49 USER_INFO, |
| 50 ALL_OAUTH_STEPS, | 50 ALL_OAUTH_STEPS, |
| 51 } AutoFetchLimit; | 51 } AutoFetchLimit; |
| 52 | 52 |
| 53 GaiaOAuthFetcher(GaiaOAuthConsumer* consumer, | 53 GaiaOAuthFetcher(GaiaOAuthConsumer* consumer, |
| 54 net::URLRequestContextGetter* getter, | 54 net::URLRequestContextGetter* getter, |
| 55 Profile* profile, | 55 Profile* profile, |
| 56 const std::string& service_name, |
| 56 const std::string& service_scope); | 57 const std::string& service_scope); |
| 57 | 58 |
| 58 virtual ~GaiaOAuthFetcher(); | 59 virtual ~GaiaOAuthFetcher(); |
| 59 | 60 |
| 60 // Sets the mask of which OAuth fetch steps should be automatically kicked | 61 // Sets the mask of which OAuth fetch steps should be automatically kicked |
| 61 // of upon successful completition of the previous steps. By default, | 62 // of upon successful completition of the previous steps. By default, |
| 62 // this class will chain all steps in OAuth proccess. | 63 // this class will chain all steps in OAuth proccess. |
| 63 void SetAutoFetchLimit(AutoFetchLimit limit) { auto_fetch_limit_ = limit; } | 64 void SetAutoFetchLimit(AutoFetchLimit limit) { auto_fetch_limit_ = limit; } |
| 64 | 65 |
| 65 // Obtains an OAuth 1 request token | 66 // Obtains an OAuth 1 request token |
| (...skipping 19 matching lines...) Expand all Loading... |
| 85 const std::string& oauth1_request_token); | 86 const std::string& oauth1_request_token); |
| 86 | 87 |
| 87 // Obtains an OAuth2 access token using Gaia's OAuth1-to-OAuth2 bridge. | 88 // Obtains an OAuth2 access token using Gaia's OAuth1-to-OAuth2 bridge. |
| 88 // | 89 // |
| 89 // oauth1_access_token and oauth1_access_token_secret are from | 90 // oauth1_access_token and oauth1_access_token_secret are from |
| 90 // OAuthGetAccessToken's result. | 91 // OAuthGetAccessToken's result. |
| 91 // | 92 // |
| 92 // wrap_token_duration is typically one hour, | 93 // wrap_token_duration is typically one hour, |
| 93 // which is also the max -- you can only decrease it. | 94 // which is also the max -- you can only decrease it. |
| 94 // | 95 // |
| 95 // oauth2_scope should be specific to a service. For example, Chromium Sync | 96 // service_name and service_scope should be specific to a service. For |
| 96 // uses https://www.googleapis.com/auth/chromesync as it's OAuth2 scope. | 97 // example, Chromium Sync uses https://www.googleapis.com/auth/chromesync as |
| 98 // its OAuth2 service scope. |
| 97 virtual void StartOAuthWrapBridge( | 99 virtual void StartOAuthWrapBridge( |
| 98 const std::string& oauth1_access_token, | 100 const std::string& oauth1_access_token, |
| 99 const std::string& oauth1_access_token_secret, | 101 const std::string& oauth1_access_token_secret, |
| 100 const std::string& wrap_token_duration, | 102 const std::string& wrap_token_duration, |
| 101 const std::string& oauth2_scope); | 103 const std::string& service_name, |
| 104 const std::string& service_scope); |
| 102 | 105 |
| 103 // Obtains user information related to an OAuth2 access token | 106 // Obtains user information related to an OAuth2 access token |
| 104 // | 107 // |
| 105 // oauth2_access_token is from OAuthWrapBridge's result. | 108 // oauth2_access_token is from OAuthWrapBridge's result. |
| 106 virtual void StartUserInfo(const std::string& oauth2_access_token); | 109 virtual void StartUserInfo(const std::string& oauth2_access_token); |
| 107 | 110 |
| 108 // NotificationObserver implementation. | 111 // NotificationObserver implementation. |
| 109 virtual void Observe(int type, | 112 virtual void Observe(int type, |
| 110 const NotificationSource& source, | 113 const NotificationSource& source, |
| 111 const NotificationDetails& details) OVERRIDE; | 114 const NotificationDetails& details) OVERRIDE; |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 const std::string& headers, | 226 const std::string& headers, |
| 224 bool send_cookies, | 227 bool send_cookies, |
| 225 URLFetcher::Delegate* delegate); | 228 URLFetcher::Delegate* delegate); |
| 226 | 229 |
| 227 bool ShouldAutoFetch(AutoFetchLimit fetch_step); | 230 bool ShouldAutoFetch(AutoFetchLimit fetch_step); |
| 228 | 231 |
| 229 // These fields are common to GaiaOAuthFetcher, same every request | 232 // These fields are common to GaiaOAuthFetcher, same every request |
| 230 GaiaOAuthConsumer* const consumer_; | 233 GaiaOAuthConsumer* const consumer_; |
| 231 net::URLRequestContextGetter* const getter_; | 234 net::URLRequestContextGetter* const getter_; |
| 232 Profile* profile_; | 235 Profile* profile_; |
| 233 std::string service_scope_; | |
| 234 Browser* popup_; | 236 Browser* popup_; |
| 235 NotificationRegistrar registrar_; | 237 NotificationRegistrar registrar_; |
| 236 | 238 |
| 237 // While a fetch is going on: | 239 // While a fetch is going on: |
| 238 scoped_ptr<URLFetcher> fetcher_; | 240 scoped_ptr<URLFetcher> fetcher_; |
| 239 std::string request_body_; | 241 std::string request_body_; |
| 240 std::string request_headers_; | 242 std::string request_headers_; |
| 243 std::string service_name_; |
| 244 std::string service_scope_; |
| 241 bool fetch_pending_; | 245 bool fetch_pending_; |
| 242 AutoFetchLimit auto_fetch_limit_; | 246 AutoFetchLimit auto_fetch_limit_; |
| 243 | 247 |
| 244 DISALLOW_COPY_AND_ASSIGN(GaiaOAuthFetcher); | 248 DISALLOW_COPY_AND_ASSIGN(GaiaOAuthFetcher); |
| 245 }; | 249 }; |
| 246 | 250 |
| 247 #endif // CHROME_BROWSER_NET_GAIA_GAIA_OAUTH_FETCHER_H_ | 251 #endif // CHROME_BROWSER_NET_GAIA_GAIA_OAUTH_FETCHER_H_ |
| OLD | NEW |