| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 ASH_PUBLIC_INTERFACES_SESSION_CONTROLLER_TRAITS_H_ | 5 #ifndef ASH_PUBLIC_INTERFACES_SESSION_CONTROLLER_TRAITS_H_ |
| 6 #define ASH_PUBLIC_INTERFACES_SESSION_CONTROLLER_TRAITS_H_ | 6 #define ASH_PUBLIC_INTERFACES_SESSION_CONTROLLER_TRAITS_H_ |
| 7 | 7 |
| 8 #include "ash/public/cpp/session_types.h" | 8 #include "ash/public/cpp/session_types.h" |
| 9 #include "ash/public/interfaces/session_controller.mojom.h" | 9 #include "ash/public/interfaces/session_controller.mojom.h" |
| 10 #include "components/session_manager/session_manager_types.h" | 10 #include "components/session_manager/session_manager_types.h" |
| 11 #include "components/user_manager/user_type.h" | |
| 12 | 11 |
| 13 namespace mojo { | 12 namespace mojo { |
| 14 | 13 |
| 15 template <> | 14 template <> |
| 16 struct EnumTraits<ash::mojom::SessionState, session_manager::SessionState> { | 15 struct EnumTraits<ash::mojom::SessionState, session_manager::SessionState> { |
| 17 static ash::mojom::SessionState ToMojom(session_manager::SessionState input) { | 16 static ash::mojom::SessionState ToMojom(session_manager::SessionState input) { |
| 18 switch (input) { | 17 switch (input) { |
| 19 case session_manager::SessionState::UNKNOWN: | 18 case session_manager::SessionState::UNKNOWN: |
| 20 return ash::mojom::SessionState::UNKNOWN; | 19 return ash::mojom::SessionState::UNKNOWN; |
| 21 case session_manager::SessionState::OOBE: | 20 case session_manager::SessionState::OOBE: |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 case ash::mojom::SessionState::LOGIN_SECONDARY: | 58 case ash::mojom::SessionState::LOGIN_SECONDARY: |
| 60 *out = session_manager::SessionState::LOGIN_SECONDARY; | 59 *out = session_manager::SessionState::LOGIN_SECONDARY; |
| 61 return true; | 60 return true; |
| 62 } | 61 } |
| 63 NOTREACHED(); | 62 NOTREACHED(); |
| 64 return false; | 63 return false; |
| 65 } | 64 } |
| 66 }; | 65 }; |
| 67 | 66 |
| 68 template <> | 67 template <> |
| 69 struct EnumTraits<ash::mojom::UserType, user_manager::UserType> { | |
| 70 static ash::mojom::UserType ToMojom(user_manager::UserType input) { | |
| 71 switch (input) { | |
| 72 case user_manager::USER_TYPE_REGULAR: | |
| 73 return ash::mojom::UserType::REGULAR; | |
| 74 case user_manager::USER_TYPE_GUEST: | |
| 75 return ash::mojom::UserType::GUEST; | |
| 76 case user_manager::USER_TYPE_PUBLIC_ACCOUNT: | |
| 77 return ash::mojom::UserType::PUBLIC_ACCOUNT; | |
| 78 case user_manager::USER_TYPE_SUPERVISED: | |
| 79 return ash::mojom::UserType::SUPERVISED; | |
| 80 case user_manager::USER_TYPE_KIOSK_APP: | |
| 81 return ash::mojom::UserType::KIOSK; | |
| 82 case user_manager::USER_TYPE_CHILD: | |
| 83 return ash::mojom::UserType::CHILD; | |
| 84 case user_manager::USER_TYPE_ARC_KIOSK_APP: | |
| 85 return ash::mojom::UserType::ARC_KIOSK; | |
| 86 case user_manager::USER_TYPE_ACTIVE_DIRECTORY: | |
| 87 return ash::mojom::UserType::ACTIVE_DIRECTORY; | |
| 88 case user_manager::NUM_USER_TYPES: | |
| 89 // Bail as this is not a valid user type. | |
| 90 break; | |
| 91 } | |
| 92 NOTREACHED(); | |
| 93 return ash::mojom::UserType::REGULAR; | |
| 94 } | |
| 95 | |
| 96 static bool FromMojom(ash::mojom::UserType input, | |
| 97 user_manager::UserType* out) { | |
| 98 switch (input) { | |
| 99 case ash::mojom::UserType::REGULAR: | |
| 100 *out = user_manager::USER_TYPE_REGULAR; | |
| 101 return true; | |
| 102 case ash::mojom::UserType::GUEST: | |
| 103 *out = user_manager::USER_TYPE_GUEST; | |
| 104 return true; | |
| 105 case ash::mojom::UserType::PUBLIC_ACCOUNT: | |
| 106 *out = user_manager::USER_TYPE_PUBLIC_ACCOUNT; | |
| 107 return true; | |
| 108 case ash::mojom::UserType::SUPERVISED: | |
| 109 *out = user_manager::USER_TYPE_SUPERVISED; | |
| 110 return true; | |
| 111 case ash::mojom::UserType::KIOSK: | |
| 112 *out = user_manager::USER_TYPE_KIOSK_APP; | |
| 113 return true; | |
| 114 case ash::mojom::UserType::CHILD: | |
| 115 *out = user_manager::USER_TYPE_CHILD; | |
| 116 return true; | |
| 117 case ash::mojom::UserType::ARC_KIOSK: | |
| 118 *out = user_manager::USER_TYPE_ARC_KIOSK_APP; | |
| 119 return true; | |
| 120 case ash::mojom::UserType::ACTIVE_DIRECTORY: | |
| 121 *out = user_manager::USER_TYPE_ACTIVE_DIRECTORY; | |
| 122 return true; | |
| 123 } | |
| 124 NOTREACHED(); | |
| 125 return false; | |
| 126 } | |
| 127 }; | |
| 128 | |
| 129 template <> | |
| 130 struct EnumTraits<ash::mojom::AddUserSessionPolicy, ash::AddUserSessionPolicy> { | 68 struct EnumTraits<ash::mojom::AddUserSessionPolicy, ash::AddUserSessionPolicy> { |
| 131 static ash::mojom::AddUserSessionPolicy ToMojom( | 69 static ash::mojom::AddUserSessionPolicy ToMojom( |
| 132 ash::AddUserSessionPolicy input) { | 70 ash::AddUserSessionPolicy input) { |
| 133 switch (input) { | 71 switch (input) { |
| 134 case ash::AddUserSessionPolicy::ALLOWED: | 72 case ash::AddUserSessionPolicy::ALLOWED: |
| 135 return ash::mojom::AddUserSessionPolicy::ALLOWED; | 73 return ash::mojom::AddUserSessionPolicy::ALLOWED; |
| 136 case ash::AddUserSessionPolicy::ERROR_NOT_ALLOWED_PRIMARY_USER: | 74 case ash::AddUserSessionPolicy::ERROR_NOT_ALLOWED_PRIMARY_USER: |
| 137 return ash::mojom::AddUserSessionPolicy::ERROR_NOT_ALLOWED_PRIMARY_USER; | 75 return ash::mojom::AddUserSessionPolicy::ERROR_NOT_ALLOWED_PRIMARY_USER; |
| 138 case ash::AddUserSessionPolicy::ERROR_NO_ELIGIBLE_USERS: | 76 case ash::AddUserSessionPolicy::ERROR_NO_ELIGIBLE_USERS: |
| 139 return ash::mojom::AddUserSessionPolicy::ERROR_NO_ELIGIBLE_USERS; | 77 return ash::mojom::AddUserSessionPolicy::ERROR_NO_ELIGIBLE_USERS; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 return true; | 127 return true; |
| 190 } | 128 } |
| 191 NOTREACHED(); | 129 NOTREACHED(); |
| 192 return false; | 130 return false; |
| 193 } | 131 } |
| 194 }; | 132 }; |
| 195 | 133 |
| 196 } // namespace mojo | 134 } // namespace mojo |
| 197 | 135 |
| 198 #endif // ASH_PUBLIC_INTERFACES_SESSION_CONTROLLER_TRAITS_H_ | 136 #endif // ASH_PUBLIC_INTERFACES_SESSION_CONTROLLER_TRAITS_H_ |
| OLD | NEW |