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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/login/oauth_login_manager.h
diff --git a/chrome/browser/chromeos/login/oauth_login_manager.h b/chrome/browser/chromeos/login/oauth_login_manager.h
new file mode 100644
index 0000000000000000000000000000000000000000..fc93cc63535ef42cd405473eda6e3ecf996fd906
--- /dev/null
+++ b/chrome/browser/chromeos/login/oauth_login_manager.h
@@ -0,0 +1,101 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_CHROMEOS_LOGIN_OAUTH_LOGIN_MANAGER_H_
+#define CHROME_BROWSER_CHROMEOS_LOGIN_OAUTH_LOGIN_MANAGER_H_
+
+#include <string>
+
+#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_ptr.h"
+#include "chrome/browser/chromeos/cros/cert_library.h"
+#include "chrome/browser/chromeos/cros/cros_library.h"
+#include "chrome/browser/chromeos/login/oauth1_login_verifier.h"
+#include "chrome/browser/chromeos/login/oauth1_token_fetcher.h"
+#include "chrome/browser/chromeos/login/oauth2_login_verifier.h"
+#include "chrome/browser/chromeos/login/oauth2_policy_fetcher.h"
+#include "chrome/browser/chromeos/login/oauth2_token_fetcher.h"
+#include "chrome/browser/chromeos/login/policy_oauth_fetcher.h"
+#include "content/public/browser/notification_observer.h"
+#include "content/public/browser/notification_registrar.h"
+#include "net/url_request/url_request_context_getter.h"
+
+class GoogleServiceAuthError;
+class Profile;
+class TokenService;
+
+namespace chromeos {
+
+// This class is responsible for restoring authenticated web sessions out of
+// OAuth tokens or vice versa.
+class OAuthLoginManager {
+ public:
+ enum SessionRestoreState {
+ // Session restore is not started.
+ SESSION_RESTORE_NOT_STARTED,
+ // Session restore is in progress. We are currently issuing calls to verify
+ // stored OAuth tokens and populate cookie jar with GAIA credentials.
+ SESSION_RESTORE_IN_PROGRESS,
+ // Session restore is completed.
+ SESSION_RESTORE_DONE,
+ };
+
+ class Delegate {
+ public:
+ virtual ~Delegate() {}
+
+ // Raised when cookie jar authentication is successfully completed.
+ virtual void OnCompletedAuthentication(Profile* user_profile) = 0;
+
+ // Raised when stored OAuth(1|2) tokens are found and authentication
+ // profile is no longer needed.
+ virtual void OnFoundStoredTokens() = 0;
+
+ // Raised when policy tokens are retrieved.
+ virtual void OnRestoredPolicyTokens() {}
+ };
+
+ // Factory method.
+ static OAuthLoginManager* Create(OAuthLoginManager::Delegate* delegate);
+
+ explicit OAuthLoginManager(OAuthLoginManager::Delegate* delegate);
+ virtual ~OAuthLoginManager();
+
+ // Starts the process of retrieving policy tokens.
+ virtual void RestorePolicyTokens(
+ net::URLRequestContextGetter* auth_request_context) = 0;
+
+ // Restores and verifies OAuth tokens either from TokenService or previously
+ // authenticated cookie jar.
+ virtual void RestoreSession(
+ Profile* user_profile,
+ net::URLRequestContextGetter* auth_request_context,
+ bool restore_from_auth_cookies) = 0;
+
+ // Continues session restore after transient network errors.
+ virtual void ContinueSessionRestore() = 0;
+
+ // Stops all background authentication requests.
+ virtual void Stop() = 0;
+
+ // Returns session restore state.
+ SessionRestoreState state() { return state_; }
+
+ protected:
+ // Signals delegate that authentication is completed, kicks off token fetching
+ // process in TokenService.
+ void CompleteAuthentication();
+
+ OAuthLoginManager::Delegate* delegate_;
+ Profile* user_profile_;
+ scoped_refptr<net::URLRequestContextGetter> auth_request_context_;
+ bool restore_from_auth_cookies_;
+ SessionRestoreState state_;
+
+ DISALLOW_COPY_AND_ASSIGN(OAuthLoginManager);
+};
+
+} // namespace chromeos
+
+#endif // CHROME_BROWSER_CHROMEOS_LOGIN_OAUTH_LOGIN_MANAGER_H_

Powered by Google App Engine
This is Rietveld 408576698