Home | History | Annotate | Download | only in session
      1 // Copyright 2014 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_CHROMEOS_SESSION_LOGOUT_BUTTON_TRAY_H_
      6 #define ASH_SYSTEM_CHROMEOS_SESSION_LOGOUT_BUTTON_TRAY_H_
      7 
      8 #include "ash/ash_export.h"
      9 #include "ash/system/chromeos/session/logout_button_observer.h"
     10 #include "ash/system/tray/tray_background_view.h"
     11 #include "ash/system/user/login_status.h"
     12 #include "base/basictypes.h"
     13 #include "base/compiler_specific.h"
     14 #include "base/time/time.h"
     15 #include "ui/views/controls/button/button.h"
     16 
     17 namespace views {
     18 class LabelButton;
     19 }
     20 
     21 namespace ash {
     22 class StatusAreaWidget;
     23 
     24 // Adds a logout button to the launcher's status area if enabled by the
     25 // kShowLogoutButtonInTray pref.
     26 class ASH_EXPORT LogoutButtonTray : public TrayBackgroundView,
     27                                     public LogoutButtonObserver,
     28                                     public views::ButtonListener {
     29  public:
     30   explicit LogoutButtonTray(StatusAreaWidget* status_area_widget);
     31   virtual ~LogoutButtonTray();
     32 
     33   // TrayBackgroundView:
     34   virtual void SetShelfAlignment(ShelfAlignment alignment) OVERRIDE;
     35   virtual base::string16 GetAccessibleNameForTray() OVERRIDE;
     36   virtual void HideBubbleWithView(
     37       const views::TrayBubbleView* bubble_view) OVERRIDE;
     38   virtual bool ClickedOutsideBubble() OVERRIDE;
     39 
     40   // LogoutButtonObserver:
     41   virtual void OnShowLogoutButtonInTrayChanged(bool show) OVERRIDE;
     42   virtual void OnLogoutDialogDurationChanged(base::TimeDelta duration) OVERRIDE;
     43 
     44   // views::ButtonListener:
     45   virtual void ButtonPressed(views::Button* sender,
     46                              const ui::Event& event) OVERRIDE;
     47 
     48   void UpdateAfterLoginStatusChange(user::LoginStatus login_status);
     49 
     50  private:
     51   void UpdateVisibility();
     52 
     53   views::LabelButton* button_;
     54   user::LoginStatus login_status_;
     55   bool show_logout_button_in_tray_;
     56   base::TimeDelta dialog_duration_;
     57 
     58   DISALLOW_COPY_AND_ASSIGN(LogoutButtonTray);
     59 };
     60 
     61 }  // namespace ash
     62 
     63 #endif  // ASH_SYSTEM_CHROMEOS_SESSION_LOGOUT_BUTTON_TRAY_H_
     64