#include "content/browser/webid/fedcm_metrics.h"
#include "base/metrics/histogram_functions.h"
#include "base/types/pass_key.h"
#include "content/browser/webid/flags.h"
#include "content/browser/webid/webid_utils.h"
#include "net/base/net_errors.h"
#include "net/base/schemeful_site.h"
#include "net/http/http_response_headers.h"
#include "net/http/http_status_code.h"
#include "services/metrics/public/cpp/metrics_utils.h"
#include "third_party/blink/public/mojom/webid/federated_auth_request.mojom.h"
#include "url/gurl.h"
namespace content {
namespace {
FedCmRequesterFrameType ComputeRequesterFrameType(const RenderFrameHost& rfh,
const url::Origin& requester,
const url::Origin& embedder) { … }
}
FedCmMetrics::FedCmMetrics(ukm::SourceId page_source_id)
: … { … }
FedCmMetrics::~FedCmMetrics() = default;
void FedCmMetrics::SetSessionID(int session_id) { … }
void FedCmMetrics::RecordShowAccountsDialogTime(
const std::vector<IdentityProviderData>& providers,
base::TimeDelta duration) { … }
void FedCmMetrics::RecordShowAccountsDialogTimeBreakdown(
base::TimeDelta well_known_and_config_fetch_duration,
base::TimeDelta accounts_fetch_duration,
base::TimeDelta client_metadata_fetch_duration) { … }
void FedCmMetrics::RecordWellKnownAndConfigFetchTime(base::TimeDelta duration) { … }
void FedCmMetrics::RecordNumRequestsPerDocument(ukm::SourceId page_source_id,
const int num_requests) { … }
void FedCmMetrics::RecordContinueOnPopupTime(const GURL& provider,
base::TimeDelta duration) { … }
void FedCmMetrics::RecordCancelOnDialogTime(
const std::vector<IdentityProviderData>& providers,
base::TimeDelta duration) { … }
void FedCmMetrics::RecordAccountsDialogShownDuration(
const std::vector<IdentityProviderData>& providers,
base::TimeDelta duration) { … }
void FedCmMetrics::RecordMismatchDialogShownDuration(
const std::vector<IdentityProviderData>& providers,
base::TimeDelta duration) { … }
void FedCmMetrics::RecordCancelReason(
IdentityRequestDialogController::DismissReason dismiss_reason) { … }
void FedCmMetrics::RecordTokenResponseAndTurnaroundTime(
const GURL& provider,
base::TimeDelta token_response_time,
base::TimeDelta turnaround_time) { … }
void FedCmMetrics::RecordContinueOnResponseAndTurnaroundTime(
base::TimeDelta token_response_time,
base::TimeDelta turnaround_time) { … }
void FedCmMetrics::RecordRequestTokenStatus(
FedCmRequestIdTokenStatus status,
MediationRequirement requirement,
const std::vector<GURL>& requested_providers,
int num_idps_mismatch,
const std::optional<GURL>& selected_idp_config_url,
const RpMode& rp_mode) { … }
void FedCmMetrics::RecordSignInStateMatchStatus(
const GURL& provider,
FedCmSignInStateMatchStatus status) { … }
void FedCmMetrics::RecordIdpSigninMatchStatus(
std::optional<bool> idp_signin_status,
IdpNetworkRequestManager::ParseStatus accounts_endpoint_status) { … }
void FedCmMetrics::RecordIsSignInUser(bool is_sign_in) { … }
void FedCmMetrics::RecordWebContentsStatusUponReadyToShowDialog(
bool is_visible,
bool is_active) { … }
void FedCmMetrics::RecordAutoReauthnMetrics(
std::optional<bool> has_single_returning_account,
const IdentityRequestAccount* auto_signin_account,
bool auto_reauthn_success,
bool is_auto_reauthn_setting_blocked,
bool is_auto_reauthn_embargoed,
std::optional<base::TimeDelta> time_from_embargo,
bool requires_user_mediation) { … }
void FedCmMetrics::RecordAccountsDialogShown(
const std::vector<IdentityProviderData>& providers) { … }
void FedCmMetrics::RecordSingleIdpMismatchDialogShown(
const IdentityProviderData& provider,
bool has_shown_mismatch,
bool has_hints) { … }
void FedCmMetrics::RecordAccountsRequestSent(const GURL& provider_url) { … }
void FedCmMetrics::RecordDisconnectMetrics(
FedCmDisconnectStatus status,
std::optional<base::TimeDelta> duration,
const RenderFrameHost& rfh,
const url::Origin& requester,
const url::Origin& embedder,
const GURL& provider_url,
int disconnect_session_id) { … }
void FedCmMetrics::RecordContinueOnPopupStatus(
FedCmContinueOnPopupStatus status) { … }
void FedCmMetrics::RecordContinueOnPopupResult(
FedCmContinueOnPopupResult result) { … }
void FedCmMetrics::RecordRpParameters(FedCmRpParameters parameters) { … }
void FedCmMetrics::RecordErrorDialogResult(FedCmErrorDialogResult result,
const GURL& provider_url) { … }
void FedCmMetrics::RecordErrorMetricsBeforeShowingErrorDialog(
IdpNetworkRequestManager::FedCmTokenResponseType response_type,
std::optional<IdpNetworkRequestManager::FedCmErrorDialogType> dialog_type,
std::optional<IdpNetworkRequestManager::FedCmErrorUrlType> url_type,
const GURL& provider_url) { … }
void FedCmMetrics::RecordMultipleRequestsRpMode(
blink::mojom::RpMode pending_request_rp_mode,
blink::mojom::RpMode new_request_rp_mode,
const std::vector<GURL>& requested_providers) { … }
void FedCmMetrics::RecordTimeBetweenUserInfoAndButtonModeAPI(
base::TimeDelta duration) { … }
ukm::SourceId FedCmMetrics::GetOrCreateProviderSourceId(const GURL& provider) { … }
void RecordPreventSilentAccess(RenderFrameHost& rfh,
const url::Origin& requester,
const url::Origin& embedder) { … }
void RecordApprovedClientsExistence(bool has_approved_clients) { … }
void RecordApprovedClientsSize(int size) { … }
void RecordIdpSignOutNetError(int response_code) { … }
void RecordAccountsResponseInvalidReason(
IdpNetworkRequestManager::AccountsResponseInvalidReason reason) { … }
void RecordSetLoginStatusIgnoredReason(
FedCmSetLoginStatusIgnoredReason reason) { … }
void RecordLifecycleStateFailureReason(
FedCmLifecycleStateFailureReason reason) { … }
void RecordRawAccountsSize(int size) { … }
void RecordReadyToShowAccountsSize(int size) { … }
}