Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(447)

Side by Side Diff: chrome/browser/net/gaia/gaia_oauth_fetcher.h

Issue 10392192: Remove content::URLFetcherDelegate (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "chrome/browser/net/chrome_cookie_notification_details.h" 13 #include "chrome/browser/net/chrome_cookie_notification_details.h"
14 #include "chrome/browser/net/gaia/gaia_oauth_consumer.h" 14 #include "chrome/browser/net/gaia/gaia_oauth_consumer.h"
15 #include "content/public/browser/notification_observer.h" 15 #include "content/public/browser/notification_observer.h"
16 #include "content/public/browser/notification_registrar.h" 16 #include "content/public/browser/notification_registrar.h"
17 #include "content/public/common/url_fetcher_delegate.h"
18 #include "googleurl/src/gurl.h" 17 #include "googleurl/src/gurl.h"
18 #include "net/url_request/url_fetcher_delegate.h"
19 19
20 struct ChromeCookieDetails; 20 struct ChromeCookieDetails;
21 21
22 class Browser; 22 class Browser;
23 class Profile; 23 class Profile;
24 24
25 namespace net { 25 namespace net {
26 class URLRequestContextGetter; 26 class URLRequestContextGetter;
wtc 2012/05/22 17:26:38 Should we forward declare URLFetcher here?
akalin 2012/05/22 21:07:05 Done.
27 class URLRequestStatus; 27 class URLRequestStatus;
28 typedef std::vector<std::string> ResponseCookies; 28 typedef std::vector<std::string> ResponseCookies;
29 } 29 }
30 30
31 // Authenticate a user using Gaia's OAuth1 and OAuth2 support. 31 // Authenticate a user using Gaia's OAuth1 and OAuth2 support.
32 // 32 //
33 // Users of this class typically desire an OAuth2 Access token scoped for a 33 // Users of this class typically desire an OAuth2 Access token scoped for a
34 // specific service. This will typically start with either an interactive 34 // specific service. This will typically start with either an interactive
35 // login, using StartGetOAuthToken, or with a long-lived OAuth1 all-scope 35 // login, using StartGetOAuthToken, or with a long-lived OAuth1 all-scope
36 // token obtained through a previous login or other means, using 36 // token obtained through a previous login or other means, using
37 // StartOAuthGetAccessToken. In fact, one can start with any of these 37 // StartOAuthGetAccessToken. In fact, one can start with any of these
38 // routines: 38 // routines:
39 // StartGetOAuthToken() 39 // StartGetOAuthToken()
40 // StartOAuthGetAccessToken() 40 // StartOAuthGetAccessToken()
41 // StartOAuthWrapBridge() 41 // StartOAuthWrapBridge()
42 // StartUserInfo() 42 // StartUserInfo()
43 // with the expectation that each of these calls the next Start* routine in 43 // with the expectation that each of these calls the next Start* routine in
44 // the sequence, except for StartUserInfo as it's the last one. 44 // the sequence, except for StartUserInfo as it's the last one.
45 // 45 //
46 // This class can handle one request at a time, and all calls through an 46 // This class can handle one request at a time, and all calls through an
47 // instance should be serialized. 47 // instance should be serialized.
48 class GaiaOAuthFetcher : public content::URLFetcherDelegate, 48 class GaiaOAuthFetcher : public net::URLFetcherDelegate,
49 public content::NotificationObserver { 49 public content::NotificationObserver {
50 public: 50 public:
51 // Defines steps of OAuth process performed by this class. 51 // Defines steps of OAuth process performed by this class.
52 typedef enum { 52 typedef enum {
53 OAUTH1_LOGIN, 53 OAUTH1_LOGIN,
54 OAUTH1_REQUEST_TOKEN, 54 OAUTH1_REQUEST_TOKEN,
55 OAUTH1_ALL_ACCESS_TOKEN, 55 OAUTH1_ALL_ACCESS_TOKEN,
56 OAUTH2_SERVICE_ACCESS_TOKEN, 56 OAUTH2_SERVICE_ACCESS_TOKEN,
57 USER_INFO, 57 USER_INFO,
58 OAUTH2_REVOKE_TOKEN, 58 OAUTH2_REVOKE_TOKEN,
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 const content::NotificationDetails& details) OVERRIDE; 129 const content::NotificationDetails& details) OVERRIDE;
130 130
131 // Called when a cookie, e. g. oauth_token, changes 131 // Called when a cookie, e. g. oauth_token, changes
132 virtual void OnCookieChanged(Profile* profile, 132 virtual void OnCookieChanged(Profile* profile,
133 ChromeCookieDetails* cookie_details); 133 ChromeCookieDetails* cookie_details);
134 134
135 // Called when a cookie, e. g. oauth_token, changes 135 // Called when a cookie, e. g. oauth_token, changes
136 virtual void OnBrowserClosing(Browser* profile, 136 virtual void OnBrowserClosing(Browser* profile,
137 bool detail); 137 bool detail);
138 138
139 // Implementation of content::URLFetcherDelegate 139 // Implementation of net::URLFetcherDelegate
140 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; 140 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE;
141 141
142 // StartGetOAuthToken (or other Start* routine) been called, but results 142 // StartGetOAuthToken (or other Start* routine) been called, but results
143 // are not back yet. 143 // are not back yet.
144 virtual bool HasPendingFetch() const; 144 virtual bool HasPendingFetch() const;
145 145
146 // Stop any URL fetches in progress. 146 // Stop any URL fetches in progress.
147 virtual void CancelRequest(); 147 virtual void CancelRequest();
148 148
149 protected: 149 protected:
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 const std::string& oauth1_access_token_secret); 230 const std::string& oauth1_access_token_secret);
231 231
232 // Given parameters, create a OAuthWrapBridge request body. 232 // Given parameters, create a OAuthWrapBridge request body.
233 static std::string MakeOAuthWrapBridgeBody( 233 static std::string MakeOAuthWrapBridgeBody(
234 const std::string& oauth1_access_token, 234 const std::string& oauth1_access_token,
235 const std::string& oauth1_access_token_secret, 235 const std::string& oauth1_access_token_secret,
236 const std::string& wrap_token_duration, 236 const std::string& wrap_token_duration,
237 const std::string& oauth2_service_scope); 237 const std::string& oauth2_service_scope);
238 238
239 // Create a fetcher useable for making any Gaia OAuth request. 239 // Create a fetcher useable for making any Gaia OAuth request.
240 static content::URLFetcher* CreateGaiaFetcher( 240 static net::URLFetcher* CreateGaiaFetcher(
241 net::URLRequestContextGetter* getter, 241 net::URLRequestContextGetter* getter,
242 const GURL& gaia_gurl_, 242 const GURL& gaia_gurl_,
243 const std::string& body, 243 const std::string& body,
244 const std::string& headers, 244 const std::string& headers,
245 bool send_cookies, 245 bool send_cookies,
246 content::URLFetcherDelegate* delegate); 246 net::URLFetcherDelegate* delegate);
247 247
248 bool ShouldAutoFetch(RequestType fetch_step); 248 bool ShouldAutoFetch(RequestType fetch_step);
249 249
250 // These fields are common to GaiaOAuthFetcher, same every request 250 // These fields are common to GaiaOAuthFetcher, same every request
251 GaiaOAuthConsumer* const consumer_; 251 GaiaOAuthConsumer* const consumer_;
252 net::URLRequestContextGetter* const getter_; 252 net::URLRequestContextGetter* const getter_;
253 Profile* profile_; 253 Profile* profile_;
254 Browser* popup_; 254 Browser* popup_;
255 content::NotificationRegistrar registrar_; 255 content::NotificationRegistrar registrar_;
256 256
257 // While a fetch is going on: 257 // While a fetch is going on:
258 scoped_ptr<content::URLFetcher> fetcher_; 258 scoped_ptr<net::URLFetcher> fetcher_;
259 std::string request_body_; 259 std::string request_body_;
260 std::string request_headers_; 260 std::string request_headers_;
261 std::string service_scope_; 261 std::string service_scope_;
262 bool fetch_pending_; 262 bool fetch_pending_;
263 RequestType auto_fetch_limit_; 263 RequestType auto_fetch_limit_;
264 264
265 DISALLOW_COPY_AND_ASSIGN(GaiaOAuthFetcher); 265 DISALLOW_COPY_AND_ASSIGN(GaiaOAuthFetcher);
266 }; 266 };
267 267
268 #endif // CHROME_BROWSER_NET_GAIA_GAIA_OAUTH_FETCHER_H_ 268 #endif // CHROME_BROWSER_NET_GAIA_GAIA_OAUTH_FETCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698