Chromium Code Reviews| Index: chrome/browser/chromeos/app_mode/kiosk_app_launch_error.cc |
| diff --git a/chrome/browser/chromeos/app_mode/kiosk_app_launch_error.cc b/chrome/browser/chromeos/app_mode/kiosk_app_launch_error.cc |
| index 3907fb3971845de126dfe76a546a351e8d25beab..fd4cb27e682f2c717031e375eeb18474dd307eb9 100644 |
| --- a/chrome/browser/chromeos/app_mode/kiosk_app_launch_error.cc |
| +++ b/chrome/browser/chromeos/app_mode/kiosk_app_launch_error.cc |
| @@ -4,9 +4,11 @@ |
| #include "chrome/browser/chromeos/app_mode/kiosk_app_launch_error.h" |
| +#include "base/metrics/histogram_macros.h" |
| #include "chrome/browser/browser_process.h" |
| #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h" |
| #include "chrome/grit/generated_resources.h" |
| +#include "chromeos/login/auth/auth_status_consumer.h" |
| #include "components/prefs/scoped_user_pref_update.h" |
| #include "ui/base/l10n/l10n_util.h" |
| @@ -14,8 +16,11 @@ namespace chromeos { |
| namespace { |
| -// Key under "kiosk" dictionary to store last launch error. |
| -const char kKeyLaunchError[] = "launch_error"; |
| +// Key under "kiosk" dictionary to store the last launch error. |
| +constexpr char kKeyLaunchError[] = "launch_error"; |
| + |
| +// Key under "kiosk" dictionary to store the last cryptohome error. |
| +constexpr char kKeyCryptohomeFailure[] = "cryptohome_failure"; |
| } // namespace |
| @@ -23,6 +28,7 @@ const char kKeyLaunchError[] = "launch_error"; |
| std::string KioskAppLaunchError::GetErrorMessage(Error error) { |
| switch (error) { |
| case NONE: |
| + case ERROR_COUNT: |
| return std::string(); |
|
tbarzic
2017/02/28 19:18:55
I'd treat ERROR_COUNT as an unknown error - NOTREA
xiyuan
2017/02/28 21:14:57
Done.
|
| case HAS_PENDING_LAUNCH: |
| @@ -64,6 +70,15 @@ void KioskAppLaunchError::Save(KioskAppLaunchError::Error error) { |
| } |
| // static |
| +void KioskAppLaunchError::SaveCryptohomeFailure( |
| + const AuthFailure& auth_failure) { |
| + PrefService* local_state = g_browser_process->local_state(); |
| + DictionaryPrefUpdate dict_update(local_state, |
| + KioskAppManager::kKioskDictionaryName); |
| + dict_update->SetInteger(kKeyCryptohomeFailure, auth_failure.reason()); |
| +} |
| + |
| +// static |
| KioskAppLaunchError::Error KioskAppLaunchError::Get() { |
| PrefService* local_state = g_browser_process->local_state(); |
| const base::DictionaryValue* dict = |
| @@ -77,11 +92,23 @@ KioskAppLaunchError::Error KioskAppLaunchError::Get() { |
| } |
| // static |
| -void KioskAppLaunchError::Clear() { |
| +void KioskAppLaunchError::RecordMetricAndClear() { |
| PrefService* local_state = g_browser_process->local_state(); |
| DictionaryPrefUpdate dict_update(local_state, |
| KioskAppManager::kKioskDictionaryName); |
| + |
| + int error; |
| + if (dict_update->GetInteger(kKeyLaunchError, &error)) |
| + UMA_HISTOGRAM_ENUMERATION("Kiosk.Launch.Error", error, ERROR_COUNT); |
| dict_update->Remove(kKeyLaunchError, NULL); |
| + |
| + int cryptohome_failure; |
| + if (dict_update->GetInteger(kKeyCryptohomeFailure, &cryptohome_failure)) { |
| + UMA_HISTOGRAM_ENUMERATION("Kiosk.Launch.CryptohomeFailure", |
| + cryptohome_failure, |
| + AuthFailure::NUM_FAILURE_REASONS); |
| + } |
| + dict_update->Remove(kKeyCryptohomeFailure, NULL); |
| } |
| } // namespace chromeos |