Drive: Add BatchableRequest subclass.
[chromium-blink-merge.git] / ui / base / ime / input_method_initializer.cc
blob2fca46cff47ab73c2d41d84c0f7675bd1732cfab
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"
12 #endif
14 namespace {
16 #if !defined(OS_CHROMEOS) && defined(USE_AURA) && defined(OS_LINUX)
17 const ui::LinuxInputMethodContextFactory* g_linux_input_method_context_factory;
18 #endif
20 } // namespace
22 namespace ui {
24 void InitializeInputMethod() {
25 #if defined(OS_CHROMEOS)
26 chromeos::IMEBridge::Initialize();
27 #endif
30 void ShutdownInputMethod() {
31 #if defined(OS_CHROMEOS)
32 chromeos::IMEBridge::Shutdown();
33 #endif
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 "
46 << "else.";
47 LinuxInputMethodContextFactory::SetInstance(
48 g_linux_input_method_context_factory);
49 #endif
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;
63 #endif
66 } // namespace ui