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_SETTINGS_RESET_SETTINGS_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_SETTINGS_RESET_SETTINGS_HANDLER_H_ |
6 #define CHROME_BROWSER_UI_WEBUI_SETTINGS_RESET_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/macros.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
14 #include "chrome/browser/ui/webui/settings/md_settings_ui.h" | 14 #include "chrome/browser/ui/webui/settings/md_settings_ui.h" |
15 | 15 |
16 namespace base { | 16 namespace base { |
17 class DictionaryValue; | 17 class DictionaryValue; |
18 class ListValue; | 18 class ListValue; |
19 } // namespace base | 19 } // namespace base |
20 | 20 |
21 namespace content { | 21 namespace content { |
22 class WebUIDataSource; | 22 class WebUIDataSource; |
23 } | 23 } |
24 | 24 |
25 class BrandcodeConfigFetcher; | 25 class BrandcodeConfigFetcher; |
26 class Profile; | |
26 class ProfileResetter; | 27 class ProfileResetter; |
27 class ResettableSettingsSnapshot; | 28 class ResettableSettingsSnapshot; |
28 | 29 |
29 namespace settings { | 30 namespace settings { |
30 | 31 |
31 // Handler for | 32 // Handler for |
32 // 1) 'Reset Profile Settings' dialog | 33 // 1) 'Reset Profile Settings' dialog |
33 // 2) 'Powerwash' dialog (ChromeOS only) | 34 // 2) 'Powerwash' dialog (ChromeOS only) |
34 class ResetSettingsHandler | 35 class ResetSettingsHandler |
35 : public SettingsPageUIHandler, | 36 : public SettingsPageUIHandler, |
36 public base::SupportsWeakPtr<ResetSettingsHandler> { | 37 public base::SupportsWeakPtr<ResetSettingsHandler> { |
37 public: | 38 public: |
38 explicit ResetSettingsHandler( | |
39 content::WebUIDataSource* html_source, content::WebUI* web_ui); | |
40 ~ResetSettingsHandler() override; | 39 ~ResetSettingsHandler() override; |
41 | 40 |
41 static ResetSettingsHandler* Create( | |
42 content::WebUIDataSource* html_source, Profile* profile); | |
43 | |
42 // WebUIMessageHandler implementation. | 44 // WebUIMessageHandler implementation. |
43 void RegisterMessages() override; | 45 void RegisterMessages() override; |
44 | 46 |
45 private: | 47 protected: |
48 ResetSettingsHandler(Profile* profile, bool allow_powerwash); | |
49 | |
50 // Overriden in tests to substitute with a test version of ProfileResetter. | |
51 virtual ProfileResetter* GetResetter(); | |
52 | |
46 // Javascript callback to start clearing data. | 53 // Javascript callback to start clearing data. |
47 void HandleResetProfileSettings(const base::ListValue* value); | 54 void HandleResetProfileSettings(const base::ListValue* value); |
48 | 55 |
49 // Closes the dialog once all requested settings has been reset. | 56 private: |
50 void OnResetProfileSettingsDone(bool send_feedback); | |
51 | |
52 // Called when the confirmation box appears. | 57 // Called when the confirmation box appears. |
53 void OnShowResetProfileDialog(const base::ListValue* value); | 58 void OnShowResetProfileDialog(const base::ListValue* value); |
54 | 59 |
55 // Called when the confirmation box disappears. | 60 // Called when the confirmation box disappears. |
56 void OnHideResetProfileDialog(const base::ListValue* value); | 61 void OnHideResetProfileDialog(const base::ListValue* value); |
57 | 62 |
63 // Closes the dialog once all requested settings has been reset. | |
64 void OnResetProfileSettingsDone(bool send_feedback); | |
Dan Beam
2015/12/02 04:40:07
nit: revert moving of this method to maintain the
dpapad
2015/12/02 19:55:22
Done.
| |
65 | |
58 // Called when BrandcodeConfigFetcher completed fetching settings. | 66 // Called when BrandcodeConfigFetcher completed fetching settings. |
59 void OnSettingsFetched(); | 67 void OnSettingsFetched(); |
60 | 68 |
61 // Resets profile settings to default values. |send_settings| is true if user | 69 // Resets profile settings to default values. |send_settings| is true if user |
62 // gave his consent to upload broken settings to Google for analysis. | 70 // gave his consent to upload broken settings to Google for analysis. |
63 void ResetProfile(bool send_settings); | 71 void ResetProfile(bool send_settings); |
64 | 72 |
65 // Sets new values for the feedback area. | 73 // Sets new values for the feedback area. |
66 void UpdateFeedbackUI(); | 74 void UpdateFeedbackUI(); |
67 | 75 |
68 #if defined(OS_CHROMEOS) | 76 #if defined(OS_CHROMEOS) |
69 // Will be called when powerwash dialog is shown. | 77 // Will be called when powerwash dialog is shown. |
70 void OnShowPowerwashDialog(const base::ListValue* args); | 78 void OnShowPowerwashDialog(const base::ListValue* args); |
71 | 79 |
72 // Sets a pref indicating that a factory reset is requested and then requests | 80 // Sets a pref indicating that a factory reset is requested and then requests |
73 // a restart. | 81 // a restart. |
74 void HandleFactoryResetRestart(const base::ListValue* args); | 82 void HandleFactoryResetRestart(const base::ListValue* args); |
75 | 83 |
76 // Whether factory reset can be performed. | 84 // Whether factory reset can be performed. |
77 bool allow_powerwash_ = false; | 85 bool allow_powerwash_ = false; |
78 #endif // defined(OS_CHROMEOS) | 86 #endif // defined(OS_CHROMEOS) |
79 | 87 |
88 Profile* profile_; | |
Dan Beam
2015/12/02 04:40:08
nit: Profile* const profile_;
dpapad
2015/12/02 19:55:22
Done.
| |
89 | |
80 scoped_ptr<ProfileResetter> resetter_; | 90 scoped_ptr<ProfileResetter> resetter_; |
81 | 91 |
82 scoped_ptr<BrandcodeConfigFetcher> config_fetcher_; | 92 scoped_ptr<BrandcodeConfigFetcher> config_fetcher_; |
83 | 93 |
84 // Snapshot of settings before profile was reseted. | 94 // Snapshot of settings before profile was reseted. |
85 scoped_ptr<ResettableSettingsSnapshot> setting_snapshot_; | 95 scoped_ptr<ResettableSettingsSnapshot> setting_snapshot_; |
86 | 96 |
87 // Contains Chrome brand code; empty for organic Chrome. | 97 // Contains Chrome brand code; empty for organic Chrome. |
88 std::string brandcode_; | 98 std::string brandcode_; |
89 | 99 |
90 DISALLOW_COPY_AND_ASSIGN(ResetSettingsHandler); | 100 DISALLOW_COPY_AND_ASSIGN(ResetSettingsHandler); |
91 }; | 101 }; |
92 | 102 |
93 } // namespace settings | 103 } // namespace settings |
94 | 104 |
95 #endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_RESET_SETTINGS_HANDLER_H_ | 105 #endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_RESET_SETTINGS_HANDLER_H_ |
OLD | NEW |