Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / ui / chromeos / ime / input_method_menu_manager.h
blob65427b7c3ccd5ab1b6c2354536ef3ef7c961a807
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.
5 #include "base/observer_list.h"
6 #include "ui/chromeos/ime/input_method_menu_item.h"
7 #include "ui/chromeos/ui_chromeos_export.h"
9 #ifndef UI_CHROMEOS_IME_INPUT_METHOD_MENU_MANAGER_H_
10 #define UI_CHROMEOS_IME_INPUT_METHOD_MENU_MANAGER_H_
12 namespace base {
13 template <typename Type>
14 struct DefaultSingletonTraits;
15 } // namespace base
17 namespace ui {
18 namespace ime {
20 class UI_CHROMEOS_EXPORT InputMethodMenuManager {
21 public:
22 class Observer {
23 public:
24 virtual ~Observer() {}
26 // Called when the list of menu items is changed.
27 virtual void InputMethodMenuItemChanged(
28 InputMethodMenuManager* manager) = 0;
31 ~InputMethodMenuManager();
33 void AddObserver(Observer* observer);
34 void RemoveObserver(Observer* observer);
36 // Obtains the singleton instance.
37 static InputMethodMenuManager* GetInstance();
39 // Sets the list of input method menu items. The list could be empty().
40 void SetCurrentInputMethodMenuItemList(
41 const InputMethodMenuItemList& menu_list);
43 // Gets the list of input method menu items. The list could be empty().
44 InputMethodMenuItemList GetCurrentInputMethodMenuItemList() const;
46 // True if the key exists in the menu_list_.
47 bool HasInputMethodMenuItemForKey(const std::string& key) const;
49 private:
50 InputMethodMenuManager();
52 // For Singleton to be able to construct an instance.
53 friend struct base::DefaultSingletonTraits<InputMethodMenuManager>;
55 // Menu item list of the input method. This is set by extension IMEs.
56 InputMethodMenuItemList menu_list_;
58 // Observers who will be notified when menu changes.
59 base::ObserverList<Observer> observers_;
61 DISALLOW_COPY_AND_ASSIGN(InputMethodMenuManager);
64 } // namespace ime
65 } // namespace ui
67 #endif // UI_CHROMEOS_IME_INPUT_METHOD_MENU_MANAGER_H_