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

Side by Side Diff: chrome/browser/managed_mode/chromeos/manager_password_service.cc

Issue 290483003: Tame the proliferation of UserContext constructors (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased. Created 6 years, 7 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 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/managed_mode/chromeos/manager_password_service.h" 5 #include "chrome/browser/managed_mode/chromeos/manager_password_service.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "chrome/browser/chromeos/login/managed/locally_managed_user_constants.h " 10 #include "chrome/browser/chromeos/login/managed/locally_managed_user_constants.h "
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 &encryption_key)) { 120 &encryption_key)) {
121 LOG(WARNING) << "Can not apply password change to " << user_id 121 LOG(WARNING) << "Can not apply password change to " << user_id
122 << ": no signature / encryption keys."; 122 << ": no signature / encryption keys.";
123 UMA_HISTOGRAM_ENUMERATION( 123 UMA_HISTOGRAM_ENUMERATION(
124 "ManagedUsers.ChromeOS.PasswordChange", 124 "ManagedUsers.ChromeOS.PasswordChange",
125 SupervisedUserAuthentication::PASSWORD_CHANGE_FAILED_NO_SIGNATURE_KEY, 125 SupervisedUserAuthentication::PASSWORD_CHANGE_FAILED_NO_SIGNATURE_KEY,
126 SupervisedUserAuthentication::PASSWORD_CHANGE_RESULT_MAX_VALUE); 126 SupervisedUserAuthentication::PASSWORD_CHANGE_RESULT_MAX_VALUE);
127 return; 127 return;
128 } 128 }
129 129
130 UserContext manager_key(user_id, master_key, std::string()); 130 UserContext manager_key(user_id);
131 manager_key.SetPassword(master_key);
131 manager_key.SetIsUsingOAuth(false); 132 manager_key.SetIsUsingOAuth(false);
132 133
133 // As master key can have old label, leave label field empty - it will work 134 // As master key can have old label, leave label field empty - it will work
134 // as wildcard. 135 // as wildcard.
135 136
136 std::string new_key; 137 std::string new_key;
137 int revision; 138 int revision;
138 139
139 bool has_data = password_data->GetStringWithoutPathExpansion( 140 bool has_data = password_data->GetStringWithoutPathExpansion(
140 kEncryptedPassword, &new_key); 141 kEncryptedPassword, &new_key);
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 } 210 }
210 } 211 }
211 212
212 void ManagerPasswordService::OnContextTransformed( 213 void ManagerPasswordService::OnContextTransformed(
213 const UserContext& master_key_context) { 214 const UserContext& master_key_context) {
214 DCHECK(!master_key_context.DoesNeedPasswordHashing()); 215 DCHECK(!master_key_context.DoesNeedPasswordHashing());
215 cryptohome::KeyDefinition new_master_key(master_key_context.GetPassword(), 216 cryptohome::KeyDefinition new_master_key(master_key_context.GetPassword(),
216 kCryptohomeMasterKeyLabel, 217 kCryptohomeMasterKeyLabel,
217 cryptohome::PRIV_DEFAULT); 218 cryptohome::PRIV_DEFAULT);
218 // Use new master key for further actions. 219 // Use new master key for further actions.
219 UserContext new_master_key_context; 220 UserContext new_master_key_context = master_key_context;
220 new_master_key_context.CopyFrom(master_key_context);
221 new_master_key_context.SetKeyLabel(kCryptohomeMasterKeyLabel); 221 new_master_key_context.SetKeyLabel(kCryptohomeMasterKeyLabel);
222 authenticator_->AddKey( 222 authenticator_->AddKey(
223 master_key_context, 223 master_key_context,
224 new_master_key, 224 new_master_key,
225 true /* replace existing */, 225 true /* replace existing */,
226 base::Bind(&ManagerPasswordService::OnNewManagerKeySuccess, 226 base::Bind(&ManagerPasswordService::OnNewManagerKeySuccess,
227 weak_ptr_factory_.GetWeakPtr(), 227 weak_ptr_factory_.GetWeakPtr(),
228 new_master_key_context)); 228 new_master_key_context));
229 } 229 }
230 230
(...skipping 23 matching lines...) Expand all
254 void ManagerPasswordService::OnOldManagerKeyDeleted( 254 void ManagerPasswordService::OnOldManagerKeyDeleted(
255 const UserContext& master_key_context) { 255 const UserContext& master_key_context) {
256 VLOG(1) << "Removed old master key for " << master_key_context.GetUserID(); 256 VLOG(1) << "Removed old master key for " << master_key_context.GetUserID();
257 } 257 }
258 258
259 void ManagerPasswordService::Shutdown() { 259 void ManagerPasswordService::Shutdown() {
260 settings_service_subscription_.reset(); 260 settings_service_subscription_.reset();
261 } 261 }
262 262
263 } // namespace chromeos 263 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698