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 #include "ui/base/ime/input_method_factory.h" | 7 #include "ui/base/ime/input_method_factory.h" |
8 | 8 |
9 #if defined(OS_CHROMEOS) | 9 #if defined(OS_CHROMEOS) |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "chromeos/dbus/dbus_thread_manager.h" | 11 #include "chromeos/dbus/dbus_thread_manager.h" |
12 #include "ui/base/ime/chromeos/ibus_bridge.h" | 12 #include "ui/base/ime/chromeos/ibus_bridge.h" |
13 #elif defined(USE_AURA) && defined(USE_X11) | 13 #elif defined(USE_AURA) |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "ui/base/ime/input_method_linux_x11.h" | 15 #include "ui/base/ime/input_method_auralinux.h" |
16 #include "ui/base/ime/linux/fake_input_method_context_factory.h" | 16 #include "ui/base/ime/linux/fake_input_method_context_factory.h" |
17 #elif defined(OS_WIN) | 17 #elif defined(OS_WIN) |
18 #include "base/win/metro.h" | 18 #include "base/win/metro.h" |
19 #include "ui/base/ime/win/tsf_bridge.h" | 19 #include "ui/base/ime/win/tsf_bridge.h" |
20 #endif | 20 #endif |
21 | 21 |
22 namespace { | 22 namespace { |
23 | 23 |
24 #if defined(OS_CHROMEOS) | 24 #if defined(OS_CHROMEOS) |
25 bool dbus_thread_manager_was_initialized = false; | 25 bool dbus_thread_manager_was_initialized = false; |
26 #elif defined(USE_AURA) && defined(USE_X11) | 26 #elif defined(USE_AURA) |
27 const ui::LinuxInputMethodContextFactory* g_linux_input_method_context_factory; | 27 const ui::LinuxInputMethodContextFactory* g_linux_input_method_context_factory; |
28 #endif | 28 #endif |
29 | 29 |
30 } // namespace | 30 } // namespace |
31 | 31 |
32 namespace ui { | 32 namespace ui { |
33 | 33 |
34 void InitializeInputMethod() { | 34 void InitializeInputMethod() { |
35 #if defined(OS_CHROMEOS) | 35 #if defined(OS_CHROMEOS) |
36 chromeos::IBusBridge::Initialize(); | 36 chromeos::IBusBridge::Initialize(); |
37 #elif defined(USE_AURA) && defined(USE_X11) | 37 #elif defined(USE_AURA) |
38 InputMethodLinuxX11::Initialize(); | 38 InputMethodAuraLinux::Initialize(); |
39 #elif defined(OS_WIN) | 39 #elif defined(OS_WIN) |
40 if (base::win::IsTSFAwareRequired()) | 40 if (base::win::IsTSFAwareRequired()) |
41 TSFBridge::Initialize(); | 41 TSFBridge::Initialize(); |
42 #endif | 42 #endif |
43 } | 43 } |
44 | 44 |
45 void ShutdownInputMethod() { | 45 void ShutdownInputMethod() { |
46 #if defined(OS_CHROMEOS) | 46 #if defined(OS_CHROMEOS) |
47 chromeos::IBusBridge::Shutdown(); | 47 chromeos::IBusBridge::Shutdown(); |
48 #elif defined(OS_WIN) | 48 #elif defined(OS_WIN) |
49 internal::DestroySharedInputMethod(); | 49 internal::DestroySharedInputMethod(); |
50 if (base::win::IsTSFAwareRequired()) | 50 if (base::win::IsTSFAwareRequired()) |
51 TSFBridge::Shutdown(); | 51 TSFBridge::Shutdown(); |
52 #endif | 52 #endif |
53 } | 53 } |
54 | 54 |
55 void InitializeInputMethodForTesting() { | 55 void InitializeInputMethodForTesting() { |
56 #if defined(OS_CHROMEOS) | 56 #if defined(OS_CHROMEOS) |
57 chromeos::IBusBridge::Initialize(); | 57 chromeos::IBusBridge::Initialize(); |
58 // TODO(nona): Remove DBusThreadManager initialize. | 58 // TODO(nona): Remove DBusThreadManager initialize. |
59 if (!chromeos::DBusThreadManager::IsInitialized()) { | 59 if (!chromeos::DBusThreadManager::IsInitialized()) { |
60 chromeos::DBusThreadManager::InitializeWithStub(); | 60 chromeos::DBusThreadManager::InitializeWithStub(); |
61 dbus_thread_manager_was_initialized = true; | 61 dbus_thread_manager_was_initialized = true; |
62 } | 62 } |
63 #elif defined(USE_AURA) && defined(USE_X11) | 63 #elif defined(USE_AURA) |
64 if (!g_linux_input_method_context_factory) | 64 if (!g_linux_input_method_context_factory) |
65 g_linux_input_method_context_factory = new FakeInputMethodContextFactory(); | 65 g_linux_input_method_context_factory = new FakeInputMethodContextFactory(); |
66 const LinuxInputMethodContextFactory* factory = | 66 const LinuxInputMethodContextFactory* factory = |
67 LinuxInputMethodContextFactory::instance(); | 67 LinuxInputMethodContextFactory::instance(); |
68 CHECK(!factory || factory == g_linux_input_method_context_factory) | 68 CHECK(!factory || factory == g_linux_input_method_context_factory) |
69 << "LinuxInputMethodContextFactory was already initialized somewhere " | 69 << "LinuxInputMethodContextFactory was already initialized somewhere " |
70 << "else."; | 70 << "else."; |
71 LinuxInputMethodContextFactory::SetInstance( | 71 LinuxInputMethodContextFactory::SetInstance( |
72 g_linux_input_method_context_factory); | 72 g_linux_input_method_context_factory); |
73 #elif defined(OS_WIN) | 73 #elif defined(OS_WIN) |
74 if (base::win::IsTSFAwareRequired()) { | 74 if (base::win::IsTSFAwareRequired()) { |
75 // Make sure COM is initialized because TSF depends on COM. | 75 // Make sure COM is initialized because TSF depends on COM. |
76 CoInitialize(NULL); | 76 CoInitialize(NULL); |
77 TSFBridge::Initialize(); | 77 TSFBridge::Initialize(); |
78 } | 78 } |
79 #endif | 79 #endif |
80 } | 80 } |
81 | 81 |
82 void ShutdownInputMethodForTesting() { | 82 void ShutdownInputMethodForTesting() { |
83 #if defined(OS_CHROMEOS) | 83 #if defined(OS_CHROMEOS) |
84 chromeos::IBusBridge::Shutdown(); | 84 chromeos::IBusBridge::Shutdown(); |
85 // TODO(nona): Remove DBusThreadManager finalize. | 85 // TODO(nona): Remove DBusThreadManager finalize. |
86 if (dbus_thread_manager_was_initialized) { | 86 if (dbus_thread_manager_was_initialized) { |
87 chromeos::DBusThreadManager::Shutdown(); | 87 chromeos::DBusThreadManager::Shutdown(); |
88 dbus_thread_manager_was_initialized = false; | 88 dbus_thread_manager_was_initialized = false; |
89 } | 89 } |
90 #elif defined(USE_AURA) && defined(USE_X11) | 90 #elif defined(USE_AURA) |
91 const LinuxInputMethodContextFactory* factory = | 91 const LinuxInputMethodContextFactory* factory = |
92 LinuxInputMethodContextFactory::instance(); | 92 LinuxInputMethodContextFactory::instance(); |
93 CHECK(!factory || factory == g_linux_input_method_context_factory) | 93 CHECK(!factory || factory == g_linux_input_method_context_factory) |
94 << "An unknown LinuxInputMethodContextFactory was set."; | 94 << "An unknown LinuxInputMethodContextFactory was set."; |
95 LinuxInputMethodContextFactory::SetInstance(NULL); | 95 LinuxInputMethodContextFactory::SetInstance(NULL); |
96 delete g_linux_input_method_context_factory; | 96 delete g_linux_input_method_context_factory; |
97 g_linux_input_method_context_factory = NULL; | 97 g_linux_input_method_context_factory = NULL; |
98 #elif defined(OS_WIN) | 98 #elif defined(OS_WIN) |
99 internal::DestroySharedInputMethod(); | 99 internal::DestroySharedInputMethod(); |
100 if (base::win::IsTSFAwareRequired()) { | 100 if (base::win::IsTSFAwareRequired()) { |
101 TSFBridge::Shutdown(); | 101 TSFBridge::Shutdown(); |
102 CoUninitialize(); | 102 CoUninitialize(); |
103 } | 103 } |
104 #endif | 104 #endif |
105 } | 105 } |
106 | 106 |
107 } // namespace ui | 107 } // namespace ui |
OLD | NEW |