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

Side by Side Diff: chrome/browser/ui/webui/options/reset_profile_settings_handler.cc

Issue 2417143003: Add UMA reporting of reset request origin. (Closed)
Patch Set: Created 4 years, 2 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/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"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/metrics/histogram_macros.h" 12 #include "base/metrics/histogram_macros.h"
13 #include "base/strings/string16.h" 13 #include "base/strings/string16.h"
14 #include "base/values.h" 14 #include "base/values.h"
15 #include "build/build_config.h" 15 #include "build/build_config.h"
16 #include "chrome/browser/google/google_brand.h" 16 #include "chrome/browser/google/google_brand.h"
17 #include "chrome/browser/profile_resetter/brandcode_config_fetcher.h" 17 #include "chrome/browser/profile_resetter/brandcode_config_fetcher.h"
18 #include "chrome/browser/profile_resetter/brandcoded_default_settings.h" 18 #include "chrome/browser/profile_resetter/brandcoded_default_settings.h"
19 #include "chrome/browser/profile_resetter/profile_reset_report.pb.h"
20 #include "chrome/browser/profile_resetter/profile_resetter.h" 19 #include "chrome/browser/profile_resetter/profile_resetter.h"
21 #include "chrome/browser/profile_resetter/resettable_settings_snapshot.h" 20 #include "chrome/browser/profile_resetter/resettable_settings_snapshot.h"
22 #include "chrome/browser/profiles/profile.h" 21 #include "chrome/browser/profiles/profile.h"
23 #include "chrome/common/url_constants.h" 22 #include "chrome/common/url_constants.h"
24 #include "chrome/grit/chromium_strings.h" 23 #include "chrome/grit/chromium_strings.h"
25 #include "chrome/grit/generated_resources.h" 24 #include "chrome/grit/generated_resources.h"
26 #include "components/prefs/pref_service.h" 25 #include "components/prefs/pref_service.h"
27 #include "components/strings/grit/components_strings.h" 26 #include "components/strings/grit/components_strings.h"
28 #include "content/public/browser/user_metrics.h" 27 #include "content/public/browser/user_metrics.h"
29 #include "content/public/browser/web_ui.h" 28 #include "content/public/browser/web_ui.h"
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 base::Bind(&ResetProfileSettingsHandler::OnShowResetProfileDialog, 146 base::Bind(&ResetProfileSettingsHandler::OnShowResetProfileDialog,
148 base::Unretained(this))); 147 base::Unretained(this)));
149 web_ui()->RegisterMessageCallback("onHideResetProfileDialog", 148 web_ui()->RegisterMessageCallback("onHideResetProfileDialog",
150 base::Bind(&ResetProfileSettingsHandler::OnHideResetProfileDialog, 149 base::Bind(&ResetProfileSettingsHandler::OnHideResetProfileDialog,
151 base::Unretained(this))); 150 base::Unretained(this)));
152 } 151 }
153 152
154 void ResetProfileSettingsHandler::HandleResetProfileSettings( 153 void ResetProfileSettingsHandler::HandleResetProfileSettings(
155 const base::ListValue* value) { 154 const base::ListValue* value) {
156 bool send_settings = false; 155 bool send_settings = false;
157 std::string reset_request_origin; 156 std::string request_origin_string;
158 bool success = value->GetBoolean(0, &send_settings) && 157 bool success = value->GetBoolean(0, &send_settings) &&
159 value->GetString(1, &reset_request_origin); 158 value->GetString(1, &request_origin_string);
160 DCHECK(success); 159 DCHECK(success);
161 160
162 DCHECK(brandcode_.empty() || config_fetcher_); 161 DCHECK(brandcode_.empty() || config_fetcher_);
162 reset_report::ChromeResetReport::ResetRequestOrigin request_origin =
163 ResetRequestOriginFromString(request_origin_string);
163 if (config_fetcher_ && config_fetcher_->IsActive()) { 164 if (config_fetcher_ && config_fetcher_->IsActive()) {
164 // Reset once the prefs are fetched. 165 // Reset once the prefs are fetched.
165 config_fetcher_->SetCallback( 166 config_fetcher_->SetCallback(
166 base::Bind(&ResetProfileSettingsHandler::ResetProfile, Unretained(this), 167 base::Bind(&ResetProfileSettingsHandler::ResetProfile, Unretained(this),
167 send_settings, reset_request_origin)); 168 send_settings, request_origin));
168 } else { 169 } else {
169 ResetProfile(send_settings, reset_request_origin); 170 ResetProfile(send_settings, request_origin);
170 } 171 }
171 } 172 }
172 173
173 void ResetProfileSettingsHandler::OnResetProfileSettingsDone( 174 void ResetProfileSettingsHandler::OnResetProfileSettingsDone(
174 bool send_feedback, 175 bool send_feedback,
175 const std::string& reset_request_origin) { 176 reset_report::ChromeResetReport::ResetRequestOrigin request_origin) {
176 web_ui()->CallJavascriptFunctionUnsafe( 177 web_ui()->CallJavascriptFunctionUnsafe(
177 "ResetProfileSettingsOverlay.doneResetting"); 178 "ResetProfileSettingsOverlay.doneResetting");
179
178 if (send_feedback && setting_snapshot_) { 180 if (send_feedback && setting_snapshot_) {
179 Profile* profile = Profile::FromWebUI(web_ui()); 181 Profile* profile = Profile::FromWebUI(web_ui());
180 ResettableSettingsSnapshot current_snapshot(profile); 182 ResettableSettingsSnapshot current_snapshot(profile);
181 int difference = setting_snapshot_->FindDifferentFields(current_snapshot); 183 int difference = setting_snapshot_->FindDifferentFields(current_snapshot);
182 if (difference) { 184 if (difference) {
183 setting_snapshot_->Subtract(current_snapshot); 185 setting_snapshot_->Subtract(current_snapshot);
184 std::unique_ptr<reset_report::ChromeResetReport> report_proto = 186 std::unique_ptr<reset_report::ChromeResetReport> report_proto =
185 SerializeSettingsReportToProto(*setting_snapshot_, difference); 187 SerializeSettingsReportToProto(*setting_snapshot_, difference);
186 if (report_proto) { 188 if (report_proto) {
187 report_proto->set_reset_request_origin( 189 report_proto->set_reset_request_origin(request_origin);
188 ResetRequestOriginFromString(reset_request_origin));
189 SendSettingsFeedbackProto(*report_proto, profile); 190 SendSettingsFeedbackProto(*report_proto, profile);
190 } 191 }
191 } 192 }
192 } 193 }
193 setting_snapshot_.reset(); 194 setting_snapshot_.reset();
194 } 195 }
195 196
196 void ResetProfileSettingsHandler::OnShowResetProfileDialog( 197 void ResetProfileSettingsHandler::OnShowResetProfileDialog(
197 const base::ListValue* value) { 198 const base::ListValue* value) {
198 if (!resetter_->IsActive()) { 199 if (!resetter_->IsActive()) {
(...skipping 20 matching lines...) Expand all
219 } 220 }
220 221
221 void ResetProfileSettingsHandler::OnSettingsFetched() { 222 void ResetProfileSettingsHandler::OnSettingsFetched() {
222 DCHECK(config_fetcher_); 223 DCHECK(config_fetcher_);
223 DCHECK(!config_fetcher_->IsActive()); 224 DCHECK(!config_fetcher_->IsActive());
224 // The master prefs is fetched. We are waiting for user pressing 'Reset'. 225 // The master prefs is fetched. We are waiting for user pressing 'Reset'.
225 } 226 }
226 227
227 void ResetProfileSettingsHandler::ResetProfile( 228 void ResetProfileSettingsHandler::ResetProfile(
228 bool send_settings, 229 bool send_settings,
229 const std::string& reset_request_origin) { 230 reset_report::ChromeResetReport::ResetRequestOrigin request_origin) {
230 DCHECK(resetter_); 231 DCHECK(resetter_);
231 DCHECK(!resetter_->IsActive()); 232 DCHECK(!resetter_->IsActive());
232 233
233 std::unique_ptr<BrandcodedDefaultSettings> default_settings; 234 std::unique_ptr<BrandcodedDefaultSettings> default_settings;
234 if (config_fetcher_) { 235 if (config_fetcher_) {
235 DCHECK(!config_fetcher_->IsActive()); 236 DCHECK(!config_fetcher_->IsActive());
236 default_settings = config_fetcher_->GetSettings(); 237 default_settings = config_fetcher_->GetSettings();
237 config_fetcher_.reset(); 238 config_fetcher_.reset();
238 } else { 239 } else {
239 DCHECK(brandcode_.empty()); 240 DCHECK(brandcode_.empty());
240 } 241 }
241 242
242 // If failed to fetch BrandcodedDefaultSettings or this is an organic 243 // If failed to fetch BrandcodedDefaultSettings or this is an organic
243 // installation, use default settings. 244 // installation, use default settings.
244 if (!default_settings) 245 if (!default_settings)
245 default_settings.reset(new BrandcodedDefaultSettings); 246 default_settings.reset(new BrandcodedDefaultSettings);
246 resetter_->Reset( 247 resetter_->Reset(
247 ProfileResetter::ALL, std::move(default_settings), 248 ProfileResetter::ALL, std::move(default_settings),
248 base::Bind(&ResetProfileSettingsHandler::OnResetProfileSettingsDone, 249 base::Bind(&ResetProfileSettingsHandler::OnResetProfileSettingsDone,
249 AsWeakPtr(), send_settings, reset_request_origin)); 250 AsWeakPtr(), send_settings, request_origin));
250 content::RecordAction(base::UserMetricsAction("ResetProfile")); 251 content::RecordAction(base::UserMetricsAction("ResetProfile"));
251 UMA_HISTOGRAM_BOOLEAN("ProfileReset.SendFeedback", send_settings); 252 UMA_HISTOGRAM_BOOLEAN("ProfileReset.SendFeedback", send_settings);
253 UMA_HISTOGRAM_ENUMERATION(
254 "ProfileReset.ResetRequestOrigin", request_origin,
255 reset_report::ChromeResetReport::ResetRequestOrigin_MAX + 1);
252 } 256 }
253 257
254 void ResetProfileSettingsHandler::UpdateFeedbackUI() { 258 void ResetProfileSettingsHandler::UpdateFeedbackUI() {
255 if (!setting_snapshot_) 259 if (!setting_snapshot_)
256 return; 260 return;
257 std::unique_ptr<base::ListValue> list = GetReadableFeedbackForSnapshot( 261 std::unique_ptr<base::ListValue> list = GetReadableFeedbackForSnapshot(
258 Profile::FromWebUI(web_ui()), *setting_snapshot_); 262 Profile::FromWebUI(web_ui()), *setting_snapshot_);
259 base::DictionaryValue feedback_info; 263 base::DictionaryValue feedback_info;
260 feedback_info.Set("feedbackInfo", list.release()); 264 feedback_info.Set("feedbackInfo", list.release());
261 web_ui()->CallJavascriptFunctionUnsafe( 265 web_ui()->CallJavascriptFunctionUnsafe(
262 "ResetProfileSettingsOverlay.setFeedbackInfo", feedback_info); 266 "ResetProfileSettingsOverlay.setFeedbackInfo", feedback_info);
263 } 267 }
264 268
265 } // namespace options 269 } // namespace options
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698