Chromium Code Reviews| 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) |
| 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_win.h" | 13 #include "ui/base/ime/input_method_win.h" |
| 14 #include "ui/base/ime/remote_input_method_win.h" | 14 #include "ui/base/ime/remote_input_method_win.h" |
| 15 #elif defined(OS_MACOSX) | 15 #elif defined(OS_MACOSX) |
| 16 #include "ui/base/ime/input_method_mac.h" | 16 #include "ui/base/ime/input_method_mac.h" |
| 17 #elif defined(USE_AURA) && defined(OS_LINUX) && !defined(OS_CHROMEOS) | 17 #elif defined(USE_AURA) && defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 18 #include "ui/base/ime/input_method_auralinux.h" | 18 #include "ui/base/ime/input_method_auralinux.h" |
| 19 #else | 19 #else |
| 20 #include "ui/base/ime/input_method_minimal.h" | 20 #include "ui/base/ime/input_method_minimal.h" |
|
Seigo Nonaka
2014/08/12 16:10:35
So, input_method_minimal.h is no longer necessary?
Shu Chen
2014/08/13 00:21:07
There is code below to new InputMethodMinimal(). I
| |
| 21 #endif | 21 #endif |
| 22 | 22 |
| 23 namespace { | 23 namespace { |
| 24 | 24 |
| 25 bool g_input_method_set_for_testing = false; | 25 bool g_input_method_set_for_testing = false; |
| 26 | 26 |
| 27 bool g_create_input_method_called = false; | 27 bool g_create_input_method_called = false; |
| 28 | 28 |
| 29 } // namespace | 29 } // namespace |
| 30 | 30 |
| 31 namespace ui { | 31 namespace ui { |
| 32 | 32 |
| 33 scoped_ptr<InputMethod> CreateInputMethod( | 33 scoped_ptr<InputMethod> CreateInputMethod( |
| 34 internal::InputMethodDelegate* delegate, | 34 internal::InputMethodDelegate* delegate, |
| 35 gfx::AcceleratedWidget widget) { | 35 gfx::AcceleratedWidget widget) { |
| 36 if (!g_create_input_method_called) | 36 if (!g_create_input_method_called) |
| 37 g_create_input_method_called = true; | 37 g_create_input_method_called = true; |
| 38 | 38 |
| 39 if (g_input_method_set_for_testing) | 39 if (g_input_method_set_for_testing) |
| 40 return scoped_ptr<InputMethod>(new MockInputMethod(delegate)); | 40 return scoped_ptr<InputMethod>(new MockInputMethod(delegate)); |
| 41 | 41 |
| 42 #if defined(OS_CHROMEOS) && defined(USE_X11) | 42 #if defined(OS_CHROMEOS) |
| 43 return scoped_ptr<InputMethod>(new InputMethodChromeOS(delegate)); | 43 return scoped_ptr<InputMethod>(new InputMethodChromeOS(delegate)); |
| 44 #elif defined(OS_WIN) | 44 #elif defined(OS_WIN) |
| 45 if (IsRemoteInputMethodWinRequired(widget)) | 45 if (IsRemoteInputMethodWinRequired(widget)) |
| 46 return CreateRemoteInputMethodWin(delegate); | 46 return CreateRemoteInputMethodWin(delegate); |
| 47 return scoped_ptr<InputMethod>(new InputMethodWin(delegate, widget)); | 47 return scoped_ptr<InputMethod>(new InputMethodWin(delegate, widget)); |
| 48 #elif defined(OS_MACOSX) | 48 #elif defined(OS_MACOSX) |
| 49 return scoped_ptr<InputMethod>(new InputMethodMac(delegate)); | 49 return scoped_ptr<InputMethod>(new InputMethodMac(delegate)); |
| 50 #elif defined(USE_AURA) && defined(OS_LINUX) && !defined(OS_CHROMEOS) | 50 #elif defined(USE_AURA) && defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 51 return scoped_ptr<InputMethod>(new InputMethodAuraLinux(delegate)); | 51 return scoped_ptr<InputMethod>(new InputMethodAuraLinux(delegate)); |
| 52 #else | 52 #else |
| 53 return scoped_ptr<InputMethod>(new InputMethodMinimal(delegate)); | 53 return scoped_ptr<InputMethod>(new InputMethodMinimal(delegate)); |
| 54 #endif | 54 #endif |
| 55 } | 55 } |
| 56 | 56 |
| 57 void SetUpInputMethodFactoryForTesting() { | 57 void SetUpInputMethodFactoryForTesting() { |
| 58 if (g_input_method_set_for_testing) | 58 if (g_input_method_set_for_testing) |
| 59 return; | 59 return; |
| 60 | 60 |
| 61 CHECK(!g_create_input_method_called) | 61 CHECK(!g_create_input_method_called) |
| 62 << "ui::SetUpInputMethodFactoryForTesting was called after use of " | 62 << "ui::SetUpInputMethodFactoryForTesting was called after use of " |
| 63 << "ui::CreateInputMethod. You must call " | 63 << "ui::CreateInputMethod. You must call " |
| 64 << "ui::SetUpInputMethodFactoryForTesting earlier."; | 64 << "ui::SetUpInputMethodFactoryForTesting earlier."; |
| 65 | 65 |
| 66 g_input_method_set_for_testing = true; | 66 g_input_method_set_for_testing = true; |
| 67 } | 67 } |
| 68 | 68 |
| 69 } // namespace ui | 69 } // namespace ui |
| OLD | NEW |