Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(999)

Side by Side Diff: chrome/browser/ui/webui/settings/reset_settings_handler.h

Issue 1490503002: MD Settings: Adding unit test for ResetSettingsHandler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleanup Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 explicit ResetSettingsHandler(Profile* profile, bool allow_powerwash);
Dan Beam 2015/12/01 04:27:37 drop explicit, make private or protected
dpapad 2015/12/01 19:06:04 Done.
39 content::WebUIDataSource* html_source, content::WebUI* web_ui);
40 ~ResetSettingsHandler() override; 40 ~ResetSettingsHandler() override;
41 41
42 static ResetSettingsHandler* Create(
43 content::WebUIDataSource* html_source, Profile* profile);
44
42 // WebUIMessageHandler implementation. 45 // WebUIMessageHandler implementation.
43 void RegisterMessages() override; 46 void RegisterMessages() override;
44 47
45 private: 48 // Overriden in tests to substitute with a test version of ProfileResetter.
49 virtual ProfileResetter* GetResetter();
Dan Beam 2015/12/01 04:27:37 protected
dpapad 2015/12/01 19:06:04 Done.
50
51 protected:
46 // Javascript callback to start clearing data. 52 // Javascript callback to start clearing data.
47 void HandleResetProfileSettings(const base::ListValue* value); 53 void HandleResetProfileSettings(const base::ListValue* value);
48 54
49 // Closes the dialog once all requested settings has been reset. 55 private:
50 void OnResetProfileSettingsDone(bool send_feedback);
51
52 // Called when the confirmation box appears. 56 // Called when the confirmation box appears.
53 void OnShowResetProfileDialog(const base::ListValue* value); 57 void OnShowResetProfileDialog(const base::ListValue* value);
54 58
55 // Called when the confirmation box disappears. 59 // Called when the confirmation box disappears.
56 void OnHideResetProfileDialog(const base::ListValue* value); 60 void OnHideResetProfileDialog(const base::ListValue* value);
57 61
62 // Closes the dialog once all requested settings has been reset.
63 void OnResetProfileSettingsDone(bool send_feedback);
64
58 // Called when BrandcodeConfigFetcher completed fetching settings. 65 // Called when BrandcodeConfigFetcher completed fetching settings.
59 void OnSettingsFetched(); 66 void OnSettingsFetched();
60 67
61 // Resets profile settings to default values. |send_settings| is true if user 68 // Resets profile settings to default values. |send_settings| is true if user
62 // gave his consent to upload broken settings to Google for analysis. 69 // gave his consent to upload broken settings to Google for analysis.
63 void ResetProfile(bool send_settings); 70 void ResetProfile(bool send_settings);
64 71
65 // Sets new values for the feedback area. 72 // Sets new values for the feedback area.
66 void UpdateFeedbackUI(); 73 void UpdateFeedbackUI();
67 74
68 #if defined(OS_CHROMEOS) 75 #if defined(OS_CHROMEOS)
69 // Will be called when powerwash dialog is shown. 76 // Will be called when powerwash dialog is shown.
70 void OnShowPowerwashDialog(const base::ListValue* args); 77 void OnShowPowerwashDialog(const base::ListValue* args);
71 78
72 // Sets a pref indicating that a factory reset is requested and then requests 79 // Sets a pref indicating that a factory reset is requested and then requests
73 // a restart. 80 // a restart.
74 void HandleFactoryResetRestart(const base::ListValue* args); 81 void HandleFactoryResetRestart(const base::ListValue* args);
75 82
76 // Whether factory reset can be performed. 83 // Whether factory reset can be performed.
77 bool allow_powerwash_ = false; 84 bool allow_powerwash_ = false;
78 #endif // defined(OS_CHROMEOS) 85 #endif // defined(OS_CHROMEOS)
79 86
87 Profile* profile_;
88
80 scoped_ptr<ProfileResetter> resetter_; 89 scoped_ptr<ProfileResetter> resetter_;
81 90
82 scoped_ptr<BrandcodeConfigFetcher> config_fetcher_; 91 scoped_ptr<BrandcodeConfigFetcher> config_fetcher_;
83 92
84 // Snapshot of settings before profile was reseted. 93 // Snapshot of settings before profile was reseted.
85 scoped_ptr<ResettableSettingsSnapshot> setting_snapshot_; 94 scoped_ptr<ResettableSettingsSnapshot> setting_snapshot_;
86 95
87 // Contains Chrome brand code; empty for organic Chrome. 96 // Contains Chrome brand code; empty for organic Chrome.
88 std::string brandcode_; 97 std::string brandcode_;
89 98
90 DISALLOW_COPY_AND_ASSIGN(ResetSettingsHandler); 99 DISALLOW_COPY_AND_ASSIGN(ResetSettingsHandler);
91 }; 100 };
92 101
93 } // namespace settings 102 } // namespace settings
94 103
95 #endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_RESET_SETTINGS_HANDLER_H_ 104 #endif // CHROME_BROWSER_UI_WEBUI_SETTINGS_RESET_SETTINGS_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698