Chromium Code Reviews

Side by Side Diff: ui/base/ime/input_method_factory.cc

Issue 1177503003: Remove the 2-level input method system & InputMethodBridge. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: reverted changes for MockInputMethod. Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
OLDNEW
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) 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(USE_X11) && \ 17 #elif defined(USE_AURA) && defined(OS_LINUX) && defined(USE_X11) && \
18 !defined(OS_CHROMEOS) 18 !defined(OS_CHROMEOS)
19 #include "ui/base/ime/input_method_auralinux.h" 19 #include "ui/base/ime/input_method_auralinux.h"
20 #else 20 #else
21 #include "ui/base/ime/input_method_minimal.h" 21 #include "ui/base/ime/input_method_minimal.h"
22 #endif 22 #endif
23 23
24 namespace { 24 namespace {
25 25
26 ui::InputMethod* g_input_method_for_testing = nullptr;
27
26 bool g_input_method_set_for_testing = false; 28 bool g_input_method_set_for_testing = false;
27 29
28 bool g_create_input_method_called = false; 30 bool g_create_input_method_called = false;
29 31
30 } // namespace 32 } // namespace
31 33
32 namespace ui { 34 namespace ui {
33 35
34 scoped_ptr<InputMethod> CreateInputMethod( 36 scoped_ptr<InputMethod> CreateInputMethod(
35 internal::InputMethodDelegate* delegate, 37 internal::InputMethodDelegate* delegate,
36 gfx::AcceleratedWidget widget) { 38 gfx::AcceleratedWidget widget) {
37 if (!g_create_input_method_called) 39 if (!g_create_input_method_called)
38 g_create_input_method_called = true; 40 g_create_input_method_called = true;
39 41
42 if (g_input_method_for_testing)
43 return make_scoped_ptr(g_input_method_for_testing);
James Su 2015/06/12 07:58:50 Not sure if this code is correct. If more than one
Shu Chen 2015/06/12 08:51:31 Done. Doing "g_input_method_for_testing = nullptr;
44
40 if (g_input_method_set_for_testing) 45 if (g_input_method_set_for_testing)
41 return make_scoped_ptr(new MockInputMethod(delegate)); 46 return make_scoped_ptr(new MockInputMethod(delegate));
42 47
43 #if defined(OS_CHROMEOS) 48 #if defined(OS_CHROMEOS)
44 return make_scoped_ptr(new InputMethodChromeOS(delegate)); 49 return make_scoped_ptr(new InputMethodChromeOS(delegate));
45 #elif defined(OS_WIN) 50 #elif defined(OS_WIN)
46 if (IsRemoteInputMethodWinRequired(widget)) 51 if (IsRemoteInputMethodWinRequired(widget))
47 return CreateRemoteInputMethodWin(delegate); 52 return CreateRemoteInputMethodWin(delegate);
48 return make_scoped_ptr(new InputMethodWin(delegate, widget)); 53 return make_scoped_ptr(new InputMethodWin(delegate, widget));
49 #elif defined(OS_MACOSX) 54 #elif defined(OS_MACOSX)
(...skipping 11 matching lines...)
61 return; 66 return;
62 67
63 CHECK(!g_create_input_method_called) 68 CHECK(!g_create_input_method_called)
64 << "ui::SetUpInputMethodFactoryForTesting was called after use of " 69 << "ui::SetUpInputMethodFactoryForTesting was called after use of "
65 << "ui::CreateInputMethod. You must call " 70 << "ui::CreateInputMethod. You must call "
66 << "ui::SetUpInputMethodFactoryForTesting earlier."; 71 << "ui::SetUpInputMethodFactoryForTesting earlier.";
67 72
68 g_input_method_set_for_testing = true; 73 g_input_method_set_for_testing = true;
69 } 74 }
70 75
76 void SetUpInputMethodForTesting(InputMethod* input_method) {
77 g_input_method_for_testing = input_method;
78 }
79
71 } // namespace ui 80 } // namespace ui
OLDNEW

Powered by Google App Engine