| 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/options/reset_profile_settings_handler.h" | 5 #include "chrome/browser/ui/webui/options/reset_profile_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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 | 144 |
| 145 void ResetProfileSettingsHandler::OnResetProfileSettingsDone( | 145 void ResetProfileSettingsHandler::OnResetProfileSettingsDone( |
| 146 bool send_feedback) { | 146 bool send_feedback) { |
| 147 web_ui()->CallJavascriptFunction("ResetProfileSettingsOverlay.doneResetting"); | 147 web_ui()->CallJavascriptFunction("ResetProfileSettingsOverlay.doneResetting"); |
| 148 if (send_feedback && setting_snapshot_) { | 148 if (send_feedback && setting_snapshot_) { |
| 149 Profile* profile = Profile::FromWebUI(web_ui()); | 149 Profile* profile = Profile::FromWebUI(web_ui()); |
| 150 ResettableSettingsSnapshot current_snapshot(profile); | 150 ResettableSettingsSnapshot current_snapshot(profile); |
| 151 int difference = setting_snapshot_->FindDifferentFields(current_snapshot); | 151 int difference = setting_snapshot_->FindDifferentFields(current_snapshot); |
| 152 if (difference) { | 152 if (difference) { |
| 153 setting_snapshot_->Subtract(current_snapshot); | 153 setting_snapshot_->Subtract(current_snapshot); |
| 154 scoped_ptr<reset_report::ChromeResetReport> report_proto = | 154 std::unique_ptr<reset_report::ChromeResetReport> report_proto = |
| 155 SerializeSettingsReportToProto(*setting_snapshot_, difference); | 155 SerializeSettingsReportToProto(*setting_snapshot_, difference); |
| 156 if (report_proto) | 156 if (report_proto) |
| 157 SendSettingsFeedbackProto(*report_proto, profile); | 157 SendSettingsFeedbackProto(*report_proto, profile); |
| 158 } | 158 } |
| 159 } | 159 } |
| 160 setting_snapshot_.reset(); | 160 setting_snapshot_.reset(); |
| 161 } | 161 } |
| 162 | 162 |
| 163 void ResetProfileSettingsHandler::OnShowResetProfileDialog( | 163 void ResetProfileSettingsHandler::OnShowResetProfileDialog( |
| 164 const base::ListValue* value) { | 164 const base::ListValue* value) { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 188 void ResetProfileSettingsHandler::OnSettingsFetched() { | 188 void ResetProfileSettingsHandler::OnSettingsFetched() { |
| 189 DCHECK(config_fetcher_); | 189 DCHECK(config_fetcher_); |
| 190 DCHECK(!config_fetcher_->IsActive()); | 190 DCHECK(!config_fetcher_->IsActive()); |
| 191 // The master prefs is fetched. We are waiting for user pressing 'Reset'. | 191 // The master prefs is fetched. We are waiting for user pressing 'Reset'. |
| 192 } | 192 } |
| 193 | 193 |
| 194 void ResetProfileSettingsHandler::ResetProfile(bool send_settings) { | 194 void ResetProfileSettingsHandler::ResetProfile(bool send_settings) { |
| 195 DCHECK(resetter_); | 195 DCHECK(resetter_); |
| 196 DCHECK(!resetter_->IsActive()); | 196 DCHECK(!resetter_->IsActive()); |
| 197 | 197 |
| 198 scoped_ptr<BrandcodedDefaultSettings> default_settings; | 198 std::unique_ptr<BrandcodedDefaultSettings> default_settings; |
| 199 if (config_fetcher_) { | 199 if (config_fetcher_) { |
| 200 DCHECK(!config_fetcher_->IsActive()); | 200 DCHECK(!config_fetcher_->IsActive()); |
| 201 default_settings = config_fetcher_->GetSettings(); | 201 default_settings = config_fetcher_->GetSettings(); |
| 202 config_fetcher_.reset(); | 202 config_fetcher_.reset(); |
| 203 } else { | 203 } else { |
| 204 DCHECK(brandcode_.empty()); | 204 DCHECK(brandcode_.empty()); |
| 205 } | 205 } |
| 206 | 206 |
| 207 // If failed to fetch BrandcodedDefaultSettings or this is an organic | 207 // If failed to fetch BrandcodedDefaultSettings or this is an organic |
| 208 // installation, use default settings. | 208 // installation, use default settings. |
| 209 if (!default_settings) | 209 if (!default_settings) |
| 210 default_settings.reset(new BrandcodedDefaultSettings); | 210 default_settings.reset(new BrandcodedDefaultSettings); |
| 211 resetter_->Reset( | 211 resetter_->Reset( |
| 212 ProfileResetter::ALL, std::move(default_settings), | 212 ProfileResetter::ALL, std::move(default_settings), |
| 213 base::Bind(&ResetProfileSettingsHandler::OnResetProfileSettingsDone, | 213 base::Bind(&ResetProfileSettingsHandler::OnResetProfileSettingsDone, |
| 214 AsWeakPtr(), send_settings)); | 214 AsWeakPtr(), send_settings)); |
| 215 content::RecordAction(base::UserMetricsAction("ResetProfile")); | 215 content::RecordAction(base::UserMetricsAction("ResetProfile")); |
| 216 UMA_HISTOGRAM_BOOLEAN("ProfileReset.SendFeedback", send_settings); | 216 UMA_HISTOGRAM_BOOLEAN("ProfileReset.SendFeedback", send_settings); |
| 217 } | 217 } |
| 218 | 218 |
| 219 void ResetProfileSettingsHandler::UpdateFeedbackUI() { | 219 void ResetProfileSettingsHandler::UpdateFeedbackUI() { |
| 220 if (!setting_snapshot_) | 220 if (!setting_snapshot_) |
| 221 return; | 221 return; |
| 222 scoped_ptr<base::ListValue> list = GetReadableFeedbackForSnapshot( | 222 std::unique_ptr<base::ListValue> list = GetReadableFeedbackForSnapshot( |
| 223 Profile::FromWebUI(web_ui()), | 223 Profile::FromWebUI(web_ui()), *setting_snapshot_); |
| 224 *setting_snapshot_); | |
| 225 base::DictionaryValue feedback_info; | 224 base::DictionaryValue feedback_info; |
| 226 feedback_info.Set("feedbackInfo", list.release()); | 225 feedback_info.Set("feedbackInfo", list.release()); |
| 227 web_ui()->CallJavascriptFunction( | 226 web_ui()->CallJavascriptFunction( |
| 228 "ResetProfileSettingsOverlay.setFeedbackInfo", | 227 "ResetProfileSettingsOverlay.setFeedbackInfo", |
| 229 feedback_info); | 228 feedback_info); |
| 230 } | 229 } |
| 231 | 230 |
| 232 } // namespace options | 231 } // namespace options |
| OLD | NEW |