• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2013 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_OUTDATED_UPGRADE_BUBBLE_VIEW_H_
6 #define CHROME_BROWSER_UI_VIEWS_OUTDATED_UPGRADE_BUBBLE_VIEW_H_
7 
8 #include "ui/views/bubble/bubble_delegate.h"
9 #include "ui/views/controls/button/button.h"
10 
11 class ElevationIconSetter;
12 
13 namespace views {
14 class LabelButton;
15 }
16 
17 namespace content {
18 class PageNavigator;
19 }
20 
21 // OutdatedUpgradeBubbleView warns the user that an upgrade is long overdue.
22 // It is intended to be used as the content of a bubble anchored off of the
23 // Chrome toolbar. Don't create an OutdatedUpgradeBubbleView directly,
24 // instead use the static ShowBubble method.
25 class OutdatedUpgradeBubbleView : public views::BubbleDelegateView,
26                                   public views::ButtonListener {
27  public:
28   static void ShowBubble(views::View* anchor_view,
29                          content::PageNavigator* navigator,
30                          bool auto_update_enabled);
31 
32   // Identifies if we are running a build that supports the
33   // outdated upgrade bubble view.
34   static bool IsAvailable();
35 
36   // views::BubbleDelegateView method.
37   virtual views::View* GetInitiallyFocusedView() OVERRIDE;
38 
39   // views::WidgetDelegate method.
40   virtual void WindowClosing() OVERRIDE;
41 
42  private:
43   OutdatedUpgradeBubbleView(views::View* anchor_view,
44                             content::PageNavigator* navigator,
45                             bool auto_update_enabled);
46   virtual ~OutdatedUpgradeBubbleView();
47 
IsShowing()48   static bool IsShowing() { return upgrade_bubble_ != NULL; }
49 
50   // views::BubbleDelegateView method.
51   virtual void Init() OVERRIDE;
52 
53   // views::ButtonListener method.
54   virtual void ButtonPressed(views::Button* sender,
55                              const ui::Event& event) OVERRIDE;
56 
57   // Handle the message when the user presses a button.
58   void HandleButtonPressed(views::Button* sender);
59 
60   // The upgrade bubble, if we're showing one.
61   static OutdatedUpgradeBubbleView* upgrade_bubble_;
62 
63   // The numer of times the user ignored the bubble before finally choosing to
64   // reinstall.
65   static int num_ignored_bubbles_;
66 
67   // Identifies if auto-update is enabled or not.
68   bool auto_update_enabled_;
69 
70   // Identifies if the accept button was hit before closing the bubble.
71   bool accepted_;
72 
73   // Button that lets the user accept the proposal, which is to navigate to a
74   // Chrome download page when |auto_update_enabled_| is true, or attempt to
75   // re-enable auto-update otherwise.
76   views::LabelButton* accept_button_;
77 
78   // Button for the user to be reminded later about the outdated upgrade.
79   views::LabelButton* later_button_;
80 
81   // The PageNavigator to use for opening the Download Chrome URL.
82   content::PageNavigator* navigator_;
83 
84   scoped_ptr<ElevationIconSetter> elevation_icon_setter_;
85 
86   DISALLOW_COPY_AND_ASSIGN(OutdatedUpgradeBubbleView);
87 };
88 
89 #endif  // CHROME_BROWSER_UI_VIEWS_OUTDATED_UPGRADE_BUBBLE_VIEW_H_
90