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) |
10 #include "base/logging.h" | 10 #include "base/logging.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 #endif | 12 #endif |
13 | 13 |
14 namespace { | 14 namespace { |
15 | 15 |
16 #if !defined(OS_CHROMEOS) && defined(USE_AURA) && defined(OS_LINUX) && \ | 16 #if !defined(OS_CHROMEOS) && defined(USE_AURA) && defined(OS_LINUX) |
17 !defined(USE_OZONE) | |
18 const ui::LinuxInputMethodContextFactory* g_linux_input_method_context_factory; | 17 const ui::LinuxInputMethodContextFactory* g_linux_input_method_context_factory; |
19 #endif | 18 #endif |
20 | 19 |
21 } // namespace | 20 } // namespace |
22 | 21 |
23 namespace ui { | 22 namespace ui { |
24 | 23 |
25 void InitializeInputMethod() { | 24 void InitializeInputMethod() { |
26 #if defined(OS_CHROMEOS) | 25 #if defined(OS_CHROMEOS) |
27 chromeos::IMEBridge::Initialize(); | 26 chromeos::IMEBridge::Initialize(); |
28 #endif | 27 #endif |
29 } | 28 } |
30 | 29 |
31 void ShutdownInputMethod() { | 30 void ShutdownInputMethod() { |
32 #if defined(OS_CHROMEOS) | 31 #if defined(OS_CHROMEOS) |
33 chromeos::IMEBridge::Shutdown(); | 32 chromeos::IMEBridge::Shutdown(); |
34 #endif | 33 #endif |
35 } | 34 } |
36 | 35 |
37 void InitializeInputMethodForTesting() { | 36 void InitializeInputMethodForTesting() { |
38 #if defined(OS_CHROMEOS) | 37 #if defined(OS_CHROMEOS) |
39 chromeos::IMEBridge::Initialize(); | 38 chromeos::IMEBridge::Initialize(); |
40 #elif defined(USE_AURA) && defined(OS_LINUX) && !defined(USE_OZONE) | 39 #elif defined(USE_AURA) && defined(OS_LINUX) |
41 if (!g_linux_input_method_context_factory) | 40 if (!g_linux_input_method_context_factory) |
42 g_linux_input_method_context_factory = new FakeInputMethodContextFactory(); | 41 g_linux_input_method_context_factory = new FakeInputMethodContextFactory(); |
43 const LinuxInputMethodContextFactory* factory = | 42 const LinuxInputMethodContextFactory* factory = |
44 LinuxInputMethodContextFactory::instance(); | 43 LinuxInputMethodContextFactory::instance(); |
45 CHECK(!factory || factory == g_linux_input_method_context_factory) | 44 CHECK(!factory || factory == g_linux_input_method_context_factory) |
46 << "LinuxInputMethodContextFactory was already initialized somewhere " | 45 << "LinuxInputMethodContextFactory was already initialized somewhere " |
47 << "else."; | 46 << "else."; |
48 LinuxInputMethodContextFactory::SetInstance( | 47 LinuxInputMethodContextFactory::SetInstance( |
49 g_linux_input_method_context_factory); | 48 g_linux_input_method_context_factory); |
50 #endif | 49 #endif |
51 } | 50 } |
52 | 51 |
53 void ShutdownInputMethodForTesting() { | 52 void ShutdownInputMethodForTesting() { |
54 #if defined(OS_CHROMEOS) | 53 #if defined(OS_CHROMEOS) |
55 chromeos::IMEBridge::Shutdown(); | 54 chromeos::IMEBridge::Shutdown(); |
56 #elif defined(USE_AURA) && defined(OS_LINUX) && !defined(USE_OZONE) | 55 #elif defined(USE_AURA) && defined(OS_LINUX) |
57 const LinuxInputMethodContextFactory* factory = | 56 const LinuxInputMethodContextFactory* factory = |
58 LinuxInputMethodContextFactory::instance(); | 57 LinuxInputMethodContextFactory::instance(); |
59 CHECK(!factory || factory == g_linux_input_method_context_factory) | 58 CHECK(!factory || factory == g_linux_input_method_context_factory) |
60 << "An unknown LinuxInputMethodContextFactory was set."; | 59 << "An unknown LinuxInputMethodContextFactory was set."; |
61 LinuxInputMethodContextFactory::SetInstance(NULL); | 60 LinuxInputMethodContextFactory::SetInstance(NULL); |
62 delete g_linux_input_method_context_factory; | 61 delete g_linux_input_method_context_factory; |
63 g_linux_input_method_context_factory = NULL; | 62 g_linux_input_method_context_factory = NULL; |
64 #endif | 63 #endif |
65 } | 64 } |
66 | 65 |
67 } // namespace ui | 66 } // namespace ui |
OLD | NEW |