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/ash_export.h"
6
7#include "ash/ime/input_method_menu_item.h"
8#include "base/observer_list.h"
9
10#ifndef ASH_IME_INPUT_METHOD_MENU_MANAGER_H_
11#define ASH_IME_INPUT_METHOD_MENU_MANAGER_H_
12
13template<typename Type> struct DefaultSingletonTraits;
14
15namespace ash {
16namespace ime {
17
18class ASH_EXPORT InputMethodMenuManager {
19public:
20  class Observer {
21   public:
22    virtual ~Observer() {}
23
24    // Called when the list of menu items is changed.
25    virtual void InputMethodMenuItemChanged(
26        InputMethodMenuManager* manager) = 0;
27  };
28
29  ~InputMethodMenuManager();
30
31  void AddObserver(Observer* observer);
32  void RemoveObserver(Observer* observer);
33
34  // Obtains the singleton instance.
35  static InputMethodMenuManager* GetInstance();
36
37  // Sets the list of input method menu items. The list could be empty().
38  void SetCurrentInputMethodMenuItemList(
39      const InputMethodMenuItemList& menu_list);
40
41  // Gets the list of input method menu items. The list could be empty().
42  InputMethodMenuItemList GetCurrentInputMethodMenuItemList() const;
43
44  // True if the key exists in the menu_list_.
45  bool HasInputMethodMenuItemForKey(const std::string& key) const;
46
47 private:
48  InputMethodMenuManager();
49
50  // For Singleton to be able to construct an instance.
51  friend struct DefaultSingletonTraits<InputMethodMenuManager>;
52
53  // Menu item list of the input method.  This is set by extension IMEs.
54  InputMethodMenuItemList menu_list_;
55
56  // Observers who will be notified when menu changes.
57  ObserverList<Observer> observers_;
58
59  DISALLOW_COPY_AND_ASSIGN(InputMethodMenuManager);
60};
61
62}  // namespace ime
63}  // namespace ash
64
65#endif // ASH_IME_INPUT_METHOD_MENU_MANAGER_H_
66