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_
8 #include "base/compiler_specific.h"
9 #include "base/memory/weak_ptr.h"
10 #include "chrome/browser/ui/webui/options/options_ui.h"
13 class DictionaryValue
;
17 class AutomaticProfileResetter
;
18 class BrandcodeConfigFetcher
;
19 class ProfileResetter
;
20 class ResettableSettingsSnapshot
;
24 // Handler for both the 'Reset Profile Settings' overlay page and also the
25 // corresponding banner that is shown at the top of the options page.
26 class ResetProfileSettingsHandler
27 : public OptionsPageUIHandler
,
28 public base::SupportsWeakPtr
<ResetProfileSettingsHandler
> {
30 ResetProfileSettingsHandler();
31 virtual ~ResetProfileSettingsHandler();
33 // OptionsPageUIHandler implementation.
34 virtual void GetLocalizedValues(
35 base::DictionaryValue
* localized_strings
) OVERRIDE
;
36 virtual void InitializeHandler() OVERRIDE
;
37 virtual void InitializePage() OVERRIDE
;
38 virtual void Uninitialize() OVERRIDE
;
40 // WebUIMessageHandler implementation.
41 virtual void RegisterMessages() OVERRIDE
;
44 // Javascript callback to start clearing data.
45 void HandleResetProfileSettings(const base::ListValue
* value
);
47 // Closes the dialog once all requested settings has been reset.
48 void OnResetProfileSettingsDone();
50 // Called when the confirmation box appears.
51 void OnShowResetProfileDialog(const base::ListValue
* value
);
53 // Called when the reset banner is dismissed from the WebUI.
54 void OnDismissedResetProfileSettingsBanner(const base::ListValue
* args
);
56 // Called when BrandcodeConfigFetcher completed fetching settings.
57 void OnSettingsFetched();
59 // Resets profile settings to default values. |send_settings| is true if user
60 // gave his consent to upload broken settings to Google for analysis.
61 void ResetProfile(bool send_settings
);
63 // Destroyed with the Profile, thus it should outlive us. This will be NULL if
64 // the underlying profile is off-the-record (e.g. in Guest mode on Chrome OS).
65 AutomaticProfileResetter
* automatic_profile_resetter_
;
67 // Records whether or not the Profile Reset confirmation dialog was opened at
68 // least once during the lifetime of the settings page.
69 bool has_shown_confirmation_dialog_
;
71 scoped_ptr
<ProfileResetter
> resetter_
;
73 scoped_ptr
<BrandcodeConfigFetcher
> config_fetcher_
;
75 // Snapshot of settings before profile was reseted.
76 scoped_ptr
<ResettableSettingsSnapshot
> setting_snapshot_
;
78 // Contains Chrome brand code; empty for organic Chrome.
79 std::string brandcode_
;
81 DISALLOW_COPY_AND_ASSIGN(ResetProfileSettingsHandler
);
84 } // namespace options
86 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_RESET_PROFILE_SETTINGS_HANDLER_H_