Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(36)

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

Issue 100213003: Support for providing IMEContext with Ozone. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/base/ime/input_method_factory.cc ('k') | ui/ozone/ime/DEPS » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 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_initializer.h" 5 #include "ui/base/ime/input_method_initializer.h"
6 6
7 #if defined(TOOLKIT_VIEWS) || defined(USE_AURA) 7 #if defined(TOOLKIT_VIEWS) || defined(USE_AURA)
8 #include "ui/base/ime/input_method_factory.h" 8 #include "ui/base/ime/input_method_factory.h"
9 #endif 9 #endif
10 10
11 #if defined(OS_CHROMEOS) 11 #if defined(OS_CHROMEOS)
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "chromeos/dbus/dbus_thread_manager.h" 13 #include "chromeos/dbus/dbus_thread_manager.h"
14 #include "ui/base/ime/chromeos/ibus_bridge.h" 14 #include "ui/base/ime/chromeos/ibus_bridge.h"
15 #elif defined(USE_AURA) && defined(USE_X11) 15 #elif defined(USE_AURA) && defined(OS_LINUX)
16 #include "ui/base/ime/input_method_auralinux.h" 16 #include "ui/base/ime/input_method_auralinux.h"
17 #include "ui/base/ime/linux/fake_input_method_context_factory.h" 17 #include "ui/base/ime/linux/fake_input_method_context_factory.h"
18 #elif defined(OS_WIN) 18 #elif defined(OS_WIN)
19 #include "base/win/metro.h" 19 #include "base/win/metro.h"
20 #include "ui/base/ime/win/tsf_bridge.h" 20 #include "ui/base/ime/win/tsf_bridge.h"
21 #endif 21 #endif
22 22
23 namespace { 23 namespace {
24 24
25 #if defined(OS_CHROMEOS) 25 #if defined(OS_CHROMEOS)
26 bool dbus_thread_manager_was_initialized = false; 26 bool dbus_thread_manager_was_initialized = false;
27 #elif defined(USE_AURA) && defined(USE_X11) 27 #elif defined(USE_AURA) && defined(OS_LINUX)
28 const ui::LinuxInputMethodContextFactory* g_linux_input_method_context_factory; 28 const ui::LinuxInputMethodContextFactory* g_linux_input_method_context_factory;
29 #endif 29 #endif
30 30
31 } // namespace 31 } // namespace
32 32
33 namespace ui { 33 namespace ui {
34 34
35 void InitializeInputMethod() { 35 void InitializeInputMethod() {
36 #if defined(OS_CHROMEOS) 36 #if defined(OS_CHROMEOS)
37 chromeos::IBusBridge::Initialize(); 37 chromeos::IBusBridge::Initialize();
38 #elif defined(USE_AURA) && defined(USE_X11) 38 #elif defined(USE_AURA) && defined(OS_LINUX)
39 InputMethodAuraLinux::Initialize(); 39 InputMethodAuraLinux::Initialize();
40 #elif defined(OS_WIN) 40 #elif defined(OS_WIN)
41 if (base::win::IsTSFAwareRequired()) 41 if (base::win::IsTSFAwareRequired())
42 TSFBridge::Initialize(); 42 TSFBridge::Initialize();
43 #endif 43 #endif
44 } 44 }
45 45
46 void ShutdownInputMethod() { 46 void ShutdownInputMethod() {
47 #if defined(TOOLKIT_VIEWS) || defined(USE_AURA) 47 #if defined(TOOLKIT_VIEWS) || defined(USE_AURA)
48 InputMethodFactory::ClearInstance(); 48 InputMethodFactory::ClearInstance();
49 #endif 49 #endif
50 #if defined(OS_CHROMEOS) 50 #if defined(OS_CHROMEOS)
51 chromeos::IBusBridge::Shutdown(); 51 chromeos::IBusBridge::Shutdown();
52 #elif defined(OS_WIN) 52 #elif defined(OS_WIN)
53 internal::DestroySharedInputMethod(); 53 internal::DestroySharedInputMethod();
54 if (base::win::IsTSFAwareRequired()) 54 if (base::win::IsTSFAwareRequired())
55 TSFBridge::Shutdown(); 55 TSFBridge::Shutdown();
56 #endif 56 #endif
57 } 57 }
58 58
59 void InitializeInputMethodForTesting() { 59 void InitializeInputMethodForTesting() {
60 #if defined(OS_CHROMEOS) 60 #if defined(OS_CHROMEOS)
61 chromeos::IBusBridge::Initialize(); 61 chromeos::IBusBridge::Initialize();
62 // TODO(nona): Remove DBusThreadManager initialize. 62 // TODO(nona): Remove DBusThreadManager initialize.
63 if (!chromeos::DBusThreadManager::IsInitialized()) { 63 if (!chromeos::DBusThreadManager::IsInitialized()) {
64 chromeos::DBusThreadManager::InitializeWithStub(); 64 chromeos::DBusThreadManager::InitializeWithStub();
65 dbus_thread_manager_was_initialized = true; 65 dbus_thread_manager_was_initialized = true;
66 } 66 }
67 #elif defined(USE_AURA) && defined(USE_X11) 67 #elif defined(USE_AURA) && defined(OS_LINUX)
68 if (!g_linux_input_method_context_factory) 68 if (!g_linux_input_method_context_factory)
69 g_linux_input_method_context_factory = new FakeInputMethodContextFactory(); 69 g_linux_input_method_context_factory = new FakeInputMethodContextFactory();
70 const LinuxInputMethodContextFactory* factory = 70 const LinuxInputMethodContextFactory* factory =
71 LinuxInputMethodContextFactory::instance(); 71 LinuxInputMethodContextFactory::instance();
72 CHECK(!factory || factory == g_linux_input_method_context_factory) 72 CHECK(!factory || factory == g_linux_input_method_context_factory)
73 << "LinuxInputMethodContextFactory was already initialized somewhere " 73 << "LinuxInputMethodContextFactory was already initialized somewhere "
74 << "else."; 74 << "else.";
75 LinuxInputMethodContextFactory::SetInstance( 75 LinuxInputMethodContextFactory::SetInstance(
76 g_linux_input_method_context_factory); 76 g_linux_input_method_context_factory);
77 #elif defined(OS_WIN) 77 #elif defined(OS_WIN)
78 if (base::win::IsTSFAwareRequired()) { 78 if (base::win::IsTSFAwareRequired()) {
79 // Make sure COM is initialized because TSF depends on COM. 79 // Make sure COM is initialized because TSF depends on COM.
80 CoInitialize(NULL); 80 CoInitialize(NULL);
81 TSFBridge::Initialize(); 81 TSFBridge::Initialize();
82 } 82 }
83 #endif 83 #endif
84 } 84 }
85 85
86 void ShutdownInputMethodForTesting() { 86 void ShutdownInputMethodForTesting() {
87 #if defined(TOOLKIT_VIEWS) || defined(USE_AURA) 87 #if defined(TOOLKIT_VIEWS) || defined(USE_AURA)
88 InputMethodFactory::ClearInstance(); 88 InputMethodFactory::ClearInstance();
89 #endif 89 #endif
90 #if defined(OS_CHROMEOS) 90 #if defined(OS_CHROMEOS)
91 chromeos::IBusBridge::Shutdown(); 91 chromeos::IBusBridge::Shutdown();
92 // TODO(nona): Remove DBusThreadManager finalize. 92 // TODO(nona): Remove DBusThreadManager finalize.
93 if (dbus_thread_manager_was_initialized) { 93 if (dbus_thread_manager_was_initialized) {
94 chromeos::DBusThreadManager::Shutdown(); 94 chromeos::DBusThreadManager::Shutdown();
95 dbus_thread_manager_was_initialized = false; 95 dbus_thread_manager_was_initialized = false;
96 } 96 }
97 #elif defined(USE_AURA) && defined(USE_X11) 97 #elif defined(USE_AURA) && defined(OS_LINUX)
98 const LinuxInputMethodContextFactory* factory = 98 const LinuxInputMethodContextFactory* factory =
99 LinuxInputMethodContextFactory::instance(); 99 LinuxInputMethodContextFactory::instance();
100 CHECK(!factory || factory == g_linux_input_method_context_factory) 100 CHECK(!factory || factory == g_linux_input_method_context_factory)
101 << "An unknown LinuxInputMethodContextFactory was set."; 101 << "An unknown LinuxInputMethodContextFactory was set.";
102 LinuxInputMethodContextFactory::SetInstance(NULL); 102 LinuxInputMethodContextFactory::SetInstance(NULL);
103 delete g_linux_input_method_context_factory; 103 delete g_linux_input_method_context_factory;
104 g_linux_input_method_context_factory = NULL; 104 g_linux_input_method_context_factory = NULL;
105 #elif defined(OS_WIN) 105 #elif defined(OS_WIN)
106 internal::DestroySharedInputMethod(); 106 internal::DestroySharedInputMethod();
107 if (base::win::IsTSFAwareRequired()) { 107 if (base::win::IsTSFAwareRequired()) {
108 TSFBridge::Shutdown(); 108 TSFBridge::Shutdown();
109 CoUninitialize(); 109 CoUninitialize();
110 } 110 }
111 #endif 111 #endif
112 } 112 }
113 113
114 } // namespace ui 114 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/ime/input_method_factory.cc ('k') | ui/ozone/ime/DEPS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698