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

Side by Side Diff: chrome/browser/chromeos/login/oauth1_token_fetcher.h

Issue 11649055: OAuth2 sign-in flow for ChromeOS (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: wired policy with OAuth2 path Created 7 years, 11 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_CHROMEOS_LOGIN_OAUTH1_TOKEN_FETCHER_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_OAUTH1_TOKEN_FETCHER_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_OAUTH1_TOKEN_FETCHER_H_ 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_OAUTH1_TOKEN_FETCHER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "chrome/browser/net/gaia/gaia_oauth_consumer.h" 13 #include "chrome/browser/net/gaia/gaia_oauth_consumer.h"
14 #include "chrome/browser/net/gaia/gaia_oauth_fetcher.h" 14 #include "chrome/browser/net/gaia/gaia_oauth_fetcher.h"
15 15
16 class Profile; 16 class Profile;
Joao da Silva 2013/01/11 16:45:07 Not needed
zel 2013/01/11 19:51:16 Done.
17 17
18 namespace chromeos { 18 namespace chromeos {
19 19
20 // Given the authenticated credentials from the cookie jar, try to exchange 20 // Given the authenticated credentials from the cookie jar, try to exchange
21 // fetch OAuth1 token and secret. Automatically retries until max retry count is 21 // fetch OAuth1 token and secret. Automatically retries until max retry count is
22 // reached. 22 // reached.
23 class OAuth1TokenFetcher : public base::SupportsWeakPtr<OAuth1TokenFetcher>, 23 class OAuth1TokenFetcher : public base::SupportsWeakPtr<OAuth1TokenFetcher>,
24 public GaiaOAuthConsumer { 24 public GaiaOAuthConsumer {
25 public: 25 public:
26 class Delegate { 26 class Delegate {
27 public: 27 public:
28 virtual ~Delegate() {} 28 virtual ~Delegate() {}
29 virtual void OnOAuth1AccessTokenAvailable(const std::string& token, 29 virtual void OnOAuth1AccessTokenAvailable(const std::string& token,
30 const std::string& secret) = 0; 30 const std::string& secret) = 0;
31 virtual void OnOAuth1AccessTokenFetchFailed() = 0; 31 virtual void OnOAuth1AccessTokenFetchFailed() = 0;
32 }; 32 };
33 33
34 OAuth1TokenFetcher(OAuth1TokenFetcher::Delegate* delegate, 34 OAuth1TokenFetcher(OAuth1TokenFetcher::Delegate* delegate,
35 Profile* auth_profile); 35 net::URLRequestContextGetter* auth_context_getter);
Joao da Silva 2013/01/11 16:45:07 Needs forward decl
zel 2013/01/11 19:51:16 Done.
36 virtual ~OAuth1TokenFetcher(); 36 virtual ~OAuth1TokenFetcher();
37 37
38 void Start(); 38 void Start();
39 39
40 private: 40 private:
41 // Decides how to proceed on GAIA response and other errors. If the error 41 // Decides how to proceed on GAIA response and other errors. If the error
42 // looks temporary, retries token fetching until max retry count is reached. 42 // looks temporary, retries token fetching until max retry count is reached.
43 // If retry count runs out, or error condition is unrecoverable, returns 43 // If retry count runs out, or error condition is unrecoverable, returns
44 // false. 44 // false.
45 bool RetryOnError(const GoogleServiceAuthError& error); 45 bool RetryOnError(const GoogleServiceAuthError& error);
46 46
47 // GaiaOAuthConsumer implementation: 47 // GaiaOAuthConsumer implementation:
48 virtual void OnGetOAuthTokenSuccess(const std::string& oauth_token) OVERRIDE; 48 virtual void OnGetOAuthTokenSuccess(const std::string& oauth_token) OVERRIDE;
49 virtual void OnGetOAuthTokenFailure( 49 virtual void OnGetOAuthTokenFailure(
50 const GoogleServiceAuthError& error) OVERRIDE; 50 const GoogleServiceAuthError& error) OVERRIDE;
51 virtual void OnOAuthGetAccessTokenSuccess(const std::string& token, 51 virtual void OnOAuthGetAccessTokenSuccess(const std::string& token,
52 const std::string& secret) OVERRIDE; 52 const std::string& secret) OVERRIDE;
53 virtual void OnOAuthGetAccessTokenFailure( 53 virtual void OnOAuthGetAccessTokenFailure(
54 const GoogleServiceAuthError& error) OVERRIDE; 54 const GoogleServiceAuthError& error) OVERRIDE;
55 55
56 OAuth1TokenFetcher::Delegate* delegate_; 56 OAuth1TokenFetcher::Delegate* delegate_;
57 Profile* auth_profile_;
58 GaiaOAuthFetcher oauth_fetcher_; 57 GaiaOAuthFetcher oauth_fetcher_;
59 58
60 // The retry counter. Increment this only when failure happened. 59 // The retry counter. Increment this only when failure happened.
61 int retry_count_; 60 int retry_count_;
62 61
63 DISALLOW_COPY_AND_ASSIGN(OAuth1TokenFetcher); 62 DISALLOW_COPY_AND_ASSIGN(OAuth1TokenFetcher);
64 }; 63 };
65 64
66 } // namespace chromeos 65 } // namespace chromeos
67 66
68 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_OAUTH1_TOKEN_FETCHER_H_ 67 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_OAUTH1_TOKEN_FETCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698