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. 4 5#ifndef CHROME_BROWSER_UI_WEBUI_OPTIONS_RESET_PROFILE_SETTINGS_HANDLER_H_ 6#define CHROME_BROWSER_UI_WEBUI_OPTIONS_RESET_PROFILE_SETTINGS_HANDLER_H_ 7 8#include "base/compiler_specific.h" 9#include "base/memory/weak_ptr.h" 10#include "chrome/browser/ui/webui/options/options_ui.h" 11 12namespace base { 13class DictionaryValue; 14class ListValue; 15} // namespace base 16 17class AutomaticProfileResetter; 18class BrandcodeConfigFetcher; 19class ProfileResetter; 20class ResettableSettingsSnapshot; 21 22namespace options { 23 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. 26class ResetProfileSettingsHandler 27 : public OptionsPageUIHandler, 28 public base::SupportsWeakPtr<ResetProfileSettingsHandler> { 29 public: 30 ResetProfileSettingsHandler(); 31 virtual ~ResetProfileSettingsHandler(); 32 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; 39 40 // WebUIMessageHandler implementation. 41 virtual void RegisterMessages() OVERRIDE; 42 43 private: 44 // Javascript callback to start clearing data. 45 void HandleResetProfileSettings(const base::ListValue* value); 46 47 // Closes the dialog once all requested settings has been reset. 48 void OnResetProfileSettingsDone(); 49 50 // Called when the confirmation box appears. 51 void OnShowResetProfileDialog(const base::ListValue* value); 52 53 // Called when the reset banner is dismissed from the WebUI. 54 void OnDismissedResetProfileSettingsBanner(const base::ListValue* args); 55 56 // Called when BrandcodeConfigFetcher completed fetching settings. 57 void OnSettingsFetched(); 58 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); 62 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_; 66 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_; 70 71 scoped_ptr<ProfileResetter> resetter_; 72 73 scoped_ptr<BrandcodeConfigFetcher> config_fetcher_; 74 75 // Snapshot of settings before profile was reseted. 76 scoped_ptr<ResettableSettingsSnapshot> setting_snapshot_; 77 78 // Contains Chrome brand code; empty for organic Chrome. 79 std::string brandcode_; 80 81 DISALLOW_COPY_AND_ASSIGN(ResetProfileSettingsHandler); 82}; 83 84} // namespace options 85 86#endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_RESET_PROFILE_SETTINGS_HANDLER_H_ 87