15821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved. 25821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 35821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)// found in the LICENSE file. 45821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 55821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#ifndef CHROME_BROWSER_UI_VIEWS_CRITICAL_NOTIFICATION_BUBBLE_VIEW_H_ 65821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#define CHROME_BROWSER_UI_VIEWS_CRITICAL_NOTIFICATION_BUBBLE_VIEW_H_ 75821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 85821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "base/timer/timer.h" 95821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)#include "ui/views/bubble/bubble_delegate.h" 10a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include "ui/views/controls/button/button.h" 115821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 125821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)namespace ui { 135821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class Accelerator; 145821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 155821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 161320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tuccinamespace views { 171320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucciclass Label; 185821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class LabelButton; 195821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)} 205821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 215821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles)class CriticalNotificationBubbleView : public views::BubbleDelegateView, 225821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) public views::ButtonListener { 23f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) public: 245821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) explicit CriticalNotificationBubbleView(views::View* anchor_view); 255821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual ~CriticalNotificationBubbleView(); 26f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) 275821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // views::ButtonListener overrides: 285821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void ButtonPressed(views::Button* sender, 295821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const ui::Event& event) OVERRIDE; 305821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 315821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // views::WidgetDelegate overrides: 325821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void WindowClosing() OVERRIDE; 335821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 345821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) // views::View overrides: 355821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void GetAccessibleState(ui::AXViewState* state) OVERRIDE; 365821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) virtual void ViewHierarchyChanged( 375821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) const ViewHierarchyChangedDetails& details) OVERRIDE; 385821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) 395821806d5e7f356e8fa4b058a389a808ea183019Torne (Richard Coles) protected: 40 // views::BubbleDelegateView overrides: 41 virtual bool AcceleratorPressed( 42 const ui::Accelerator& accelerator) OVERRIDE; 43 virtual void Init() OVERRIDE; 44 45 private: 46 // Helper function to calculate the remaining time (in seconds) until 47 // spontaneous reboot. 48 int GetRemainingTime(); 49 50 // Helper function to set the headline for the bubble. 51 void UpdateBubbleHeadline(int seconds); 52 53 // Called when the timer fires each time the clock ticks. 54 void OnCountdown(); 55 56 // The headline and buttons on the bubble. 57 views::Label* headline_; 58 views::LabelButton* restart_button_; 59 views::LabelButton* dismiss_button_; 60 61 // A timer to refresh the bubble to show new countdown value. 62 base::RepeatingTimer<CriticalNotificationBubbleView> refresh_timer_; 63 64 // When the bubble was created. 65 base::Time bubble_created_; 66 67 DISALLOW_COPY_AND_ASSIGN(CriticalNotificationBubbleView); 68}; 69 70#endif // CHROME_BROWSER_UI_VIEWS_CRITICAL_NOTIFICATION_BUBBLE_VIEW_H_ 71