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