[Metrics] Make MetricsStateManager take a callback param to check if UMA is enabled.
[chromium-blink-merge.git] / chrome / browser / ui / views / profiles / profile_reset_bubble_view.h
blob454bb2f29b8085d049a1b9973a1897741bd6b2b6
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.
5 #ifndef CHROME_BROWSER_UI_VIEWS_PROFILES_PROFILE_RESET_BUBBLE_VIEW_H_
6 #define CHROME_BROWSER_UI_VIEWS_PROFILES_PROFILE_RESET_BUBBLE_VIEW_H_
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"
18 namespace content {
19 class PageNavigator;
22 namespace views {
23 class Checkbox;
24 class ImageButton;
25 class LabelButton;
26 class Link;
29 class Browser;
30 class Profile;
31 class ProfileResetGlobalError;
32 class ResettableSettingsSnapshot;
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);
46 // views::BubbleDelegateView methods.
47 virtual views::View* GetInitiallyFocusedView() OVERRIDE;
48 virtual void Init() OVERRIDE;
50 // views::WidgetDelegate method.
51 virtual void WindowClosing() OVERRIDE;
53 // GlobalErrorBubbleViewBase:
54 virtual void CloseBubbleView() OVERRIDE;
56 private:
57 ProfileResetBubbleView(
58 const base::WeakPtr<ProfileResetGlobalError>& global_error,
59 views::View* anchor_view,
60 content::PageNavigator* navigator,
61 Profile* profile);
63 virtual ~ProfileResetBubbleView();
65 // Reset all child views members and remove children from view hierarchy.
66 void ResetAllChildren();
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);
72 // views::ButtonListener method.
73 virtual void ButtonPressed(views::Button* sender,
74 const ui::Event& event) OVERRIDE;
76 // views::LinkListener method.
77 virtual void LinkClicked(views::Link* source, int event_flags) OVERRIDE;
79 // Sets the fully populated feedback data.
80 void UpdateFeedbackDetails();
82 struct Controls {
83 Controls() {
84 Reset();
86 void Reset() {
87 reset_button = NULL;
88 no_thanks_button = NULL;
89 help_button = NULL;
90 report_settings_checkbox = NULL;
93 // Button for the user to confirm a settings reset.
94 views::LabelButton* reset_button;
96 // Button for the user to refuse a settings reset.
97 views::LabelButton* no_thanks_button;
99 // Button for the user to get more info about reporting settings.
100 views::ImageButton* help_button;
102 // Checkbox for the user to choose to report the settings or not.
103 views::Checkbox* report_settings_checkbox;
104 } controls_;
106 // The snapshot is used to show user feedback information.
107 scoped_ptr<ResettableSettingsSnapshot> snapshot_;
109 // A version of the help image that is brighter.
110 gfx::ImageSkia brighter_help_image_;
112 // Used for opening the learn more link.
113 content::PageNavigator* navigator_;
115 // Used to access profile specific stuff like the global error or readable
116 // feedback.
117 Profile* profile_;
119 // The GlobalError this Bubble belongs to.
120 base::WeakPtr<ProfileResetGlobalError> global_error_;
122 // Remembers if we are currently resetting or not.
123 bool resetting_;
125 // Remembers if the reset button was hit before closing the bubble.
126 bool chose_to_reset_;
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_;
132 // To cancel pending callbacks after destruction.
133 base::WeakPtrFactory<ProfileResetBubbleView> weak_factory_;
135 DISALLOW_COPY_AND_ASSIGN(ProfileResetBubbleView);
138 #endif // CHROME_BROWSER_UI_VIEWS_PROFILES_PROFILE_RESET_BUBBLE_VIEW_H_