Index: chrome/browser/sync/signin_manager_oauth.h |
diff --git a/chrome/browser/sync/signin_manager_oauth.h b/chrome/browser/sync/signin_manager_oauth.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..25d9759083ecb196fdd0a2c254c4f89929679e78 |
--- /dev/null |
+++ b/chrome/browser/sync/signin_manager_oauth.h |
@@ -0,0 +1,78 @@ |
+// Copyright (c) 2011 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. |
+// |
+// The signin manager encapsulates some functionality tracking |
+// which user is signed in. When a user is signed in, a ClientLogin |
+// request is run on their behalf. Auth tokens are fetched from Google |
+// and the results are stored in the TokenService. |
+ |
+#ifndef CHROME_BROWSER_SYNC_SIGNIN_MANAGER_OAUTH_H_ |
+#define CHROME_BROWSER_SYNC_SIGNIN_MANAGER_OAUTH_H_ |
+#pragma once |
+ |
+#include <string> |
+ |
+#include "base/logging.h" |
+#include "base/memory/scoped_ptr.h" |
+#include "chrome/browser/sync/signin_manager.h" |
+#include "chrome/common/net/gaia/authentication_consumer_oauth.h" |
+#include "chrome/common/net/gaia/authentication_fetcher_oauth.h" |
+#include "chrome/common/net/gaia/google_service_auth_error.h" |
+ |
+class AuthenticationFetcher; |
+class Profile; |
+class PrefService; |
+ |
+class SigninManagerOAuth : public SigninManager, AuthenticationConsumerOAuth { |
+ public: |
+ static const char kSigninManagerVariantName[]; |
+ |
+ SigninManagerOAuth(); |
+ virtual ~SigninManagerOAuth(); |
+ |
+ // Call to register our prefs. |
+ static void RegisterUserPrefs(PrefService* user_prefs); |
+ |
+ // If user was signed in, load tokens from DB if available. |
+ virtual void Initialize(Profile* profile); |
+ |
+ // If a user is signed in, this will return their name. |
+ // Otherwise, it will return an empty string. |
+ const std::string& GetUsername(); |
+ |
+ // Sets the user name. Used for migrating credentials from previous system. |
+ void SetUsername(const std::string& username); |
+ |
+ // Attempt to sign in this user. If successful, set a preference indicating |
+ // the signed in user and send out a notification, then start fetching tokens |
+ // for the user. |
+ void StartSignIn(const std::string& username, |
+ const std::string& password, |
+ const std::string& login_token, |
+ const std::string& login_captcha); |
+ |
+ // Used when a second factor access code was required to complete a signin |
+ // attempt. |
+ void ProvideSecondFactorAccessCode(const std::string& access_code); |
+ |
+ // Sign a user out, removing the preference, erasing all keys |
+ // associated with the user, and canceling all auth in progress. |
+ void SignOut(); |
+ |
+ // GaiaAuthConsumer |
+ virtual void OnAuthenticationSuccess(AuthenticationResult* result); |
+ virtual void OnAuthenticationFailure(const GoogleServiceAuthError& error); |
+ virtual void OnGetUserInfoSuccess(const std::string& key, |
+ const std::string& value); |
+ virtual void OnGetUserInfoKeyNotFound(const std::string& key); |
+ virtual void OnGetUserInfoFailure(const GoogleServiceAuthError& error); |
+ |
+ private: |
+ Profile* profile_; |
+ std::string username_; |
+ std::string password_; // This is kept empty whenever possible. |
+ bool had_two_factor_error_; |
+}; |
+ |
+#endif // CHROME_BROWSER_SYNC_SIGNIN_MANAGER_OAUTH_H_ |