OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/supervised/supervised_user_login_flow.h" | 5 #include "chrome/browser/chromeos/login/supervised/supervised_user_login_flow.h" |
6 | 6 |
7 #include "base/base64.h" | 7 #include "base/base64.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/prefs/pref_registry_simple.h" | 10 #include "base/prefs/pref_registry_simple.h" |
11 #include "base/prefs/pref_service.h" | 11 #include "base/prefs/pref_service.h" |
12 #include "base/values.h" | 12 #include "base/values.h" |
13 #include "chrome/browser/chromeos/login/login_utils.h" | 13 #include "chrome/browser/chromeos/login/login_utils.h" |
14 #include "chrome/browser/chromeos/login/supervised/supervised_user_authenticatio
n.h" | 14 #include "chrome/browser/chromeos/login/supervised/supervised_user_authenticatio
n.h" |
15 #include "chrome/browser/chromeos/login/supervised/supervised_user_constants.h" | 15 #include "chrome/browser/chromeos/login/supervised/supervised_user_constants.h" |
16 #include "chrome/browser/chromeos/login/supervised/supervised_user_creation_scre
en.h" | 16 #include "chrome/browser/chromeos/login/supervised/supervised_user_creation_scre
en.h" |
17 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" | 17 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" |
| 18 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h" |
18 #include "chrome/browser/chromeos/login/users/supervised_user_manager.h" | 19 #include "chrome/browser/chromeos/login/users/supervised_user_manager.h" |
19 #include "chrome/browser/chromeos/login/users/user_manager.h" | |
20 #include "chrome/browser/chromeos/login/wizard_controller.h" | 20 #include "chrome/browser/chromeos/login/wizard_controller.h" |
21 #include "chromeos/login/auth/key.h" | 21 #include "chromeos/login/auth/key.h" |
| 22 #include "components/user_manager/user_manager.h" |
22 #include "content/public/browser/browser_thread.h" | 23 #include "content/public/browser/browser_thread.h" |
23 | 24 |
24 using content::BrowserThread; | 25 using content::BrowserThread; |
25 | 26 |
26 namespace chromeos { | 27 namespace chromeos { |
27 | 28 |
28 SupervisedUserLoginFlow::SupervisedUserLoginFlow( | 29 SupervisedUserLoginFlow::SupervisedUserLoginFlow( |
29 const std::string& user_id) | 30 const std::string& user_id) |
30 : ExtendedUserFlow(user_id), | 31 : ExtendedUserFlow(user_id), |
31 data_loaded_(false), | 32 data_loaded_(false), |
(...skipping 30 matching lines...) Expand all Loading... |
62 const std::string& token) { | 63 const std::string& token) { |
63 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 64 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
64 ConfigureSync(token); | 65 ConfigureSync(token); |
65 } | 66 } |
66 | 67 |
67 void SupervisedUserLoginFlow::ConfigureSync(const std::string& token) { | 68 void SupervisedUserLoginFlow::ConfigureSync(const std::string& token) { |
68 data_loaded_ = true; | 69 data_loaded_ = true; |
69 | 70 |
70 // TODO(antrim): add error handling (no token loaded). | 71 // TODO(antrim): add error handling (no token loaded). |
71 // See also: http://crbug.com/312751 | 72 // See also: http://crbug.com/312751 |
72 UserManager::Get()->GetSupervisedUserManager()->ConfigureSyncWithToken( | 73 ChromeUserManager::Get()->GetSupervisedUserManager()->ConfigureSyncWithToken( |
73 profile_, token); | 74 profile_, token); |
74 SupervisedUserAuthentication* auth = | 75 SupervisedUserAuthentication* auth = |
75 UserManager::Get()->GetSupervisedUserManager()->GetAuthentication(); | 76 ChromeUserManager::Get()->GetSupervisedUserManager()->GetAuthentication(); |
76 | 77 |
77 if (auth->HasScheduledPasswordUpdate(user_id())) { | 78 if (auth->HasScheduledPasswordUpdate(user_id())) { |
78 auth->LoadPasswordUpdateData( | 79 auth->LoadPasswordUpdateData( |
79 user_id(), | 80 user_id(), |
80 base::Bind(&SupervisedUserLoginFlow::OnPasswordChangeDataLoaded, | 81 base::Bind(&SupervisedUserLoginFlow::OnPasswordChangeDataLoaded, |
81 weak_factory_.GetWeakPtr()), | 82 weak_factory_.GetWeakPtr()), |
82 base::Bind(&SupervisedUserLoginFlow::OnPasswordChangeDataLoadFailed, | 83 base::Bind(&SupervisedUserLoginFlow::OnPasswordChangeDataLoadFailed, |
83 weak_factory_.GetWeakPtr())); | 84 weak_factory_.GetWeakPtr())); |
84 return; | 85 return; |
85 } | 86 } |
86 Finish(); | 87 Finish(); |
87 } | 88 } |
88 | 89 |
89 void SupervisedUserLoginFlow::HandleLoginSuccess( | 90 void SupervisedUserLoginFlow::HandleLoginSuccess( |
90 const UserContext& login_context) { | 91 const UserContext& login_context) { |
91 context_ = login_context; | 92 context_ = login_context; |
92 } | 93 } |
93 | 94 |
94 void SupervisedUserLoginFlow::OnPasswordChangeDataLoaded( | 95 void SupervisedUserLoginFlow::OnPasswordChangeDataLoaded( |
95 const base::DictionaryValue* password_data) { | 96 const base::DictionaryValue* password_data) { |
96 // Edge case, when manager has signed in and already updated the password. | 97 // Edge case, when manager has signed in and already updated the password. |
97 SupervisedUserAuthentication* auth = | 98 SupervisedUserAuthentication* auth = |
98 UserManager::Get()->GetSupervisedUserManager()->GetAuthentication(); | 99 ChromeUserManager::Get()->GetSupervisedUserManager()->GetAuthentication(); |
99 if (!auth->NeedPasswordChange(user_id(), password_data)) { | 100 if (!auth->NeedPasswordChange(user_id(), password_data)) { |
100 VLOG(1) << "Password already changed for " << user_id(); | 101 VLOG(1) << "Password already changed for " << user_id(); |
101 auth->ClearScheduledPasswordUpdate(user_id()); | 102 auth->ClearScheduledPasswordUpdate(user_id()); |
102 Finish(); | 103 Finish(); |
103 return; | 104 return; |
104 } | 105 } |
105 | 106 |
106 // Two cases now - we can currently have either old-style password, or new | 107 // Two cases now - we can currently have either old-style password, or new |
107 // password. | 108 // password. |
108 std::string base64_signature; | 109 std::string base64_signature; |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 Passed(&data_copy))); | 173 Passed(&data_copy))); |
173 } else { | 174 } else { |
174 NOTREACHED() << "Unsupported password schema"; | 175 NOTREACHED() << "Unsupported password schema"; |
175 } | 176 } |
176 } | 177 } |
177 | 178 |
178 void SupervisedUserLoginFlow::OnNewKeyAdded( | 179 void SupervisedUserLoginFlow::OnNewKeyAdded( |
179 scoped_ptr<base::DictionaryValue> password_data) { | 180 scoped_ptr<base::DictionaryValue> password_data) { |
180 VLOG(1) << "New key added"; | 181 VLOG(1) << "New key added"; |
181 SupervisedUserAuthentication* auth = | 182 SupervisedUserAuthentication* auth = |
182 UserManager::Get()->GetSupervisedUserManager()->GetAuthentication(); | 183 ChromeUserManager::Get()->GetSupervisedUserManager()->GetAuthentication(); |
183 auth->StorePasswordData(user_id(), *password_data.get()); | 184 auth->StorePasswordData(user_id(), *password_data.get()); |
184 auth->MarkKeyIncomplete(user_id(), true /* incomplete */); | 185 auth->MarkKeyIncomplete(user_id(), true /* incomplete */); |
185 authenticator_->RemoveKey( | 186 authenticator_->RemoveKey( |
186 context_, | 187 context_, |
187 kLegacyCryptohomeSupervisedUserKeyLabel, | 188 kLegacyCryptohomeSupervisedUserKeyLabel, |
188 base::Bind(&SupervisedUserLoginFlow::OnOldKeyRemoved, | 189 base::Bind(&SupervisedUserLoginFlow::OnOldKeyRemoved, |
189 weak_factory_.GetWeakPtr())); | 190 weak_factory_.GetWeakPtr())); |
190 } | 191 } |
191 | 192 |
192 void SupervisedUserLoginFlow::OnOldKeyRemoved() { | 193 void SupervisedUserLoginFlow::OnOldKeyRemoved() { |
(...skipping 24 matching lines...) Expand all Loading... |
217 PASSWORD_CHANGE_FAILED_AUTHENTICATION_FAILURE, | 218 PASSWORD_CHANGE_FAILED_AUTHENTICATION_FAILURE, |
218 SupervisedUserAuthentication::PASSWORD_CHANGE_RESULT_MAX_VALUE); | 219 SupervisedUserAuthentication::PASSWORD_CHANGE_RESULT_MAX_VALUE); |
219 Finish(); | 220 Finish(); |
220 } | 221 } |
221 | 222 |
222 void SupervisedUserLoginFlow::OnPasswordUpdated( | 223 void SupervisedUserLoginFlow::OnPasswordUpdated( |
223 scoped_ptr<base::DictionaryValue> password_data) { | 224 scoped_ptr<base::DictionaryValue> password_data) { |
224 VLOG(1) << "Updated password for supervised user"; | 225 VLOG(1) << "Updated password for supervised user"; |
225 | 226 |
226 SupervisedUserAuthentication* auth = | 227 SupervisedUserAuthentication* auth = |
227 UserManager::Get()->GetSupervisedUserManager()->GetAuthentication(); | 228 ChromeUserManager::Get()->GetSupervisedUserManager()->GetAuthentication(); |
228 | 229 |
229 // Incomplete state is not there in password_data, carry it from old state. | 230 // Incomplete state is not there in password_data, carry it from old state. |
230 bool was_incomplete = auth->HasIncompleteKey(user_id()); | 231 bool was_incomplete = auth->HasIncompleteKey(user_id()); |
231 auth->StorePasswordData(user_id(), *password_data.get()); | 232 auth->StorePasswordData(user_id(), *password_data.get()); |
232 if (was_incomplete) | 233 if (was_incomplete) |
233 auth->MarkKeyIncomplete(user_id(), true /* incomplete */); | 234 auth->MarkKeyIncomplete(user_id(), true /* incomplete */); |
234 | 235 |
235 UMA_HISTOGRAM_ENUMERATION( | 236 UMA_HISTOGRAM_ENUMERATION( |
236 "ManagedUsers.ChromeOS.PasswordChange", | 237 "ManagedUsers.ChromeOS.PasswordChange", |
237 SupervisedUserAuthentication::PASSWORD_CHANGED_IN_USER_SESSION, | 238 SupervisedUserAuthentication::PASSWORD_CHANGED_IN_USER_SESSION, |
238 SupervisedUserAuthentication::PASSWORD_CHANGE_RESULT_MAX_VALUE); | 239 SupervisedUserAuthentication::PASSWORD_CHANGE_RESULT_MAX_VALUE); |
239 Finish(); | 240 Finish(); |
240 } | 241 } |
241 | 242 |
242 void SupervisedUserLoginFlow::Finish() { | 243 void SupervisedUserLoginFlow::Finish() { |
243 LoginUtils::Get()->DoBrowserLaunch(profile_, host()); | 244 LoginUtils::Get()->DoBrowserLaunch(profile_, host()); |
244 profile_ = NULL; | 245 profile_ = NULL; |
245 UnregisterFlowSoon(); | 246 UnregisterFlowSoon(); |
246 } | 247 } |
247 | 248 |
248 void SupervisedUserLoginFlow::LaunchExtraSteps( | 249 void SupervisedUserLoginFlow::LaunchExtraSteps( |
249 Profile* profile) { | 250 Profile* profile) { |
250 profile_ = profile; | 251 profile_ = profile; |
251 UserManager::Get()->GetSupervisedUserManager()->LoadSupervisedUserToken( | 252 ChromeUserManager::Get()->GetSupervisedUserManager()->LoadSupervisedUserToken( |
252 profile, | 253 profile, |
253 base::Bind( | 254 base::Bind(&SupervisedUserLoginFlow::OnSyncSetupDataLoaded, |
254 &SupervisedUserLoginFlow::OnSyncSetupDataLoaded, | 255 weak_factory_.GetWeakPtr())); |
255 weak_factory_.GetWeakPtr())); | |
256 } | 256 } |
257 | 257 |
258 } // namespace chromeos | 258 } // namespace chromeos |
OLD | NEW |