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 #include "ui/base/ime/input_method_factory.h" | 5 #include "ui/base/ime/input_method_factory.h" |
6 | 6 |
7 #include "ui/base/ime/mock_input_method.h" | 7 #include "ui/base/ime/mock_input_method.h" |
8 | 8 |
9 #if defined(OS_CHROMEOS) && defined(USE_X11) | 9 #if defined(OS_CHROMEOS) && defined(USE_X11) |
10 #include "ui/base/ime/input_method_chromeos.h" | 10 #include "ui/base/ime/input_method_chromeos.h" |
11 #elif defined(OS_WIN) | 11 #elif defined(OS_WIN) |
12 #include "base/win/metro.h" | 12 #include "base/win/metro.h" |
13 #include "ui/base/ime/input_method_imm32.h" | 13 #include "ui/base/ime/input_method_imm32.h" |
14 #include "ui/base/ime/remote_input_method_win.h" | 14 #include "ui/base/ime/remote_input_method_win.h" |
15 #elif defined(USE_AURA) && defined(OS_LINUX) | 15 #elif defined(USE_AURA) && defined(OS_LINUX) |
16 #include "ui/base/ime/input_method_auralinux.h" | 16 #include "ui/base/ime/input_method_auralinux.h" |
17 #else | 17 #else |
18 #include "ui/base/ime/input_method_minimal.h" | 18 #include "ui/base/ime/input_method_minimal.h" |
19 #endif | 19 #endif |
20 | 20 |
21 namespace { | 21 namespace { |
22 | 22 |
23 bool g_input_method_set_for_testing = false; | 23 bool g_input_method_set_for_testing = false; |
24 | 24 |
25 bool g_create_input_method_called = false; | 25 bool g_create_input_method_called = false; |
26 | 26 |
27 #if defined(OS_WIN) | |
28 ui::InputMethod* g_shared_input_method = NULL; | |
29 #endif | |
30 | |
31 } // namespace | 27 } // namespace |
32 | 28 |
33 namespace ui { | 29 namespace ui { |
34 | 30 |
35 scoped_ptr<InputMethod> CreateInputMethod( | 31 scoped_ptr<InputMethod> CreateInputMethod( |
36 internal::InputMethodDelegate* delegate, | 32 internal::InputMethodDelegate* delegate, |
37 gfx::AcceleratedWidget widget) { | 33 gfx::AcceleratedWidget widget) { |
38 if (!g_create_input_method_called) | 34 if (!g_create_input_method_called) |
39 g_create_input_method_called = true; | 35 g_create_input_method_called = true; |
40 | 36 |
(...skipping 18 matching lines...) Expand all Loading... |
59 return; | 55 return; |
60 | 56 |
61 CHECK(!g_create_input_method_called) | 57 CHECK(!g_create_input_method_called) |
62 << "ui::SetUpInputMethodFactoryForTesting was called after use of " | 58 << "ui::SetUpInputMethodFactoryForTesting was called after use of " |
63 << "ui::CreateInputMethod. You must call " | 59 << "ui::CreateInputMethod. You must call " |
64 << "ui::SetUpInputMethodFactoryForTesting earlier."; | 60 << "ui::SetUpInputMethodFactoryForTesting earlier."; |
65 | 61 |
66 g_input_method_set_for_testing = true; | 62 g_input_method_set_for_testing = true; |
67 } | 63 } |
68 | 64 |
69 #if defined(OS_WIN) | |
70 InputMethod* GetSharedInputMethod() { | |
71 if (!g_shared_input_method) | |
72 g_shared_input_method = CreateInputMethod(NULL, NULL).release(); | |
73 return g_shared_input_method; | |
74 } | |
75 | |
76 namespace internal { | |
77 | |
78 void DestroySharedInputMethod() { | |
79 delete g_shared_input_method; | |
80 g_shared_input_method = NULL; | |
81 } | |
82 | |
83 } // namespace internal | |
84 #endif | |
85 | |
86 } // namespace ui | 65 } // namespace ui |
OLD | NEW |