1 // Copyright (c) 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/chromeos/login/reauth_stats.h"
7 #include "base/metrics/histogram_macros.h"
8 #include "components/user_manager/user_manager.h"
12 void RecordReauthReason(const std::string
& user_id
, ReauthReason reason
) {
13 user_manager::UserManager
* user_manager
= user_manager::UserManager::Get();
15 // We record only the first value, skipping everything else, except "none"
16 // value, which is used to reset the current state.
17 if (!user_manager
->FindReauthReason(user_id
, &old_reason
) ||
18 (static_cast<ReauthReason
>(old_reason
) == ReauthReason::NONE
&&
19 reason
!= ReauthReason::NONE
)) {
20 user_manager
->UpdateReauthReason(user_id
, static_cast<int>(reason
));
24 void SendReauthReason(const std::string
& user_id
) {
25 user_manager::UserManager
* user_manager
= user_manager::UserManager::Get();
27 if (user_manager
->FindReauthReason(user_id
, &reauth_reason
) &&
28 static_cast<ReauthReason
>(reauth_reason
) != ReauthReason::NONE
) {
29 UMA_HISTOGRAM_ENUMERATION("Login.ReauthReason", reauth_reason
,
30 NUM_REAUTH_FLOW_REASONS
);
31 user_manager
->UpdateReauthReason(user_id
,
32 static_cast<int>(ReauthReason::NONE
));
36 } // namespace chromeos