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"
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
37 class ProfileResetBubbleView
: public views::BubbleDelegateView
,
38 public views::ButtonListener
,
39 public views::LinkListener
,
40 public GlobalErrorBubbleViewBase
{
42 static ProfileResetBubbleView
* ShowBubble(
43 const base::WeakPtr
<ProfileResetGlobalError
>& global_error
,
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
;
57 ProfileResetBubbleView(
58 const base::WeakPtr
<ProfileResetGlobalError
>& global_error
,
59 views::View
* anchor_view
,
60 content::PageNavigator
* navigator
,
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();
88 no_thanks_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
;
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
119 // The GlobalError this Bubble belongs to.
120 base::WeakPtr
<ProfileResetGlobalError
> global_error_
;
122 // Remembers if we are currently resetting or not.
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_