| 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 #include "ui/events/ozone/layout/xkb/xkb_keyboard_layout_engine.h" | 5 #include "ui/events/ozone/layout/xkb/xkb_keyboard_layout_engine.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <xkbcommon/xkbcommon-names.h> | 8 #include <xkbcommon/xkbcommon-names.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 679 current_layout_name_ = layout_name; | 679 current_layout_name_ = layout_name; |
| 680 for (const auto& entry : xkb_keymaps_) { | 680 for (const auto& entry : xkb_keymaps_) { |
| 681 if (entry.layout_name == layout_name) { | 681 if (entry.layout_name == layout_name) { |
| 682 SetKeymap(entry.keymap); | 682 SetKeymap(entry.keymap); |
| 683 return true; | 683 return true; |
| 684 } | 684 } |
| 685 } | 685 } |
| 686 LoadKeymapCallback reply_callback = base::Bind( | 686 LoadKeymapCallback reply_callback = base::Bind( |
| 687 &XkbKeyboardLayoutEngine::OnKeymapLoaded, weak_ptr_factory_.GetWeakPtr()); | 687 &XkbKeyboardLayoutEngine::OnKeymapLoaded, weak_ptr_factory_.GetWeakPtr()); |
| 688 base::PostTaskWithTraits( | 688 base::PostTaskWithTraits( |
| 689 FROM_HERE, base::TaskTraits() | 689 FROM_HERE, |
| 690 .WithShutdownBehavior( | 690 {base::MayBlock(), base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN}, |
| 691 base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN) | |
| 692 .MayBlock(), | |
| 693 base::Bind(&LoadKeymap, layout_name, base::ThreadTaskRunnerHandle::Get(), | 691 base::Bind(&LoadKeymap, layout_name, base::ThreadTaskRunnerHandle::Get(), |
| 694 reply_callback)); | 692 reply_callback)); |
| 695 #else | 693 #else |
| 696 NOTIMPLEMENTED(); | 694 NOTIMPLEMENTED(); |
| 697 #endif // defined(OS_CHROMEOS) | 695 #endif // defined(OS_CHROMEOS) |
| 698 return true; | 696 return true; |
| 699 } | 697 } |
| 700 | 698 |
| 701 void XkbKeyboardLayoutEngine::OnKeymapLoaded( | 699 void XkbKeyboardLayoutEngine::OnKeymapLoaded( |
| 702 const std::string& layout_name, | 700 const std::string& layout_name, |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 969 close_index = layout_name.size(); | 967 close_index = layout_name.size(); |
| 970 *layout_variant = layout_name.substr(parentheses_index + 1, | 968 *layout_variant = layout_name.substr(parentheses_index + 1, |
| 971 close_index - parentheses_index - 1); | 969 close_index - parentheses_index - 1); |
| 972 } else if (dash_index != std::string::npos) { | 970 } else if (dash_index != std::string::npos) { |
| 973 *layout_id = layout_name.substr(0, dash_index); | 971 *layout_id = layout_name.substr(0, dash_index); |
| 974 *layout_variant = layout_name.substr(dash_index + 1); | 972 *layout_variant = layout_name.substr(dash_index + 1); |
| 975 } | 973 } |
| 976 } | 974 } |
| 977 | 975 |
| 978 } // namespace ui | 976 } // namespace ui |
| OLD | NEW |