Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / views / profiles / profile_reset_bubble_view.h
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   views::View* GetInitiallyFocusedView() override;
48   void Init() override;
49
50   // views::WidgetDelegate method.
51   void WindowClosing() override;
52
53   // GlobalErrorBubbleViewBase:
54   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   ~ProfileResetBubbleView() override;
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   void ButtonPressed(views::Button* sender, const ui::Event& event) override;
74
75   // views::LinkListener method.
76   void LinkClicked(views::Link* source, int event_flags) override;
77
78   // Sets the fully populated feedback data.
79   void UpdateFeedbackDetails();
80
81   struct Controls {
82     Controls() {
83       Reset();
84     }
85     void Reset() {
86       reset_button = NULL;
87       no_thanks_button = NULL;
88       help_button = NULL;
89       report_settings_checkbox = NULL;
90     }
91
92     // Button for the user to confirm a settings reset.
93     views::LabelButton* reset_button;
94
95     // Button for the user to refuse a settings reset.
96     views::LabelButton* no_thanks_button;
97
98     // Button for the user to get more info about reporting settings.
99     views::ImageButton* help_button;
100
101     // Checkbox for the user to choose to report the settings or not.
102     views::Checkbox* report_settings_checkbox;
103   } controls_;
104
105   // The snapshot is used to show user feedback information.
106   scoped_ptr<ResettableSettingsSnapshot> snapshot_;
107
108   // A version of the help image that is brighter.
109   gfx::ImageSkia brighter_help_image_;
110
111   // Used for opening the learn more link.
112   content::PageNavigator* navigator_;
113
114   // Used to access profile specific stuff like the global error or readable
115   // feedback.
116   Profile* profile_;
117
118   // The GlobalError this Bubble belongs to.
119   base::WeakPtr<ProfileResetGlobalError> global_error_;
120
121   // Remembers if we are currently resetting or not.
122   bool resetting_;
123
124   // Remembers if the reset button was hit before closing the bubble.
125   bool chose_to_reset_;
126
127   // Toggles when the user clicks on the |help_button_| to identify if we should
128   // show the help pane or not.
129   bool show_help_pane_;
130
131   // To cancel pending callbacks after destruction.
132   base::WeakPtrFactory<ProfileResetBubbleView> weak_factory_;
133
134   DISALLOW_COPY_AND_ASSIGN(ProfileResetBubbleView);
135 };
136
137 #endif  // CHROME_BROWSER_UI_VIEWS_PROFILES_PROFILE_RESET_BUBBLE_VIEW_H_