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

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

Issue 1988463002: MD Settings: Convert C++ handlers to be JavaScript-lifecycle aware. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months 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 #include "chrome/browser/ui/webui/settings/reset_settings_handler.h" 5 #include "chrome/browser/ui/webui/settings/reset_settings_handler.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 base::Unretained(this))); 107 base::Unretained(this)));
108 web_ui()->RegisterMessageCallback( 108 web_ui()->RegisterMessageCallback(
109 "requestFactoryResetRestart", 109 "requestFactoryResetRestart",
110 base::Bind(&ResetSettingsHandler::HandleFactoryResetRestart, 110 base::Bind(&ResetSettingsHandler::HandleFactoryResetRestart,
111 base::Unretained(this))); 111 base::Unretained(this)));
112 #endif // defined(OS_CHROMEOS) 112 #endif // defined(OS_CHROMEOS)
113 } 113 }
114 114
115 void ResetSettingsHandler::HandleResetProfileSettings( 115 void ResetSettingsHandler::HandleResetProfileSettings(
116 const base::ListValue* args) { 116 const base::ListValue* args) {
117 AllowJavascript();
118
117 CHECK_EQ(2U, args->GetSize()); 119 CHECK_EQ(2U, args->GetSize());
118 std::string callback_id; 120 std::string callback_id;
119 CHECK(args->GetString(0, &callback_id)); 121 CHECK(args->GetString(0, &callback_id));
120 bool send_settings = false; 122 bool send_settings = false;
121 CHECK(args->GetBoolean(1, &send_settings)); 123 CHECK(args->GetBoolean(1, &send_settings));
122 124
123 DCHECK(brandcode_.empty() || config_fetcher_); 125 DCHECK(brandcode_.empty() || config_fetcher_);
124 if (config_fetcher_ && config_fetcher_->IsActive()) { 126 if (config_fetcher_ && config_fetcher_->IsActive()) {
125 // Reset once the prefs are fetched. 127 // Reset once the prefs are fetched.
126 config_fetcher_->SetCallback( 128 config_fetcher_->SetCallback(
(...skipping 19 matching lines...) Expand all
146 SerializeSettingsReportToProto(*setting_snapshot_, difference); 148 SerializeSettingsReportToProto(*setting_snapshot_, difference);
147 if (report_proto) 149 if (report_proto)
148 SendSettingsFeedbackProto(*report_proto, profile_); 150 SendSettingsFeedbackProto(*report_proto, profile_);
149 } 151 }
150 } 152 }
151 setting_snapshot_.reset(); 153 setting_snapshot_.reset();
152 } 154 }
153 155
154 void ResetSettingsHandler::HandleGetReportedSettings( 156 void ResetSettingsHandler::HandleGetReportedSettings(
155 const base::ListValue* args) { 157 const base::ListValue* args) {
158 AllowJavascript();
159
156 CHECK_EQ(1U, args->GetSize()); 160 CHECK_EQ(1U, args->GetSize());
157 std::string callback_id; 161 std::string callback_id;
158 CHECK(args->GetString(0, &callback_id)); 162 CHECK(args->GetString(0, &callback_id));
159 163
160 setting_snapshot_->RequestShortcuts(base::Bind( 164 setting_snapshot_->RequestShortcuts(base::Bind(
161 &ResetSettingsHandler::OnGetReportedSettingsDone, 165 &ResetSettingsHandler::OnGetReportedSettingsDone,
162 weak_ptr_factory_.GetWeakPtr(), 166 weak_ptr_factory_.GetWeakPtr(),
163 callback_id)); 167 callback_id));
164 } 168 }
165 169
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 prefs->SetBoolean(prefs::kFactoryResetRequested, true); 257 prefs->SetBoolean(prefs::kFactoryResetRequested, true);
254 prefs->CommitPendingWrite(); 258 prefs->CommitPendingWrite();
255 259
256 // Perform sign out. Current chrome process will then terminate, new one will 260 // Perform sign out. Current chrome process will then terminate, new one will
257 // be launched (as if it was a restart). 261 // be launched (as if it was a restart).
258 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->RequestRestart(); 262 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->RequestRestart();
259 } 263 }
260 #endif // defined(OS_CHROMEOS) 264 #endif // defined(OS_CHROMEOS)
261 265
262 } // namespace settings 266 } // namespace settings
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/settings/reset_settings_handler.h ('k') | chrome/browser/ui/webui/settings/search_engines_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698