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

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

Issue 1165323004: We should use UserID object to identify users instead of username. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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
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 #ifndef CHROME_BROWSER_SUPERVISED_USER_CHROMEOS_MANAGER_PASSWORD_SERVICE_H_ 5 #ifndef CHROME_BROWSER_SUPERVISED_USER_CHROMEOS_MANAGER_PASSWORD_SERVICE_H_
6 #define CHROME_BROWSER_SUPERVISED_USER_CHROMEOS_MANAGER_PASSWORD_SERVICE_H_ 6 #define CHROME_BROWSER_SUPERVISED_USER_CHROMEOS_MANAGER_PASSWORD_SERVICE_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "chrome/browser/supervised_user/legacy/supervised_user_shared_settings_ service.h" 13 #include "chrome/browser/supervised_user/legacy/supervised_user_shared_settings_ service.h"
14 #include "chrome/browser/supervised_user/legacy/supervised_user_sync_service.h" 14 #include "chrome/browser/supervised_user/legacy/supervised_user_sync_service.h"
15 #include "chrome/browser/supervised_user/supervised_users.h" 15 #include "chrome/browser/supervised_user/supervised_users.h"
16 #include "chromeos/login/auth/extended_authenticator.h" 16 #include "chromeos/login/auth/extended_authenticator.h"
17 #include "components/keyed_service/core/keyed_service.h" 17 #include "components/keyed_service/core/keyed_service.h"
18 #include "components/user_manager/user_id.h"
19
18 20
19 namespace chromeos { 21 namespace chromeos {
20 22
21 class UserContext; 23 class UserContext;
22 24
23 // Handles supervised user password change that is detected while manager is 25 // Handles supervised user password change that is detected while manager is
24 // signed in. 26 // signed in.
25 // It uses manager's master key to authorize update of supervised user's key. 27 // It uses manager's master key to authorize update of supervised user's key.
26 // Edge case: Pre-M35 supervised users don't have correct labels for keys. 28 // Edge case: Pre-M35 supervised users don't have correct labels for keys.
27 // After new supervised user key is added, migration is done in following way: 29 // After new supervised user key is added, migration is done in following way:
28 // 1) Master key is added with correct label 30 // 1) Master key is added with correct label
29 // 2) Old supervised user's key is deleted. 31 // 2) Old supervised user's key is deleted.
30 // 3) Old master key is deleted. 32 // 3) Old master key is deleted.
31 class ManagerPasswordService 33 class ManagerPasswordService
32 : public KeyedService, 34 : public KeyedService,
33 public chromeos::ExtendedAuthenticator::NewAuthStatusConsumer { 35 public chromeos::ExtendedAuthenticator::NewAuthStatusConsumer {
34 public: 36 public:
35 ManagerPasswordService(); 37 ManagerPasswordService();
36 ~ManagerPasswordService() override; 38 ~ManagerPasswordService() override;
37 39
38 void Shutdown() override; 40 void Shutdown() override;
39 41
40 void Init(const std::string& user_id, 42 void Init(const user_manager::UserID& user_id,
41 SupervisedUserSyncService* user_service, 43 SupervisedUserSyncService* user_service,
42 SupervisedUserSharedSettingsService* service); 44 SupervisedUserSharedSettingsService* service);
43 45
44 // chromeos::ExtendedAuthenticator::AuthStatusConsumer overrides: 46 // chromeos::ExtendedAuthenticator::AuthStatusConsumer overrides:
45 void OnAuthenticationFailure(ExtendedAuthenticator::AuthState state) override; 47 void OnAuthenticationFailure(ExtendedAuthenticator::AuthState state) override;
46 48
47 private: 49 private:
48 void OnSharedSettingsChange(const std::string& su_id, const std::string& key); 50 void OnSharedSettingsChange(const std::string& su_id, const std::string& key);
49 void GetSupervisedUsersCallback( 51 void GetSupervisedUsersCallback(
50 const std::string& sync_su_id, 52 const std::string& sync_su_id,
51 const std::string& user_id, 53 const user_manager::UserID& user_id,
52 scoped_ptr<base::DictionaryValue> password_data, 54 scoped_ptr<base::DictionaryValue> password_data,
53 const base::DictionaryValue* supervised_users); 55 const base::DictionaryValue* supervised_users);
54 void OnAddKeySuccess(const UserContext& master_key_context, 56 void OnAddKeySuccess(const UserContext& master_key_context,
55 const std::string& user_id, 57 const user_manager::UserID& user_id,
56 scoped_ptr<base::DictionaryValue> password_data); 58 scoped_ptr<base::DictionaryValue> password_data);
57 void OnKeyTransformedIfNeeded(const UserContext& master_key_context); 59 void OnKeyTransformedIfNeeded(const UserContext& master_key_context);
58 void OnNewManagerKeySuccess(const UserContext& master_key_context); 60 void OnNewManagerKeySuccess(const UserContext& master_key_context);
59 void OnOldSupervisedUserKeyDeleted(const UserContext& master_key_context); 61 void OnOldSupervisedUserKeyDeleted(const UserContext& master_key_context);
60 void OnOldManagerKeyDeleted(const UserContext& master_key_context); 62 void OnOldManagerKeyDeleted(const UserContext& master_key_context);
61 63
62 // Cached value from Init(). 64 // Cached value from Init().
63 // User id of currently logged in user, that have supervised users on device. 65 // User id of currently logged in user, that have supervised users on device.
64 std::string user_id_; 66 user_manager::UserID user_id_;
65 SupervisedUserSyncService* user_service_; 67 SupervisedUserSyncService* user_service_;
66 SupervisedUserSharedSettingsService* settings_service_; 68 SupervisedUserSharedSettingsService* settings_service_;
67 69
68 scoped_ptr<SupervisedUserSharedSettingsService::ChangeCallbackList:: 70 scoped_ptr<SupervisedUserSharedSettingsService::ChangeCallbackList::
69 Subscription> 71 Subscription>
70 settings_service_subscription_; 72 settings_service_subscription_;
71 73
72 scoped_refptr<ExtendedAuthenticator> authenticator_; 74 scoped_refptr<ExtendedAuthenticator> authenticator_;
73 75
74 base::WeakPtrFactory<ManagerPasswordService> weak_ptr_factory_; 76 base::WeakPtrFactory<ManagerPasswordService> weak_ptr_factory_;
75 77
76 DISALLOW_COPY_AND_ASSIGN(ManagerPasswordService); 78 DISALLOW_COPY_AND_ASSIGN(ManagerPasswordService);
77 }; 79 };
78 80
79 } // namespace chromeos 81 } // namespace chromeos
80 #endif // CHROME_BROWSER_SUPERVISED_USER_CHROMEOS_MANAGER_PASSWORD_SERVICE_H_ 82 #endif // CHROME_BROWSER_SUPERVISED_USER_CHROMEOS_MANAGER_PASSWORD_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698