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

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

Issue 8373021: Convert URLFetcher::Delegates to use an interface in content/public/common. Also remove the old U... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: sync and remove unncessary forward declares Created 9 years, 2 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) 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 #include <vector>
10 11
11 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
12 #include "chrome/browser/net/chrome_cookie_notification_details.h" 13 #include "chrome/browser/net/chrome_cookie_notification_details.h"
13 #include "chrome/browser/net/gaia/gaia_oauth_consumer.h" 14 #include "chrome/browser/net/gaia/gaia_oauth_consumer.h"
14 #include "content/common/net/url_fetcher.h" 15 #include "content/public/common/url_fetcher_delegate.h"
15 #include "content/public/browser/notification_observer.h" 16 #include "content/public/browser/notification_observer.h"
16 #include "content/public/browser/notification_registrar.h" 17 #include "content/public/browser/notification_registrar.h"
17 #include "googleurl/src/gurl.h" 18 #include "googleurl/src/gurl.h"
18 19
19 struct ChromeCookieDetails; 20 struct ChromeCookieDetails;
20 21
21 class Browser; 22 class Browser;
22 class Profile; 23 class Profile;
23 24
25 namespace net {
26 class URLRequestContextGetter;
27 class URLRequestStatus;
28 typedef std::vector<std::string> ResponseCookies;
29 }
30
24 // Authenticate a user using Gaia's OAuth1 and OAuth2 support. 31 // Authenticate a user using Gaia's OAuth1 and OAuth2 support.
25 // 32 //
26 // 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
27 // specific service. This will typically start with either an interactive 34 // specific service. This will typically start with either an interactive
28 // login, using StartGetOAuthToken, or with a long-lived OAuth1 all-scope 35 // login, using StartGetOAuthToken, or with a long-lived OAuth1 all-scope
29 // token obtained through a previous login or other means, using 36 // token obtained through a previous login or other means, using
30 // StartOAuthGetAccessToken. In fact, one can start with any of these 37 // StartOAuthGetAccessToken. In fact, one can start with any of these
31 // routines: 38 // routines:
32 // StartGetOAuthToken() 39 // StartGetOAuthToken()
33 // StartOAuthGetAccessToken() 40 // StartOAuthGetAccessToken()
34 // StartOAuthWrapBridge() 41 // StartOAuthWrapBridge()
35 // StartUserInfo() 42 // StartUserInfo()
36 // 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
37 // the sequence, except for StartUserInfo as it's the last one. 44 // the sequence, except for StartUserInfo as it's the last one.
38 // 45 //
39 // 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
40 // instance should be serialized. 47 // instance should be serialized.
41 class GaiaOAuthFetcher : public URLFetcher::Delegate, 48 class GaiaOAuthFetcher : public content::URLFetcherDelegate,
42 public content::NotificationObserver { 49 public content::NotificationObserver {
43 public: 50 public:
44 // Defines steps of OAuth process performed by this class. 51 // Defines steps of OAuth process performed by this class.
45 typedef enum { 52 typedef enum {
46 OAUTH1_REQUEST_TOKEN, 53 OAUTH1_REQUEST_TOKEN,
47 OAUTH1_ALL_ACCESS_TOKEN, 54 OAUTH1_ALL_ACCESS_TOKEN,
48 OAUTH2_SERVICE_ACCESS_TOKEN, 55 OAUTH2_SERVICE_ACCESS_TOKEN,
49 USER_INFO, 56 USER_INFO,
50 ALL_OAUTH_STEPS, 57 ALL_OAUTH_STEPS,
51 } AutoFetchLimit; 58 } AutoFetchLimit;
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 const content::NotificationDetails& details) OVERRIDE; 128 const content::NotificationDetails& details) OVERRIDE;
122 129
123 // Called when a cookie, e. g. oauth_token, changes 130 // Called when a cookie, e. g. oauth_token, changes
124 virtual void OnCookieChanged(Profile* profile, 131 virtual void OnCookieChanged(Profile* profile,
125 ChromeCookieDetails* cookie_details); 132 ChromeCookieDetails* cookie_details);
126 133
127 // Called when a cookie, e. g. oauth_token, changes 134 // Called when a cookie, e. g. oauth_token, changes
128 virtual void OnBrowserClosing(Browser* profile, 135 virtual void OnBrowserClosing(Browser* profile,
129 bool detail); 136 bool detail);
130 137
131 // Implementation of URLFetcher::Delegate 138 // Implementation of content::URLFetcherDelegate
132 virtual void OnURLFetchComplete(const URLFetcher* source, 139 virtual void OnURLFetchComplete(const URLFetcher* source) OVERRIDE;
133 const GURL& url,
134 const net::URLRequestStatus& status,
135 int response_code,
136 const net::ResponseCookies& cookies,
137 const std::string& data) OVERRIDE;
138 140
139 // StartGetOAuthToken (or other Start* routine) been called, but results 141 // StartGetOAuthToken (or other Start* routine) been called, but results
140 // are not back yet. 142 // are not back yet.
141 virtual bool HasPendingFetch(); 143 virtual bool HasPendingFetch();
142 144
143 // Stop any URL fetches in progress. 145 // Stop any URL fetches in progress.
144 virtual void CancelRequest(); 146 virtual void CancelRequest();
145 147
146 private: 148 private:
147 // Process the results of a GetOAuthToken fetch via UI. 149 // Process the results of a GetOAuthToken fetch via UI.
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 const std::string& oauth1_access_token_secret, 229 const std::string& oauth1_access_token_secret,
228 const std::string& wrap_token_duration, 230 const std::string& wrap_token_duration,
229 const std::string& oauth2_service_scope); 231 const std::string& oauth2_service_scope);
230 232
231 // Create a fetcher useable for making any Gaia OAuth request. 233 // Create a fetcher useable for making any Gaia OAuth request.
232 static URLFetcher* CreateGaiaFetcher(net::URLRequestContextGetter* getter, 234 static URLFetcher* CreateGaiaFetcher(net::URLRequestContextGetter* getter,
233 const GURL& gaia_gurl_, 235 const GURL& gaia_gurl_,
234 const std::string& body, 236 const std::string& body,
235 const std::string& headers, 237 const std::string& headers,
236 bool send_cookies, 238 bool send_cookies,
237 URLFetcher::Delegate* delegate); 239 content::URLFetcherDelegate* delegate);
238 240
239 bool ShouldAutoFetch(AutoFetchLimit fetch_step); 241 bool ShouldAutoFetch(AutoFetchLimit fetch_step);
240 242
241 // These fields are common to GaiaOAuthFetcher, same every request 243 // These fields are common to GaiaOAuthFetcher, same every request
242 GaiaOAuthConsumer* const consumer_; 244 GaiaOAuthConsumer* const consumer_;
243 net::URLRequestContextGetter* const getter_; 245 net::URLRequestContextGetter* const getter_;
244 Profile* profile_; 246 Profile* profile_;
245 Browser* popup_; 247 Browser* popup_;
246 content::NotificationRegistrar registrar_; 248 content::NotificationRegistrar registrar_;
247 249
248 // While a fetch is going on: 250 // While a fetch is going on:
249 scoped_ptr<URLFetcher> fetcher_; 251 scoped_ptr<URLFetcher> fetcher_;
250 std::string request_body_; 252 std::string request_body_;
251 std::string request_headers_; 253 std::string request_headers_;
252 std::string service_scope_; 254 std::string service_scope_;
253 bool fetch_pending_; 255 bool fetch_pending_;
254 AutoFetchLimit auto_fetch_limit_; 256 AutoFetchLimit auto_fetch_limit_;
255 257
256 DISALLOW_COPY_AND_ASSIGN(GaiaOAuthFetcher); 258 DISALLOW_COPY_AND_ASSIGN(GaiaOAuthFetcher);
257 }; 259 };
258 260
259 #endif // CHROME_BROWSER_NET_GAIA_GAIA_OAUTH_FETCHER_H_ 261 #endif // CHROME_BROWSER_NET_GAIA_GAIA_OAUTH_FETCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698