Chromium Code Reviews| 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..e938facffd24566ae3d71c004ca3b1691262879a 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,13 @@ namespace safe_browsing { |
| namespace { |
| +enum DialogState { |
|
robertshield
2017/03/07 07:43:19
Add a comment mentioning this is used for UMA repo
alito
2017/03/07 16:23:29
Done.
|
| + 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,6 +63,9 @@ 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) |
|
csharp
2017/03/07 14:39:40
nit: I wonder if this part would look a bit cleare
alito
2017/03/07 16:23:29
Done.
|
| + model->ReportUmaMetrics(); |
| + |
| if (!model || !model->ShouldPromptForReset()) |
| return; |
| @@ -137,15 +150,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 +233,6 @@ void SettingsResetPromptController::InitMainText() { |
| } |
| void SettingsResetPromptController::OnInteractionDone() { |
| - // TODO(alito): Add metrics reporting here. |
| delete this; |
| } |