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
3 // found in the LICENSE file.
5 #include "ui/base/ime/input_method_initializer.h"
7 #if defined(OS_CHROMEOS)
8 #include "ui/base/ime/chromeos/ime_bridge.h"
9 #elif defined(USE_AURA) && defined(OS_LINUX)
10 #include "base/logging.h"
11 #include "ui/base/ime/linux/fake_input_method_context_factory.h"
16 #if !defined(OS_CHROMEOS) && defined(USE_AURA) && defined(OS_LINUX)
17 const ui::LinuxInputMethodContextFactory
* g_linux_input_method_context_factory
;
24 void InitializeInputMethod() {
25 #if defined(OS_CHROMEOS)
26 chromeos::IMEBridge::Initialize();
30 void ShutdownInputMethod() {
31 #if defined(OS_CHROMEOS)
32 chromeos::IMEBridge::Shutdown();
36 void InitializeInputMethodForTesting() {
37 #if defined(OS_CHROMEOS)
38 chromeos::IMEBridge::Initialize();
39 #elif defined(USE_AURA) && defined(OS_LINUX)
40 if (!g_linux_input_method_context_factory
)
41 g_linux_input_method_context_factory
= new FakeInputMethodContextFactory();
42 const LinuxInputMethodContextFactory
* factory
=
43 LinuxInputMethodContextFactory::instance();
44 CHECK(!factory
|| factory
== g_linux_input_method_context_factory
)
45 << "LinuxInputMethodContextFactory was already initialized somewhere "
47 LinuxInputMethodContextFactory::SetInstance(
48 g_linux_input_method_context_factory
);
52 void ShutdownInputMethodForTesting() {
53 #if defined(OS_CHROMEOS)
54 chromeos::IMEBridge::Shutdown();
55 #elif defined(USE_AURA) && defined(OS_LINUX)
56 const LinuxInputMethodContextFactory
* factory
=
57 LinuxInputMethodContextFactory::instance();
58 CHECK(!factory
|| factory
== g_linux_input_method_context_factory
)
59 << "An unknown LinuxInputMethodContextFactory was set.";
60 LinuxInputMethodContextFactory::SetInstance(NULL
);
61 delete g_linux_input_method_context_factory
;
62 g_linux_input_method_context_factory
= NULL
;