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()) | |
satorux1
2013/02/07 01:46:16
Please add a comment why !IsRunningOnChromeOS()
Seigo Nonaka
2013/02/08 07:53:01
Done.
| |
37 IBusBridge::Initialize(); | |
38 | |
34 InputMethodManagerImpl* impl = new InputMethodManagerImpl( | 39 InputMethodManagerImpl* impl = new InputMethodManagerImpl( |
35 scoped_ptr<InputMethodDelegate>(new InputMethodDelegateImpl)); | 40 scoped_ptr<InputMethodDelegate>(new InputMethodDelegateImpl)); |
36 impl->Init(); | 41 impl->Init(); |
37 g_input_method_manager = impl; | 42 g_input_method_manager = impl; |
38 g_input_method_persistence = | 43 g_input_method_persistence = |
39 new InputMethodPersistence(g_input_method_manager); | 44 new InputMethodPersistence(g_input_method_manager); |
40 g_browser_state_monitor = new BrowserStateMonitor( | 45 g_browser_state_monitor = new BrowserStateMonitor( |
41 base::Bind(&OnSessionStateChange, impl, g_input_method_persistence)); | 46 base::Bind(&OnSessionStateChange, impl, g_input_method_persistence)); |
42 | 47 |
43 DVLOG(1) << "InputMethodManager initialized"; | 48 DVLOG(1) << "InputMethodManager initialized"; |
44 } | 49 } |
45 | 50 |
46 void InitializeForTesting(InputMethodManager* mock_manager) { | 51 void InitializeForTesting(InputMethodManager* mock_manager) { |
47 DCHECK(!g_input_method_manager); | 52 DCHECK(!g_input_method_manager); |
48 g_input_method_manager = mock_manager; | 53 g_input_method_manager = mock_manager; |
49 DVLOG(1) << "InputMethodManager for testing initialized"; | 54 DVLOG(1) << "InputMethodManager for testing initialized"; |
50 } | 55 } |
51 | 56 |
52 void Shutdown() { | 57 void Shutdown() { |
53 delete g_browser_state_monitor; | 58 delete g_browser_state_monitor; |
54 g_browser_state_monitor = NULL; | 59 g_browser_state_monitor = NULL; |
55 | 60 |
56 delete g_input_method_persistence; | 61 delete g_input_method_persistence; |
57 g_input_method_persistence = NULL; | 62 g_input_method_persistence = NULL; |
58 | 63 |
59 delete g_input_method_manager; | 64 delete g_input_method_manager; |
60 g_input_method_manager = NULL; | 65 g_input_method_manager = NULL; |
61 | 66 |
67 if (!base::chromeos::IsRunningOnChromeOS()) | |
satorux1
2013/02/07 01:46:16
This looks rather fragile.
Can you do something l
Seigo Nonaka
2013/02/08 07:53:01
Done.
| |
68 IBusBridge::Shutdown(); | |
69 | |
62 DVLOG(1) << "InputMethodManager shutdown"; | 70 DVLOG(1) << "InputMethodManager shutdown"; |
63 } | 71 } |
64 | 72 |
65 InputMethodManager* GetInputMethodManager() { | 73 InputMethodManager* GetInputMethodManager() { |
66 DCHECK(g_input_method_manager); | 74 DCHECK(g_input_method_manager); |
67 return g_input_method_manager; | 75 return g_input_method_manager; |
68 } | 76 } |
69 | 77 |
70 } // namespace input_method | 78 } // namespace input_method |
71 } // namespace chromeos | 79 } // namespace chromeos |
OLD | NEW |