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

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: Cherry-picked patchset #9 and #10 in http://codereview.chromium.org/8576005/ 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
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;
55
56 // Initializes the InputMethod object.
57 virtual void Init(const base::NativeWindow& system_toplevel_window) = 0;
58
59 // Called when the top-level system window gets keyboard focus.
60 virtual void OnFocus() = 0;
61
62 // Called when the top-level system window loses keyboard focus.
63 virtual void OnBlur() = 0;
64
65 // Sets the text input client which receives text input events such as
66 // SetCompositionText(). |client| can be NULL. A gfx::NativeWindow which
67 // implementes TextInputClient interface, e.g. NWA and RWHVA, should register
68 // itself by calling the method when it is focused, and unregister itself by
69 // calling the metho with NULL when it is unfocused.
70 virtual void SetFocusedTextInputClient(TextInputClient* client) = 0;
71
72 // Gets the current text input client. Returns NULL when no client is set.
73 virtual TextInputClient* GetTextInputClient() const = 0;
74
75 // Dispatches a key event to the input method. The key event will be
76 // dispatched back to the caller via
77 // ui::InputMethodDelegate::DispatchKeyEventPostIME(), once it's processed by
78 // the input method. It should only be called by a message dispatcher.
79 virtual void DispatchKeyEvent(const base::NativeEvent& native_key_event) = 0;
80
81 // TODO(yusukes): Add DispatchFabricatedKeyEvent to support virtual keyboards.
82
83 // Called by the focused client whenever its text input type is changed.
84 // Before calling this method, the focused client must confirm or clear
85 // existing composition text and call InputMethod::CancelComposition() when
86 // necessary. Otherwise unexpected behavior may happen. This method has no
87 // effect if the client is not the focused client.
88 virtual void OnTextInputTypeChanged(const TextInputClient* client) = 0;
89
90 // Called by the focused client whenever its caret bounds is changed.
91 // This method has no effect if the client is not the focused client.
92 virtual void OnCaretBoundsChanged(const TextInputClient* client) = 0;
93
94 // Called by the focused client to ask the input method cancel the ongoing
95 // composition session. This method has no effect if the client is not the
96 // focused client.
97 virtual void CancelComposition(const TextInputClient* client) = 0;
98
99 // Returns the locale of current keyboard layout or input method, as a BCP-47
100 // tag, or an empty string if the input method cannot provide it.
101 virtual std::string GetInputLocale() = 0;
102
103 // Returns the text direction of current keyboard layout or input method, or
104 // base::i18n::UNKNOWN_DIRECTION if the input method cannot provide it.
105 virtual base::i18n::TextDirection GetInputTextDirection() = 0;
106
107 // Checks if the input method is active, i.e. if it's ready for processing
108 // keyboard event and generate composition or text result.
109 // If the input method is inactive, then it's not necessary to inform it the
110 // changes of caret bounds and text input type.
111 // Note: character results may still be generated and sent to the text input
112 // client by calling TextInputClient::InsertChar(), even if the input method
113 // is not active.
114 virtual bool IsActive() = 0;
115
116 // Gets the text input type of the focused text input client. Returns
117 // ui::TEXT_INPUT_TYPE_NONE if there is no focused client.
118 virtual TextInputType GetTextInputType() const = 0;
119 };
120
121 } // namespace ui
122
123 #endif // UI_BASE_IME_INPUT_METHOD_H_
OLDNEW
« base/event_types.h ('K') | « base/event_types.h ('k') | ui/base/ime/input_method.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698