Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / ui / views / profile_reset_bubble_view.h
blob89241128474aeb2b1ba14c007a7cb9139d087f38
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"
17 namespace content {
18 class PageNavigator;
21 namespace views {
22 class Checkbox;
23 class ImageButton;
24 class LabelButton;
25 class Link;
28 class Browser;
29 class Profile;
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
34 // Chrome toolbar.
35 class ProfileResetBubbleView : public views::BubbleDelegateView,
36 public views::ButtonListener,
37 public views::LinkListener,
38 public GlobalErrorBubbleViewBase {
39 public:
40 static ProfileResetBubbleView* ShowBubble(
41 const base::WeakPtr<ProfileResetGlobalError>& global_error,
42 Browser* browser);
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;
54 private:
55 ProfileResetBubbleView(
56 const base::WeakPtr<ProfileResetGlobalError>& global_error,
57 views::View* anchor_view,
58 content::PageNavigator* navigator,
59 Profile* profile);
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;
77 struct Controls {
78 Controls() {
79 Reset();
81 void Reset() {
82 reset_button = NULL;
83 no_thanks_button = NULL;
84 help_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;
99 } controls_;
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
108 // feedback.
109 Profile* profile_;
111 // The GlobalError this Bubble belongs to.
112 base::WeakPtr<ProfileResetGlobalError> global_error_;
114 // Remembers if we are currently resetting or not.
115 bool resetting_;
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_