ime_controller_client.h 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. // Copyright 2019 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. #ifndef ASH_PUBLIC_CPP_IME_CONTROLLER_CLIENT_H_
  5. #define ASH_PUBLIC_CPP_IME_CONTROLLER_CLIENT_H_
  6. #include <string>
  7. #include "ash/public/cpp/ash_public_export.h"
  8. #include "base/callback.h"
  9. #include "ui/base/ime/ash/ime_keyset.h"
  10. namespace ash {
  11. // Interface for ash to send input method requests to its client (e.g. Chrome).
  12. class ASH_PUBLIC_EXPORT ImeControllerClient {
  13. public:
  14. // Switches to the next input method. Does nothing if only one input method
  15. // is installed.
  16. virtual void SwitchToNextIme() = 0;
  17. // Switches to the last used input method. Does nothing if only one input
  18. // method is installed.
  19. virtual void SwitchToLastUsedIme() = 0;
  20. // Switches to an input method by |id|. Does nothing if the input method is
  21. // not installed. The ID is usually the output of a call like
  22. // extension_ime_util::GetInputMethodIDByEngineID("xkb:jp::jpn"),
  23. // see that function for details. Shows a bubble with the input method short
  24. // name when |show_message| is true.
  25. virtual void SwitchImeById(const std::string& id, bool show_message) = 0;
  26. // Activates an input method menu item. The |key| must be a value from the
  27. // ImeMenuItems provided via RefreshIme. Does nothing if the |key| is invalid.
  28. virtual void ActivateImeMenuItem(const std::string& key) = 0;
  29. // When the caps lock state change originates from the tray (i.e. clicking the
  30. // caps lock toggle from the settings menu from the caps lock icon), from an
  31. // accelerator (e.g. pressing Alt + Search), or from the debug UI (i.e.
  32. // toggling the caps lock button), propagate the change to the client without
  33. // sending a change notification back.
  34. // TODO(crbug/759435): Ideally this interaction should only be to disable the
  35. // caps lock.
  36. virtual void SetCapsLockEnabled(bool enabled) = 0;
  37. // Notifies the mirroring state change to the client where IME lives (e.g.
  38. // Chrome), so that the IME can behave according to the state.
  39. virtual void UpdateMirroringState(bool enabled) = 0;
  40. // Notifies the casting state change to the client where IME lives (e.g.
  41. // Chrome), so that the IME can behave according to the state.
  42. virtual void UpdateCastingState(bool enabled) = 0;
  43. // Overrides the keyboard keyset (emoji, handwriting or voice). If keyset is
  44. // 'kNone', we switch to the default keyset. Because this is asynchronous,
  45. // any code that needs the keyset to be updated first must use the callback.
  46. using OverrideKeyboardKeysetCallback = base::OnceCallback<void()>;
  47. virtual void OverrideKeyboardKeyset(
  48. input_method::ImeKeyset keyset,
  49. OverrideKeyboardKeysetCallback callback) = 0;
  50. // Show the current mode.
  51. virtual void ShowModeIndicator() = 0;
  52. };
  53. } // namespace ash
  54. #endif // ASH_PUBLIC_CPP_IME_CONTROLLER_CLIENT_H_