| 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 30 matching lines...) Expand all Loading... |
| 41 } | 41 } |
| 42 | 42 |
| 43 ResetProfileSettingsHandler::~ResetProfileSettingsHandler() {} | 43 ResetProfileSettingsHandler::~ResetProfileSettingsHandler() {} |
| 44 | 44 |
| 45 void ResetProfileSettingsHandler::InitializeHandler() { | 45 void ResetProfileSettingsHandler::InitializeHandler() { |
| 46 Profile* profile = Profile::FromWebUI(web_ui()); | 46 Profile* profile = Profile::FromWebUI(web_ui()); |
| 47 resetter_.reset(new ProfileResetter(profile)); | 47 resetter_.reset(new ProfileResetter(profile)); |
| 48 } | 48 } |
| 49 | 49 |
| 50 void ResetProfileSettingsHandler::InitializePage() { | 50 void ResetProfileSettingsHandler::InitializePage() { |
| 51 web_ui()->CallJavascriptFunction( | 51 web_ui()->CallJavascriptFunctionUnsafe( |
| 52 "ResetProfileSettingsOverlay.setResettingState", | 52 "ResetProfileSettingsOverlay.setResettingState", |
| 53 base::FundamentalValue(resetter_->IsActive())); | 53 base::FundamentalValue(resetter_->IsActive())); |
| 54 } | 54 } |
| 55 | 55 |
| 56 void ResetProfileSettingsHandler::GetLocalizedValues( | 56 void ResetProfileSettingsHandler::GetLocalizedValues( |
| 57 base::DictionaryValue* localized_strings) { | 57 base::DictionaryValue* localized_strings) { |
| 58 DCHECK(localized_strings); | 58 DCHECK(localized_strings); |
| 59 | 59 |
| 60 static OptionsStringResource resources[] = { | 60 static OptionsStringResource resources[] = { |
| 61 { "resetProfileSettingsCommit", IDS_RESET_PROFILE_SETTINGS_COMMIT_BUTTON }, | 61 { "resetProfileSettingsCommit", IDS_RESET_PROFILE_SETTINGS_COMMIT_BUTTON }, |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 base::Bind(&ResetProfileSettingsHandler::ResetProfile, | 137 base::Bind(&ResetProfileSettingsHandler::ResetProfile, |
| 138 Unretained(this), | 138 Unretained(this), |
| 139 send_settings)); | 139 send_settings)); |
| 140 } else { | 140 } else { |
| 141 ResetProfile(send_settings); | 141 ResetProfile(send_settings); |
| 142 } | 142 } |
| 143 } | 143 } |
| 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()->CallJavascriptFunctionUnsafe( |
| 148 "ResetProfileSettingsOverlay.doneResetting"); |
| 148 if (send_feedback && setting_snapshot_) { | 149 if (send_feedback && setting_snapshot_) { |
| 149 Profile* profile = Profile::FromWebUI(web_ui()); | 150 Profile* profile = Profile::FromWebUI(web_ui()); |
| 150 ResettableSettingsSnapshot current_snapshot(profile); | 151 ResettableSettingsSnapshot current_snapshot(profile); |
| 151 int difference = setting_snapshot_->FindDifferentFields(current_snapshot); | 152 int difference = setting_snapshot_->FindDifferentFields(current_snapshot); |
| 152 if (difference) { | 153 if (difference) { |
| 153 setting_snapshot_->Subtract(current_snapshot); | 154 setting_snapshot_->Subtract(current_snapshot); |
| 154 std::unique_ptr<reset_report::ChromeResetReport> report_proto = | 155 std::unique_ptr<reset_report::ChromeResetReport> report_proto = |
| 155 SerializeSettingsReportToProto(*setting_snapshot_, difference); | 156 SerializeSettingsReportToProto(*setting_snapshot_, difference); |
| 156 if (report_proto) | 157 if (report_proto) |
| 157 SendSettingsFeedbackProto(*report_proto, profile); | 158 SendSettingsFeedbackProto(*report_proto, profile); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 UMA_HISTOGRAM_BOOLEAN("ProfileReset.SendFeedback", send_settings); | 217 UMA_HISTOGRAM_BOOLEAN("ProfileReset.SendFeedback", send_settings); |
| 217 } | 218 } |
| 218 | 219 |
| 219 void ResetProfileSettingsHandler::UpdateFeedbackUI() { | 220 void ResetProfileSettingsHandler::UpdateFeedbackUI() { |
| 220 if (!setting_snapshot_) | 221 if (!setting_snapshot_) |
| 221 return; | 222 return; |
| 222 std::unique_ptr<base::ListValue> list = GetReadableFeedbackForSnapshot( | 223 std::unique_ptr<base::ListValue> list = GetReadableFeedbackForSnapshot( |
| 223 Profile::FromWebUI(web_ui()), *setting_snapshot_); | 224 Profile::FromWebUI(web_ui()), *setting_snapshot_); |
| 224 base::DictionaryValue feedback_info; | 225 base::DictionaryValue feedback_info; |
| 225 feedback_info.Set("feedbackInfo", list.release()); | 226 feedback_info.Set("feedbackInfo", list.release()); |
| 226 web_ui()->CallJavascriptFunction( | 227 web_ui()->CallJavascriptFunctionUnsafe( |
| 227 "ResetProfileSettingsOverlay.setFeedbackInfo", | 228 "ResetProfileSettingsOverlay.setFeedbackInfo", feedback_info); |
| 228 feedback_info); | |
| 229 } | 229 } |
| 230 | 230 |
| 231 } // namespace options | 231 } // namespace options |
| OLD | NEW |