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

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

Issue 10656033: [sync] Automatic bootstrapping of Sync on Win 8 from cached credentials (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: "" Created 8 years, 5 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // The signin manager encapsulates some functionality tracking 5 // The signin manager encapsulates some functionality tracking
6 // which user is signed in. When a user is signed in, a ClientLogin 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 7 // request is run on their behalf. Auth tokens are fetched from Google
8 // and the results are stored in the TokenService. 8 // and the results are stored in the TokenService.
9 // 9 //
10 // **NOTE** on semantics of SigninManager: 10 // **NOTE** on semantics of SigninManager:
11 // 11 //
12 // Once a signin is successful, the username becomes "established" and will not 12 // Once a signin is successful, the username becomes "established" and will not
13 // be cleared until a SignOut operation is performed (persists across 13 // be cleared until a SignOut operation is performed (persists across
14 // restarts). Until that happens, the signin manager can still be used to 14 // restarts). Until that happens, the signin manager can still be used to
15 // refresh credentials, but changing the username is not permitted. 15 // refresh credentials, but changing the username is not permitted.
16 16
17 #ifndef CHROME_BROWSER_SIGNIN_SIGNIN_MANAGER_H_ 17 #ifndef CHROME_BROWSER_SIGNIN_SIGNIN_MANAGER_H_
18 #define CHROME_BROWSER_SIGNIN_SIGNIN_MANAGER_H_ 18 #define CHROME_BROWSER_SIGNIN_SIGNIN_MANAGER_H_
19 #pragma once 19 #pragma once
20 20
21 #include <string> 21 #include <string>
22 22
23 #include "base/compiler_specific.h" 23 #include "base/compiler_specific.h"
24 #include "base/gtest_prod_util.h" 24 #include "base/gtest_prod_util.h"
25 #include "base/logging.h" 25 #include "base/logging.h"
26 #include "base/memory/ref_counted.h"
26 #include "base/memory/scoped_ptr.h" 27 #include "base/memory/scoped_ptr.h"
27 #include "chrome/browser/prefs/pref_change_registrar.h" 28 #include "chrome/browser/prefs/pref_change_registrar.h"
28 #include "chrome/browser/profiles/profile_keyed_service.h" 29 #include "chrome/browser/profiles/profile_keyed_service.h"
30 #if defined(OS_WIN)
31 #include "chrome/browser/sync/credential_cache_win.h"
32 #endif
29 #include "chrome/common/net/gaia/gaia_auth_consumer.h" 33 #include "chrome/common/net/gaia/gaia_auth_consumer.h"
30 #include "chrome/common/net/gaia/google_service_auth_error.h" 34 #include "chrome/common/net/gaia/google_service_auth_error.h"
31 #include "content/public/browser/notification_observer.h" 35 #include "content/public/browser/notification_observer.h"
32 #include "content/public/browser/notification_registrar.h" 36 #include "content/public/browser/notification_registrar.h"
33 37
34 class GaiaAuthFetcher; 38 class GaiaAuthFetcher;
35 class Profile; 39 class Profile;
36 class PrefService; 40 class PrefService;
37 41
38 // Details for the Notification type GOOGLE_SIGNIN_SUCCESSFUL. 42 // Details for the Notification type GOOGLE_SIGNIN_SUCCESSFUL.
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 virtual void StartSignInWithCredentials(const std::string& session_index, 102 virtual void StartSignInWithCredentials(const std::string& session_index,
99 const std::string& username, 103 const std::string& username,
100 const std::string& password); 104 const std::string& password);
101 105
102 // Attempt to sign in this user with ClientOAuth. If successful, set a 106 // Attempt to sign in this user with ClientOAuth. If successful, set a
103 // preference indicating the signed in user and send out a notification, 107 // preference indicating the signed in user and send out a notification,
104 // then start fetching tokens for the user. 108 // then start fetching tokens for the user.
105 virtual void StartSignInWithOAuth(const std::string& username, 109 virtual void StartSignInWithOAuth(const std::string& username,
106 const std::string& password); 110 const std::string& password);
107 111
112 #if defined(OS_WIN)
113 // Attempt to sign in using credentials cached by the alternate profile
114 // on Windows 8.
115 virtual void StartSignInWithCachedCredentials(
116 scoped_refptr<csync::CredentialCache> credentials);
117 #endif
Roger Tawa OOO till Jul 10th 2012/06/27 21:23:28 generally speaking there should be no #ifdef for p
Raghu Simha 2012/07/19 06:57:07 Done.
118
108 // Provide a challenge solution to a failed signin attempt with 119 // Provide a challenge solution to a failed signin attempt with
109 // StartSignInWithOAuth(). |type| and |token| come from the 120 // StartSignInWithOAuth(). |type| and |token| come from the
110 // GoogleServiceAuthError of the failed attempt. 121 // GoogleServiceAuthError of the failed attempt.
111 // |solution| is the answer typed by the user. 122 // |solution| is the answer typed by the user.
112 void ProvideOAuthChallengeResponse(GoogleServiceAuthError::State type, 123 void ProvideOAuthChallengeResponse(GoogleServiceAuthError::State type,
113 const std::string& token, 124 const std::string& token,
114 const std::string& solution); 125 const std::string& solution);
115 126
116 // Sign a user out, removing the preference, erasing all keys 127 // Sign a user out, removing the preference, erasing all keys
117 // associated with the user, and canceling all auth in progress. 128 // associated with the user, and canceling all auth in progress.
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 // Will clear in memory data but leaves the db as such so when the browser 178 // Will clear in memory data but leaves the db as such so when the browser
168 // restarts we can use the old token(which might throw a password error). 179 // restarts we can use the old token(which might throw a password error).
169 void ClearTransientSigninData(); 180 void ClearTransientSigninData();
170 181
171 // Called to handle an error from a GAIA auth fetch. Sets the last error 182 // Called to handle an error from a GAIA auth fetch. Sets the last error
172 // to |error|, sends out a notification of login failure, and clears the 183 // to |error|, sends out a notification of login failure, and clears the
173 // transient signin data if |clear_transient_data| is true. 184 // transient signin data if |clear_transient_data| is true.
174 void HandleAuthError(const GoogleServiceAuthError& error, 185 void HandleAuthError(const GoogleServiceAuthError& error,
175 bool clear_transient_data); 186 bool clear_transient_data);
176 187
188 // Unsubscribes from notifications from the token service.
189 void CleanupNotificationRegistration();
190
191 // Sends out the NOTIFICATION_GOOGLE_SIGNIN_SUCCESSFUL notification and starts
192 // fetching tokens. Called by OnGetUserInfoSuccess when the user manually
193 // signs in to sync, and by StartSignInWithCachedCredentials when sync is
194 // auto started on Windows 8 using cached credentials.
195 void ConsumeUserInfoAndFinishSignin();
196
197 #if defined(OS_WIN)
198 // Persists the authenticated username and auth tokens (sid and lsid) to the
199 // sync credential cache when the user successfully signs in to sync on Win 8.
200 // These credentials may be used later by the alternate Metro / Desktop
201 // profile to automatically start up sync.
Andrew T Wilson (Slow) 2012/06/26 23:26:13 What happens if both are already running? Is there
Raghu Simha 2012/06/27 00:17:04 I don't believe there is a mechanism within Chrome
202 void PersistAuthTokensAsync();
203 #endif
204
177 Profile* profile_; 205 Profile* profile_;
178 206
179 // ClientLogin identity. 207 // ClientLogin identity.
180 std::string possibly_invalid_username_; 208 std::string possibly_invalid_username_;
181 std::string password_; // This is kept empty whenever possible. 209 std::string password_; // This is kept empty whenever possible.
182 bool had_two_factor_error_; 210 bool had_two_factor_error_;
183 211
184 void CleanupNotificationRegistration();
185
186 // Result of the last client login, kept pending the lookup of the 212 // Result of the last client login, kept pending the lookup of the
187 // canonical email. 213 // canonical email.
188 ClientLoginResult last_result_; 214 ClientLoginResult last_result_;
189 215
190 // Actual client login handler. 216 // Actual client login handler.
191 scoped_ptr<GaiaAuthFetcher> client_login_; 217 scoped_ptr<GaiaAuthFetcher> client_login_;
192 218
193 // Registrar for notifications from the TokenService. 219 // Registrar for notifications from the TokenService.
194 content::NotificationRegistrar registrar_; 220 content::NotificationRegistrar registrar_;
195 221
196 // Helper object to listen for changes to signin preferences stored in non- 222 // Helper object to listen for changes to signin preferences stored in non-
197 // profile-specific local prefs (like kGoogleServicesUsernamePattern). 223 // profile-specific local prefs (like kGoogleServicesUsernamePattern).
198 PrefChangeRegistrar local_state_pref_registrar_; 224 PrefChangeRegistrar local_state_pref_registrar_;
199 225
200 // Actual username after successful authentication. 226 // Actual username after successful authentication.
201 std::string authenticated_username_; 227 std::string authenticated_username_;
202 228
203 // The type of sign being performed. This value is valid only between a call 229 // The type of sign being performed. This value is valid only between a call
204 // to one of the StartSigninXXX methods and when the sign in is either 230 // to one of the StartSigninXXX methods and when the sign in is either
205 // successful or not. 231 // successful or not.
206 SigninType type_; 232 SigninType type_;
207 233
208 DISALLOW_COPY_AND_ASSIGN(SigninManager); 234 DISALLOW_COPY_AND_ASSIGN(SigninManager);
209 }; 235 };
210 236
211 #endif // CHROME_BROWSER_SIGNIN_SIGNIN_MANAGER_H_ 237 #endif // CHROME_BROWSER_SIGNIN_SIGNIN_MANAGER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/signin/signin_manager.cc » ('j') | chrome/browser/signin/signin_manager.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698