blob: e8b6a1a7a302019b57a81f49056d02bcb24690fc [file] [log] [blame]
Yuichiro Hanadae05251ec2018-05-23 06:19:591// Copyright 2018 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
Yuichiro Hanada0109cc42018-12-18 01:13:575// Next MinVersion: 6
yusukesc4aa4232018-08-27 17:22:456
Yuichiro Hanadae05251ec2018-05-23 06:19:597module arc.mojom;
8
Yuichiro Hanada176393f2018-10-01 09:02:149import "mojo/public/mojom/base/string16.mojom";
10import "components/arc/common/gfx.mojom";
11import "components/arc/common/ime.mojom";
12
Yuichiro Hanadae05251ec2018-05-23 06:19:5913// Represents the information of an Android IME.
14struct ImeInfo {
15 // The unique ID for the Android IME. Corresponds to InputMethodInfo.getId().
16 string ime_id;
17 // The user-displayed label for the IME. Corresponds to
18 // InputMethodInfo.loadLabel().
19 string display_name;
20 // Whether the IME is enabled or not. It's equivalent to whether the IME is
21 // in ENABLED_INPUT_METHODS settings.
22 bool enabled;
23 // intent: URL to open the settings activity of the IME.
24 string settings_url;
25};
26
Yuichiro Hanada176393f2018-10-01 09:02:1427// Represents the information of the text field.
28[MinVersion=2]
29struct TextInputState {
30 // The current cursor position in 16-bit code units in the overall text
31 // of the text field.
32 int32 cursor_pos;
33 // A part of the text in the text field. The text is in UTF-8,
34 // but should be converted to UTF-16 in both ends of mojo call.
35 mojo_base.mojom.String16 text;
36 // The range of |text| in 16-bit code units index in the overall text
37 // of the text field.
38 Range text_range;
39 // The range of the selected text in 16-bit code units index
40 // in the overall text of the text field.
41 Range selection_range;
42 // The type of the text field.
43 TextInputType type;
44 // Indicates that IMEs should do personalized learning based on the contents.
45 bool should_do_learning;
46 // The other text input flags. For example auto-capitalization flag
47 // and auto-correction flag are included in this flag.
48 // These values are from ui::TextInputFlags in ui/base/ime/text_input_flags.h
49 uint32 flags;
50 // Whether this state update is sent as a first update after an operation
51 // by Android IMEs.
52 // Android IMEs need this flag to know the latest state after their operation
53 // becomes effective.
54 bool first_update_after_operation;
55};
56
57// This interface provides methods to control a text field.
58// It is generated for each focused text field and passed to Android.
59// This interface will be closed when the focus moves to another text field.
60//
Yuichiro Hanada0109cc42018-12-18 01:13:5761// Next method ID: 6
Yuichiro Hanada176393f2018-10-01 09:02:1462[MinVersion=2]
63interface InputConnection {
64 // Commits text to the focused text field and set the new cursor position.
65 CommitText@0(mojo_base.mojom.String16 text, int32 new_cursor_pos);
66
67 // Deletes |before| characters of text before the cursor position,
68 // and deletes |after| characters of text after the cursor position.
69 DeleteSurroundingText@1(int32 before, int32 after);
70
71 // Has the text field finish the ongoing composition.
72 FinishComposingText@2();
73
74 // Requests to send the latest TextInputState of the active text field.
75 // For example, this is called when the IME calls getTextBeforeCursor()
76 // and getTextAfterCursor().
77 RequestTextInputState@3() => (TextInputState state);
78
79 // Replaces the currently composing text with the given text,
Yuichiro Hanada4ac1c7722018-10-04 09:34:4880 // and sets the cursor position and the selection range.
81 SetComposingText@4(mojo_base.mojom.String16 text,
82 int32 new_cursor_pos,
83 [MinVersion=3] Range? new_selection_range);
Yuichiro Hanadacfb638642018-12-13 10:16:3584
85 // Selects the given UTF-16 based character range.
Yuichiro Hanada0109cc42018-12-18 01:13:5786 [MinVersion=5] SetSelection@5(Range new_selection_range);
Yuichiro Hanada176393f2018-10-01 09:02:1487};
88
Yuichiro Hanadae05251ec2018-05-23 06:19:5989// This interface is called by container when Android's InputMethodManager state
90// is changed.
91// In Android container, ArcInputMethodService IME is pre-installed to bridge
92// Chrome OS's IME to Android apps. The bridge is defined in ime.mojom.
93//
yusukesc4aa4232018-08-27 17:22:4594// Next method ID: 3
Yuichiro Hanadae05251ec2018-05-23 06:19:5995interface InputMethodManagerHost {
96 // Notifies Chrome that active IME in Android is changed.
97 OnActiveImeChanged@0(string ime_id);
98
yusukesc4aa4232018-08-27 17:22:4599 // Notifies Chrome of the ID of the IME Android has disabled.
100 [MinVersion=1] OnImeDisabled@2(string ime_id);
101
Yuichiro Hanadae05251ec2018-05-23 06:19:59102 // Notifies Chrome of information of installed IMEs in Android.
103 // The passed list doesn't contain information of our bridge IME,
104 // ArcInputMethodService.
105 OnImeInfoChanged@1(array<ImeInfo> ime_infos);
106};
107
108// This interface provides methods to control Android's InputMethodManager.
109//
Yuichiro Hanada7e2e3d32018-10-11 14:10:16110// Next method ID: 7
Yuichiro Hanadae05251ec2018-05-23 06:19:59111interface InputMethodManagerInstance {
112 // Establishes full-duplex communication with the host.
113 Init@0(InputMethodManagerHost host_ptr) => ();
114
115 // Enables/Disables an IME in Android. Calling this method will add/remove
116 // the specified IME to/from ENABLED_INPUT_METHODS settings.
117 EnableIme@1(string ime_id, bool enable) => (bool success);
118
119 // Switches active IME in Android.
120 SwitchImeTo@2(string ime_id) => (bool success);
Yuichiro Hanada176393f2018-10-01 09:02:14121
122 // Notifies Android's ArcInputMethodManagerService that
123 // a text field is focused.
124 [MinVersion=2] Focus@3(InputConnection connection,
125 TextInputState initial_state);
126
127 // Sends the latest TextInputState of the active text field.
128 [MinVersion=2] UpdateTextInputState@4(TextInputState state);
Yuichiro Hanada7e2e3d32018-10-11 14:10:16129
130 // Requests the active IME to show virtual keyboard.
131 [MinVersion=4] ShowVirtualKeyboard@5();
132
133 // Requests the active IME to hide virtual keyboard.
134 [MinVersion=4] HideVirtualKeyboard@6();
Yuichiro Hanadae05251ec2018-05-23 06:19:59135};