OLD | NEW |
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 #include "chrome/browser/chromeos/login/online_attempt_host.h" | 5 #include "chrome/browser/chromeos/login/online_attempt_host.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/sha1.h" | 8 #include "base/sha1.h" |
9 #include "chrome/browser/chromeos/login/auth_attempt_state.h" | 9 #include "chrome/browser/chromeos/login/auth_attempt_state.h" |
10 #include "chrome/browser/chromeos/login/online_attempt.h" | 10 #include "chrome/browser/chromeos/login/online_attempt.h" |
11 #include "chrome/browser/chromeos/login/user.h" | 11 #include "chrome/browser/chromeos/login/user.h" |
12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
13 #include "content/public/browser/browser_thread.h" | 13 #include "content/public/browser/browser_thread.h" |
14 #include "google_apis/gaia/gaia_auth_util.h" | 14 #include "google_apis/gaia/gaia_auth_util.h" |
15 | 15 |
16 namespace chromeos { | 16 namespace chromeos { |
17 | 17 |
18 OnlineAttemptHost::OnlineAttemptHost(Delegate* delegate) | 18 OnlineAttemptHost::OnlineAttemptHost(Delegate* delegate) |
19 : delegate_(delegate) { | 19 : delegate_(delegate) { |
20 } | 20 } |
21 | 21 |
22 OnlineAttemptHost::~OnlineAttemptHost() { | 22 OnlineAttemptHost::~OnlineAttemptHost() { |
23 Reset(); | 23 Reset(); |
24 } | 24 } |
25 | 25 |
26 void OnlineAttemptHost::Check(Profile* profile, | 26 void OnlineAttemptHost::Check(Profile* profile, |
27 const std::string& username, | 27 const UserCredentials& credentials) { |
28 const std::string& password) { | |
29 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 28 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
30 std::string attempt_hash = base::SHA1HashString(username + "\n" + password); | 29 std::string attempt_hash = base::SHA1HashString( |
| 30 credentials.username + "\n" + credentials.password); |
31 if (attempt_hash != current_attempt_hash_) { | 31 if (attempt_hash != current_attempt_hash_) { |
32 Reset(); | 32 Reset(); |
33 current_attempt_hash_ = attempt_hash; | 33 current_attempt_hash_ = attempt_hash; |
34 current_username_ = username; | 34 current_username_ = credentials.username; |
35 | 35 |
36 state_.reset( | 36 state_.reset( |
37 new AuthAttemptState( | 37 new AuthAttemptState( |
38 gaia::CanonicalizeEmail(username), | 38 UserCredentials(gaia::CanonicalizeEmail(credentials.username), |
39 password, | 39 credentials.password, |
40 std::string(), | 40 credentials.auth_code), |
41 std::string(), | 41 std::string(), // ascii_hash |
42 std::string(), | 42 std::string(), // login_token |
| 43 std::string(), // login_captcha |
43 User::USER_TYPE_REGULAR, | 44 User::USER_TYPE_REGULAR, |
44 false)); // Isn't a new user. | 45 false)); // user_is_new. |
45 online_attempt_.reset(new OnlineAttempt(state_.get(), | 46 online_attempt_.reset(new OnlineAttempt(state_.get(), |
46 this)); | 47 this)); |
47 online_attempt_->Initiate(profile); | 48 online_attempt_->Initiate(profile); |
48 } | 49 } |
49 } | 50 } |
50 | 51 |
51 void OnlineAttemptHost::Reset() { | 52 void OnlineAttemptHost::Reset() { |
52 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 53 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
53 online_attempt_.reset(NULL); | 54 online_attempt_.reset(NULL); |
54 current_attempt_hash_.clear(); | 55 current_attempt_hash_.clear(); |
(...skipping 11 matching lines...) Expand all Loading... |
66 } | 67 } |
67 } | 68 } |
68 | 69 |
69 void OnlineAttemptHost::ResolveOnUIThread(bool success) { | 70 void OnlineAttemptHost::ResolveOnUIThread(bool success) { |
70 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 71 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
71 delegate_->OnChecked(current_username_, success); | 72 delegate_->OnChecked(current_username_, success); |
72 Reset(); | 73 Reset(); |
73 } | 74 } |
74 | 75 |
75 } // chromeos | 76 } // chromeos |
OLD | NEW |