ime_controller.h 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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_H_
  5. #define ASH_PUBLIC_CPP_IME_CONTROLLER_H_
  6. #include <string>
  7. #include "ash/public/cpp/ash_public_export.h"
  8. #include "ash/public/cpp/ime_controller_client.h"
  9. #include "ash/public/cpp/ime_info.h"
  10. namespace gfx {
  11. class Rect;
  12. }
  13. namespace ash {
  14. // Interface for ash client (e.g. Chrome) to send input method info to ash.
  15. class ASH_PUBLIC_EXPORT ImeController {
  16. public:
  17. // Sets the global ImeController instance returned by ImeController::Get().
  18. // Use this when you need to override existing ImeController instances.
  19. static void SetInstanceForTest(ImeController* controller);
  20. virtual ~ImeController();
  21. static ImeController* Get();
  22. // Sets the client interface.
  23. virtual void SetClient(ImeControllerClient* client) = 0;
  24. // Updates the cached IME information and refreshes the IME menus.
  25. // |current_ime_id| is empty when there is no active IME yet.
  26. virtual void RefreshIme(const std::string& current_ime_id,
  27. std::vector<ImeInfo> available_imes,
  28. std::vector<ImeMenuItem> menu_items) = 0;
  29. // Shows an icon in the IME menu indicating that IMEs are controlled by device
  30. // policy.
  31. virtual void SetImesManagedByPolicy(bool managed) = 0;
  32. // Shows the IME menu on the shelf instead of inside the system tray menu.
  33. // Users with multiple IMEs that have multiple configurable properties (e.g.
  34. // some Chinese IMEs) prefer this to keeping the IME menu under the primary
  35. // system tray menu.
  36. virtual void ShowImeMenuOnShelf(bool show) = 0;
  37. // Report caps lock state changes from chrome (which is the source of truth)
  38. // to the tray.
  39. virtual void UpdateCapsLockState(bool enabled) = 0;
  40. // Report keyboard layout changes from chrome (which is the source of truth)
  41. // This is also called when a connection is first established between
  42. // ImeController and ImeControllerClient.
  43. // The layout name is a XKB keyboard layout name (e.g. "us").
  44. virtual void OnKeyboardLayoutNameChanged(const std::string& layout_name) = 0;
  45. // Report the enabled state of the various extra input options (currently
  46. // emoji, handwriting, and voice input). |is_extra_input_options_enabled| set
  47. // to false will disable all extra input option UI regardless of the enabled
  48. // state of the individual options (which will be ignored).
  49. virtual void SetExtraInputOptionsEnabledState(
  50. bool is_extra_input_options_enabled,
  51. bool is_emoji_enabled,
  52. bool is_handwriting_enabled,
  53. bool is_voice_enabled) = 0;
  54. // Show the mode indicator view (e.g. a bubble with "DV" for Dvorak).
  55. // The view fades out after a delay and close itself.
  56. // The anchor bounds is in the universal screen coordinates in DIP.
  57. virtual void ShowModeIndicator(const gfx::Rect& anchor_bounds,
  58. const std::u16string& ime_short_name) = 0;
  59. protected:
  60. ImeController();
  61. };
  62. } // namespace ash
  63. #endif // ASH_PUBLIC_CPP_IME_CONTROLLER_H_