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