| Index: ui/events/ozone/layout/xkb/xkb_keyboard_layout_engine.cc
|
| diff --git a/ui/events/ozone/layout/xkb/xkb_keyboard_layout_engine.cc b/ui/events/ozone/layout/xkb/xkb_keyboard_layout_engine.cc
|
| index 4e15b2b01c2790608d33bb62e680dea6b3127476..4ebd6390422f9ae6060edffb51c8fa543195f16a 100644
|
| --- a/ui/events/ozone/layout/xkb/xkb_keyboard_layout_engine.cc
|
| +++ b/ui/events/ozone/layout/xkb/xkb_keyboard_layout_engine.cc
|
| @@ -647,17 +647,20 @@ bool XkbKeyboardLayoutEngine::CanSetCurrentLayout() const {
|
| bool XkbKeyboardLayoutEngine::SetCurrentLayoutByName(
|
| const std::string& layout_name) {
|
| #if defined(OS_CHROMEOS)
|
| - size_t dash_index = layout_name.find("-");
|
| - size_t parentheses_index = layout_name.find("(");
|
| + size_t dash_index = layout_name.find('-');
|
| + size_t parentheses_index = layout_name.find('(');
|
| std::string layout_id = layout_name;
|
| std::string layout_variant = "";
|
| - if (dash_index != std::string::npos) {
|
| - layout_id = layout_name.substr(0, dash_index);
|
| - layout_variant = layout_name.substr(dash_index + 1);
|
| - } else if (parentheses_index != std::string::npos) {
|
| + if (parentheses_index != std::string::npos) {
|
| layout_id = layout_name.substr(0, parentheses_index);
|
| + size_t close_index = layout_name.find(')', parentheses_index);
|
| + if (close_index == std::string::npos)
|
| + close_index = layout_name.size();
|
| layout_variant = layout_name.substr(parentheses_index + 1,
|
| - layout_name.size() - 1);
|
| + close_index - parentheses_index - 1);
|
| + } else if (dash_index != std::string::npos) {
|
| + layout_id = layout_name.substr(0, dash_index);
|
| + layout_variant = layout_name.substr(dash_index + 1);
|
| }
|
| struct xkb_rule_names names = {
|
| .rules = NULL,
|
|
|