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

Side by Side Diff: chrome/browser/sync/signin_manager.h

Issue 3305003: New authorization framework for sync. ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 3 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) 2010 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 // The signin manager encapsulates some functionality tracking
6 // which user is signed in. When a user is signed in, a ClientLogin
7 // request is run on their behalf. Auth tokens are fetched from Google
8 // and the results are stored in the TokenService.
9
10 #ifndef CHROME_BROWSER_SYNC_SIGNIN_MANAGER_H_
11 #define CHROME_BROWSER_SYNC_SIGNIN_MANAGER_H_
12 #pragma once
13
14 #include <string>
15 #include "base/logging.h"
16 #include "base/scoped_ptr.h"
17 #include "chrome/common/net/gaia/gaia_auth_consumer.h"
18 #include "chrome/common/net/gaia/google_service_auth_error.h"
19
20 class GaiaAuthenticator2;
21 class Profile;
22 class PrefService;
23
24 // Details for the Notification type GOOGLE_SIGNIN_SUCCESSFUL.
25 // A listener might use this to make note of a username / password
26 // pair for encryption keys.
27 struct GoogleServiceSigninSuccessDetails {
28 GoogleServiceSigninSuccessDetails(const std::string& in_username,
29 const std::string& in_password)
30 : username(in_username),
31 password(in_password) {}
32 std::string username;
33 std::string password;
34 };
35
36 class SigninManager : public GaiaAuthConsumer {
37 public:
38 // Call to register our prefs.
39 static void RegisterUserPrefs(PrefService* user_prefs);
40
41 // If user was signed in, load tokens from DB if available.
42 void Initialize(Profile* profile);
43
44 // If a user is signed in, this will return their name.
45 // Otherwise, it will return an empty string.
46 const std::string& GetUsername();
47
48 // Sets the user name. Used for migrating credentials from previous system.
49 void SetUsername(const std::string& username);
50
51 // Attempt to sign in this user. If successful, set a preference indicating
52 // the signed in user and send out a notification, then start fetching tokens
53 // for the user.
54 void StartSignIn(const std::string& username,
55 const std::string& password,
56 const std::string& login_token,
57 const std::string& login_captcha);
58 // Sign a user out, removing the preference, erasing all keys
59 // associated with the user, and cancelling all auth in progress.
60 void SignOut();
61
62 // GaiaAuthConsumer
63 virtual void OnClientLoginSuccess(const ClientLoginResult& result);
64 virtual void OnClientLoginFailure(const GoogleServiceAuthError& error);
65 virtual void OnIssueAuthTokenSuccess(const std::string& service,
66 const std::string& auth_token) {
67 NOTREACHED();
68 }
69 virtual void OnIssueAuthTokenFailure(const std::string& service,
70 const GoogleServiceAuthError& error) {
71 NOTREACHED();
72 }
73
74 private:
75 Profile* profile_;
76 std::string username_;
77 std::string password_; // This is kept empty whenever possible.
78 scoped_ptr<GaiaAuthenticator2> client_login_;
79 };
80
81 #endif // CHROME_BROWSER_SYNC_SIGNIN_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698