cygprofile: increase timeouts to allow showing web contents
[chromium-blink-merge.git] / ash / system / tray / tray_notification_view.h
blob784450e93b7196b66b6da498b4e4662c1c0e1362
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.
5 #ifndef ASH_SYSTEM_TRAY_TRAY_NOTIFICATION_VIEW_H_
6 #define ASH_SYSTEM_TRAY_TRAY_NOTIFICATION_VIEW_H_
8 #include "base/timer/timer.h"
9 #include "ui/views/controls/button/image_button.h"
10 #include "ui/views/controls/slide_out_view.h"
12 namespace gfx {
13 class ImageSkia;
16 namespace views {
17 class ImageView;
20 namespace ash {
21 class SystemTrayItem;
23 // A view for closable notification views, laid out like:
24 // -------------------
25 // | icon contents x |
26 // ----------------v--
27 // The close button will call OnClose() when clicked.
28 class TrayNotificationView : public views::SlideOutView,
29 public views::ButtonListener {
30 public:
31 // If icon_id is 0, no icon image will be set. SetIconImage can be called
32 // to later set the icon image.
33 TrayNotificationView(SystemTrayItem* owner, int icon_id);
34 ~TrayNotificationView() override;
36 // InitView must be called once with the contents to be displayed.
37 void InitView(views::View* contents);
39 // Sets/updates the icon image.
40 void SetIconImage(const gfx::ImageSkia& image);
42 // Replaces the contents view.
43 void UpdateView(views::View* new_contents);
45 // Replaces the contents view and updates the icon image.
46 void UpdateViewAndImage(views::View* new_contents,
47 const gfx::ImageSkia& image);
49 // Autoclose timer operations.
50 void StartAutoCloseTimer(int seconds);
51 void StopAutoCloseTimer();
52 void RestartAutoCloseTimer();
54 // Overridden from ButtonListener.
55 void ButtonPressed(views::Button* sender, const ui::Event& event) override;
57 // Overridden from views::View.
58 bool OnMousePressed(const ui::MouseEvent& event) override;
60 // Overridden from ui::EventHandler.
61 void OnGestureEvent(ui::GestureEvent* event) override;
63 protected:
64 // Called when the close button is pressed. Does nothing by default.
65 virtual void OnClose();
66 // Called when the notification is clicked on. Does nothing by default.
67 virtual void OnClickAction();
69 // Overridden from views::SlideOutView.
70 void OnSlideOut() override;
72 SystemTrayItem* owner() { return owner_; }
74 private:
75 void HandleClose();
76 void HandleClickAction();
78 SystemTrayItem* owner_;
79 int icon_id_;
80 views::ImageView* icon_;
82 int autoclose_delay_;
83 base::OneShotTimer<TrayNotificationView> autoclose_;
85 DISALLOW_COPY_AND_ASSIGN(TrayNotificationView);
88 } // namespace ash
90 #endif // ASH_SYSTEM_TRAY_TRAY_NOTIFICATION_VIEW_H_