Home | History | Annotate | Download | only in system
      1 // Copyright (c) 2012 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 #ifndef ASH_SYSTEM_STATUS_AREA_WIDGET_H_
      6 #define ASH_SYSTEM_STATUS_AREA_WIDGET_H_
      7 
      8 #include "ash/ash_export.h"
      9 #include "ash/shelf/shelf_types.h"
     10 #include "ash/system/user/login_status.h"
     11 #include "ui/views/widget/widget.h"
     12 
     13 namespace ash {
     14 
     15 class ShellDelegate;
     16 class SystemTray;
     17 class WebNotificationTray;
     18 
     19 namespace internal {
     20 
     21 class LogoutButtonTray;
     22 class StatusAreaWidgetDelegate;
     23 
     24 class ASH_EXPORT StatusAreaWidget : public views::Widget {
     25  public:
     26   static const char kNativeViewName[];
     27 
     28   explicit StatusAreaWidget(aura::Window* status_container);
     29   virtual ~StatusAreaWidget();
     30 
     31   // Creates the SystemTray, WebNotificationTray and LogoutButtonTray.
     32   void CreateTrayViews();
     33 
     34   // Destroys the system tray and web notification tray. Called before
     35   // tearing down the windows to avoid shutdown ordering issues.
     36   void Shutdown();
     37 
     38   // Update the alignment of the widget and tray views.
     39   void SetShelfAlignment(ShelfAlignment alignment);
     40 
     41   // Set the visibility of system notifications.
     42   void SetHideSystemNotifications(bool hide);
     43 
     44   // Called by the client when the login status changes. Caches login_status
     45   // and calls UpdateAfterLoginStatusChange for the system tray and the web
     46   // notification tray.
     47   void UpdateAfterLoginStatusChange(user::LoginStatus login_status);
     48 
     49   internal::StatusAreaWidgetDelegate* status_area_widget_delegate() {
     50     return status_area_widget_delegate_;
     51   }
     52   SystemTray* system_tray() { return system_tray_; }
     53   WebNotificationTray* web_notification_tray() {
     54     return web_notification_tray_;
     55   }
     56 
     57   user::LoginStatus login_status() const { return login_status_; }
     58 
     59   // Returns true if the launcher should be visible. This is used when the
     60   // launcher is configured to auto-hide and test if the shelf should force
     61   // the launcher to remain visible.
     62   bool ShouldShowLauncher() const;
     63 
     64   // True if any message bubble is shown.
     65   bool IsMessageBubbleShown() const;
     66 
     67   // Overridden from views::Widget:
     68   virtual void OnNativeWidgetActivationChanged(bool active) OVERRIDE;
     69 
     70  private:
     71   void AddSystemTray();
     72   void AddWebNotificationTray();
     73   void AddLogoutButtonTray();
     74 
     75   // Weak pointers to View classes that are parented to StatusAreaWidget:
     76   internal::StatusAreaWidgetDelegate* status_area_widget_delegate_;
     77   SystemTray* system_tray_;
     78   WebNotificationTray* web_notification_tray_;
     79   LogoutButtonTray* logout_button_tray_;
     80   user::LoginStatus login_status_;
     81 
     82   DISALLOW_COPY_AND_ASSIGN(StatusAreaWidget);
     83 };
     84 
     85 }  // namespace internal
     86 }  // namespace ash
     87 
     88 #endif  // ASH_SYSTEM_STATUS_AREA_WIDGET_H_
     89