OLD | NEW |
| (Empty) |
1 // Copyright 2014 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_PROFILES_PROFILE_RESET_BUBBLE_VIEW_H_ | |
6 #define CHROME_BROWSER_UI_VIEWS_PROFILES_PROFILE_RESET_BUBBLE_VIEW_H_ | |
7 | |
8 #include "base/callback.h" | |
9 #include "base/memory/scoped_ptr.h" | |
10 #include "base/memory/weak_ptr.h" | |
11 #include "base/values.h" | |
12 #include "chrome/browser/ui/global_error/global_error_bubble_view_base.h" | |
13 #include "ui/gfx/image/image_skia.h" | |
14 #include "ui/views/bubble/bubble_delegate.h" | |
15 #include "ui/views/controls/button/button.h" | |
16 #include "ui/views/controls/link_listener.h" | |
17 | |
18 namespace content { | |
19 class PageNavigator; | |
20 } | |
21 | |
22 namespace views { | |
23 class Checkbox; | |
24 class ImageButton; | |
25 class LabelButton; | |
26 class Link; | |
27 } | |
28 | |
29 class Browser; | |
30 class Profile; | |
31 class ProfileResetGlobalError; | |
32 class ResettableSettingsSnapshot; | |
33 | |
34 // ProfileResetBubbleView warns the user that a settings reset might be needed. | |
35 // It is intended to be used as the content of a bubble anchored off of the | |
36 // Chrome toolbar. | |
37 class ProfileResetBubbleView : public views::BubbleDelegateView, | |
38 public views::ButtonListener, | |
39 public views::LinkListener, | |
40 public GlobalErrorBubbleViewBase { | |
41 public: | |
42 static ProfileResetBubbleView* ShowBubble( | |
43 const base::WeakPtr<ProfileResetGlobalError>& global_error, | |
44 Browser* browser); | |
45 | |
46 // views::BubbleDelegateView methods. | |
47 virtual views::View* GetInitiallyFocusedView() OVERRIDE; | |
48 virtual void Init() OVERRIDE; | |
49 | |
50 // views::WidgetDelegate method. | |
51 virtual void WindowClosing() OVERRIDE; | |
52 | |
53 // GlobalErrorBubbleViewBase: | |
54 virtual void CloseBubbleView() OVERRIDE; | |
55 | |
56 private: | |
57 ProfileResetBubbleView( | |
58 const base::WeakPtr<ProfileResetGlobalError>& global_error, | |
59 views::View* anchor_view, | |
60 content::PageNavigator* navigator, | |
61 Profile* profile); | |
62 | |
63 virtual ~ProfileResetBubbleView(); | |
64 | |
65 // Reset all child views members and remove children from view hierarchy. | |
66 void ResetAllChildren(); | |
67 | |
68 // Sets up the layout manager and set the report checkbox to the value passed | |
69 // in |report_checked|. | |
70 void SetupLayoutManager(bool report_checked); | |
71 | |
72 // views::ButtonListener method. | |
73 virtual void ButtonPressed(views::Button* sender, | |
74 const ui::Event& event) OVERRIDE; | |
75 | |
76 // views::LinkListener method. | |
77 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE; | |
78 | |
79 // Sets the fully populated feedback data. | |
80 void UpdateFeedbackDetails(); | |
81 | |
82 struct Controls { | |
83 Controls() { | |
84 Reset(); | |
85 } | |
86 void Reset() { | |
87 reset_button = NULL; | |
88 no_thanks_button = NULL; | |
89 help_button = NULL; | |
90 report_settings_checkbox = NULL; | |
91 } | |
92 | |
93 // Button for the user to confirm a settings reset. | |
94 views::LabelButton* reset_button; | |
95 | |
96 // Button for the user to refuse a settings reset. | |
97 views::LabelButton* no_thanks_button; | |
98 | |
99 // Button for the user to get more info about reporting settings. | |
100 views::ImageButton* help_button; | |
101 | |
102 // Checkbox for the user to choose to report the settings or not. | |
103 views::Checkbox* report_settings_checkbox; | |
104 } controls_; | |
105 | |
106 // The snapshot is used to show user feedback information. | |
107 scoped_ptr<ResettableSettingsSnapshot> snapshot_; | |
108 | |
109 // A version of the help image that is brighter. | |
110 gfx::ImageSkia brighter_help_image_; | |
111 | |
112 // Used for opening the learn more link. | |
113 content::PageNavigator* navigator_; | |
114 | |
115 // Used to access profile specific stuff like the global error or readable | |
116 // feedback. | |
117 Profile* profile_; | |
118 | |
119 // The GlobalError this Bubble belongs to. | |
120 base::WeakPtr<ProfileResetGlobalError> global_error_; | |
121 | |
122 // Remembers if we are currently resetting or not. | |
123 bool resetting_; | |
124 | |
125 // Remembers if the reset button was hit before closing the bubble. | |
126 bool chose_to_reset_; | |
127 | |
128 // Toggles when the user clicks on the |help_button_| to identify if we should | |
129 // show the help pane or not. | |
130 bool show_help_pane_; | |
131 | |
132 // To cancel pending callbacks after destruction. | |
133 base::WeakPtrFactory<ProfileResetBubbleView> weak_factory_; | |
134 | |
135 DISALLOW_COPY_AND_ASSIGN(ProfileResetBubbleView); | |
136 }; | |
137 | |
138 #endif // CHROME_BROWSER_UI_VIEWS_PROFILES_PROFILE_RESET_BUBBLE_VIEW_H_ | |
OLD | NEW |