| 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" |
| 11 #include "chrome/browser/chromeos/input_method/browser_state_monitor.h" | 11 #include "chrome/browser/chromeos/input_method/browser_state_monitor.h" |
| 12 #include "chrome/browser/chromeos/input_method/input_method_delegate_impl.h" | 12 #include "chrome/browser/chromeos/input_method/input_method_delegate_impl.h" |
| 13 #include "chrome/browser/chromeos/input_method/input_method_manager_impl.h" | 13 #include "chrome/browser/chromeos/input_method/input_method_manager_impl.h" |
| 14 #include "chrome/browser/chromeos/input_method/input_method_persistence.h" | 14 #include "chrome/browser/chromeos/input_method/input_method_persistence.h" |
| 15 #include "ui/base/ime/chromeos/ime_bridge.h" | 15 #include "ui/base/ime/chromeos/ime_bridge.h" |
| 16 | 16 |
| 17 namespace chromeos { | 17 namespace chromeos { |
| 18 namespace input_method { | 18 namespace input_method { |
| 19 | 19 |
| 20 namespace { | 20 namespace { |
| 21 void OnSessionStateChange(InputMethodManagerImpl* input_method_manager_impl, | 21 void OnSessionStateChange(InputMethodManagerImpl* input_method_manager_impl, |
| 22 InputMethodPersistence* input_method_persistence, | 22 InputMethodPersistence* input_method_persistence, |
| 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 bool g_disable_extension_loading = false; |
| 29 |
| 28 class InputMethodConfiguration { | 30 class InputMethodConfiguration { |
| 29 public: | 31 public: |
| 30 InputMethodConfiguration() {} | 32 InputMethodConfiguration() {} |
| 31 virtual ~InputMethodConfiguration() {} | 33 virtual ~InputMethodConfiguration() {} |
| 32 | 34 |
| 33 void Initialize() { | 35 void Initialize() { |
| 34 IMEBridge::Initialize(); | 36 IMEBridge::Initialize(); |
| 35 | 37 |
| 36 InputMethodManagerImpl* impl = new InputMethodManagerImpl( | 38 InputMethodManagerImpl* impl = new InputMethodManagerImpl( |
| 37 scoped_ptr<InputMethodDelegate>(new InputMethodDelegateImpl)); | 39 scoped_ptr<InputMethodDelegate>(new InputMethodDelegateImpl), |
| 40 !g_disable_extension_loading); |
| 38 InputMethodManager::Initialize(impl); | 41 InputMethodManager::Initialize(impl); |
| 39 | 42 |
| 40 DCHECK(InputMethodManager::Get()); | 43 DCHECK(InputMethodManager::Get()); |
| 41 | 44 |
| 42 accessibility_.reset(new Accessibility(impl)); | 45 accessibility_.reset(new Accessibility(impl)); |
| 43 input_method_persistence_.reset(new InputMethodPersistence(impl)); | 46 input_method_persistence_.reset(new InputMethodPersistence(impl)); |
| 44 browser_state_monitor_.reset(new BrowserStateMonitor( | 47 browser_state_monitor_.reset(new BrowserStateMonitor( |
| 45 base::Bind(&OnSessionStateChange, | 48 base::Bind(&OnSessionStateChange, |
| 46 impl, | 49 impl, |
| 47 input_method_persistence_.get()))); | 50 input_method_persistence_.get()))); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 g_input_method_configuration = new InputMethodConfiguration(); | 84 g_input_method_configuration = new InputMethodConfiguration(); |
| 82 g_input_method_configuration->Initialize(); | 85 g_input_method_configuration->Initialize(); |
| 83 } | 86 } |
| 84 | 87 |
| 85 void InitializeForTesting(InputMethodManager* mock_manager) { | 88 void InitializeForTesting(InputMethodManager* mock_manager) { |
| 86 if (!g_input_method_configuration) | 89 if (!g_input_method_configuration) |
| 87 g_input_method_configuration = new InputMethodConfiguration(); | 90 g_input_method_configuration = new InputMethodConfiguration(); |
| 88 g_input_method_configuration->InitializeForTesting(mock_manager); | 91 g_input_method_configuration->InitializeForTesting(mock_manager); |
| 89 } | 92 } |
| 90 | 93 |
| 94 void DisableExtensionLoading() { |
| 95 g_disable_extension_loading = true; |
| 96 } |
| 97 |
| 91 void Shutdown() { | 98 void Shutdown() { |
| 92 if (!g_input_method_configuration) | 99 if (!g_input_method_configuration) |
| 93 return; | 100 return; |
| 94 | 101 |
| 95 g_input_method_configuration->Shutdown(); | 102 g_input_method_configuration->Shutdown(); |
| 96 delete g_input_method_configuration; | 103 delete g_input_method_configuration; |
| 97 g_input_method_configuration = NULL; | 104 g_input_method_configuration = NULL; |
| 98 } | 105 } |
| 99 | 106 |
| 100 } // namespace input_method | 107 } // namespace input_method |
| 101 } // namespace chromeos | 108 } // namespace chromeos |
| OLD | NEW |