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 #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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
138 bool send_settings = false; | 138 bool send_settings = false; |
139 CHECK(args->GetBoolean(1, &send_settings)); | 139 CHECK(args->GetBoolean(1, &send_settings)); |
140 std::string request_origin_string; | 140 std::string request_origin_string; |
141 CHECK(args->GetString(2, &request_origin_string)); | 141 CHECK(args->GetString(2, &request_origin_string)); |
142 reset_report::ChromeResetReport::ResetRequestOrigin request_origin = | 142 reset_report::ChromeResetReport::ResetRequestOrigin request_origin = |
143 ResetRequestOriginFromString(request_origin_string); | 143 ResetRequestOriginFromString(request_origin_string); |
144 | 144 |
145 DCHECK(brandcode_.empty() || config_fetcher_); | 145 DCHECK(brandcode_.empty() || config_fetcher_); |
146 if (config_fetcher_ && config_fetcher_->IsActive()) { | 146 if (config_fetcher_ && config_fetcher_->IsActive()) { |
147 // Reset once the prefs are fetched. | 147 // Reset once the prefs are fetched. |
148 config_fetcher_->SetCallback(base::Bind( | 148 config_fetcher_->SetCallback(base::Bind(&ResetSettingsHandler::ResetProfile, |
149 &ResetSettingsHandler::ResetProfile, weak_ptr_factory_.GetWeakPtr(), | 149 base::Unretained(this), callback_id, |
150 callback_id, send_settings, request_origin)); | 150 send_settings, request_origin)); |
151 } else { | 151 } else { |
152 ResetProfile(callback_id, send_settings, request_origin); | 152 ResetProfile(callback_id, send_settings, request_origin); |
153 } | 153 } |
154 } | 154 } |
155 | 155 |
156 void ResetSettingsHandler::OnResetProfileSettingsDone( | 156 void ResetSettingsHandler::OnResetProfileSettingsDone( |
157 std::string callback_id, | 157 std::string callback_id, |
158 bool send_feedback, | 158 bool send_feedback, |
159 reset_report::ChromeResetReport::ResetRequestOrigin request_origin) { | 159 reset_report::ChromeResetReport::ResetRequestOrigin request_origin) { |
160 ResolveJavascriptCallback(base::Value(callback_id), | 160 ResolveJavascriptCallback(base::Value(callback_id), |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
229 | 229 |
230 void ResetSettingsHandler::ResetProfile( | 230 void ResetSettingsHandler::ResetProfile( |
231 const std::string& callback_id, | 231 const std::string& callback_id, |
232 bool send_settings, | 232 bool send_settings, |
233 reset_report::ChromeResetReport::ResetRequestOrigin request_origin) { | 233 reset_report::ChromeResetReport::ResetRequestOrigin request_origin) { |
234 DCHECK(!GetResetter()->IsActive()); | 234 DCHECK(!GetResetter()->IsActive()); |
235 | 235 |
236 std::unique_ptr<BrandcodedDefaultSettings> default_settings; | 236 std::unique_ptr<BrandcodedDefaultSettings> default_settings; |
237 if (config_fetcher_) { | 237 if (config_fetcher_) { |
238 DCHECK(!config_fetcher_->IsActive()); | 238 DCHECK(!config_fetcher_->IsActive()); |
239 default_settings = config_fetcher_->GetSettings(); | 239 default_settings = config_fetcher_->GetSettings(); |
dschuyler
2017/03/31 19:21:39
Can |config_fetcher_| be true (at line 237) with t
tommycli
2017/04/03 15:34:23
Hi, yes, that will remain true. The base::ResetAnd
dschuyler
2017/04/03 18:27:09
Cool. Yeah, that makes sense.
| |
240 config_fetcher_.reset(); | 240 config_fetcher_.reset(); |
241 } else { | 241 } else { |
242 DCHECK(brandcode_.empty()); | 242 DCHECK(brandcode_.empty()); |
243 } | 243 } |
244 | 244 |
245 // If failed to fetch BrandcodedDefaultSettings or this is an organic | 245 // If failed to fetch BrandcodedDefaultSettings or this is an organic |
246 // installation, use default settings. | 246 // installation, use default settings. |
247 if (!default_settings) | 247 if (!default_settings) |
248 default_settings.reset(new BrandcodedDefaultSettings); | 248 default_settings.reset(new BrandcodedDefaultSettings); |
249 | 249 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
302 void ResetSettingsHandler::OnShowPowerwashDialog( | 302 void ResetSettingsHandler::OnShowPowerwashDialog( |
303 const base::ListValue* args) { | 303 const base::ListValue* args) { |
304 UMA_HISTOGRAM_ENUMERATION( | 304 UMA_HISTOGRAM_ENUMERATION( |
305 "Reset.ChromeOS.PowerwashDialogShown", | 305 "Reset.ChromeOS.PowerwashDialogShown", |
306 chromeos::reset::DIALOG_FROM_OPTIONS, | 306 chromeos::reset::DIALOG_FROM_OPTIONS, |
307 chromeos::reset::DIALOG_VIEW_TYPE_SIZE); | 307 chromeos::reset::DIALOG_VIEW_TYPE_SIZE); |
308 } | 308 } |
309 #endif // defined(OS_CHROMEOS) | 309 #endif // defined(OS_CHROMEOS) |
310 | 310 |
311 } // namespace settings | 311 } // namespace settings |
OLD | NEW |