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_PROFILE_RESETTER_PROFILE_RESET_GLOBAL_ERROR_H_
6 #define CHROME_BROWSER_PROFILE_RESETTER_PROFILE_RESET_GLOBAL_ERROR_H_
8 #include "base/basictypes.h"
9 #include "base/memory/weak_ptr.h"
10 #include "base/timer/elapsed_timer.h"
11 #include "chrome/browser/ui/global_error/global_error.h"
13 class AutomaticProfileResetter
;
14 class GlobalErrorBubbleViewBase
;
17 // Encapsulates UI-related functionality for the one-time profile settings reset
18 // prompt. The UI consists of two parts: (1.) the profile reset (pop-up) bubble,
19 // and (2.) a menu item in the wrench menu (provided by us being a GlobalError).
20 class ProfileResetGlobalError
22 public base::SupportsWeakPtr
<ProfileResetGlobalError
> {
24 explicit ProfileResetGlobalError(Profile
* profile
);
25 ~ProfileResetGlobalError() override
;
27 // Returns whether or not the reset prompt is supported on this platform.
28 static bool IsSupportedOnPlatform(Browser
* browser
);
30 // Called by the bubble view when it is closed.
31 void OnBubbleViewDidClose();
33 // Called when the user clicks on the 'Reset' button. The user can choose to
34 // send feedback containing the old settings that are now being reset, this is
35 // indicated by |send_feedback|.
36 void OnBubbleViewResetButtonPressed(bool send_feedback
);
38 // Called when the user clicks the 'No, thanks' button.
39 void OnBubbleViewNoThanksButtonPressed();
42 bool HasMenuItem() override
;
43 int MenuItemCommandID() override
;
44 base::string16
MenuItemLabel() override
;
45 void ExecuteMenuItem(Browser
* browser
) override
;
46 bool HasBubbleView() override
;
47 bool HasShownBubbleView() override
;
48 void ShowBubbleView(Browser
* browser
) override
;
49 GlobalErrorBubbleViewBase
* GetBubbleView() override
;
54 // GlobalErrorService owns us, on which AutomaticProfileResetter depends, so
55 // during shutdown, it may get destroyed before we are.
56 // Note: the AutomaticProfileResetter expects call-backs from us to always be
57 // synchronous, so that there will be no call-backs once we are destroyed.
58 base::WeakPtr
<AutomaticProfileResetter
> automatic_profile_resetter_
;
60 // Used to measure the delay before the bubble actually gets shown.
61 base::ElapsedTimer timer_
;
63 // Whether or not we have already shown the bubble.
64 bool has_shown_bubble_view_
;
66 // The reset bubble, if we're currently showing one.
67 GlobalErrorBubbleViewBase
* bubble_view_
;
69 DISALLOW_COPY_AND_ASSIGN(ProfileResetGlobalError
);
72 #endif // CHROME_BROWSER_PROFILE_RESETTER_PROFILE_RESET_GLOBAL_ERROR_H_