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
3 // found in the LICENSE file.
5 #include "chrome/browser/chromeos/input_method/input_method_configuration.h"
8 #include "base/logging.h"
9 #include "base/memory/scoped_ptr.h"
10 #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_manager_impl.h"
13 #include "chrome/browser/chromeos/input_method/input_method_persistence.h"
14 #include "chromeos/ime/ibus_bridge.h"
17 namespace input_method {
20 InputMethodPersistence* g_input_method_persistence = NULL;
21 BrowserStateMonitor* g_browser_state_monitor = NULL;
24 void OnSessionStateChange(InputMethodManagerImpl* input_method_manager_impl,
25 InputMethodPersistence* input_method_persistence,
26 InputMethodManager::State new_state) {
27 input_method_persistence->OnSessionStateChange(new_state);
28 input_method_manager_impl->SetState(new_state);
32 const scoped_refptr<base::SequencedTaskRunner>& ui_task_runner,
33 const scoped_refptr<base::SequencedTaskRunner>& file_task_runner) {
34 IBusDaemonController::Initialize(ui_task_runner, file_task_runner);
35 IBusBridge::Initialize();
36 IBusDaemonController::GetInstance()->Start();
38 InputMethodManagerImpl* impl = new InputMethodManagerImpl(
39 scoped_ptr<InputMethodDelegate>(new InputMethodDelegateImpl));
40 impl->Init(ui_task_runner.get());
41 InputMethodManager::Initialize(impl);
42 g_input_method_persistence = new InputMethodPersistence(impl);
43 g_browser_state_monitor = new BrowserStateMonitor(
44 base::Bind(&OnSessionStateChange, impl, g_input_method_persistence));
46 DVLOG(1) << "InputMethodManager initialized";
49 void InitializeForTesting(InputMethodManager* mock_manager) {
50 InputMethodManager::Initialize(mock_manager);
51 DVLOG(1) << "InputMethodManager for testing initialized";
55 delete g_browser_state_monitor;
56 g_browser_state_monitor = NULL;
58 delete g_input_method_persistence;
59 g_input_method_persistence = NULL;
61 InputMethodManager::Shutdown();
63 IBusBridge::Shutdown();
64 IBusDaemonController::Shutdown();
66 DVLOG(1) << "InputMethodManager shutdown";
69 InputMethodManager* GetInputMethodManager() {
70 return InputMethodManager::Get();
73 } // namespace input_method
74 } // namespace chromeos