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 "chrome/browser/chromeos/input_method/input_method_configuration.h" | 5 #include "chrome/browser/chromeos/input_method/input_method_configuration.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/chromeos/chromeos_version.h" | |
8 #include "base/logging.h" | 9 #include "base/logging.h" |
9 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
10 #include "chrome/browser/chromeos/input_method/browser_state_monitor.h" | 11 #include "chrome/browser/chromeos/input_method/browser_state_monitor.h" |
11 #include "chrome/browser/chromeos/input_method/input_method_delegate_impl.h" | 12 #include "chrome/browser/chromeos/input_method/input_method_delegate_impl.h" |
12 #include "chrome/browser/chromeos/input_method/input_method_manager_impl.h" | 13 #include "chrome/browser/chromeos/input_method/input_method_manager_impl.h" |
13 #include "chrome/browser/chromeos/input_method/input_method_persistence.h" | 14 #include "chrome/browser/chromeos/input_method/input_method_persistence.h" |
15 #include "chromeos/ime/ibus_bridge.h" | |
14 | 16 |
15 namespace chromeos { | 17 namespace chromeos { |
16 namespace input_method { | 18 namespace input_method { |
17 | 19 |
18 namespace { | 20 namespace { |
19 InputMethodManager* g_input_method_manager = NULL; | 21 InputMethodManager* g_input_method_manager = NULL; |
20 InputMethodPersistence* g_input_method_persistence = NULL; | 22 InputMethodPersistence* g_input_method_persistence = NULL; |
21 BrowserStateMonitor* g_browser_state_monitor = NULL; | 23 BrowserStateMonitor* g_browser_state_monitor = NULL; |
22 } // namespace | 24 } // namespace |
23 | 25 |
24 void OnSessionStateChange(InputMethodManagerImpl* input_method_manager_impl, | 26 void OnSessionStateChange(InputMethodManagerImpl* input_method_manager_impl, |
25 InputMethodPersistence* input_method_persistence, | 27 InputMethodPersistence* input_method_persistence, |
26 InputMethodManager::State new_state) { | 28 InputMethodManager::State new_state) { |
27 input_method_persistence->OnSessionStateChange(new_state); | 29 input_method_persistence->OnSessionStateChange(new_state); |
28 input_method_manager_impl->SetState(new_state); | 30 input_method_manager_impl->SetState(new_state); |
29 } | 31 } |
30 | 32 |
31 void Initialize() { | 33 void Initialize() { |
32 DCHECK(!g_input_method_manager); | 34 DCHECK(!g_input_method_manager); |
33 | 35 |
36 if (!base::chromeos::IsRunningOnChromeOS()) { | |
37 // IBusBridge is for ChromeOS on desktop Linux not for ChromeOS Devices or | |
38 // production at this moment. | |
39 // TODO(nona): Remove this condition when ibus-daemon is gone. | |
satorux1
2013/02/12 03:26:53
Add a crbug.com/ URL?
Seigo Nonaka
2013/02/12 13:44:55
Done.
| |
40 IBusBridge::Initialize(); | |
41 } | |
42 | |
34 InputMethodManagerImpl* impl = new InputMethodManagerImpl( | 43 InputMethodManagerImpl* impl = new InputMethodManagerImpl( |
35 scoped_ptr<InputMethodDelegate>(new InputMethodDelegateImpl)); | 44 scoped_ptr<InputMethodDelegate>(new InputMethodDelegateImpl)); |
36 impl->Init(); | 45 impl->Init(); |
37 g_input_method_manager = impl; | 46 g_input_method_manager = impl; |
38 g_input_method_persistence = | 47 g_input_method_persistence = |
39 new InputMethodPersistence(g_input_method_manager); | 48 new InputMethodPersistence(g_input_method_manager); |
40 g_browser_state_monitor = new BrowserStateMonitor( | 49 g_browser_state_monitor = new BrowserStateMonitor( |
41 base::Bind(&OnSessionStateChange, impl, g_input_method_persistence)); | 50 base::Bind(&OnSessionStateChange, impl, g_input_method_persistence)); |
42 | 51 |
43 DVLOG(1) << "InputMethodManager initialized"; | 52 DVLOG(1) << "InputMethodManager initialized"; |
44 } | 53 } |
45 | 54 |
46 void InitializeForTesting(InputMethodManager* mock_manager) { | 55 void InitializeForTesting(InputMethodManager* mock_manager) { |
47 DCHECK(!g_input_method_manager); | 56 DCHECK(!g_input_method_manager); |
48 g_input_method_manager = mock_manager; | 57 g_input_method_manager = mock_manager; |
49 DVLOG(1) << "InputMethodManager for testing initialized"; | 58 DVLOG(1) << "InputMethodManager for testing initialized"; |
50 } | 59 } |
51 | 60 |
52 void Shutdown() { | 61 void Shutdown() { |
53 delete g_browser_state_monitor; | 62 delete g_browser_state_monitor; |
54 g_browser_state_monitor = NULL; | 63 g_browser_state_monitor = NULL; |
55 | 64 |
56 delete g_input_method_persistence; | 65 delete g_input_method_persistence; |
57 g_input_method_persistence = NULL; | 66 g_input_method_persistence = NULL; |
58 | 67 |
59 delete g_input_method_manager; | 68 delete g_input_method_manager; |
60 g_input_method_manager = NULL; | 69 g_input_method_manager = NULL; |
61 | 70 |
71 if (IBusBridge::Get()) { | |
72 // TODO(nona): Remove this condition when ibus-daemon is gone. | |
73 IBusBridge::Shutdown(); | |
74 } | |
75 | |
62 DVLOG(1) << "InputMethodManager shutdown"; | 76 DVLOG(1) << "InputMethodManager shutdown"; |
63 } | 77 } |
64 | 78 |
65 InputMethodManager* GetInputMethodManager() { | 79 InputMethodManager* GetInputMethodManager() { |
66 DCHECK(g_input_method_manager); | 80 DCHECK(g_input_method_manager); |
67 return g_input_method_manager; | 81 return g_input_method_manager; |
68 } | 82 } |
69 | 83 |
70 } // namespace input_method | 84 } // namespace input_method |
71 } // namespace chromeos | 85 } // namespace chromeos |
OLD | NEW |