OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef ASH_PUBLIC_INTERFACES_SESSION_CONTROLLER_TRAITS_H_ |
| 6 #define ASH_PUBLIC_INTERFACES_SESSION_CONTROLLER_TRAITS_H_ |
| 7 |
| 8 #include "ash/public/cpp/session_types.h" |
| 9 #include "ash/public/interfaces/session_controller.mojom.h" |
| 10 #include "components/session_manager/session_manager_types.h" |
| 11 #include "components/user_manager/user_type.h" |
| 12 |
| 13 namespace mojo { |
| 14 |
| 15 template <> |
| 16 struct EnumTraits<ash::mojom::SessionState, session_manager::SessionState> { |
| 17 static ash::mojom::SessionState ToMojom(session_manager::SessionState input) { |
| 18 switch (input) { |
| 19 case session_manager::SessionState::UNKNOWN: |
| 20 return ash::mojom::SessionState::UNKNOWN; |
| 21 case session_manager::SessionState::OOBE: |
| 22 return ash::mojom::SessionState::OOBE; |
| 23 case session_manager::SessionState::LOGIN_PRIMARY: |
| 24 return ash::mojom::SessionState::LOGIN_PRIMARY; |
| 25 case session_manager::SessionState::LOGGED_IN_NOT_ACTIVE: |
| 26 return ash::mojom::SessionState::LOGGED_IN_NOT_ACTIVE; |
| 27 case session_manager::SessionState::ACTIVE: |
| 28 return ash::mojom::SessionState::ACTIVE; |
| 29 case session_manager::SessionState::LOCKED: |
| 30 return ash::mojom::SessionState::LOCKED; |
| 31 case session_manager::SessionState::LOGIN_SECONDARY: |
| 32 return ash::mojom::SessionState::LOGIN_SECONDARY; |
| 33 } |
| 34 NOTREACHED(); |
| 35 return ash::mojom::SessionState::UNKNOWN; |
| 36 } |
| 37 |
| 38 static bool FromMojom(ash::mojom::SessionState input, |
| 39 session_manager::SessionState* out) { |
| 40 switch (input) { |
| 41 case ash::mojom::SessionState::UNKNOWN: |
| 42 *out = session_manager::SessionState::UNKNOWN; |
| 43 return true; |
| 44 case ash::mojom::SessionState::OOBE: |
| 45 *out = session_manager::SessionState::OOBE; |
| 46 return true; |
| 47 case ash::mojom::SessionState::LOGIN_PRIMARY: |
| 48 *out = session_manager::SessionState::LOGIN_PRIMARY; |
| 49 return true; |
| 50 case ash::mojom::SessionState::LOGGED_IN_NOT_ACTIVE: |
| 51 *out = session_manager::SessionState::LOGGED_IN_NOT_ACTIVE; |
| 52 return true; |
| 53 case ash::mojom::SessionState::ACTIVE: |
| 54 *out = session_manager::SessionState::ACTIVE; |
| 55 return true; |
| 56 case ash::mojom::SessionState::LOCKED: |
| 57 *out = session_manager::SessionState::LOCKED; |
| 58 return true; |
| 59 case ash::mojom::SessionState::LOGIN_SECONDARY: |
| 60 *out = session_manager::SessionState::LOGIN_SECONDARY; |
| 61 return true; |
| 62 } |
| 63 NOTREACHED(); |
| 64 return false; |
| 65 } |
| 66 }; |
| 67 |
| 68 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::NUM_USER_TYPES: |
| 87 // Bail as this is not a valid user type. |
| 88 break; |
| 89 } |
| 90 NOTREACHED(); |
| 91 return ash::mojom::UserType::REGULAR; |
| 92 } |
| 93 |
| 94 static bool FromMojom(ash::mojom::UserType input, |
| 95 user_manager::UserType* out) { |
| 96 switch (input) { |
| 97 case ash::mojom::UserType::REGULAR: |
| 98 *out = user_manager::USER_TYPE_REGULAR; |
| 99 return true; |
| 100 case ash::mojom::UserType::GUEST: |
| 101 *out = user_manager::USER_TYPE_GUEST; |
| 102 return true; |
| 103 case ash::mojom::UserType::PUBLIC_ACCOUNT: |
| 104 *out = user_manager::USER_TYPE_PUBLIC_ACCOUNT; |
| 105 return true; |
| 106 case ash::mojom::UserType::SUPERVISED: |
| 107 *out = user_manager::USER_TYPE_SUPERVISED; |
| 108 return true; |
| 109 case ash::mojom::UserType::KIOSK: |
| 110 *out = user_manager::USER_TYPE_KIOSK_APP; |
| 111 return true; |
| 112 case ash::mojom::UserType::CHILD: |
| 113 *out = user_manager::USER_TYPE_CHILD; |
| 114 return true; |
| 115 case ash::mojom::UserType::ARC_KIOSK: |
| 116 *out = user_manager::USER_TYPE_ARC_KIOSK_APP; |
| 117 return true; |
| 118 } |
| 119 NOTREACHED(); |
| 120 return false; |
| 121 } |
| 122 }; |
| 123 |
| 124 template <> |
| 125 struct EnumTraits<ash::mojom::AddUserSessionPolicy, ash::AddUserSessionPolicy> { |
| 126 static ash::mojom::AddUserSessionPolicy ToMojom( |
| 127 ash::AddUserSessionPolicy input) { |
| 128 switch (input) { |
| 129 case ash::AddUserSessionPolicy::ALLOWED: |
| 130 return ash::mojom::AddUserSessionPolicy::ALLOWED; |
| 131 case ash::AddUserSessionPolicy::ERROR_NOT_ALLOWED_PRIMARY_USER: |
| 132 return ash::mojom::AddUserSessionPolicy::ERROR_NOT_ALLOWED_PRIMARY_USER; |
| 133 case ash::AddUserSessionPolicy::ERROR_NO_ELIGIBLE_USERS: |
| 134 return ash::mojom::AddUserSessionPolicy::ERROR_NO_ELIGIBLE_USERS; |
| 135 case ash::AddUserSessionPolicy::ERROR_MAXIMUM_USERS_REACHED: |
| 136 return ash::mojom::AddUserSessionPolicy::ERROR_MAXIMUM_USERS_REACHED; |
| 137 } |
| 138 NOTREACHED(); |
| 139 return ash::mojom::AddUserSessionPolicy::ALLOWED; |
| 140 } |
| 141 |
| 142 static bool FromMojom(ash::mojom::AddUserSessionPolicy input, |
| 143 ash::AddUserSessionPolicy* out) { |
| 144 switch (input) { |
| 145 case ash::mojom::AddUserSessionPolicy::ALLOWED: |
| 146 *out = ash::AddUserSessionPolicy::ALLOWED; |
| 147 return true; |
| 148 case ash::mojom::AddUserSessionPolicy::ERROR_NOT_ALLOWED_PRIMARY_USER: |
| 149 *out = ash::AddUserSessionPolicy::ERROR_NOT_ALLOWED_PRIMARY_USER; |
| 150 return true; |
| 151 case ash::mojom::AddUserSessionPolicy::ERROR_NO_ELIGIBLE_USERS: |
| 152 *out = ash::AddUserSessionPolicy::ERROR_NO_ELIGIBLE_USERS; |
| 153 return true; |
| 154 case ash::mojom::AddUserSessionPolicy::ERROR_MAXIMUM_USERS_REACHED: |
| 155 *out = ash::AddUserSessionPolicy::ERROR_MAXIMUM_USERS_REACHED; |
| 156 return true; |
| 157 } |
| 158 NOTREACHED(); |
| 159 return false; |
| 160 } |
| 161 }; |
| 162 |
| 163 } // namespace mojo |
| 164 |
| 165 #endif // ASH_PUBLIC_INTERFACES_SESSION_CONTROLLER_TRAITS_H_ |
OLD | NEW |