| 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/supervised_user/chromeos/manager_password_service.h" | 5 #include "chrome/browser/supervised_user/chromeos/manager_password_service.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.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/values.h" | 10 #include "base/values.h" |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 return; | 79 return; |
| 80 } | 80 } |
| 81 | 81 |
| 82 SupervisedUserAuthentication* auth = | 82 SupervisedUserAuthentication* auth = |
| 83 supervised_user_manager->GetAuthentication(); | 83 supervised_user_manager->GetAuthentication(); |
| 84 | 84 |
| 85 if (!auth->NeedPasswordChange(user->email(), dict) && | 85 if (!auth->NeedPasswordChange(user->email(), dict) && |
| 86 !auth->HasIncompleteKey(user->email())) { | 86 !auth->HasIncompleteKey(user->email())) { |
| 87 return; | 87 return; |
| 88 } | 88 } |
| 89 scoped_ptr<base::DictionaryValue> wrapper(dict->DeepCopy()); | 89 std::unique_ptr<base::DictionaryValue> wrapper(dict->DeepCopy()); |
| 90 user_service_->GetSupervisedUsersAsync( | 90 user_service_->GetSupervisedUsersAsync( |
| 91 base::Bind(&ManagerPasswordService::GetSupervisedUsersCallback, | 91 base::Bind(&ManagerPasswordService::GetSupervisedUsersCallback, |
| 92 weak_ptr_factory_.GetWeakPtr(), | 92 weak_ptr_factory_.GetWeakPtr(), |
| 93 su_id, | 93 su_id, |
| 94 user->email(), | 94 user->email(), |
| 95 Passed(&wrapper))); | 95 Passed(&wrapper))); |
| 96 } | 96 } |
| 97 | 97 |
| 98 void ManagerPasswordService::GetSupervisedUsersCallback( | 98 void ManagerPasswordService::GetSupervisedUsersCallback( |
| 99 const std::string& sync_su_id, | 99 const std::string& sync_su_id, |
| 100 const std::string& user_id, | 100 const std::string& user_id, |
| 101 scoped_ptr<base::DictionaryValue> password_data, | 101 std::unique_ptr<base::DictionaryValue> password_data, |
| 102 const base::DictionaryValue* supervised_users) { | 102 const base::DictionaryValue* supervised_users) { |
| 103 const base::DictionaryValue* supervised_user = NULL; | 103 const base::DictionaryValue* supervised_user = NULL; |
| 104 if (!supervised_users->GetDictionary(sync_su_id, &supervised_user)) | 104 if (!supervised_users->GetDictionary(sync_su_id, &supervised_user)) |
| 105 return; | 105 return; |
| 106 std::string master_key; | 106 std::string master_key; |
| 107 std::string encryption_key; | 107 std::string encryption_key; |
| 108 std::string signature_key; | 108 std::string signature_key; |
| 109 if (!supervised_user->GetString(SupervisedUserSyncService::kMasterKey, | 109 if (!supervised_user->GetString(SupervisedUserSyncService::kMasterKey, |
| 110 &master_key)) { | 110 &master_key)) { |
| 111 LOG(WARNING) << "Can not apply password change to " << user_id | 111 LOG(WARNING) << "Can not apply password change to " << user_id |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 UMA_HISTOGRAM_ENUMERATION( | 184 UMA_HISTOGRAM_ENUMERATION( |
| 185 "ManagedUsers.ChromeOS.PasswordChange", | 185 "ManagedUsers.ChromeOS.PasswordChange", |
| 186 SupervisedUserAuthentication::PASSWORD_CHANGE_FAILED_MASTER_KEY_FAILURE, | 186 SupervisedUserAuthentication::PASSWORD_CHANGE_FAILED_MASTER_KEY_FAILURE, |
| 187 SupervisedUserAuthentication::PASSWORD_CHANGE_RESULT_MAX_VALUE); | 187 SupervisedUserAuthentication::PASSWORD_CHANGE_RESULT_MAX_VALUE); |
| 188 LOG(ERROR) << "Can not apply password change, master key failure"; | 188 LOG(ERROR) << "Can not apply password change, master key failure"; |
| 189 } | 189 } |
| 190 | 190 |
| 191 void ManagerPasswordService::OnAddKeySuccess( | 191 void ManagerPasswordService::OnAddKeySuccess( |
| 192 const UserContext& master_key_context, | 192 const UserContext& master_key_context, |
| 193 const std::string& user_id, | 193 const std::string& user_id, |
| 194 scoped_ptr<base::DictionaryValue> password_data) { | 194 std::unique_ptr<base::DictionaryValue> password_data) { |
| 195 VLOG(0) << "Password changed for " << user_id; | 195 VLOG(0) << "Password changed for " << user_id; |
| 196 UMA_HISTOGRAM_ENUMERATION( | 196 UMA_HISTOGRAM_ENUMERATION( |
| 197 "ManagedUsers.ChromeOS.PasswordChange", | 197 "ManagedUsers.ChromeOS.PasswordChange", |
| 198 SupervisedUserAuthentication::PASSWORD_CHANGED_IN_MANAGER_SESSION, | 198 SupervisedUserAuthentication::PASSWORD_CHANGED_IN_MANAGER_SESSION, |
| 199 SupervisedUserAuthentication::PASSWORD_CHANGE_RESULT_MAX_VALUE); | 199 SupervisedUserAuthentication::PASSWORD_CHANGE_RESULT_MAX_VALUE); |
| 200 | 200 |
| 201 SupervisedUserAuthentication* auth = | 201 SupervisedUserAuthentication* auth = |
| 202 ChromeUserManager::Get()->GetSupervisedUserManager()->GetAuthentication(); | 202 ChromeUserManager::Get()->GetSupervisedUserManager()->GetAuthentication(); |
| 203 int old_schema = auth->GetPasswordSchema(user_id); | 203 int old_schema = auth->GetPasswordSchema(user_id); |
| 204 auth->StorePasswordData(user_id, *password_data.get()); | 204 auth->StorePasswordData(user_id, *password_data.get()); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 const UserContext& master_key_context) { | 266 const UserContext& master_key_context) { |
| 267 VLOG(1) << "Removed old master key for " | 267 VLOG(1) << "Removed old master key for " |
| 268 << master_key_context.GetAccountId().GetUserEmail(); | 268 << master_key_context.GetAccountId().GetUserEmail(); |
| 269 } | 269 } |
| 270 | 270 |
| 271 void ManagerPasswordService::Shutdown() { | 271 void ManagerPasswordService::Shutdown() { |
| 272 settings_service_subscription_.reset(); | 272 settings_service_subscription_.reset(); |
| 273 } | 273 } |
| 274 | 274 |
| 275 } // namespace chromeos | 275 } // namespace chromeos |
| OLD | NEW |