OLD | NEW |
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 <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
| 12 #include "ash/public/interfaces/login_user_info.mojom.h" |
12 #include "base/macros.h" | 13 #include "base/macros.h" |
13 | 14 |
14 class PrefChangeRegistrar; | 15 class PrefChangeRegistrar; |
15 class PrefRegistrySimple; | 16 class PrefRegistrySimple; |
16 class PrefService; | 17 class PrefService; |
17 class Profile; | 18 class Profile; |
18 | 19 |
19 namespace user_prefs { | 20 namespace user_prefs { |
20 class PrefRegistrySyncable; | 21 class PrefRegistrySyncable; |
21 } | 22 } |
(...skipping 26 matching lines...) Expand all Loading... |
48 | 49 |
49 // Not allowed since primary user policy forbids it to be part of | 50 // Not allowed since primary user policy forbids it to be part of |
50 // multi-profiles session. | 51 // multi-profiles session. |
51 NOT_ALLOWED_PRIMARY_USER_POLICY_FORBIDS, | 52 NOT_ALLOWED_PRIMARY_USER_POLICY_FORBIDS, |
52 | 53 |
53 // Not allowed since user policy forbids this user being part of | 54 // Not allowed since user policy forbids this user being part of |
54 // multi-profiles session. Either 'primary-only' or 'not-allowed'. | 55 // multi-profiles session. Either 'primary-only' or 'not-allowed'. |
55 NOT_ALLOWED_POLICY_FORBIDS | 56 NOT_ALLOWED_POLICY_FORBIDS |
56 }; | 57 }; |
57 | 58 |
58 // Supported user behavior values. Keep in sync with the enum in | |
59 // md_user_pod_row.js and user_pod_row.js | |
60 enum class MultiProfileUserBehavior { | |
61 kUnrestriced, | |
62 kPrimaryOnly, | |
63 kNotAllowed, | |
64 kOwnerPrimaryOnly | |
65 }; | |
66 | |
67 MultiProfileUserController(MultiProfileUserControllerDelegate* delegate, | 59 MultiProfileUserController(MultiProfileUserControllerDelegate* delegate, |
68 PrefService* local_state); | 60 PrefService* local_state); |
69 ~MultiProfileUserController(); | 61 ~MultiProfileUserController(); |
70 | 62 |
71 static void RegisterPrefs(PrefRegistrySimple* registry); | 63 static void RegisterPrefs(PrefRegistrySimple* registry); |
72 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); | 64 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
73 | 65 |
74 // Returns the cached policy value for |user_email|. | 66 // Returns the cached policy value for |user_email|. |
75 std::string GetCachedValue(const std::string& user_email) const; | 67 std::string GetCachedValue(const std::string& user_email) const; |
76 | 68 |
77 // Returns primary user policy (only ALLOW, | 69 // Returns primary user policy (only ALLOW, |
78 // NOT_ALLOWED_PRIMARY_POLICY_CERT_TAINTED, | 70 // NOT_ALLOWED_PRIMARY_POLICY_CERT_TAINTED, |
79 // NOT_ALLOWED_PRIMARY_USER_POLICY_FORBIDS) | 71 // NOT_ALLOWED_PRIMARY_USER_POLICY_FORBIDS) |
80 static UserAllowedInSessionReason GetPrimaryUserPolicy(); | 72 static UserAllowedInSessionReason GetPrimaryUserPolicy(); |
81 | 73 |
82 // Returns the user behavior in MultiProfileUserBehavior enum. | 74 // Returns the user behavior in MultiProfileUserBehavior enum. |
83 static MultiProfileUserBehavior UserBehaviorStringToEnum( | 75 static ash::mojom::MultiProfileUserBehavior UserBehaviorStringToEnum( |
84 const std::string& behavior); | 76 const std::string& behavior); |
85 | 77 |
86 // Returns true if user allowed to be in the current session. If |reason| not | 78 // Returns true if user allowed to be in the current session. If |reason| not |
87 // null stores UserAllowedInSessionReason enum that describes actual reason. | 79 // null stores UserAllowedInSessionReason enum that describes actual reason. |
88 bool IsUserAllowedInSession(const std::string& user_email, | 80 bool IsUserAllowedInSession(const std::string& user_email, |
89 UserAllowedInSessionReason* reason) const; | 81 UserAllowedInSessionReason* reason) const; |
90 | 82 |
91 // Starts to observe the multiprofile user behavior pref of the given profile. | 83 // Starts to observe the multiprofile user behavior pref of the given profile. |
92 void StartObserving(Profile* user_profile); | 84 void StartObserving(Profile* user_profile); |
93 | 85 |
(...skipping 22 matching lines...) Expand all Loading... |
116 MultiProfileUserControllerDelegate* delegate_; // Not owned. | 108 MultiProfileUserControllerDelegate* delegate_; // Not owned. |
117 PrefService* local_state_; // Not owned. | 109 PrefService* local_state_; // Not owned. |
118 std::vector<std::unique_ptr<PrefChangeRegistrar>> pref_watchers_; | 110 std::vector<std::unique_ptr<PrefChangeRegistrar>> pref_watchers_; |
119 | 111 |
120 DISALLOW_COPY_AND_ASSIGN(MultiProfileUserController); | 112 DISALLOW_COPY_AND_ASSIGN(MultiProfileUserController); |
121 }; | 113 }; |
122 | 114 |
123 } // namespace chromeos | 115 } // namespace chromeos |
124 | 116 |
125 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USERS_MULTI_PROFILE_USER_CONTROLLER_H_ | 117 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_USERS_MULTI_PROFILE_USER_CONTROLLER_H_ |
OLD | NEW |