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

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

Issue 11649055: OAuth2 sign-in flow for ChromeOS (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: clang fix 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) 2013 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_MANAGER_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_OAUTH_LOGIN_MANAGER_H_
7
8 #include <string>
9
10 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "chrome/browser/chromeos/cros/cert_library.h"
13 #include "chrome/browser/chromeos/cros/cros_library.h"
14 #include "chrome/browser/chromeos/login/oauth1_login_verifier.h"
15 #include "chrome/browser/chromeos/login/oauth1_token_fetcher.h"
16 #include "chrome/browser/chromeos/login/oauth2_login_verifier.h"
17 #include "chrome/browser/chromeos/login/oauth2_policy_fetcher.h"
18 #include "chrome/browser/chromeos/login/oauth2_token_fetcher.h"
19 #include "chrome/browser/chromeos/login/policy_oauth_fetcher.h"
20 #include "content/public/browser/notification_observer.h"
21 #include "content/public/browser/notification_registrar.h"
22 #include "net/url_request/url_request_context_getter.h"
23
24 class GoogleServiceAuthError;
25 class Profile;
26 class TokenService;
27
28 namespace chromeos {
29
30 // This class is responsible for restoring authenticated web sessions out of
31 // OAuth tokens or vice versa.
32 class OAuthLoginManager {
33 public:
34 enum SessionRestoreState {
35 // Session restore is not started.
36 SESSION_RESTORE_NOT_STARTED,
37 // Session restore is in progress. We are currently issuing calls to verify
38 // stored OAuth tokens and populate cookie jar with GAIA credentials.
39 SESSION_RESTORE_IN_PROGRESS,
40 // Session restore is completed.
41 SESSION_RESTORE_DONE,
42 };
43
44 class Delegate {
45 public:
46 virtual ~Delegate() {}
47
48 // Raised when cookie jar authentication is successfully completed.
49 virtual void OnCompletedAuthentication(Profile* user_profile) = 0;
50
51 // Raised when stored OAuth(1|2) tokens are found and authentication
52 // profile is no longer needed.
53 virtual void OnFoundStoredTokens() = 0;
54
55 // Raised when policy tokens are retrieved.
56 virtual void OnRestoredPolicyTokens() {}
57 };
58
59 // Factory method.
60 static OAuthLoginManager* Create(OAuthLoginManager::Delegate* delegate);
61
62 explicit OAuthLoginManager(OAuthLoginManager::Delegate* delegate);
63 virtual ~OAuthLoginManager();
64
65 // Starts the process of retrieving policy tokens.
66 virtual void RestorePolicyTokens(
67 net::URLRequestContextGetter* auth_request_context) = 0;
68
69 // Restores and verifies OAuth tokens either from TokenService or previously
70 // authenticated cookie jar.
71 virtual void RestoreSession(
72 Profile* user_profile,
73 net::URLRequestContextGetter* auth_request_context,
74 bool restore_from_auth_cookies) = 0;
75
76 // Continues session restore after transient network errors.
77 virtual void ContinueSessionRestore() = 0;
78
79 // Stops all background authentication requests.
80 virtual void Stop() = 0;
81
82 // Returns session restore state.
83 SessionRestoreState state() { return state_; }
84
85 protected:
86 // Signals delegate that authentication is completed, kicks off token fetching
87 // process in TokenService.
88 void CompleteAuthentication();
89
90 OAuthLoginManager::Delegate* delegate_;
91 Profile* user_profile_;
92 scoped_refptr<net::URLRequestContextGetter> auth_request_context_;
93 bool restore_from_auth_cookies_;
94 SessionRestoreState state_;
95
96 DISALLOW_COPY_AND_ASSIGN(OAuthLoginManager);
97 };
98
99 } // namespace chromeos
100
101 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_OAUTH_LOGIN_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698