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

Side by Side Diff: chrome/browser/chromeos/login/google_authenticator.cc

Issue 7982025: Made Authenticator::CompleteLogin, AuthenticateToLogin and AuthenticateToUnlock return void. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: One more obsolete comment fixed. Created 9 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
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/chromeos/login/google_authenticator.h" 5 #include "chrome/browser/chromeos/login/google_authenticator.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/file_path.h" 10 #include "base/file_path.h"
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 login_token_.assign(token); 110 login_token_.assign(token);
111 login_captcha_.assign(captcha); 111 login_captcha_.assign(captcha);
112 } 112 }
113 113
114 void GoogleAuthenticator::ClearClientLoginAttempt() { 114 void GoogleAuthenticator::ClearClientLoginAttempt() {
115 // Not clearing the password, because we may need to pass it to the 115 // Not clearing the password, because we may need to pass it to the
116 // sync service if login is successful. 116 // sync service if login is successful.
117 login_token_.clear(); 117 login_token_.clear();
118 login_captcha_.clear(); 118 login_captcha_.clear();
119 } 119 }
120 bool GoogleAuthenticator::CompleteLogin(Profile* profile, 120 void GoogleAuthenticator::CompleteLogin(Profile* profile,
121 const std::string& username, 121 const std::string& username,
122 const std::string& password) { 122 const std::string& password) {
123 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 123 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
124 authentication_profile_ = profile; 124 authentication_profile_ = profile;
125 username_.assign(Canonicalize(username)); 125 username_.assign(Canonicalize(username));
126 ascii_hash_.assign(HashPassword(password)); 126 ascii_hash_.assign(HashPassword(password));
127 127
128 BrowserThread::PostTask( 128 BrowserThread::PostTask(
129 BrowserThread::UI, FROM_HERE, 129 BrowserThread::UI, FROM_HERE,
130 NewRunnableMethod(this, 130 NewRunnableMethod(this,
131 &GoogleAuthenticator::OnLoginSuccess, 131 &GoogleAuthenticator::OnLoginSuccess,
132 GaiaAuthConsumer::ClientLoginResult(), false)); 132 GaiaAuthConsumer::ClientLoginResult(), false));
133 return true;
134 } 133 }
135 134
136 bool GoogleAuthenticator::AuthenticateToLogin( 135 void GoogleAuthenticator::AuthenticateToLogin(
137 Profile* profile, 136 Profile* profile,
138 const std::string& username, 137 const std::string& username,
139 const std::string& password, 138 const std::string& password,
140 const std::string& login_token, 139 const std::string& login_token,
141 const std::string& login_captcha) { 140 const std::string& login_captcha) {
142 unlock_ = false; 141 unlock_ = false;
143 authentication_profile_ = profile; 142 authentication_profile_ = profile;
144 143
145 // TODO(cmasone): Figure out how to parallelize fetch, username/password 144 // TODO(cmasone): Figure out how to parallelize fetch, username/password
146 // processing without impacting testability. 145 // processing without impacting testability.
147 username_.assign(Canonicalize(username)); 146 username_.assign(Canonicalize(username));
148 ascii_hash_.assign(HashPassword(password)); 147 ascii_hash_.assign(HashPassword(password));
149 148
150 gaia_authenticator_.reset( 149 gaia_authenticator_.reset(
151 new GaiaAuthFetcher(this, 150 new GaiaAuthFetcher(this,
152 GaiaConstants::kChromeOSSource, 151 GaiaConstants::kChromeOSSource,
153 profile->GetRequestContext())); 152 profile->GetRequestContext()));
154 // Will be used for retries. 153 // Will be used for retries.
155 PrepareClientLoginAttempt(password, login_token, login_captcha); 154 PrepareClientLoginAttempt(password, login_token, login_captcha);
156 TryClientLogin(); 155 TryClientLogin();
157 return true;
158 } 156 }
159 157
160 bool GoogleAuthenticator::AuthenticateToUnlock(const std::string& username, 158 void GoogleAuthenticator::AuthenticateToUnlock(const std::string& username,
161 const std::string& password) { 159 const std::string& password) {
162 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 160 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
163 username_.assign(Canonicalize(username)); 161 username_.assign(Canonicalize(username));
164 ascii_hash_.assign(HashPassword(password)); 162 ascii_hash_.assign(HashPassword(password));
165 unlock_ = true; 163 unlock_ = true;
166 BrowserThread::PostTask( 164 BrowserThread::PostTask(
167 BrowserThread::FILE, FROM_HERE, 165 BrowserThread::FILE, FROM_HERE,
168 NewRunnableMethod(this, 166 NewRunnableMethod(this,
169 &GoogleAuthenticator::LoadLocalaccount, 167 &GoogleAuthenticator::LoadLocalaccount,
170 std::string(kLocalaccountFile))); 168 std::string(kLocalaccountFile)));
171 BrowserThread::PostTask( 169 BrowserThread::PostTask(
172 BrowserThread::UI, FROM_HERE, 170 BrowserThread::UI, FROM_HERE,
173 NewRunnableMethod(this, &GoogleAuthenticator::CheckOffline, 171 NewRunnableMethod(this, &GoogleAuthenticator::CheckOffline,
174 LoginFailure(LoginFailure::UNLOCK_FAILED))); 172 LoginFailure(LoginFailure::UNLOCK_FAILED)));
175 return true;
176 } 173 }
177 174
178 void GoogleAuthenticator::LoginOffTheRecord() { 175 void GoogleAuthenticator::LoginOffTheRecord() {
179 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 176 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
180 int mount_error = chromeos::kCryptohomeMountErrorNone; 177 int mount_error = chromeos::kCryptohomeMountErrorNone;
181 if (CrosLibrary::Get()->GetCryptohomeLibrary()->MountForBwsi(&mount_error)) { 178 if (CrosLibrary::Get()->GetCryptohomeLibrary()->MountForBwsi(&mount_error)) {
182 AuthenticationNotificationDetails details(true); 179 AuthenticationNotificationDetails details(true);
183 NotificationService::current()->Notify( 180 NotificationService::current()->Notify(
184 chrome::NOTIFICATION_LOGIN_AUTHENTICATION, 181 chrome::NOTIFICATION_LOGIN_AUTHENTICATION,
185 NotificationService::AllSources(), 182 NotificationService::AllSources(),
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 const unsigned int len) { 505 const unsigned int len) {
509 if (len < 2*binary_len) 506 if (len < 2*binary_len)
510 return false; 507 return false;
511 memset(hex_string, 0, len); 508 memset(hex_string, 0, len);
512 for (uint i = 0, j = 0; i < binary_len; i++, j+=2) 509 for (uint i = 0, j = 0; i < binary_len; i++, j+=2)
513 snprintf(hex_string + j, len - j, "%02x", binary[i]); 510 snprintf(hex_string + j, len - j, "%02x", binary[i]);
514 return true; 511 return true;
515 } 512 }
516 513
517 } // namespace chromeos 514 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/google_authenticator.h ('k') | chrome/browser/chromeos/login/mock_authenticator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698