1 // Copyright 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.
5 #ifndef CHROME_BROWSER_UI_VIEWS_PROFILE_RESET_BUBBLE_VIEW_H_
6 #define CHROME_BROWSER_UI_VIEWS_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 "chrome/browser/ui/global_error/global_error_bubble_view_base.h"
12 #include "ui/gfx/image/image_skia.h"
13 #include "ui/views/bubble/bubble_delegate.h"
14 #include "ui/views/controls/button/button.h"
15 #include "ui/views/controls/link_listener.h"
30 class ProfileResetGlobalError
;
32 // ProfileResetBubbleView warns the user that a settings reset might be needed.
33 // It is intended to be used as the content of a bubble anchored off of the
35 class ProfileResetBubbleView
: public views::BubbleDelegateView
,
36 public views::ButtonListener
,
37 public views::LinkListener
,
38 public GlobalErrorBubbleViewBase
{
40 static ProfileResetBubbleView
* ShowBubble(
41 const base::WeakPtr
<ProfileResetGlobalError
>& global_error
,
44 // views::BubbleDelegateView methods.
45 virtual views::View
* GetInitiallyFocusedView() OVERRIDE
;
46 virtual void Init() OVERRIDE
;
48 // views::WidgetDelegate method.
49 virtual void WindowClosing() OVERRIDE
;
51 // GlobalErrorBubbleViewBase:
52 virtual void CloseBubbleView() OVERRIDE
;
55 ProfileResetBubbleView(
56 const base::WeakPtr
<ProfileResetGlobalError
>& global_error
,
57 views::View
* anchor_view
,
58 content::PageNavigator
* navigator
,
61 virtual ~ProfileResetBubbleView();
63 // Reset all child views members and remove children from view hierarchy.
64 void ResetAllChildren();
66 // Sets up the layout manager and set the report checkbox to the value passed
67 // in |report_checked|.
68 void SetupLayoutManager(bool report_checked
);
70 // views::ButtonListener method.
71 virtual void ButtonPressed(views::Button
* sender
,
72 const ui::Event
& event
) OVERRIDE
;
74 // views::LinkListener method.
75 virtual void LinkClicked(views::Link
* source
, int event_flags
) OVERRIDE
;
83 no_thanks_button
= NULL
;
85 report_settings_checkbox
= NULL
;
88 // Button for the user to confirm a settings reset.
89 views::LabelButton
* reset_button
;
91 // Button for the user to refuse a settings reset.
92 views::LabelButton
* no_thanks_button
;
94 // Button for the user to get more info about reporting settings.
95 views::ImageButton
* help_button
;
97 // Checkbox for the user to choose to report the settings or not.
98 views::Checkbox
* report_settings_checkbox
;
101 // A version of the help image that is brighter.
102 gfx::ImageSkia brighter_help_image_
;
104 // Used for opening the learn more link.
105 content::PageNavigator
* navigator_
;
107 // Used to access profile specific stuff like the global error or readable
111 // The GlobalError this Bubble belongs to.
112 base::WeakPtr
<ProfileResetGlobalError
> global_error_
;
114 // Remembers if we are currently resetting or not.
117 // Remembers if the reset button was hit before closing the bubble.
118 bool chose_to_reset_
;
120 // Toggles when the user clicks on the |help_button_| to identify if we should
121 // show the help pane or not.
122 bool show_help_pane_
;
124 // To cancel pending callbacks after destruction.
125 base::WeakPtrFactory
<ProfileResetBubbleView
> weak_factory_
;
127 DISALLOW_COPY_AND_ASSIGN(ProfileResetBubbleView
);
130 #endif // CHROME_BROWSER_UI_VIEWS_PROFILE_RESET_BUBBLE_VIEW_H_