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

Unified Diff: chrome/browser/safe_browsing/settings_reset_prompt/settings_reset_prompt_controller.cc

Issue 2739513002: Settings reset prompt: add UMA metrics reporting. (Closed)
Patch Set: Addressed comments. Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/safe_browsing/settings_reset_prompt/settings_reset_prompt_controller.cc
diff --git a/chrome/browser/safe_browsing/settings_reset_prompt/settings_reset_prompt_controller.cc b/chrome/browser/safe_browsing/settings_reset_prompt/settings_reset_prompt_controller.cc
index 1689fd8bb00307a6f0322b98589e348e8565bc9b..d772f887921c4f245aba39ad46c31ccb06a52d18 100644
--- a/chrome/browser/safe_browsing/settings_reset_prompt/settings_reset_prompt_controller.cc
+++ b/chrome/browser/safe_browsing/settings_reset_prompt/settings_reset_prompt_controller.cc
@@ -10,6 +10,9 @@
#include "base/bind_helpers.h"
#include "base/location.h"
#include "base/logging.h"
+#include "base/metrics/histogram_macros.h"
+#include "base/metrics/user_metrics.h"
+#include "base/metrics/user_metrics_action.h"
#include "base/time/time.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/safe_browsing/settings_reset_prompt/settings_reset_prompt_config.h"
@@ -28,6 +31,15 @@ namespace safe_browsing {
namespace {
+// These values are used for reporting UMA metrics. New enum values can be
+// added, but existing enums must never be renumbered or deleted and reused.
+enum DialogState {
+ DIALOG_STATE_SHOWN = 1,
+ DIALOG_STATE_ACCEPTED = 2,
+ DIALOG_STATE_DECLINED = 3,
+ DIALOG_STATE_MAX = 4,
+};
+
base::string16 FormatUrlForDisplay(const GURL& url) {
return url_formatter::FormatUrlForSecurityDisplay(
url, url_formatter::SchemeDisplay::OMIT_HTTP_AND_HTTPS);
@@ -53,7 +65,12 @@ bool ResetHomepageEnabled(const SettingsResetPromptModel& model) {
// the settings reset prompt if required by the model and there is at least one
// non-incognito browser available for the corresponding profile.
void OnModelCreated(std::unique_ptr<SettingsResetPromptModel> model) {
- if (!model || !model->ShouldPromptForReset())
+ if (!model)
+ return;
+
+ model->ReportUmaMetrics();
+
+ if (!model->ShouldPromptForReset())
return;
Profile* profile = model->profile();
@@ -137,15 +154,31 @@ gfx::Range SettingsResetPromptController::GetMainTextUrlRange() const {
void SettingsResetPromptController::DialogShown() {
model_->DialogShown();
+ time_dialog_shown_ = base::Time::Now();
+ base::RecordAction(base::UserMetricsAction("SettingsResetPrompt_Shown"));
+ UMA_HISTOGRAM_ENUMERATION("SettingsResetPrompt.DialogState",
+ DIALOG_STATE_SHOWN, DIALOG_STATE_MAX);
}
void SettingsResetPromptController::Accept() {
+ DCHECK(!time_dialog_shown_.is_null());
+ base::RecordAction(base::UserMetricsAction("SettingsResetPrompt_Accepted"));
+ UMA_HISTOGRAM_LONG_TIMES_100("SettingsResetPrompt.TimeUntilAccepted",
+ base::Time::Now() - time_dialog_shown_);
+ UMA_HISTOGRAM_ENUMERATION("SettingsResetPrompt.DialogState",
+ DIALOG_STATE_ACCEPTED, DIALOG_STATE_MAX);
model_->PerformReset(
base::Bind(&SettingsResetPromptController::OnInteractionDone,
base::Unretained(this)));
}
void SettingsResetPromptController::Cancel() {
+ DCHECK(!time_dialog_shown_.is_null());
+ base::RecordAction(base::UserMetricsAction("SettingsResetPrompt_Declined"));
+ UMA_HISTOGRAM_LONG_TIMES_100("SettingsResetPrompt.TimeUntilDeclined",
+ base::Time::Now() - time_dialog_shown_);
+ UMA_HISTOGRAM_ENUMERATION("SettingsResetPrompt.DialogState",
+ DIALOG_STATE_DECLINED, DIALOG_STATE_MAX);
OnInteractionDone();
}
@@ -204,7 +237,6 @@ void SettingsResetPromptController::InitMainText() {
}
void SettingsResetPromptController::OnInteractionDone() {
- // TODO(alito): Add metrics reporting here.
delete this;
}

Powered by Google App Engine
This is Rietveld 408576698