summaryrefslogtreecommitdiff
path: root/chromium/ash/system/logout_button/logout_button_tray.h
blob: 5683e5e2654c13f52e1d2e9efe0a9403e91b9cf2 (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
// Copyright 2013 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 ASH_SYSTEM_LOGOUT_BUTTON_LOGOUT_BUTTON_TRAY_H_
#define ASH_SYSTEM_LOGOUT_BUTTON_LOGOUT_BUTTON_TRAY_H_

#include "ash/system/logout_button/logout_button_observer.h"
#include "ash/system/tray/tray_background_view.h"
#include "ash/system/user/login_status.h"
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "ui/views/controls/button/button.h"

namespace views {
class LabelButton;
}

namespace ash {
namespace internal {

class StatusAreaWidget;

// Adds a logout button to the launcher's status area if enabled by the
// kShowLogoutButtonInTray pref.
class LogoutButtonTray : public TrayBackgroundView,
                         public LogoutButtonObserver,
                         public views::ButtonListener {
 public:
  explicit LogoutButtonTray(StatusAreaWidget* status_area_widget);
  virtual ~LogoutButtonTray();

  // TrayBackgroundView:
  virtual void SetShelfAlignment(ShelfAlignment alignment) OVERRIDE;
  virtual base::string16 GetAccessibleNameForTray() OVERRIDE;
  virtual void HideBubbleWithView(
      const views::TrayBubbleView* bubble_view) OVERRIDE;
  virtual bool ClickedOutsideBubble() OVERRIDE;

  // LogoutButtonObserver:
  virtual void OnShowLogoutButtonInTrayChanged(bool show) OVERRIDE;

  // views::ButtonListener:
  virtual void ButtonPressed(views::Button* sender,
                             const ui::Event& event) OVERRIDE;

  void UpdateAfterLoginStatusChange(user::LoginStatus login_status);

 private:
  void UpdateVisibility();

  views::LabelButton* button_;  // Not owned.
  user::LoginStatus login_status_;
  bool show_logout_button_in_tray_;

  DISALLOW_COPY_AND_ASSIGN(LogoutButtonTray);
};

}  // namespace internal
}  // namespace ash

#endif  // ASH_SYSTEM_LOGOUT_BUTTON_LOGOUT_BUTTON_TRAY_H_