• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "base/memory/singleton.h"
9 
10 namespace ash {
11 namespace ime {
12 
InputMethodMenuManager()13 InputMethodMenuManager::InputMethodMenuManager()
14     : menu_list_(), observers_() {}
15 
~InputMethodMenuManager()16 InputMethodMenuManager::~InputMethodMenuManager() {}
17 
AddObserver(InputMethodMenuManager::Observer * observer)18 void InputMethodMenuManager::AddObserver(
19     InputMethodMenuManager::Observer* observer) {
20   observers_.AddObserver(observer);
21 }
22 
RemoveObserver(InputMethodMenuManager::Observer * observer)23 void InputMethodMenuManager::RemoveObserver(
24     InputMethodMenuManager::Observer* observer) {
25   observers_.RemoveObserver(observer);
26 }
27 
28 InputMethodMenuItemList
GetCurrentInputMethodMenuItemList() const29 InputMethodMenuManager::GetCurrentInputMethodMenuItemList() const {
30   return menu_list_;
31 }
32 
SetCurrentInputMethodMenuItemList(const InputMethodMenuItemList & menu_list)33 void InputMethodMenuManager::SetCurrentInputMethodMenuItemList(
34     const InputMethodMenuItemList& menu_list) {
35   menu_list_ = menu_list;
36   FOR_EACH_OBSERVER(InputMethodMenuManager::Observer,
37                     observers_,
38                     InputMethodMenuItemChanged(this));
39 }
40 
HasInputMethodMenuItemForKey(const std::string & key) const41 bool InputMethodMenuManager::HasInputMethodMenuItemForKey(
42     const std::string& key) const {
43   for (size_t i = 0; i < menu_list_.size(); ++i) {
44     if (menu_list_[i].key == key) {
45       return true;
46     }
47   }
48   return false;
49 }
50 
51 // static
GetInstance()52 InputMethodMenuManager* InputMethodMenuManager::GetInstance() {
53   return Singleton<InputMethodMenuManager>::get();
54 }
55 
56 }  // namespace ime
57 }  // namespace ash
58