Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / browser / ui / views / critical_notification_bubble_view.h
blob8b769cfc15ed13dd1c62950286d04684aaec5e25
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 CHROME_BROWSER_UI_VIEWS_CRITICAL_NOTIFICATION_BUBBLE_VIEW_H_
6 #define CHROME_BROWSER_UI_VIEWS_CRITICAL_NOTIFICATION_BUBBLE_VIEW_H_
8 #include "base/timer/timer.h"
9 #include "ui/views/bubble/bubble_delegate.h"
10 #include "ui/views/controls/button/button.h"
12 namespace ui {
13 class Accelerator;
16 namespace views {
17 class Label;
18 class LabelButton;
21 class CriticalNotificationBubbleView : public views::BubbleDelegateView,
22 public views::ButtonListener {
23 public:
24 explicit CriticalNotificationBubbleView(views::View* anchor_view);
25 ~CriticalNotificationBubbleView() override;
27 // views::ButtonListener overrides:
28 void ButtonPressed(views::Button* sender, const ui::Event& event) override;
30 // views::WidgetDelegate overrides:
31 void WindowClosing() override;
33 // views::View overrides:
34 void GetAccessibleState(ui::AXViewState* state) override;
35 void ViewHierarchyChanged(
36 const ViewHierarchyChangedDetails& details) override;
38 protected:
39 // views::BubbleDelegateView overrides:
40 bool AcceleratorPressed(const ui::Accelerator& accelerator) override;
41 void Init() override;
43 private:
44 // Helper function to calculate the remaining time (in seconds) until
45 // spontaneous reboot.
46 int GetRemainingTime();
48 // Helper function to set the headline for the bubble.
49 void UpdateBubbleHeadline(int seconds);
51 // Called when the timer fires each time the clock ticks.
52 void OnCountdown();
54 // The headline and buttons on the bubble.
55 views::Label* headline_;
56 views::LabelButton* restart_button_;
57 views::LabelButton* dismiss_button_;
59 // A timer to refresh the bubble to show new countdown value.
60 base::RepeatingTimer<CriticalNotificationBubbleView> refresh_timer_;
62 // When the bubble was created.
63 base::Time bubble_created_;
65 DISALLOW_COPY_AND_ASSIGN(CriticalNotificationBubbleView);
68 #endif // CHROME_BROWSER_UI_VIEWS_CRITICAL_NOTIFICATION_BUBBLE_VIEW_H_