1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
|
// Copyright 2024 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/supervised_user/supervised_user_verification_page_youtube.h"
#include <utility>
#include "base/metrics/histogram_functions.h"
#include "components/grit/components_resources.h"
#include "components/security_interstitials/content/security_interstitial_controller_client.h"
#include "components/security_interstitials/core/common_string_util.h"
#include "components/strings/grit/components_strings.h"
#include "content/public/browser/web_contents.h"
#include "services/metrics/public/cpp/ukm_builders.h"
#include "services/metrics/public/cpp/ukm_recorder.h"
#include "ui/base/l10n/l10n_util.h"
namespace {
constexpr char kSubframeYoutubeReauthenticationInterstitiaHistogramName[] =
"FamilyLinkUser.SubframeYoutubeReauthenticationInterstitial";
void RecordUkmForMainFrame(SupervisedUserVerificationPage::Status status,
ukm::SourceId source_id) {
auto builder =
ukm::builders::FamilyLinkUser_ReauthenticationInterstitial(source_id);
switch (status) {
case SupervisedUserVerificationPage::Status::SHOWN:
builder.SetInterstitialShown(true);
break;
case SupervisedUserVerificationPage::Status::REAUTH_STARTED:
builder.SetReauthenticationStarted(true);
break;
case SupervisedUserVerificationPage::Status::REAUTH_COMPLETED:
builder.SetReauthenticationCompleted(true);
break;
default:
NOTREACHED();
}
builder.Record(ukm::UkmRecorder::Get());
}
void RecordUmaForSubFrame(SupervisedUserVerificationPage::Status status) {
base::UmaHistogramEnumeration(
kSubframeYoutubeReauthenticationInterstitiaHistogramName,
SupervisedUserVerificationPage::
GetReauthenticationInterstitialStateFromStatus(status));
}
} // namespace
// static
const security_interstitials::SecurityInterstitialPage::TypeID
SupervisedUserVerificationPageForYouTube::kTypeForTesting =
&SupervisedUserVerificationPageForYouTube::kTypeForTesting;
SupervisedUserVerificationPageForYouTube::
SupervisedUserVerificationPageForYouTube(
content::WebContents* web_contents,
const std::string& email_to_reauth,
const GURL& request_url,
supervised_user::ChildAccountService* child_account_service,
ukm::SourceId source_id,
std::unique_ptr<
security_interstitials::SecurityInterstitialControllerClient>
controller_client,
bool is_main_frame)
: SupervisedUserVerificationPage(web_contents,
email_to_reauth,
request_url,
child_account_service,
std::move(controller_client)),
source_id_(source_id),
is_main_frame_(is_main_frame) {
// Demo interstitials are created without `child_account_service` and should
// not have metrics recorded.
if (child_account_service) {
RecordReauthStatusMetrics(Status::SHOWN);
}
}
SupervisedUserVerificationPageForYouTube::
~SupervisedUserVerificationPageForYouTube() {
if (IsReauthCompleted()) {
RecordReauthStatusMetrics(Status::REAUTH_COMPLETED);
}
}
security_interstitials::SecurityInterstitialPage::TypeID
SupervisedUserVerificationPageForYouTube::GetTypeForTesting() {
return SupervisedUserVerificationPageForYouTube::kTypeForTesting;
}
void SupervisedUserVerificationPageForYouTube::PopulateInterstitialStrings(
base::Value::Dict& load_time_data) {
if (is_main_frame_) {
load_time_data.Set("type", "SUPERVISED_USER_VERIFY");
} else {
load_time_data.Set("type", "SUPERVISED_USER_VERIFY_SUBFRAME");
}
PopulateCommonStrings(load_time_data);
load_time_data.Set(
"tabTitle",
l10n_util::GetStringUTF16(IDS_SUPERVISED_USER_VERIFY_PAGE_TAB_TITLE));
load_time_data.Set(
"heading",
is_main_frame_
? l10n_util::GetStringUTF16(
IDS_SUPERVISED_USER_VERIFY_PAGE_PRIMARY_HEADING)
: l10n_util::GetStringUTF16(
IDS_SUPERVISED_USER_VERIFY_PAGE_SUBFRAME_YOUTUBE_HEADING));
load_time_data.Set("primaryParagraph",
l10n_util::GetStringUTF16(
IDS_SUPERVISED_USER_VERIFY_PAGE_PRIMARY_PARAGRAPH));
load_time_data.Set("primaryButtonText",
l10n_util::GetStringUTF16(
IDS_SUPERVISED_USER_VERIFY_PAGE_PRIMARY_BUTTON));
}
void SupervisedUserVerificationPageForYouTube::RecordReauthStatusMetrics(
Status status) {
if (is_main_frame_) {
RecordUkmForMainFrame(status, source_id_);
} else {
RecordUmaForSubFrame(status);
}
}
|