1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_VIEWS_CRITICAL_NOTIFICATION_BUBBLE_VIEW_H_
#define CHROME_BROWSER_UI_VIEWS_CRITICAL_NOTIFICATION_BUBBLE_VIEW_H_
#include "base/timer/timer.h"
#include "ui/views/bubble/bubble_delegate.h"
#include "ui/views/controls/button/button.h"
namespace ui {
class Accelerator;
}
namespace views {
class Label;
class LabelButton;
}
class CriticalNotificationBubbleView : public views::BubbleDelegateView,
public views::ButtonListener {
public:
explicit CriticalNotificationBubbleView(views::View* anchor_view);
~CriticalNotificationBubbleView() override;
// views::ButtonListener overrides:
void ButtonPressed(views::Button* sender, const ui::Event& event) override;
// views::WidgetDelegate overrides:
void WindowClosing() override;
// views::View overrides:
void GetAccessibleState(ui::AXViewState* state) override;
void ViewHierarchyChanged(
const ViewHierarchyChangedDetails& details) override;
protected:
// views::BubbleDelegateView overrides:
bool AcceleratorPressed(const ui::Accelerator& accelerator) override;
void Init() override;
private:
// Helper function to calculate the remaining time (in seconds) until
// spontaneous reboot.
int GetRemainingTime();
// Helper function to set the headline for the bubble.
void UpdateBubbleHeadline(int seconds);
// Called when the timer fires each time the clock ticks.
void OnCountdown();
// The headline and buttons on the bubble.
views::Label* headline_;
views::LabelButton* restart_button_;
views::LabelButton* dismiss_button_;
// A timer to refresh the bubble to show new countdown value.
base::RepeatingTimer<CriticalNotificationBubbleView> refresh_timer_;
// When the bubble was created.
base::Time bubble_created_;
DISALLOW_COPY_AND_ASSIGN(CriticalNotificationBubbleView);
};
#endif // CHROME_BROWSER_UI_VIEWS_CRITICAL_NOTIFICATION_BUBBLE_VIEW_H_
|