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

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

Issue 398753004: [cros] Move User class to user_manager component. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase 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"
11 #include "chrome/browser/chromeos/login/supervised/supervised_user_authenticatio n.h" 11 #include "chrome/browser/chromeos/login/supervised/supervised_user_authenticatio n.h"
12 #include "chrome/browser/chromeos/login/supervised/supervised_user_constants.h" 12 #include "chrome/browser/chromeos/login/supervised/supervised_user_constants.h"
13 #include "chrome/browser/chromeos/login/users/supervised_user_manager.h" 13 #include "chrome/browser/chromeos/login/users/supervised_user_manager.h"
14 #include "chrome/browser/chromeos/login/users/user.h"
15 #include "chrome/browser/chromeos/login/users/user_manager.h" 14 #include "chrome/browser/chromeos/login/users/user_manager.h"
16 #include "chrome/browser/supervised_user/supervised_user_constants.h" 15 #include "chrome/browser/supervised_user/supervised_user_constants.h"
17 #include "chrome/browser/supervised_user/supervised_user_sync_service.h" 16 #include "chrome/browser/supervised_user/supervised_user_sync_service.h"
18 #include "chromeos/login/auth/key.h" 17 #include "chromeos/login/auth/key.h"
19 #include "chromeos/login/auth/user_context.h" 18 #include "chromeos/login/auth/user_context.h"
19 #include "components/user_manager/user.h"
20 #include "components/user_manager/user_type.h" 20 #include "components/user_manager/user_type.h"
21 21
22 namespace chromeos { 22 namespace chromeos {
23 23
24 ManagerPasswordService::ManagerPasswordService() : weak_ptr_factory_(this) {} 24 ManagerPasswordService::ManagerPasswordService() : weak_ptr_factory_(this) {}
25 25
26 ManagerPasswordService::~ManagerPasswordService() {} 26 ManagerPasswordService::~ManagerPasswordService() {}
27 27
28 void ManagerPasswordService::Init( 28 void ManagerPasswordService::Init(
29 const std::string& user_id, 29 const std::string& user_id,
30 SupervisedUserSyncService* user_service, 30 SupervisedUserSyncService* user_service,
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 = UserManager::Get();
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 user_manager::UserList& users = user_manager->GetUsers();
47 47
48 for (UserList::const_iterator it = users.begin(); it != users.end(); ++it) { 48 for (user_manager::UserList::const_iterator it = users.begin();
49 it != users.end();
50 ++it) {
49 if ((*it)->GetType() != user_manager::USER_TYPE_SUPERVISED) 51 if ((*it)->GetType() != user_manager::USER_TYPE_SUPERVISED)
50 continue; 52 continue;
51 if (user_id != supervised_user_manager->GetManagerUserId((*it)->email())) 53 if (user_id != supervised_user_manager->GetManagerUserId((*it)->email()))
52 continue; 54 continue;
53 OnSharedSettingsChange( 55 OnSharedSettingsChange(
54 supervised_user_manager->GetUserSyncId((*it)->email()), 56 supervised_user_manager->GetUserSyncId((*it)->email()),
55 supervised_users::kChromeOSPasswordData); 57 supervised_users::kChromeOSPasswordData);
56 } 58 }
57 } 59 }
58 60
59 void ManagerPasswordService::OnSharedSettingsChange( 61 void ManagerPasswordService::OnSharedSettingsChange(
60 const std::string& su_id, 62 const std::string& su_id,
61 const std::string& key) { 63 const std::string& key) {
62 if (key != supervised_users::kChromeOSPasswordData) 64 if (key != supervised_users::kChromeOSPasswordData)
63 return; 65 return;
64 66
65 SupervisedUserManager* supervised_user_manager = 67 SupervisedUserManager* supervised_user_manager =
66 UserManager::Get()->GetSupervisedUserManager(); 68 UserManager::Get()->GetSupervisedUserManager();
67 const User* user = supervised_user_manager->FindBySyncId(su_id); 69 const user_manager::User* user = supervised_user_manager->FindBySyncId(su_id);
68 // No user on device. 70 // No user on device.
69 if (user == NULL) 71 if (user == NULL)
70 return; 72 return;
71 73
72 const base::Value* value = settings_service_->GetValue(su_id, key); 74 const base::Value* value = settings_service_->GetValue(su_id, key);
73 75
74 if (value == NULL) { 76 if (value == NULL) {
75 LOG(WARNING) << "Got empty value from sync."; 77 LOG(WARNING) << "Got empty value from sync.";
76 return; 78 return;
77 } 79 }
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 void ManagerPasswordService::OnOldManagerKeyDeleted( 263 void ManagerPasswordService::OnOldManagerKeyDeleted(
262 const UserContext& master_key_context) { 264 const UserContext& master_key_context) {
263 VLOG(1) << "Removed old master key for " << master_key_context.GetUserID(); 265 VLOG(1) << "Removed old master key for " << master_key_context.GetUserID();
264 } 266 }
265 267
266 void ManagerPasswordService::Shutdown() { 268 void ManagerPasswordService::Shutdown() {
267 settings_service_subscription_.reset(); 269 settings_service_subscription_.reset();
268 } 270 }
269 271
270 } // namespace chromeos 272 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698