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/logging.h" | 8 #include "base/logging.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "chrome/browser/chromeos/input_method/accessibility.h" | 10 #include "chrome/browser/chromeos/input_method/accessibility.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 InputMethodManager::State new_state) { | 23 InputMethodManager::State new_state) { |
24 input_method_persistence->OnSessionStateChange(new_state); | 24 input_method_persistence->OnSessionStateChange(new_state); |
25 input_method_manager_impl->SetState(new_state); | 25 input_method_manager_impl->SetState(new_state); |
26 } | 26 } |
27 | 27 |
28 class InputMethodConfiguration { | 28 class InputMethodConfiguration { |
29 public: | 29 public: |
30 InputMethodConfiguration() {} | 30 InputMethodConfiguration() {} |
31 virtual ~InputMethodConfiguration() {} | 31 virtual ~InputMethodConfiguration() {} |
32 | 32 |
33 void Initialize( | 33 void Initialize() { |
34 const scoped_refptr<base::SequencedTaskRunner>& ui_task_runner) { | |
35 IMEBridge::Initialize(); | 34 IMEBridge::Initialize(); |
36 | 35 |
37 InputMethodManagerImpl* impl = new InputMethodManagerImpl( | 36 InputMethodManagerImpl* impl = new InputMethodManagerImpl( |
38 scoped_ptr<InputMethodDelegate>(new InputMethodDelegateImpl)); | 37 scoped_ptr<InputMethodDelegate>(new InputMethodDelegateImpl)); |
39 impl->Init(ui_task_runner.get()); | |
40 InputMethodManager::Initialize(impl); | 38 InputMethodManager::Initialize(impl); |
41 | 39 |
42 DCHECK(InputMethodManager::Get()); | 40 DCHECK(InputMethodManager::Get()); |
43 | 41 |
44 accessibility_.reset(new Accessibility(impl)); | 42 accessibility_.reset(new Accessibility(impl)); |
45 input_method_persistence_.reset(new InputMethodPersistence(impl)); | 43 input_method_persistence_.reset(new InputMethodPersistence(impl)); |
46 browser_state_monitor_.reset(new BrowserStateMonitor( | 44 browser_state_monitor_.reset(new BrowserStateMonitor( |
47 base::Bind(&OnSessionStateChange, | 45 base::Bind(&OnSessionStateChange, |
48 impl, | 46 impl, |
49 input_method_persistence_.get()))); | 47 input_method_persistence_.get()))); |
(...skipping 21 matching lines...) Expand all Loading... |
71 private: | 69 private: |
72 scoped_ptr<Accessibility> accessibility_; | 70 scoped_ptr<Accessibility> accessibility_; |
73 scoped_ptr<BrowserStateMonitor> browser_state_monitor_; | 71 scoped_ptr<BrowserStateMonitor> browser_state_monitor_; |
74 scoped_ptr<InputMethodPersistence> input_method_persistence_; | 72 scoped_ptr<InputMethodPersistence> input_method_persistence_; |
75 }; | 73 }; |
76 | 74 |
77 InputMethodConfiguration* g_input_method_configuration = NULL; | 75 InputMethodConfiguration* g_input_method_configuration = NULL; |
78 | 76 |
79 } // namespace | 77 } // namespace |
80 | 78 |
81 void Initialize( | 79 void Initialize() { |
82 const scoped_refptr<base::SequencedTaskRunner>& ui_task_runner, | |
83 const scoped_refptr<base::SequencedTaskRunner>& file_task_runner) { | |
84 if (!g_input_method_configuration) | 80 if (!g_input_method_configuration) |
85 g_input_method_configuration = new InputMethodConfiguration(); | 81 g_input_method_configuration = new InputMethodConfiguration(); |
86 g_input_method_configuration->Initialize(ui_task_runner); | 82 g_input_method_configuration->Initialize(); |
87 } | 83 } |
88 | 84 |
89 void InitializeForTesting(InputMethodManager* mock_manager) { | 85 void InitializeForTesting(InputMethodManager* mock_manager) { |
90 if (!g_input_method_configuration) | 86 if (!g_input_method_configuration) |
91 g_input_method_configuration = new InputMethodConfiguration(); | 87 g_input_method_configuration = new InputMethodConfiguration(); |
92 g_input_method_configuration->InitializeForTesting(mock_manager); | 88 g_input_method_configuration->InitializeForTesting(mock_manager); |
93 } | 89 } |
94 | 90 |
95 void Shutdown() { | 91 void Shutdown() { |
96 if (!g_input_method_configuration) | 92 if (!g_input_method_configuration) |
97 return; | 93 return; |
98 | 94 |
99 g_input_method_configuration->Shutdown(); | 95 g_input_method_configuration->Shutdown(); |
100 delete g_input_method_configuration; | 96 delete g_input_method_configuration; |
101 g_input_method_configuration = NULL; | 97 g_input_method_configuration = NULL; |
102 } | 98 } |
103 | 99 |
104 } // namespace input_method | 100 } // namespace input_method |
105 } // namespace chromeos | 101 } // namespace chromeos |
OLD | NEW |