OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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 #include "ui/base/ime/input_method_initializer.h" | 5 #include "ui/base/ime/input_method_initializer.h" |
6 | 6 |
7 #if defined(OS_CHROMEOS) | 7 #if defined(OS_CHROMEOS) |
8 #include "ui/base/ime/chromeos/ime_bridge.h" | 8 #include "ui/base/ime/chromeos/ime_bridge.h" |
9 #elif defined(USE_AURA) && defined(OS_LINUX) && !defined(USE_OZONE) | 9 #elif defined(USE_AURA) && defined(OS_LINUX) && !defined(USE_OZONE) |
10 #include "ui/base/ime/input_method_auralinux.h" | 10 #include "ui/base/ime/input_method_auralinux.h" |
11 #include "ui/base/ime/linux/fake_input_method_context_factory.h" | 11 #include "ui/base/ime/linux/fake_input_method_context_factory.h" |
12 #elif defined(OS_WIN) | 12 #elif defined(OS_WIN) |
13 #include "base/win/metro.h" | 13 #include "base/win/metro.h" |
14 #include "ui/base/ime/input_method_factory.h" | 14 #include "ui/base/ime/input_method_factory.h" |
15 #include "ui/base/ime/win/tsf_bridge.h" | |
16 #endif | 15 #endif |
17 | 16 |
18 namespace { | 17 namespace { |
19 | 18 |
20 #if !defined(OS_CHROMEOS) && defined(USE_AURA) && defined(OS_LINUX) && \ | 19 #if !defined(OS_CHROMEOS) && defined(USE_AURA) && defined(OS_LINUX) && \ |
21 !defined(USE_OZONE) | 20 !defined(USE_OZONE) |
22 const ui::LinuxInputMethodContextFactory* g_linux_input_method_context_factory; | 21 const ui::LinuxInputMethodContextFactory* g_linux_input_method_context_factory; |
23 #endif | 22 #endif |
24 | 23 |
25 } // namespace | 24 } // namespace |
26 | 25 |
27 namespace ui { | 26 namespace ui { |
28 | 27 |
29 void InitializeInputMethod() { | 28 void InitializeInputMethod() { |
30 #if defined(OS_CHROMEOS) | 29 #if defined(OS_CHROMEOS) |
31 chromeos::IMEBridge::Initialize(); | 30 chromeos::IMEBridge::Initialize(); |
32 #elif defined(USE_AURA) && defined(OS_LINUX) && !defined(USE_OZONE) | 31 #elif defined(USE_AURA) && defined(OS_LINUX) && !defined(USE_OZONE) |
33 InputMethodAuraLinux::Initialize(); | 32 InputMethodAuraLinux::Initialize(); |
34 #elif defined(OS_WIN) | |
35 if (base::win::IsTSFAwareRequired()) | |
36 TSFBridge::Initialize(); | |
37 #endif | 33 #endif |
38 } | 34 } |
39 | 35 |
40 void ShutdownInputMethod() { | 36 void ShutdownInputMethod() { |
41 #if defined(OS_CHROMEOS) | 37 #if defined(OS_CHROMEOS) |
42 chromeos::IMEBridge::Shutdown(); | 38 chromeos::IMEBridge::Shutdown(); |
43 #elif defined(OS_WIN) | 39 #elif defined(OS_WIN) |
44 internal::DestroySharedInputMethod(); | 40 internal::DestroySharedInputMethod(); |
45 if (base::win::IsTSFAwareRequired()) | |
46 TSFBridge::Shutdown(); | |
47 #endif | 41 #endif |
48 } | 42 } |
49 | 43 |
50 void InitializeInputMethodForTesting() { | 44 void InitializeInputMethodForTesting() { |
51 #if defined(OS_CHROMEOS) | 45 #if defined(OS_CHROMEOS) |
52 chromeos::IMEBridge::Initialize(); | 46 chromeos::IMEBridge::Initialize(); |
53 #elif defined(USE_AURA) && defined(OS_LINUX) && !defined(USE_OZONE) | 47 #elif defined(USE_AURA) && defined(OS_LINUX) && !defined(USE_OZONE) |
54 if (!g_linux_input_method_context_factory) | 48 if (!g_linux_input_method_context_factory) |
55 g_linux_input_method_context_factory = new FakeInputMethodContextFactory(); | 49 g_linux_input_method_context_factory = new FakeInputMethodContextFactory(); |
56 const LinuxInputMethodContextFactory* factory = | 50 const LinuxInputMethodContextFactory* factory = |
57 LinuxInputMethodContextFactory::instance(); | 51 LinuxInputMethodContextFactory::instance(); |
58 CHECK(!factory || factory == g_linux_input_method_context_factory) | 52 CHECK(!factory || factory == g_linux_input_method_context_factory) |
59 << "LinuxInputMethodContextFactory was already initialized somewhere " | 53 << "LinuxInputMethodContextFactory was already initialized somewhere " |
60 << "else."; | 54 << "else."; |
61 LinuxInputMethodContextFactory::SetInstance( | 55 LinuxInputMethodContextFactory::SetInstance( |
62 g_linux_input_method_context_factory); | 56 g_linux_input_method_context_factory); |
63 #elif defined(OS_WIN) | |
64 if (base::win::IsTSFAwareRequired()) { | |
65 // Make sure COM is initialized because TSF depends on COM. | |
66 CoInitialize(NULL); | |
67 TSFBridge::Initialize(); | |
68 } | |
69 #endif | 57 #endif |
70 } | 58 } |
71 | 59 |
72 void ShutdownInputMethodForTesting() { | 60 void ShutdownInputMethodForTesting() { |
73 #if defined(OS_CHROMEOS) | 61 #if defined(OS_CHROMEOS) |
74 chromeos::IMEBridge::Shutdown(); | 62 chromeos::IMEBridge::Shutdown(); |
75 #elif defined(USE_AURA) && defined(OS_LINUX) && !defined(USE_OZONE) | 63 #elif defined(USE_AURA) && defined(OS_LINUX) && !defined(USE_OZONE) |
76 const LinuxInputMethodContextFactory* factory = | 64 const LinuxInputMethodContextFactory* factory = |
77 LinuxInputMethodContextFactory::instance(); | 65 LinuxInputMethodContextFactory::instance(); |
78 CHECK(!factory || factory == g_linux_input_method_context_factory) | 66 CHECK(!factory || factory == g_linux_input_method_context_factory) |
79 << "An unknown LinuxInputMethodContextFactory was set."; | 67 << "An unknown LinuxInputMethodContextFactory was set."; |
80 LinuxInputMethodContextFactory::SetInstance(NULL); | 68 LinuxInputMethodContextFactory::SetInstance(NULL); |
81 delete g_linux_input_method_context_factory; | 69 delete g_linux_input_method_context_factory; |
82 g_linux_input_method_context_factory = NULL; | 70 g_linux_input_method_context_factory = NULL; |
83 #elif defined(OS_WIN) | 71 #elif defined(OS_WIN) |
84 internal::DestroySharedInputMethod(); | 72 internal::DestroySharedInputMethod(); |
85 if (base::win::IsTSFAwareRequired()) { | |
86 TSFBridge::Shutdown(); | |
87 CoUninitialize(); | |
88 } | |
89 #endif | 73 #endif |
90 } | 74 } |
91 | 75 |
92 } // namespace ui | 76 } // namespace ui |
OLD | NEW |