Home | History | Annotate | Download | only in options
      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 
     12 namespace base {
     13 class DictionaryValue;
     14 class ListValue;
     15 }  // namespace base
     16 
     17 class BrandcodeConfigFetcher;
     18 class ProfileResetter;
     19 class ResettableSettingsSnapshot;
     20 
     21 namespace options {
     22 
     23 // Reset Profile Settings handler page UI handler.
     24 class ResetProfileSettingsHandler
     25     : public OptionsPageUIHandler,
     26       public base::SupportsWeakPtr<ResetProfileSettingsHandler> {
     27  public:
     28   ResetProfileSettingsHandler();
     29   virtual ~ResetProfileSettingsHandler();
     30 
     31   // OptionsPageUIHandler implementation.
     32   virtual void GetLocalizedValues(
     33       base::DictionaryValue* localized_strings) OVERRIDE;
     34   virtual void InitializeHandler() OVERRIDE;
     35 
     36   // WebUIMessageHandler implementation.
     37   virtual void RegisterMessages() OVERRIDE;
     38 
     39  private:
     40   // Javascript callback to start clearing data.
     41   void HandleResetProfileSettings(const base::ListValue* value);
     42 
     43   // Closes the dialog once all requested settings has been reset.
     44   void OnResetProfileSettingsDone();
     45 
     46   // Called when the confirmation box appears.
     47   void OnShowResetProfileDialog(const base::ListValue* value);
     48 
     49   // Called when BrandcodeConfigFetcher completed fetching settings.
     50   void OnSettingsFetched();
     51 
     52   // Resets profile settings to default values. |send_settings| is true if user
     53   // gave his consent to upload broken settings to Google for analysis.
     54   void ResetProfile(bool send_settings);
     55 
     56   scoped_ptr<ProfileResetter> resetter_;
     57 
     58   scoped_ptr<BrandcodeConfigFetcher> config_fetcher_;
     59 
     60   // Snapshot of settings before profile was reseted.
     61   scoped_ptr<ResettableSettingsSnapshot> setting_snapshot_;
     62 
     63   // Contains Chrome brand code; empty for organic Chrome.
     64   std::string brandcode_;
     65 
     66   DISALLOW_COPY_AND_ASSIGN(ResetProfileSettingsHandler);
     67 };
     68 
     69 }  // namespace options
     70 
     71 #endif  // CHROME_BROWSER_UI_WEBUI_OPTIONS_RESET_PROFILE_SETTINGS_HANDLER_H_
     72