summaryrefslogtreecommitdiffstats
path: root/ash/system/status_area_widget.h
blob: 3b58a10cb8b059b01da44817eba5e3d07f0585b3 (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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
// 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 ASH_SYSTEM_STATUS_AREA_WIDGET_H_
#define ASH_SYSTEM_STATUS_AREA_WIDGET_H_

#include "ash/ash_export.h"
#include "ash/shelf/shelf_types.h"
#include "ash/system/user/login_status.h"
#include "ui/views/widget/widget.h"

namespace ash {

class OverviewButtonTray;
class ShellDelegate;
class SystemTray;
class WebNotificationTray;

namespace internal {

class LogoutButtonTray;
class StatusAreaWidgetDelegate;
#if defined(OS_CHROMEOS)
class VirtualKeyboardTray;
#endif

class ASH_EXPORT StatusAreaWidget : public views::Widget {
 public:
  static const char kNativeViewName[];

  explicit StatusAreaWidget(aura::Window* status_container);
  virtual ~StatusAreaWidget();

  // Creates the SystemTray, WebNotificationTray and LogoutButtonTray.
  void CreateTrayViews();

  // Destroys the system tray and web notification tray. Called before
  // tearing down the windows to avoid shutdown ordering issues.
  void Shutdown();

  // Update the alignment of the widget and tray views.
  void SetShelfAlignment(ShelfAlignment alignment);

  // Set the visibility of system notifications.
  void SetHideSystemNotifications(bool hide);

  // Called by the client when the login status changes. Caches login_status
  // and calls UpdateAfterLoginStatusChange for the system tray and the web
  // notification tray.
  void UpdateAfterLoginStatusChange(user::LoginStatus login_status);

  internal::StatusAreaWidgetDelegate* status_area_widget_delegate() {
    return status_area_widget_delegate_;
  }
  SystemTray* system_tray() { return system_tray_; }
  WebNotificationTray* web_notification_tray() {
    return web_notification_tray_;
  }
  OverviewButtonTray* overview_button_tray() {
    return overview_button_tray_;
  }

  user::LoginStatus login_status() const { return login_status_; }

  // Returns true if the shelf should be visible. This is used when the
  // shelf is configured to auto-hide and test if the shelf should force
  // the shelf to remain visible.
  bool ShouldShowShelf() const;

  // True if any message bubble is shown.
  bool IsMessageBubbleShown() const;

  // Overridden from views::Widget:
  virtual void OnNativeWidgetActivationChanged(bool active) OVERRIDE;

 private:
  void AddSystemTray();
  void AddWebNotificationTray();
  void AddLogoutButtonTray();
#if defined(OS_CHROMEOS)
  void AddVirtualKeyboardTray();
#endif
  void AddOverviewButtonTray();

  // Weak pointers to View classes that are parented to StatusAreaWidget:
  internal::StatusAreaWidgetDelegate* status_area_widget_delegate_;
  OverviewButtonTray* overview_button_tray_;
  SystemTray* system_tray_;
  WebNotificationTray* web_notification_tray_;
  LogoutButtonTray* logout_button_tray_;
#if defined(OS_CHROMEOS)
  VirtualKeyboardTray* virtual_keyboard_tray_;
#endif
  user::LoginStatus login_status_;

  DISALLOW_COPY_AND_ASSIGN(StatusAreaWidget);
};

}  // namespace internal
}  // namespace ash

#endif  // ASH_SYSTEM_STATUS_AREA_WIDGET_H_