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

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

Issue 12704002: Support for auth code based authentication flow for both app and web UI driven flow. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 9 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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_OAUTH_LOGIN_MANAGER_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_OAUTH_LOGIN_MANAGER_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_OAUTH_LOGIN_MANAGER_H_ 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_OAUTH_LOGIN_MANAGER_H_
7 7
8 #include <string>
9
8 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
9 #include "net/url_request/url_request_context_getter.h" 11 #include "net/url_request/url_request_context_getter.h"
10 12
11 class Profile; 13 class Profile;
12 14
13 namespace chromeos { 15 namespace chromeos {
14 16
15 // This class is responsible for restoring authenticated web sessions out of 17 // This class is responsible for restoring authenticated web sessions out of
16 // OAuth tokens or vice versa. 18 // OAuth tokens or vice versa.
17 class OAuthLoginManager { 19 class OAuthLoginManager {
18 public: 20 public:
19 enum SessionRestoreState { 21 enum SessionRestoreState {
20 // Session restore is not started. 22 // Session restore is not started.
21 SESSION_RESTORE_NOT_STARTED, 23 SESSION_RESTORE_NOT_STARTED,
22 // Session restore is in progress. We are currently issuing calls to verify 24 // Session restore is in progress. We are currently issuing calls to verify
23 // stored OAuth tokens and populate cookie jar with GAIA credentials. 25 // stored OAuth tokens and populate cookie jar with GAIA credentials.
24 SESSION_RESTORE_IN_PROGRESS, 26 SESSION_RESTORE_IN_PROGRESS,
25 // Session restore is completed. 27 // Session restore is completed.
26 SESSION_RESTORE_DONE, 28 SESSION_RESTORE_DONE,
27 }; 29 };
28 30
31 // Session restore strategy.
32 enum SessionRestoreStrategy {
33 // Generate OAuth2 refresh token from authentication profile's cookie jar.
34 // Restore session from generated OAuth2 refresh token.
35 RESTORE_FROM_COOKIE_JAR,
36 // Restore session from saved OAuth2 refresh token from TokenServices.
37 RESTORE_FROM_SAVED_OAUTH2_REFRESH_TOKEN,
38 // Restore session from OAuth2 refresh token passed via command line.
39 RESTORE_FROM_PASSED_OAUTH2_REFRESH_TOKEN,
40 // Restore session from authentication code passed via command line.
41 RESTORE_FROM_AUTH_CODE,
42 };
43
29 class Delegate { 44 class Delegate {
30 public: 45 public:
31 virtual ~Delegate() {} 46 virtual ~Delegate() {}
32 47
33 // Raised when merge session is completed. 48 // Raised when merge session is completed.
34 virtual void OnCompletedMergeSession() = 0; 49 virtual void OnCompletedMergeSession() = 0;
35 50
36 // Raised when cookie jar authentication is successfully completed. 51 // Raised when cookie jar authentication is successfully completed.
37 virtual void OnCompletedAuthentication(Profile* user_profile) = 0; 52 virtual void OnCompletedAuthentication(Profile* user_profile) = 0;
38 53
39 // Raised when stored OAuth(1|2) tokens are found and authentication 54 // Raised when stored OAuth(1|2) tokens are found and authentication
40 // profile is no longer needed. 55 // profile is no longer needed.
41 virtual void OnFoundStoredTokens() = 0; 56 virtual void OnFoundStoredTokens() = 0;
42 57
43 // Raised when policy tokens are retrieved. 58 // Raised when policy tokens are retrieved.
44 virtual void OnRestoredPolicyTokens() {} 59 virtual void OnRestoredPolicyTokens() {}
45 }; 60 };
46 61
47 // Factory method. 62 // Factory method.
48 static OAuthLoginManager* Create(OAuthLoginManager::Delegate* delegate); 63 static OAuthLoginManager* Create(OAuthLoginManager::Delegate* delegate);
49 64
50 explicit OAuthLoginManager(OAuthLoginManager::Delegate* delegate); 65 explicit OAuthLoginManager(OAuthLoginManager::Delegate* delegate);
51 virtual ~OAuthLoginManager(); 66 virtual ~OAuthLoginManager();
52 67
53 // Starts the process of retrieving policy tokens. 68 // Starts the process of retrieving policy tokens.
54 virtual void RestorePolicyTokens( 69 virtual void RestorePolicyTokens(
55 net::URLRequestContextGetter* auth_request_context) = 0; 70 net::URLRequestContextGetter* auth_request_context) = 0;
56 71
57 // Restores and verifies OAuth tokens either from TokenService or previously 72 // Restores and verifies OAuth tokens either following specified
58 // authenticated cookie jar. 73 // |restore_strategy|. For |restore_strategy| with values
74 // RESTORE_FROM_COMMAND_LINE_OAUTH2_REFRESH_TOKEN or
xiyuan 2013/03/20 20:08:29 nit: RESTORE_FROM_COMMAND_LINE_OAUTH2_REFRESH_TOKE
zel 2013/03/20 21:03:38 Done.
75 // RESTORE_FROM_PASSED_OAUTH2_REFRESH_TOKEN, respectively
76 // parameters |oauth2_refresh_token| or |auth_code| need to have non-empty
77 // value.
59 virtual void RestoreSession( 78 virtual void RestoreSession(
60 Profile* user_profile, 79 Profile* user_profile,
61 net::URLRequestContextGetter* auth_request_context, 80 net::URLRequestContextGetter* auth_request_context,
62 bool restore_from_auth_cookies) = 0; 81 SessionRestoreStrategy restore_strategy,
82 const std::string& oauth2_refresh_token,
83 const std::string& auth_code) = 0;
63 84
64 // Continues session restore after transient network errors. 85 // Continues session restore after transient network errors.
65 virtual void ContinueSessionRestore() = 0; 86 virtual void ContinueSessionRestore() = 0;
66 87
67 // Stops all background authentication requests. 88 // Stops all background authentication requests.
68 virtual void Stop() = 0; 89 virtual void Stop() = 0;
69 90
70 // Returns session restore state. 91 // Returns session restore state.
71 SessionRestoreState state() { return state_; } 92 SessionRestoreState state() { return state_; }
72 93
73 protected: 94 protected:
74 // Signals delegate that authentication is completed, kicks off token fetching 95 // Signals delegate that authentication is completed, kicks off token fetching
75 // process in TokenService. 96 // process in TokenService.
76 void CompleteAuthentication(); 97 void CompleteAuthentication();
77 98
78 OAuthLoginManager::Delegate* delegate_; 99 OAuthLoginManager::Delegate* delegate_;
79 Profile* user_profile_; 100 Profile* user_profile_;
80 scoped_refptr<net::URLRequestContextGetter> auth_request_context_; 101 scoped_refptr<net::URLRequestContextGetter> auth_request_context_;
81 bool restore_from_auth_cookies_; 102 SessionRestoreStrategy restore_strategy_;
82 SessionRestoreState state_; 103 SessionRestoreState state_;
83 104
84 DISALLOW_COPY_AND_ASSIGN(OAuthLoginManager); 105 DISALLOW_COPY_AND_ASSIGN(OAuthLoginManager);
85 }; 106 };
86 107
87 } // namespace chromeos 108 } // namespace chromeos
88 109
89 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_OAUTH_LOGIN_MANAGER_H_ 110 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_OAUTH_LOGIN_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698