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

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: Addressing comments 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 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
56 private:
49 // Closes the dialog once all requested settings has been reset. 57 // Closes the dialog once all requested settings has been reset.
50 void OnResetProfileSettingsDone(bool send_feedback); 58 void OnResetProfileSettingsDone(bool send_feedback);
51 59
52 // Called when the confirmation box appears. 60 // Called when the confirmation box appears.
53 void OnShowResetProfileDialog(const base::ListValue* value); 61 void OnShowResetProfileDialog(const base::ListValue* value);
54 62
55 // Called when the confirmation box disappears. 63 // Called when the confirmation box disappears.
56 void OnHideResetProfileDialog(const base::ListValue* value); 64 void OnHideResetProfileDialog(const base::ListValue* value);
57 65
58 // Called when BrandcodeConfigFetcher completed fetching settings. 66 // Called when BrandcodeConfigFetcher completed fetching settings.
(...skipping 11 matching lines...) Expand all
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* const profile_;
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_
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/settings/md_settings_ui.cc ('k') | chrome/browser/ui/webui/settings/reset_settings_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698