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 "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
9 #include "ui/base/ime/mock_input_method.h" | 9 #include "ui/base/ime/mock_input_method.h" |
10 | 10 |
(...skipping 30 matching lines...) Expand all Loading... |
41 if (!g_create_input_method_called) | 41 if (!g_create_input_method_called) |
42 g_create_input_method_called = true; | 42 g_create_input_method_called = true; |
43 | 43 |
44 if (g_input_method_for_testing) { | 44 if (g_input_method_for_testing) { |
45 ui::InputMethod* ret = g_input_method_for_testing; | 45 ui::InputMethod* ret = g_input_method_for_testing; |
46 g_input_method_for_testing = nullptr; | 46 g_input_method_for_testing = nullptr; |
47 return base::WrapUnique(ret); | 47 return base::WrapUnique(ret); |
48 } | 48 } |
49 | 49 |
50 if (g_input_method_set_for_testing) | 50 if (g_input_method_set_for_testing) |
51 return base::WrapUnique(new MockInputMethod(delegate)); | 51 return base::MakeUnique<MockInputMethod>(delegate); |
52 | 52 |
53 #if defined(OS_CHROMEOS) | 53 #if defined(OS_CHROMEOS) |
54 return base::WrapUnique(new InputMethodChromeOS(delegate)); | 54 return base::MakeUnique<InputMethodChromeOS>(delegate); |
55 #elif defined(OS_WIN) | 55 #elif defined(OS_WIN) |
56 return base::WrapUnique(new InputMethodWin(delegate, widget)); | 56 return base::MakeUnique<InputMethodWin>(delegate, widget); |
57 #elif defined(OS_MACOSX) | 57 #elif defined(OS_MACOSX) |
58 return base::WrapUnique(new InputMethodMac(delegate)); | 58 return base::MakeUnique<InputMethodMac>(delegate); |
59 #elif defined(USE_AURA) && defined(OS_LINUX) && defined(USE_X11) && \ | 59 #elif defined(USE_AURA) && defined(OS_LINUX) && defined(USE_X11) && \ |
60 !defined(OS_CHROMEOS) | 60 !defined(OS_CHROMEOS) |
61 return base::WrapUnique(new InputMethodAuraLinux(delegate)); | 61 return base::MakeUnique<InputMethodAuraLinux>(delegate); |
62 #elif defined(OS_ANDROID) | 62 #elif defined(OS_ANDROID) |
63 return base::WrapUnique(new InputMethodAndroid(delegate)); | 63 return base::MakeUnique<InputMethodAndroid>(delegate); |
64 #else | 64 #else |
65 return base::WrapUnique(new InputMethodMinimal(delegate)); | 65 return base::MakeUnique<InputMethodMinimal>(delegate); |
66 #endif | 66 #endif |
67 } | 67 } |
68 | 68 |
69 void SetUpInputMethodFactoryForTesting() { | 69 void SetUpInputMethodFactoryForTesting() { |
70 if (g_input_method_set_for_testing) | 70 if (g_input_method_set_for_testing) |
71 return; | 71 return; |
72 | 72 |
73 CHECK(!g_create_input_method_called) | 73 CHECK(!g_create_input_method_called) |
74 << "ui::SetUpInputMethodFactoryForTesting was called after use of " | 74 << "ui::SetUpInputMethodFactoryForTesting was called after use of " |
75 << "ui::CreateInputMethod. You must call " | 75 << "ui::CreateInputMethod. You must call " |
76 << "ui::SetUpInputMethodFactoryForTesting earlier."; | 76 << "ui::SetUpInputMethodFactoryForTesting earlier."; |
77 | 77 |
78 g_input_method_set_for_testing = true; | 78 g_input_method_set_for_testing = true; |
79 } | 79 } |
80 | 80 |
81 void SetUpInputMethodForTesting(InputMethod* input_method) { | 81 void SetUpInputMethodForTesting(InputMethod* input_method) { |
82 g_input_method_for_testing = input_method; | 82 g_input_method_for_testing = input_method; |
83 } | 83 } |
84 | 84 |
85 } // namespace ui | 85 } // namespace ui |
OLD | NEW |