OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 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. |
| 4 |
| 5 #include "ash/ime/input_method_menu_manager.h" |
| 6 |
| 7 #include "base/logging.h" |
| 8 // #include "chrome/browser/chromeos/input_method/input_method_util.h" |
| 9 |
| 10 namespace ash { |
| 11 namespace ime { |
| 12 |
| 13 namespace { |
| 14 InputMethodMenuManager* g_input_method_menu_manager = NULL; |
| 15 } |
| 16 |
| 17 InputMethodMenuManager::InputMethodMenuManager() |
| 18 : menu_list_(), observers_() {} |
| 19 |
| 20 InputMethodMenuManager::~InputMethodMenuManager() {} |
| 21 |
| 22 void InputMethodMenuManager::AddObserver( |
| 23 InputMethodMenuManager::Observer* observer) { |
| 24 observers_.AddObserver(observer); |
| 25 } |
| 26 |
| 27 void InputMethodMenuManager::RemoveObserver( |
| 28 InputMethodMenuManager::Observer* observer) { |
| 29 observers_.RemoveObserver(observer); |
| 30 } |
| 31 |
| 32 InputMethodMenuItemList |
| 33 InputMethodMenuManager::GetCurrentInputMethodMenuItemList() const { |
| 34 return menu_list_; |
| 35 } |
| 36 |
| 37 void InputMethodMenuManager::SetCurrentInputMethodMenuItemList( |
| 38 const InputMethodMenuItemList& menu_list) { |
| 39 menu_list_ = menu_list; |
| 40 FOR_EACH_OBSERVER(InputMethodMenuManager::Observer, |
| 41 observers_, |
| 42 InputMethodMenuItemChanged(this)); |
| 43 } |
| 44 |
| 45 bool InputMethodMenuManager::HasInputMethodMenuItemForKey( |
| 46 const std::string& key) const { |
| 47 for (size_t i = 0; i < menu_list_.size(); ++i) { |
| 48 if (menu_list_[i].key == key) { |
| 49 return true; |
| 50 } |
| 51 } |
| 52 return false; |
| 53 } |
| 54 |
| 55 // static |
| 56 InputMethodMenuManager* InputMethodMenuManager::Get() { |
| 57 DCHECK(g_input_method_menu_manager) |
| 58 << "g_input_method_menu_manager not initialized"; |
| 59 return g_input_method_menu_manager; |
| 60 } |
| 61 |
| 62 // static |
| 63 void InputMethodMenuManager::Initialize() { |
| 64 DCHECK(!g_input_method_menu_manager) << "initialize() called multiple times."; |
| 65 g_input_method_menu_manager = new InputMethodMenuManager(); |
| 66 } |
| 67 |
| 68 // static |
| 69 void InputMethodMenuManager::Shutdown() { |
| 70 DCHECK(g_input_method_menu_manager) |
| 71 << "g_input_method_menu_manager not initialized"; |
| 72 delete g_input_method_menu_manager; |
| 73 g_input_method_menu_manager = NULL; |
| 74 } |
| 75 |
| 76 } // namespace ime |
| 77 } // namespace ash |
OLD | NEW |