Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(21)

Side by Side Diff: ui/base/ime/input_method.h

Issue 8659033: IME (input method editor) support for Aura, part 1 of 3: Add ui/base/ime/ classes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | ui/base/ime/input_method.cc » ('j') | ui/base/ime/input_method.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011 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 UI_BASE_IME_INPUT_METHOD_H_
6 #define UI_BASE_IME_INPUT_METHOD_H_
7 #pragma once
8
9 #include <string>
10
11 #include "base/basictypes.h"
12 #include "base/event_types.h"
13 #include "base/i18n/rtl.h"
14 #include "ui/base/ime/text_input_type.h"
15 #include "ui/base/keycodes/keyboard_codes.h"
16 #include "ui/base/ui_export.h"
17
18 namespace ui {
19
20 namespace internal {
21 class InputMethodDelegate;
22 } // namespace internal
23
24 class TextInputClient;
25
26 // An interface implemented by an object that encapsulates a native input method
27 // service provided by the underlying operating system, and acts as a "system
28 // wide" input method for all Chrome windows. A class that implements this
29 // interface should behave as follows:
30 // - Receives a keyboard event directly from a message dispatcher for the
31 // system through the InputMethod::DispatchKeyEvent API, and forwards it to
32 // an underlying input method for the OS.
33 // - The input method should handle the key event either of the following ways:
34 // 1) Send the original key down event to the focused window, which is e.g.
35 // a NativeWidgetAura (NWA) or a RenderWidgetHostViewAura (RWHVA), using
36 // internal::InputMethodDelegate::DispatchKeyEventPostIME API, then send
37 // a Char event using TextInputClient::InsertChar API to a text input
38 // client, which is, again, e.g. NWA or RWHVA, and then send the original
39 // key up event to the same window.
40 // 2) Send VKEY_PROCESSKEY event to the window using the DispatchKeyEvent API,
41 // then update IME status (e.g. composition text) using TextInputClient,
42 // and then send the original key up event to the window.
43 // - Keeps track of the focused TextInputClient to see which client can call
44 // APIs, OnTextInputTypeChanged, OnCaretBoundsChanged, and CancelComposition,
45 // that change the state of the input method.
46 // In Aura environment, aura::DesktopHost creates an instance of ui::InputMethod
47 // and owns it.
48 class UI_EXPORT InputMethod {
49 public:
50 virtual ~InputMethod();
51
52 // Sets the delegate used by this InputMethod instance. It should only be
53 // called by an object which manages the whole UI (e.g. aura::DesktopHost).
54 virtual void set_delegate(internal::InputMethodDelegate* delegate) = 0;
sky 2011/12/05 15:15:29 virtual methods shouldn't use unix_hacker_style sy
Yusuke Sato 2011/12/05 22:55:14 Done.
55
56 // Initializes the InputMethod object. Pass true if the system toplevel window
57 // already has keyboard focus.
58 virtual void Init(bool focused) = 0;
59
60 // Called when the top-level system window gets keyboard focus.
61 virtual void OnFocus() = 0;
62
63 // Called when the top-level system window loses keyboard focus.
64 virtual void OnBlur() = 0;
65
66 // Sets the text input client which receives text input events such as
67 // SetCompositionText(). |client| can be NULL. A gfx::NativeWindow which
68 // implementes TextInputClient interface, e.g. NWA and RWHVA, should register
69 // itself by calling the method when it is focused, and unregister itself by
70 // calling the metho with NULL when it is unfocused.
71 virtual void SetFocusedTextInputClient(TextInputClient* client) = 0;
72
73 // Gets the current text input client. Returns NULL when no client is set.
74 virtual TextInputClient* GetTextInputClient() const = 0;
75
76 // Dispatches a key event to the input method. The key event will be
77 // dispatched back to the caller via
78 // ui::InputMethodDelegate::DispatchKeyEventPostIME(), once it's processed by
79 // the input method. It should only be called by a message dispatcher.
80 virtual void DispatchKeyEvent(const base::NativeEvent& native_key_event) = 0;
81
82 // TODO(yusukes): Add DispatchFabricatedKeyEvent to support virtual keyboards.
83
84 // Called by the focused client whenever its text input type is changed.
85 // Before calling this method, the focused client must confirm or clear
86 // existing composition text and call InputMethod::CancelComposition() when
87 // necessary. Otherwise unexpected behavior may happen. This method has no
88 // effect if the client is not the focused client.
89 virtual void OnTextInputTypeChanged(const TextInputClient* client) = 0;
90
91 // Called by the focused client whenever its caret bounds is changed.
92 // This method has no effect if the client is not the focused client.
93 virtual void OnCaretBoundsChanged(const TextInputClient* client) = 0;
94
95 // Called by the focused client to ask the input method cancel the ongoing
96 // composition session. This method has no effect if the client is not the
97 // focused client.
98 virtual void CancelComposition(const TextInputClient* client) = 0;
99
100 // Returns the locale of current keyboard layout or input method, as a BCP-47
101 // tag, or an empty string if the input method cannot provide it.
102 virtual std::string GetInputLocale() = 0;
103
104 // Returns the text direction of current keyboard layout or input method, or
105 // base::i18n::UNKNOWN_DIRECTION if the input method cannot provide it.
106 virtual base::i18n::TextDirection GetInputTextDirection() = 0;
107
108 // Checks if the input method is active, i.e. if it's ready for processing
109 // keyboard event and generate composition or text result.
110 // If the input method is inactive, then it's not necessary to inform it the
111 // changes of caret bounds and text input type.
112 // Note: character results may still be generated and sent to the text input
113 // client by calling TextInputClient::InsertChar(), even if the input method
114 // is not active.
115 virtual bool IsActive() = 0;
116
117 // Gets the text input type of the focused text input client. Returns
118 // ui::TEXT_INPUT_TYPE_NONE if there is no focused client.
119 virtual TextInputType GetTextInputType() const = 0;
120 };
121
122 } // namespace ui
123
124 #endif // UI_BASE_IME_INPUT_METHOD_H_
OLDNEW
« no previous file with comments | « no previous file | ui/base/ime/input_method.cc » ('j') | ui/base/ime/input_method.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698