OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_PROFILE_RESETTER_PROFILE_RESET_GLOBAL_ERROR_H_ | 5 #ifndef CHROME_BROWSER_PROFILE_RESETTER_PROFILE_RESET_GLOBAL_ERROR_H_ |
6 #define CHROME_BROWSER_PROFILE_RESETTER_PROFILE_RESET_GLOBAL_ERROR_H_ | 6 #define CHROME_BROWSER_PROFILE_RESETTER_PROFILE_RESET_GLOBAL_ERROR_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
| 10 #include "base/timer/elapsed_timer.h" |
10 #include "chrome/browser/ui/global_error/global_error.h" | 11 #include "chrome/browser/ui/global_error/global_error.h" |
11 | 12 |
| 13 class AutomaticProfileResetter; |
12 class GlobalErrorBubbleViewBase; | 14 class GlobalErrorBubbleViewBase; |
13 class Profile; | 15 class Profile; |
14 | 16 |
15 // Shows preferences reset errors on the wrench menu and exposes a menu item to | 17 // Encapsulates UI-related functionality for the one-time profile settings reset |
16 // launch a bubble view. | 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). |
17 class ProfileResetGlobalError | 20 class ProfileResetGlobalError |
18 : public GlobalError, | 21 : public GlobalError, |
19 public base::SupportsWeakPtr<ProfileResetGlobalError> { | 22 public base::SupportsWeakPtr<ProfileResetGlobalError> { |
20 public: | 23 public: |
21 explicit ProfileResetGlobalError(Profile* profile); | 24 explicit ProfileResetGlobalError(Profile* profile); |
22 virtual ~ProfileResetGlobalError(); | 25 virtual ~ProfileResetGlobalError(); |
23 | 26 |
| 27 // Returns whether or not the reset prompt is supported on this platform. |
| 28 static bool IsSupportedOnPlatform(); |
| 29 |
24 // Called by the bubble view when it is closed. | 30 // Called by the bubble view when it is closed. |
25 void OnBubbleViewDidClose(); | 31 void OnBubbleViewDidClose(); |
26 | 32 |
27 // Called when the user clicks on the 'Reset' button. The user can choose to | 33 // Called when the user clicks on the 'Reset' button. The user can choose to |
28 // send feedback containing the old settings that are now being reset, this is | 34 // send feedback containing the old settings that are now being reset, this is |
29 // indicated by |send_feedback|. | 35 // indicated by |send_feedback|. |
30 void OnBubbleViewResetButtonPressed(bool send_feedback); | 36 void OnBubbleViewResetButtonPressed(bool send_feedback); |
31 | 37 |
32 // Called when the user clicks the 'No, thanks' button. | 38 // Called when the user clicks the 'No, thanks' button. |
33 void OnBubbleViewNoThanksButtonPressed(); | 39 void OnBubbleViewNoThanksButtonPressed(); |
34 | 40 |
35 // GlobalError: | 41 // GlobalError: |
36 virtual bool HasMenuItem() OVERRIDE; | 42 virtual bool HasMenuItem() OVERRIDE; |
37 virtual int MenuItemCommandID() OVERRIDE; | 43 virtual int MenuItemCommandID() OVERRIDE; |
38 virtual string16 MenuItemLabel() OVERRIDE; | 44 virtual string16 MenuItemLabel() OVERRIDE; |
39 virtual void ExecuteMenuItem(Browser* browser) OVERRIDE; | 45 virtual void ExecuteMenuItem(Browser* browser) OVERRIDE; |
40 virtual bool HasBubbleView() OVERRIDE; | 46 virtual bool HasBubbleView() OVERRIDE; |
41 virtual bool HasShownBubbleView() OVERRIDE; | 47 virtual bool HasShownBubbleView() OVERRIDE; |
42 virtual void ShowBubbleView(Browser* browser) OVERRIDE; | 48 virtual void ShowBubbleView(Browser* browser) OVERRIDE; |
43 virtual GlobalErrorBubbleViewBase* GetBubbleView() OVERRIDE; | 49 virtual GlobalErrorBubbleViewBase* GetBubbleView() OVERRIDE; |
44 | 50 |
45 private: | 51 private: |
46 Profile* profile_; | 52 Profile* profile_; |
47 | 53 |
48 // The number of times we have shown the bubble so far. This can be >1 if the | 54 // GlobalErrorService owns us, on which AutomaticProfileResetter depends, so |
49 // user dismissed the bubble, then selected the menu item to show it again. | 55 // during shutdown, it may get destroyed before we are. |
50 int num_times_bubble_view_shown_; | 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_; |
| 59 |
| 60 // Used to measure the delay before the bubble actually gets shown. |
| 61 base::ElapsedTimer timer_; |
| 62 |
| 63 // Whether or not we have already shown the bubble. |
| 64 bool has_shown_bubble_view_; |
51 | 65 |
52 // The reset bubble, if we're currently showing one. | 66 // The reset bubble, if we're currently showing one. |
53 GlobalErrorBubbleViewBase* bubble_view_; | 67 GlobalErrorBubbleViewBase* bubble_view_; |
54 | 68 |
55 DISALLOW_COPY_AND_ASSIGN(ProfileResetGlobalError); | 69 DISALLOW_COPY_AND_ASSIGN(ProfileResetGlobalError); |
56 }; | 70 }; |
57 | 71 |
58 #endif // CHROME_BROWSER_PROFILE_RESETTER_PROFILE_RESET_GLOBAL_ERROR_H_ | 72 #endif // CHROME_BROWSER_PROFILE_RESETTER_PROFILE_RESET_GLOBAL_ERROR_H_ |
OLD | NEW |