OLD | NEW |
| (Empty) |
1 // Copyright 2013 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_REMOTE_INPUT_METHOD_WIN_H_ | |
6 #define UI_BASE_IME_REMOTE_INPUT_METHOD_WIN_H_ | |
7 | |
8 #include <Windows.h> | |
9 | |
10 #include <string> | |
11 | |
12 #include "base/compiler_specific.h" | |
13 #include "base/macros.h" | |
14 #include "base/memory/scoped_ptr.h" | |
15 #include "base/strings/string16.h" | |
16 #include "ui/base/ime/ui_base_ime_export.h" | |
17 #include "ui/gfx/native_widget_types.h" | |
18 | |
19 namespace ui { | |
20 namespace internal { | |
21 class InputMethodDelegate; | |
22 class RemoteInputMethodDelegateWin; | |
23 } // namespace internal | |
24 | |
25 class InputMethod; | |
26 struct CompositionText; | |
27 | |
28 // RemoteInputMethodWin is a special implementation of ui::InputMethod that | |
29 // works as a proxy of an IME handler running in the metro_driver process. | |
30 // RemoteInputMethodWin works as follows. | |
31 // - Any action to RemoteInputMethodWin should be delegated to the | |
32 // metro_driver process via RemoteInputMethodDelegateWin. | |
33 // - Data retrieval from RemoteInputMethodPrivateWin is implemented with | |
34 // data cache. Whenever the IME state in the metro_driver process is changed, | |
35 // RemoteWindowTreeHostWin, which receives IPCs from metro_driver process, | |
36 // will call RemoteInputMethodPrivateWin::OnCandidatePopupChanged and/or | |
37 // RemoteInputMethodPrivateWin::OnInputSourceChanged accordingly so that | |
38 // the state cache should be updated. | |
39 // - Some IPC messages that represent actions to TextInputClient should be | |
40 // delegated to RemoteInputMethodPrivateWin so that RemoteInputMethodWin can | |
41 // work as a real proxy. | |
42 | |
43 // Returns true if |widget| requires RemoteInputMethodWin. | |
44 bool IsRemoteInputMethodWinRequired(gfx::AcceleratedWidget widget); | |
45 | |
46 // Returns the public interface of RemoteInputMethodWin. | |
47 // Caveats: Currently only one instance of RemoteInputMethodWin is able to run | |
48 // at the same time. | |
49 UI_BASE_IME_EXPORT scoped_ptr<InputMethod> CreateRemoteInputMethodWin( | |
50 internal::InputMethodDelegate* delegate); | |
51 | |
52 // Private interface of RemoteInputMethodWin. | |
53 class UI_BASE_IME_EXPORT RemoteInputMethodPrivateWin { | |
54 public: | |
55 RemoteInputMethodPrivateWin(); | |
56 | |
57 // Returns the private interface of RemoteInputMethodWin when and only when | |
58 // |input_method| is instanciated via CreateRemoteInputMethodWin. Caller does | |
59 // not take the ownership of the returned object. | |
60 // As you might notice, this is yet another reinplementation of dynamic_cast | |
61 // or IUnknown::QueryInterface. | |
62 static RemoteInputMethodPrivateWin* Get(InputMethod* input_method); | |
63 | |
64 // Installs RemoteInputMethodDelegateWin delegate. Set NULL to |delegate| to | |
65 // unregister. | |
66 virtual void SetRemoteDelegate( | |
67 internal::RemoteInputMethodDelegateWin* delegate) = 0; | |
68 | |
69 // Updates internal cache so that subsequent calls of | |
70 // RemoteInputMethodWin::IsCandidatePopupOpen can return the correct value | |
71 // based on remote IME activities in the metro_driver process. | |
72 virtual void OnCandidatePopupChanged(bool visible) = 0; | |
73 | |
74 // Updates internal cache so that subsequent calls of | |
75 // RemoteInputMethodWin::GetInputLocale can return the correct values based on | |
76 // remote IME activities in the metro_driver process. | |
77 virtual void OnInputSourceChanged(LANGID langid, bool is_ime) = 0; | |
78 | |
79 // Handles composition-update events occurred in the metro_driver process. | |
80 // Caveats: This method is designed to be used only with | |
81 // metro_driver::TextService. In other words, there is no garantee that this | |
82 // method works a wrapper to call ui::TextInputClient::SetCompositionText. | |
83 virtual void OnCompositionChanged( | |
84 const CompositionText& composition_text) = 0; | |
85 | |
86 // Handles text-commit events occurred in the metro_driver process. | |
87 // Caveats: This method is designed to be used only with | |
88 // metro_driver::TextService. In other words, there is no garantee that this | |
89 // method works a wrapper to call ui::TextInputClient::InsertText. In fact, | |
90 // this method may call ui::TextInputClient::InsertChar when the text input | |
91 // type of the focused text input client is TEXT_INPUT_TYPE_NONE. | |
92 virtual void OnTextCommitted(const base::string16& text) = 0; | |
93 | |
94 private: | |
95 DISALLOW_COPY_AND_ASSIGN(RemoteInputMethodPrivateWin); | |
96 }; | |
97 | |
98 } // namespace ui | |
99 | |
100 #endif // UI_BASE_IME_REMOTE_INPUT_METHOD_WIN_H_ | |
OLD | NEW |