summaryrefslogtreecommitdiffstats
path: root/chrome/browser/chromeos/status/accessibility_menu_button.h
blob: 54f19eba1873ec8c7112e21c33ef6856dc776439 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_CHROMEOS_STATUS_ACCESSIBILITY_MENU_BUTTON_H_
#define CHROME_BROWSER_CHROMEOS_STATUS_ACCESSIBILITY_MENU_BUTTON_H_
#pragma once

#include "chrome/browser/chromeos/status/status_area_button.h"
#include "chrome/browser/prefs/pref_member.h"
#include "content/public/browser/notification_observer.h"
#include "ui/views/controls/button/menu_button_listener.h"
#include "ui/views/controls/menu/menu_delegate.h"

namespace views {
class MenuRunner;
}

namespace chromeos {

class StatusAreaBubbleController;

// A class for the button in the status area which alerts the user when
// accessibility features are enabled.
class AccessibilityMenuButton : public StatusAreaButton,
                                public views::MenuButtonListener,
                                public views::MenuDelegate,
                                public content::NotificationObserver {
 public:
  explicit AccessibilityMenuButton(StatusAreaButton::Delegate* delegate);
  virtual ~AccessibilityMenuButton();

  // Overridden from views::MenuButtonListener:
  virtual void OnMenuButtonClicked(views::View* source,
                                   const gfx::Point& point) OVERRIDE;

  // Overridden from views::MenuDelegate:
  virtual void ExecuteCommand(int id) OVERRIDE;

  // content::NotificationObserver implementation
  virtual void Observe(int type,
                       const content::NotificationSource& source,
                       const content::NotificationDetails& details) OVERRIDE;

 private:
  // Updates the state along with the preferences.
  void Update();

  // Prepares menu before showing it.
  void PrepareMenu();

  // An object synced to the preference, representing if accessibility feature
  // is enabled or not.
  BooleanPrefMember accessibility_enabled_;
  // An object to show menu.
  scoped_ptr<views::MenuRunner> menu_runner_;
  // The currently showing bubble controller.
  scoped_ptr<StatusAreaBubbleController> bubble_controller_;

  DISALLOW_COPY_AND_ASSIGN(AccessibilityMenuButton);
};

}  // namespace chromeos

#endif  // CHROME_BROWSER_CHROMEOS_STATUS_ACCESSIBILITY_MENU_BUTTON_H_