| 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 <memory> |
| 8 |
| 7 #include "base/bind.h" | 9 #include "base/bind.h" |
| 8 #include "base/logging.h" | 10 #include "base/logging.h" |
| 9 #include "base/memory/scoped_ptr.h" | |
| 10 #include "chrome/browser/chromeos/input_method/accessibility.h" | 11 #include "chrome/browser/chromeos/input_method/accessibility.h" |
| 11 #include "chrome/browser/chromeos/input_method/browser_state_monitor.h" | 12 #include "chrome/browser/chromeos/input_method/browser_state_monitor.h" |
| 12 #include "chrome/browser/chromeos/input_method/input_method_delegate_impl.h" | 13 #include "chrome/browser/chromeos/input_method/input_method_delegate_impl.h" |
| 13 #include "chrome/browser/chromeos/input_method/input_method_manager_impl.h" | 14 #include "chrome/browser/chromeos/input_method/input_method_manager_impl.h" |
| 14 #include "chrome/browser/chromeos/input_method/input_method_persistence.h" | 15 #include "chrome/browser/chromeos/input_method/input_method_persistence.h" |
| 15 #include "ui/base/ime/ime_bridge.h" | 16 #include "ui/base/ime/ime_bridge.h" |
| 16 | 17 |
| 17 namespace chromeos { | 18 namespace chromeos { |
| 18 namespace input_method { | 19 namespace input_method { |
| 19 | 20 |
| 20 namespace { | 21 namespace { |
| 21 void OnSessionStateChange(InputMethodManagerImpl* input_method_manager_impl, | 22 void OnSessionStateChange(InputMethodManagerImpl* input_method_manager_impl, |
| 22 InputMethodPersistence* input_method_persistence, | 23 InputMethodPersistence* input_method_persistence, |
| 23 InputMethodManager::UISessionState new_ui_session) { | 24 InputMethodManager::UISessionState new_ui_session) { |
| 24 input_method_persistence->OnSessionStateChange(new_ui_session); | 25 input_method_persistence->OnSessionStateChange(new_ui_session); |
| 25 input_method_manager_impl->SetUISessionState(new_ui_session); | 26 input_method_manager_impl->SetUISessionState(new_ui_session); |
| 26 } | 27 } |
| 27 | 28 |
| 28 bool g_disable_extension_loading = false; | 29 bool g_disable_extension_loading = false; |
| 29 | 30 |
| 30 class InputMethodConfiguration { | 31 class InputMethodConfiguration { |
| 31 public: | 32 public: |
| 32 InputMethodConfiguration() {} | 33 InputMethodConfiguration() {} |
| 33 virtual ~InputMethodConfiguration() {} | 34 virtual ~InputMethodConfiguration() {} |
| 34 | 35 |
| 35 void Initialize() { | 36 void Initialize() { |
| 36 ui::IMEBridge::Initialize(); | 37 ui::IMEBridge::Initialize(); |
| 37 | 38 |
| 38 InputMethodManagerImpl* impl = new InputMethodManagerImpl( | 39 InputMethodManagerImpl* impl = new InputMethodManagerImpl( |
| 39 scoped_ptr<InputMethodDelegate>(new InputMethodDelegateImpl), | 40 std::unique_ptr<InputMethodDelegate>(new InputMethodDelegateImpl), |
| 40 !g_disable_extension_loading); | 41 !g_disable_extension_loading); |
| 41 InputMethodManager::Initialize(impl); | 42 InputMethodManager::Initialize(impl); |
| 42 | 43 |
| 43 DCHECK(InputMethodManager::Get()); | 44 DCHECK(InputMethodManager::Get()); |
| 44 | 45 |
| 45 accessibility_.reset(new Accessibility(impl)); | 46 accessibility_.reset(new Accessibility(impl)); |
| 46 input_method_persistence_.reset(new InputMethodPersistence(impl)); | 47 input_method_persistence_.reset(new InputMethodPersistence(impl)); |
| 47 browser_state_monitor_.reset(new BrowserStateMonitor( | 48 browser_state_monitor_.reset(new BrowserStateMonitor( |
| 48 base::Bind(&OnSessionStateChange, | 49 base::Bind(&OnSessionStateChange, |
| 49 impl, | 50 impl, |
| (...skipping 13 matching lines...) Expand all Loading... |
| 63 input_method_persistence_.reset(); | 64 input_method_persistence_.reset(); |
| 64 | 65 |
| 65 InputMethodManager::Shutdown(); | 66 InputMethodManager::Shutdown(); |
| 66 | 67 |
| 67 ui::IMEBridge::Shutdown(); | 68 ui::IMEBridge::Shutdown(); |
| 68 | 69 |
| 69 DVLOG(1) << "InputMethodManager shutdown"; | 70 DVLOG(1) << "InputMethodManager shutdown"; |
| 70 } | 71 } |
| 71 | 72 |
| 72 private: | 73 private: |
| 73 scoped_ptr<Accessibility> accessibility_; | 74 std::unique_ptr<Accessibility> accessibility_; |
| 74 scoped_ptr<BrowserStateMonitor> browser_state_monitor_; | 75 std::unique_ptr<BrowserStateMonitor> browser_state_monitor_; |
| 75 scoped_ptr<InputMethodPersistence> input_method_persistence_; | 76 std::unique_ptr<InputMethodPersistence> input_method_persistence_; |
| 76 }; | 77 }; |
| 77 | 78 |
| 78 InputMethodConfiguration* g_input_method_configuration = NULL; | 79 InputMethodConfiguration* g_input_method_configuration = NULL; |
| 79 | 80 |
| 80 } // namespace | 81 } // namespace |
| 81 | 82 |
| 82 void Initialize() { | 83 void Initialize() { |
| 83 if (!g_input_method_configuration) | 84 if (!g_input_method_configuration) |
| 84 g_input_method_configuration = new InputMethodConfiguration(); | 85 g_input_method_configuration = new InputMethodConfiguration(); |
| 85 g_input_method_configuration->Initialize(); | 86 g_input_method_configuration->Initialize(); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 99 if (!g_input_method_configuration) | 100 if (!g_input_method_configuration) |
| 100 return; | 101 return; |
| 101 | 102 |
| 102 g_input_method_configuration->Shutdown(); | 103 g_input_method_configuration->Shutdown(); |
| 103 delete g_input_method_configuration; | 104 delete g_input_method_configuration; |
| 104 g_input_method_configuration = NULL; | 105 g_input_method_configuration = NULL; |
| 105 } | 106 } |
| 106 | 107 |
| 107 } // namespace input_method | 108 } // namespace input_method |
| 108 } // namespace chromeos | 109 } // namespace chromeos |
| OLD | NEW |