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

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

Issue 11991002: Merge 176800 (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1364/src/
Patch Set: 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_OAUTH_LOGIN_VERIFIER_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_OAUTH_LOGIN_VERIFIER_H_
7
8 #include <string>
9
10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h"
12 #include "base/memory/weak_ptr.h"
13 #include "chrome/browser/net/gaia/gaia_oauth_consumer.h"
14 #include "chrome/browser/net/gaia/gaia_oauth_fetcher.h"
15 #include "google_apis/gaia/gaia_auth_consumer.h"
16 #include "google_apis/gaia/gaia_auth_fetcher.h"
17
18 class Profile;
19
20 namespace chromeos {
21
22 // Verifies OAuth1 access token by performing OAuthLogin. Fetches user cookies
23 // on successful OAuth authentication.
24 class OAuthLoginVerifier : public base::SupportsWeakPtr<OAuthLoginVerifier>,
25 public GaiaOAuthConsumer,
26 public GaiaAuthConsumer {
27 public:
28 class Delegate {
29 public:
30 virtual ~Delegate() {}
31 virtual void OnOAuthVerificationSucceeded(const std::string& user_name,
32 const std::string& sid,
33 const std::string& lsid,
34 const std::string& auth) {}
35 virtual void OnOAuthVerificationFailed(const std::string& user_name) {}
36 virtual void OnUserCookiesFetchSucceeded(const std::string& user_name) {}
37 virtual void OnUserCookiesFetchFailed(const std::string& user_name) {}
38 };
39
40 OAuthLoginVerifier(OAuthLoginVerifier::Delegate* delegate,
41 Profile* user_profile,
42 const std::string& oauth1_token,
43 const std::string& oauth1_secret,
44 const std::string& username);
45 virtual ~OAuthLoginVerifier();
46
47 bool is_done() {
48 return step_ == VERIFICATION_STEP_FAILED ||
49 step_ == VERIFICATION_STEP_COOKIES_FETCHED;
50 }
51
52 void StartOAuthVerification();
53 void ContinueVerification();
54
55 private:
56 typedef enum {
57 VERIFICATION_STEP_UNVERIFIED,
58 VERIFICATION_STEP_OAUTH_VERIFIED,
59 VERIFICATION_STEP_COOKIES_FETCHED,
60 VERIFICATION_STEP_FAILED,
61 } VerificationStep;
62
63 // Kicks off GAIA session cookie retrieval process.
64 void StartCookiesRetrieval();
65
66 // Decides how to proceed on GAIA response and other errors. It can schedule
67 // to rerun the verification process if detects transient network or service
68 // errors.
69 bool RetryOnError(const GoogleServiceAuthError& error);
70
71 // GaiaOAuthConsumer implementation:
72 virtual void OnOAuthLoginSuccess(const std::string& sid,
73 const std::string& lsid,
74 const std::string& auth) OVERRIDE;
75 virtual void OnOAuthLoginFailure(
76 const GoogleServiceAuthError& error) OVERRIDE;
77 void OnCookieFetchFailed(const GoogleServiceAuthError& error);
78
79 // GaiaAuthConsumer overrides.
80 virtual void OnIssueAuthTokenSuccess(const std::string& service,
81 const std::string& auth_token) OVERRIDE;
82 virtual void OnIssueAuthTokenFailure(
83 const std::string& service,
84 const GoogleServiceAuthError& error) OVERRIDE;
85 virtual void OnMergeSessionSuccess(const std::string& data) OVERRIDE;
86 virtual void OnMergeSessionFailure(
87 const GoogleServiceAuthError& error) OVERRIDE;
88
89 OAuthLoginVerifier::Delegate* delegate_;
90 GaiaOAuthFetcher oauth_fetcher_;
91 GaiaAuthFetcher gaia_fetcher_;
92 std::string oauth1_token_;
93 std::string oauth1_secret_;
94 std::string sid_;
95 std::string lsid_;
96 std::string username_;
97 Profile* user_profile_;
98 int verification_count_;
99 VerificationStep step_;
100
101 DISALLOW_COPY_AND_ASSIGN(OAuthLoginVerifier);
102 };
103
104 } // namespace chromeos
105
106 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_OAUTH_LOGIN_VERIFIER_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/oauth_login_manager.cc ('k') | chrome/browser/chromeos/login/oauth_login_verifier.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698