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

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

Issue 8511064: GAIA Profile info prototype (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: test Created 9 years, 1 month 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #include "chrome/browser/sync/signin_manager.h" 5 #include "chrome/browser/sync/signin_manager.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "chrome/browser/net/gaia/token_service.h" 9 #include "chrome/browser/net/gaia/token_service.h"
10 #include "chrome/browser/prefs/pref_service.h" 10 #include "chrome/browser/prefs/pref_service.h"
(...skipping 20 matching lines...) Expand all
31 PrefService::UNSYNCABLE_PREF); 31 PrefService::UNSYNCABLE_PREF);
32 user_prefs->RegisterStringPref(prefs::kGoogleServicesUsername, 32 user_prefs->RegisterStringPref(prefs::kGoogleServicesUsername,
33 "", 33 "",
34 PrefService::UNSYNCABLE_PREF); 34 PrefService::UNSYNCABLE_PREF);
35 user_prefs->RegisterBooleanPref(prefs::kAutologinEnabled, 35 user_prefs->RegisterBooleanPref(prefs::kAutologinEnabled,
36 true, 36 true,
37 PrefService::UNSYNCABLE_PREF); 37 PrefService::UNSYNCABLE_PREF);
38 } 38 }
39 39
40 void SigninManager::Initialize(Profile* profile) { 40 void SigninManager::Initialize(Profile* profile) {
41 fprintf(stderr, "%s\n", __func__);
41 profile_ = profile; 42 profile_ = profile;
42 SetUsername(profile_->GetPrefs()->GetString(prefs::kGoogleServicesUsername)); 43 SetUsername(profile_->GetPrefs()->GetString(prefs::kGoogleServicesUsername));
43 profile_->GetTokenService()->Initialize( 44 profile_->GetTokenService()->Initialize(
44 GaiaConstants::kChromeSource, profile_); 45 GaiaConstants::kChromeSource, profile_);
45 if (!GetUsername().empty()) { 46 if (!GetUsername().empty()) {
46 profile_->GetTokenService()->LoadTokensFromDB(); 47 profile_->GetTokenService()->LoadTokensFromDB();
47 } 48 }
48 } 49 }
49 50
50 bool SigninManager::IsInitialized() const { 51 bool SigninManager::IsInitialized() const {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 #if !defined(OS_CHROMEOS) 96 #if !defined(OS_CHROMEOS)
96 // The Sign out should clear the token service credentials. 97 // The Sign out should clear the token service credentials.
97 // Note: In CHROMEOS we might have valid credentials but still need to 98 // Note: In CHROMEOS we might have valid credentials but still need to
98 // set up 2-factor authentication. 99 // set up 2-factor authentication.
99 DCHECK(!profile_->GetTokenService()->HasOAuthCredentials()); 100 DCHECK(!profile_->GetTokenService()->HasOAuthCredentials());
100 #endif 101 #endif
101 } 102 }
102 103
103 // Users must always sign out before they sign in again. 104 // Users must always sign out before they sign in again.
104 void SigninManager::StartOAuthSignIn(const std::string& oauth1_request_token) { 105 void SigninManager::StartOAuthSignIn(const std::string& oauth1_request_token) {
106 fprintf(stderr, "%s\n", __func__);
105 DCHECK(browser_sync::IsUsingOAuth()); 107 DCHECK(browser_sync::IsUsingOAuth());
106 PrepareForOAuthSignin(); 108 PrepareForOAuthSignin();
107 oauth1_request_token_.assign(oauth1_request_token); 109 oauth1_request_token_.assign(oauth1_request_token);
108 oauth_login_.reset(new GaiaOAuthFetcher(this, 110 oauth_login_.reset(new GaiaOAuthFetcher(this,
109 profile_->GetRequestContext(), 111 profile_->GetRequestContext(),
110 profile_, 112 profile_,
111 GaiaConstants::kSyncServiceOAuth)); 113 GaiaConstants::kSyncServiceOAuth));
112 oauth_login_->StartOAuthGetAccessToken(oauth1_request_token_); 114 oauth_login_->StartOAuthGetAccessToken(oauth1_request_token_);
113 // TODO(rogerta?): Bug 92325: Expand Autologin to include OAuth signin 115 // TODO(rogerta?): Bug 92325: Expand Autologin to include OAuth signin
114 } 116 }
115 117
116 // Users must always sign out before they sign in again. 118 // Users must always sign out before they sign in again.
117 void SigninManager::StartSignIn(const std::string& username, 119 void SigninManager::StartSignIn(const std::string& username,
118 const std::string& password, 120 const std::string& password,
119 const std::string& login_token, 121 const std::string& login_token,
120 const std::string& login_captcha) { 122 const std::string& login_captcha) {
123 fprintf(stderr, "%s\n", __func__);
121 DCHECK(!browser_sync::IsUsingOAuth()); 124 DCHECK(!browser_sync::IsUsingOAuth());
122 PrepareForSignin(); 125 PrepareForSignin();
123 username_.assign(username); 126 username_.assign(username);
124 password_.assign(password); 127 password_.assign(password);
125 128
126 client_login_.reset(new GaiaAuthFetcher(this, 129 client_login_.reset(new GaiaAuthFetcher(this,
127 GaiaConstants::kChromeSource, 130 GaiaConstants::kChromeSource,
128 profile_->GetRequestContext())); 131 profile_->GetRequestContext()));
129 client_login_->StartClientLogin(username, 132 client_login_->StartClientLogin(username,
130 password, 133 password,
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 password_.clear(); 176 password_.clear();
174 had_two_factor_error_ = false; 177 had_two_factor_error_ = false;
175 profile_->GetPrefs()->ClearPref(prefs::kGoogleServicesUsername); 178 profile_->GetPrefs()->ClearPref(prefs::kGoogleServicesUsername);
176 profile_->GetPrefs()->ClearPref(prefs::kSyncUsingOAuth); 179 profile_->GetPrefs()->ClearPref(prefs::kSyncUsingOAuth);
177 profile_->GetPrefs()->ScheduleSavePersistentPrefs(); 180 profile_->GetPrefs()->ScheduleSavePersistentPrefs();
178 profile_->GetTokenService()->ResetCredentialsInMemory(); 181 profile_->GetTokenService()->ResetCredentialsInMemory();
179 profile_->GetTokenService()->EraseTokensFromDB(); 182 profile_->GetTokenService()->EraseTokensFromDB();
180 } 183 }
181 184
182 void SigninManager::OnClientLoginSuccess(const ClientLoginResult& result) { 185 void SigninManager::OnClientLoginSuccess(const ClientLoginResult& result) {
186 fprintf(stderr, "%s\n", __func__);
183 DCHECK(!browser_sync::IsUsingOAuth()); 187 DCHECK(!browser_sync::IsUsingOAuth());
184 last_result_ = result; 188 last_result_ = result;
185 // Make a request for the canonical email address. 189 // Make a request for the canonical email address.
186 client_login_->StartGetUserInfo(result.lsid, kGetInfoEmailKey); 190 client_login_->StartGetUserInfo(result.lsid, kGetInfoEmailKey);
187 } 191 }
188 192
189 // NOTE: GetUserInfo is a ClientLogin request similar to OAuth's userinfo 193 // NOTE: GetUserInfo is a ClientLogin request similar to OAuth's userinfo
190 void SigninManager::OnGetUserInfoSuccess(const std::string& key, 194 void SigninManager::OnGetUserInfoSuccess(const std::string& key,
191 const std::string& value) { 195 const std::string& value) {
196 fprintf(stderr, "%s\n", __func__);
192 DCHECK(!browser_sync::IsUsingOAuth()); 197 DCHECK(!browser_sync::IsUsingOAuth());
193 DCHECK(key == kGetInfoEmailKey); 198 DCHECK(key == kGetInfoEmailKey);
194 199
195 username_ = value; 200 username_ = value;
196 profile_->GetPrefs()->SetString(prefs::kGoogleServicesUsername, username_); 201 profile_->GetPrefs()->SetString(prefs::kGoogleServicesUsername, username_);
197 profile_->GetPrefs()->SetBoolean(prefs::kSyncUsingOAuth, false); 202 profile_->GetPrefs()->SetBoolean(prefs::kSyncUsingOAuth, false);
198 profile_->GetPrefs()->ScheduleSavePersistentPrefs(); 203 profile_->GetPrefs()->ScheduleSavePersistentPrefs();
199 204
200 GoogleServiceSigninSuccessDetails details(username_, password_); 205 GoogleServiceSigninSuccessDetails details(username_, password_);
201 content::NotificationService::current()->Notify( 206 content::NotificationService::current()->Notify(
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 profile_->GetRequestContext())); 339 profile_->GetRequestContext()));
335 } 340 }
336 341
337 client_login_->StartMergeSession(tok_details->token()); 342 client_login_->StartMergeSession(tok_details->token());
338 343
339 // We only want to do this once per sign-in. 344 // We only want to do this once per sign-in.
340 CleanupNotificationRegistration(); 345 CleanupNotificationRegistration();
341 } 346 }
342 #endif 347 #endif
343 } 348 }
OLDNEW
« no previous file with comments | « chrome/browser/sync/profile_sync_service.cc ('k') | chrome/browser/ui/views/avatar_menu_bubble_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698