| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2011 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 CHROME_BROWSER_UI_VIEWS_CRITICAL_NOTIFICATION_BUBBLE_VIEW_H_ |
| 6 #define CHROME_BROWSER_UI_VIEWS_CRITICAL_NOTIFICATION_BUBBLE_VIEW_H_ |
| 7 #pragma once |
| 8 |
| 9 #include "base/timer.h" |
| 10 #include "chrome/browser/ui/views/bubble/bubble.h" |
| 11 #include "views/controls/button/button.h" |
| 12 #include "views/view.h" |
| 13 |
| 14 namespace views { |
| 15 class ImageView; |
| 16 class Label; |
| 17 class NativeTextButton; |
| 18 } |
| 19 |
| 20 class CriticalNotificationBubbleView : public views::View, |
| 21 public views::ButtonListener, |
| 22 public BubbleDelegate, |
| 23 public ui::AnimationDelegate { |
| 24 public: |
| 25 CriticalNotificationBubbleView(); |
| 26 virtual ~CriticalNotificationBubbleView(); |
| 27 |
| 28 void set_bubble(Bubble* bubble) { bubble_ = bubble; } |
| 29 |
| 30 // views::View methods: |
| 31 virtual gfx::Size GetPreferredSize() OVERRIDE; |
| 32 virtual void Layout() OVERRIDE; |
| 33 |
| 34 // views::ButtonListener methods: |
| 35 virtual void ButtonPressed(views::Button* sender, |
| 36 const views::Event& event) OVERRIDE; |
| 37 |
| 38 // BubbleDelegate methods: |
| 39 virtual void BubbleClosing(Bubble* bubble, bool closed_by_escape) OVERRIDE; |
| 40 virtual bool CloseOnEscape() OVERRIDE; |
| 41 virtual bool FadeInOnShow() OVERRIDE; |
| 42 virtual string16 accessible_name() OVERRIDE; |
| 43 |
| 44 private: |
| 45 // Helper function to calculate the remaining time (in seconds) until |
| 46 // spontaneous reboot. |
| 47 int GetRemainingTime(); |
| 48 |
| 49 // Helper function to set the headline for the bubble. |
| 50 void UpdateBubbleHeadline(int seconds); |
| 51 |
| 52 // Called when the timer fires each time the clock ticks. |
| 53 void OnCountdown(); |
| 54 |
| 55 // Global pointer to the bubble that is hosting our view. |
| 56 static Bubble* bubble_; |
| 57 |
| 58 // The views on the bubble. |
| 59 views::ImageView* image_; |
| 60 views::Label* headline_; |
| 61 views::Label* message_; |
| 62 views::NativeTextButton* restart_button_; |
| 63 views::NativeTextButton* dismiss_button_; |
| 64 |
| 65 // A timer to refresh the bubble to show new countdown value. |
| 66 base::RepeatingTimer<CriticalNotificationBubbleView> refresh_timer_; |
| 67 |
| 68 // When the bubble was created. |
| 69 base::Time bubble_created_; |
| 70 |
| 71 DISALLOW_COPY_AND_ASSIGN(CriticalNotificationBubbleView); |
| 72 }; |
| 73 |
| 74 #endif // CHROME_BROWSER_UI_VIEWS_CRITICAL_NOTIFICATION_BUBBLE_VIEW_H_ |
| OLD | NEW |