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

Side by Side Diff: chrome/browser/chromeos/login/users/multi_profile_user_controller.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_CHROMEOS_LOGIN_USERS_MULTI_PROFILE_USER_CONTROLLER_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_USERS_MULTI_PROFILE_USER_CONTROLLER_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_USERS_MULTI_PROFILE_USER_CONTROLLER_H_ 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_USERS_MULTI_PROFILE_USER_CONTROLLER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/memory/scoped_vector.h" 11 #include "base/memory/scoped_vector.h"
12 12
13 class PrefChangeRegistrar; 13 class PrefChangeRegistrar;
14 class PrefRegistrySimple; 14 class PrefRegistrySimple;
15 class PrefService; 15 class PrefService;
16 class Profile; 16 class Profile;
17 17
18 namespace user_manager {
19 class UserID;
20 }
21
18 namespace user_prefs { 22 namespace user_prefs {
19 class PrefRegistrySyncable; 23 class PrefRegistrySyncable;
20 } 24 }
21 25
22 namespace chromeos { 26 namespace chromeos {
23 27
24 class MultiProfileUserControllerDelegate; 28 class MultiProfileUserControllerDelegate;
25 class UserManager; 29 class UserManager;
26 30
27 // MultiProfileUserController decides whether a user is allowed to be in a 31 // MultiProfileUserController decides whether a user is allowed to be in a
(...skipping 27 matching lines...) Expand all
55 NOT_ALLOWED_POLICY_FORBIDS 59 NOT_ALLOWED_POLICY_FORBIDS
56 }; 60 };
57 61
58 MultiProfileUserController(MultiProfileUserControllerDelegate* delegate, 62 MultiProfileUserController(MultiProfileUserControllerDelegate* delegate,
59 PrefService* local_state); 63 PrefService* local_state);
60 ~MultiProfileUserController(); 64 ~MultiProfileUserController();
61 65
62 static void RegisterPrefs(PrefRegistrySimple* registry); 66 static void RegisterPrefs(PrefRegistrySimple* registry);
63 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); 67 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
64 68
65 // Returns the cached policy value for |user_email|. 69 // Returns the cached policy value for |user_id|.
66 std::string GetCachedValue(const std::string& user_email) const; 70 std::string GetCachedValue(const user_manager::UserID& user_id) const;
67 71
68 // Returns primary user policy (only ALLOW, 72 // Returns primary user policy (only ALLOW,
69 // NOT_ALLOWED_PRIMARY_POLICY_CERT_TAINTED, 73 // NOT_ALLOWED_PRIMARY_POLICY_CERT_TAINTED,
70 // NOT_ALLOWED_PRIMARY_USER_POLICY_FORBIDS) 74 // NOT_ALLOWED_PRIMARY_USER_POLICY_FORBIDS)
71 static UserAllowedInSessionReason GetPrimaryUserPolicy(); 75 static UserAllowedInSessionReason GetPrimaryUserPolicy();
72 76
73 // Returns true if user allowed to be in the current session. If |reason| not 77 // Returns true if user allowed to be in the current session. If |reason| not
74 // null stores UserAllowedInSessionReason enum that describes actual reason. 78 // null stores UserAllowedInSessionReason enum that describes actual reason.
75 bool IsUserAllowedInSession(const std::string& user_email, 79 bool IsUserAllowedInSession(const user_manager::UserID& user_id,
76 UserAllowedInSessionReason* reason) const; 80 UserAllowedInSessionReason* reason) const;
77 81
78 // Starts to observe the multiprofile user behavior pref of the given profile. 82 // Starts to observe the multiprofile user behavior pref of the given profile.
79 void StartObserving(Profile* user_profile); 83 void StartObserving(Profile* user_profile);
80 84
81 // Removes the cached values for the given user. 85 // Removes the cached values for the given user.
82 void RemoveCachedValues(const std::string& user_email); 86 void RemoveCachedValues(const user_manager::UserID& user_id);
83 87
84 // Possible behavior values. 88 // Possible behavior values.
85 static const char kBehaviorUnrestricted[]; 89 static const char kBehaviorUnrestricted[];
86 static const char kBehaviorPrimaryOnly[]; 90 static const char kBehaviorPrimaryOnly[];
87 static const char kBehaviorNotAllowed[]; 91 static const char kBehaviorNotAllowed[];
88 static const char kBehaviorOwnerPrimaryOnly[]; 92 static const char kBehaviorOwnerPrimaryOnly[];
89 93
90 private: 94 private:
91 friend class MultiProfileUserControllerTest; 95 friend class MultiProfileUserControllerTest;
92 96
93 // Sets the cached policy value. 97 // Sets the cached policy value.
94 void SetCachedValue(const std::string& user_email, 98 void SetCachedValue(const user_manager::UserID& user_id,
95 const std::string& behavior); 99 const std::string& behavior);
96 100
97 // Checks if all users are allowed in the current session. 101 // Checks if all users are allowed in the current session.
98 void CheckSessionUsers(); 102 void CheckSessionUsers();
99 103
100 // Invoked when user behavior pref value changes. 104 // Invoked when user behavior pref value changes.
101 void OnUserPrefChanged(Profile* profile); 105 void OnUserPrefChanged(Profile* profile);
102 106
103 MultiProfileUserControllerDelegate* delegate_; // Not owned. 107 MultiProfileUserControllerDelegate* delegate_; // Not owned.
104 PrefService* local_state_; // Not owned. 108 PrefService* local_state_; // Not owned.
105 ScopedVector<PrefChangeRegistrar> pref_watchers_; 109 ScopedVector<PrefChangeRegistrar> pref_watchers_;
106 110
107 DISALLOW_COPY_AND_ASSIGN(MultiProfileUserController); 111 DISALLOW_COPY_AND_ASSIGN(MultiProfileUserController);
108 }; 112 };
109 113
110 } // namespace chromeos 114 } // namespace chromeos
111 115
112 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USERS_MULTI_PROFILE_USER_CONTROLLER_H_ 116 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USERS_MULTI_PROFILE_USER_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698