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 StatusAreaWidgetDelegate;
     22 
     23 class ASH_EXPORT StatusAreaWidget : public views::Widget {
     24  public:
     25   static const char kNativeViewName[];
     26 
     27   explicit StatusAreaWidget(aura::Window* status_container);
     28   virtual ~StatusAreaWidget();
     29 
     30   // Creates the SystemTray and the WebNotificationTray.
     31   void CreateTrayViews();
     32 
     33   // Destroys the system tray and web notification tray. Called before
     34   // tearing down the windows to avoid shutdown ordering issues.
     35   void Shutdown();
     36 
     37   // Update the alignment of the widget and tray views.
     38   void SetShelfAlignment(ShelfAlignment alignment);
     39 
     40   // Set the visibility of system notifications.
     41   void SetHideSystemNotifications(bool hide);
     42 
     43   // Returns true if it is OK to show a non system notification.
     44   bool ShouldShowWebNotifications();
     45 
     46   // Called by the client when the login status changes. Caches login_status
     47   // and calls UpdateAfterLoginStatusChange for the system tray and the web
     48   // notification tray.
     49   void UpdateAfterLoginStatusChange(user::LoginStatus login_status);
     50 
     51   internal::StatusAreaWidgetDelegate* status_area_widget_delegate() {
     52     return status_area_widget_delegate_;
     53   }
     54   SystemTray* system_tray() { return system_tray_; }
     55   WebNotificationTray* web_notification_tray() {
     56     return web_notification_tray_;
     57   }
     58 
     59   user::LoginStatus login_status() const { return login_status_; }
     60 
     61   // Returns true if the launcher should be visible. This is used when the
     62   // launcher is configured to auto-hide and test if the shelf should force
     63   // the launcher to remain visible.
     64   bool ShouldShowLauncher() const;
     65 
     66   // True if any message bubble is shown.
     67   bool IsMessageBubbleShown() const;
     68 
     69   // Overridden from views::Widget:
     70   virtual void OnNativeWidgetActivationChanged(bool active) OVERRIDE;
     71 
     72  private:
     73   void AddSystemTray();
     74   void AddWebNotificationTray();
     75 
     76   // Weak pointers to View classes that are parented to StatusAreaWidget:
     77   internal::StatusAreaWidgetDelegate* status_area_widget_delegate_;
     78   SystemTray* system_tray_;
     79   WebNotificationTray* web_notification_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