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

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

Issue 375413002: Replace chromeos::UserManager::Get() with chromeos::GetUserManager(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix test Created 6 years, 5 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/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 20 matching lines...) Expand all
31 SupervisedUserSharedSettingsService* shared_settings_service) { 31 SupervisedUserSharedSettingsService* shared_settings_service) {
32 user_id_ = user_id; 32 user_id_ = user_id;
33 user_service_ = user_service; 33 user_service_ = user_service;
34 settings_service_ = shared_settings_service; 34 settings_service_ = shared_settings_service;
35 settings_service_subscription_ = settings_service_->Subscribe( 35 settings_service_subscription_ = settings_service_->Subscribe(
36 base::Bind(&ManagerPasswordService::OnSharedSettingsChange, 36 base::Bind(&ManagerPasswordService::OnSharedSettingsChange,
37 weak_ptr_factory_.GetWeakPtr())); 37 weak_ptr_factory_.GetWeakPtr()));
38 38
39 authenticator_ = new ExtendedAuthenticator(this); 39 authenticator_ = new ExtendedAuthenticator(this);
40 40
41 UserManager* user_manager = UserManager::Get(); 41 UserManager* user_manager = GetUserManager();
42 42
43 SupervisedUserManager* supervised_user_manager = 43 SupervisedUserManager* supervised_user_manager =
44 user_manager->GetSupervisedUserManager(); 44 user_manager->GetSupervisedUserManager();
45 45
46 const UserList& users = user_manager->GetUsers(); 46 const UserList& users = user_manager->GetUsers();
47 47
48 for (UserList::const_iterator it = users.begin(); it != users.end(); ++it) { 48 for (UserList::const_iterator it = users.begin(); it != users.end(); ++it) {
49 if ((*it)->GetType() != user_manager::USER_TYPE_LOCALLY_MANAGED) 49 if ((*it)->GetType() != user_manager::USER_TYPE_LOCALLY_MANAGED)
50 continue; 50 continue;
51 if (user_id != supervised_user_manager->GetManagerUserId((*it)->email())) 51 if (user_id != supervised_user_manager->GetManagerUserId((*it)->email()))
52 continue; 52 continue;
53 OnSharedSettingsChange( 53 OnSharedSettingsChange(
54 supervised_user_manager->GetUserSyncId((*it)->email()), 54 supervised_user_manager->GetUserSyncId((*it)->email()),
55 supervised_users::kChromeOSPasswordData); 55 supervised_users::kChromeOSPasswordData);
56 } 56 }
57 } 57 }
58 58
59 void ManagerPasswordService::OnSharedSettingsChange( 59 void ManagerPasswordService::OnSharedSettingsChange(
60 const std::string& su_id, 60 const std::string& su_id,
61 const std::string& key) { 61 const std::string& key) {
62 if (key != supervised_users::kChromeOSPasswordData) 62 if (key != supervised_users::kChromeOSPasswordData)
63 return; 63 return;
64 64
65 SupervisedUserManager* supervised_user_manager = 65 SupervisedUserManager* supervised_user_manager =
66 UserManager::Get()->GetSupervisedUserManager(); 66 GetUserManager()->GetSupervisedUserManager();
67 const User* user = supervised_user_manager->FindBySyncId(su_id); 67 const User* user = supervised_user_manager->FindBySyncId(su_id);
68 // No user on device. 68 // No user on device.
69 if (user == NULL) 69 if (user == NULL)
70 return; 70 return;
71 71
72 const base::Value* value = settings_service_->GetValue(su_id, key); 72 const base::Value* value = settings_service_->GetValue(su_id, key);
73 73
74 if (value == NULL) { 74 if (value == NULL) {
75 LOG(WARNING) << "Got empty value from sync."; 75 LOG(WARNING) << "Got empty value from sync.";
76 return; 76 return;
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 const UserContext& master_key_context, 189 const UserContext& master_key_context,
190 const std::string& user_id, 190 const std::string& user_id,
191 scoped_ptr<base::DictionaryValue> password_data) { 191 scoped_ptr<base::DictionaryValue> password_data) {
192 VLOG(0) << "Password changed for " << user_id; 192 VLOG(0) << "Password changed for " << user_id;
193 UMA_HISTOGRAM_ENUMERATION( 193 UMA_HISTOGRAM_ENUMERATION(
194 "ManagedUsers.ChromeOS.PasswordChange", 194 "ManagedUsers.ChromeOS.PasswordChange",
195 SupervisedUserAuthentication::PASSWORD_CHANGED_IN_MANAGER_SESSION, 195 SupervisedUserAuthentication::PASSWORD_CHANGED_IN_MANAGER_SESSION,
196 SupervisedUserAuthentication::PASSWORD_CHANGE_RESULT_MAX_VALUE); 196 SupervisedUserAuthentication::PASSWORD_CHANGE_RESULT_MAX_VALUE);
197 197
198 SupervisedUserAuthentication* auth = 198 SupervisedUserAuthentication* auth =
199 UserManager::Get()->GetSupervisedUserManager()->GetAuthentication(); 199 GetUserManager()->GetSupervisedUserManager()->GetAuthentication();
200 int old_schema = auth->GetPasswordSchema(user_id); 200 int old_schema = auth->GetPasswordSchema(user_id);
201 auth->StorePasswordData(user_id, *password_data.get()); 201 auth->StorePasswordData(user_id, *password_data.get());
202 202
203 if (auth->HasIncompleteKey(user_id)) 203 if (auth->HasIncompleteKey(user_id))
204 auth->MarkKeyIncomplete(user_id, false /* key is complete now */); 204 auth->MarkKeyIncomplete(user_id, false /* key is complete now */);
205 205
206 // Check if we have legacy labels for keys. 206 // Check if we have legacy labels for keys.
207 // TODO(antrim): Migrate it to GetLabels call once wad@ implement it. 207 // TODO(antrim): Migrate it to GetLabels call once wad@ implement it.
208 if (old_schema == SupervisedUserAuthentication::SCHEMA_PLAIN) { 208 if (old_schema == SupervisedUserAuthentication::SCHEMA_PLAIN) {
209 // 1) Add new manager key (using old key). 209 // 1) Add new manager key (using old key).
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 void ManagerPasswordService::OnOldManagerKeyDeleted( 261 void ManagerPasswordService::OnOldManagerKeyDeleted(
262 const UserContext& master_key_context) { 262 const UserContext& master_key_context) {
263 VLOG(1) << "Removed old master key for " << master_key_context.GetUserID(); 263 VLOG(1) << "Removed old master key for " << master_key_context.GetUserID();
264 } 264 }
265 265
266 void ManagerPasswordService::Shutdown() { 266 void ManagerPasswordService::Shutdown() {
267 settings_service_subscription_.reset(); 267 settings_service_subscription_.reset();
268 } 268 }
269 269
270 } // namespace chromeos 270 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698