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_WEBUI_OPTIONS_RESET_PROFILE_SETTINGS_HANDLER_H_
6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS_RESET_PROFILE_SETTINGS_HANDLER_H_
10 #include "base/compiler_specific.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/weak_ptr.h"
13 #include "chrome/browser/ui/webui/options/options_ui.h"
16 class DictionaryValue
;
20 class AutomaticProfileResetter
;
21 class BrandcodeConfigFetcher
;
22 class ProfileResetter
;
23 class ResettableSettingsSnapshot
;
27 // Handler for both the 'Reset Profile Settings' overlay page and also the
28 // corresponding banner that is shown at the top of the options page.
29 class ResetProfileSettingsHandler
30 : public OptionsPageUIHandler
,
31 public base::SupportsWeakPtr
<ResetProfileSettingsHandler
> {
33 ResetProfileSettingsHandler();
34 virtual ~ResetProfileSettingsHandler();
36 // OptionsPageUIHandler implementation.
37 virtual void GetLocalizedValues(
38 base::DictionaryValue
* localized_strings
) OVERRIDE
;
39 virtual void InitializeHandler() OVERRIDE
;
40 virtual void InitializePage() OVERRIDE
;
41 virtual void Uninitialize() OVERRIDE
;
43 // WebUIMessageHandler implementation.
44 virtual void RegisterMessages() OVERRIDE
;
47 // Javascript callback to start clearing data.
48 void HandleResetProfileSettings(const base::ListValue
* value
);
50 // Closes the dialog once all requested settings has been reset.
51 void OnResetProfileSettingsDone(bool send_feedback
);
53 // Called when the confirmation box appears.
54 void OnShowResetProfileDialog(const base::ListValue
* value
);
56 // Called when the confirmation box disappears.
57 void OnHideResetProfileDialog(const base::ListValue
* value
);
59 // Called when the reset banner is dismissed from the WebUI.
60 void OnDismissedResetProfileSettingsBanner(const base::ListValue
* args
);
62 // Called when BrandcodeConfigFetcher completed fetching settings.
63 void OnSettingsFetched();
65 // Resets profile settings to default values. |send_settings| is true if user
66 // gave his consent to upload broken settings to Google for analysis.
67 void ResetProfile(bool send_settings
);
69 // Sets new values for the feedback area.
70 void UpdateFeedbackUI();
72 // Destroyed with the Profile, thus it should outlive us. This will be NULL if
73 // the underlying profile is off-the-record (e.g. in Guest mode on Chrome OS).
74 AutomaticProfileResetter
* automatic_profile_resetter_
;
76 // Records whether or not the Profile Reset confirmation dialog was opened at
77 // least once during the lifetime of the settings page.
78 bool has_shown_confirmation_dialog_
;
80 scoped_ptr
<ProfileResetter
> resetter_
;
82 scoped_ptr
<BrandcodeConfigFetcher
> config_fetcher_
;
84 // Snapshot of settings before profile was reseted.
85 scoped_ptr
<ResettableSettingsSnapshot
> setting_snapshot_
;
87 // Contains Chrome brand code; empty for organic Chrome.
88 std::string brandcode_
;
90 DISALLOW_COPY_AND_ASSIGN(ResetProfileSettingsHandler
);
93 } // namespace options
95 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_RESET_PROFILE_SETTINGS_HANDLER_H_