OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef UI_BASE_WIN_TSF_BRIDGE_H_ | 5 #ifndef UI_BASE_WIN_TSF_BRIDGE_H_ |
6 #define UI_BASE_WIN_TSF_BRIDGE_H_ | 6 #define UI_BASE_WIN_TSF_BRIDGE_H_ |
7 | 7 |
8 #include <Windows.h> | 8 #include <Windows.h> |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "ui/base/ui_export.h" | 10 #include "ui/base/ui_export.h" |
11 | 11 |
12 namespace ui { | 12 namespace ui { |
13 class TextInputClient; | 13 class TextInputClient; |
14 | 14 |
15 // TsfBridge provides high level IME related operations on top of Text Services | 15 // TsfBridge provides high level IME related operations on top of Text Services |
16 // Framework (TSF). TsfBridge is managed by TLS because TSF related stuff is | 16 // Framework (TSF). TsfBridge is managed by TLS because TSF related stuff is |
17 // associated with each thread and not allowed to access across thread boundary. | 17 // associated with each thread and not allowed to access across thread boundary. |
18 // To be consistent with IMM32 behavior, TsfBridge is shared in the same thread. | 18 // To be consistent with IMM32 behavior, TsfBridge is shared in the same thread. |
19 // TsfBridge is used by the web content text inputting field, for example | 19 // TsfBridge is used by the web content text inputting field, for example |
20 // DisableIME() should be called if a password field is focused. | 20 // DisableIME() should be called if a password field is focused. |
21 // | 21 // |
22 // TsfBridge also manages connectivity between TsfTextStore which is the backend | 22 // TsfBridge also manages connectivity between TsfTextStore which is the backend |
23 // of text inputting and current focused TextInputClient. | 23 // of text inputting and current focused TextInputClient. |
24 // | 24 // |
25 // All methods in this class must be used in UI thread. | 25 // All methods in this class must be used in UI thread. |
26 class TsfBridge { | 26 class UI_EXPORT TsfBridge { |
27 public: | 27 public: |
28 virtual ~TsfBridge(); | 28 virtual ~TsfBridge(); |
29 | 29 |
30 // Returns the thread local TsfBridge instance. Initialize() must be called | 30 // Returns the thread local TsfBridge instance. Initialize() must be called |
31 // first. Do not cache this pointer and use it after TsfBridge Shutdown(). | 31 // first. Do not cache this pointer and use it after TsfBridge Shutdown(). |
32 static UI_EXPORT TsfBridge* GetInstance(); | 32 static TsfBridge* GetInstance(); |
33 | 33 |
34 // Sets the thread local instance. Must be called before any calls to | 34 // Sets the thread local instance. Must be called before any calls to |
35 // GetInstance(). | 35 // GetInstance(). |
36 static UI_EXPORT bool Initialize(); | 36 static bool Initialize(); |
| 37 |
| 38 // Injects an alternative TsfBridge such as MockTsfBridge for testing. The |
| 39 // injected object should be released by the caller. This function returns |
| 40 // previous TsfBridge pointer with ownership. |
| 41 static TsfBridge* ReplaceForTesting(TsfBridge* bridge); |
37 | 42 |
38 // Destroys the thread local instance. | 43 // Destroys the thread local instance. |
39 virtual void Shutdown() = 0; | 44 virtual void Shutdown() = 0; |
40 | 45 |
41 // Enables the IME. | 46 // Enables the IME. |
42 // Returns false if an error occures. | 47 // Returns false if an error occures. |
43 virtual bool EnableIME() = 0; | 48 virtual bool EnableIME() = 0; |
44 | 49 |
45 // Diables the IME. | 50 // Diables the IME. |
46 // Returns false if an error occures. | 51 // Returns false if an error occures. |
(...skipping 19 matching lines...) Expand all Loading... |
66 // Uses GetInstance() instead. | 71 // Uses GetInstance() instead. |
67 TsfBridge(); | 72 TsfBridge(); |
68 | 73 |
69 private: | 74 private: |
70 DISALLOW_COPY_AND_ASSIGN(TsfBridge); | 75 DISALLOW_COPY_AND_ASSIGN(TsfBridge); |
71 }; | 76 }; |
72 | 77 |
73 } // namespace ui | 78 } // namespace ui |
74 | 79 |
75 #endif // UI_BASE_WIN_TSF_BRIDGE_H_ | 80 #endif // UI_BASE_WIN_TSF_BRIDGE_H_ |
OLD | NEW |