Skip to content

Commit

Permalink
Add UI to interstitial page
Browse files Browse the repository at this point in the history
* Follow up to crrev/c/4481448 and based on crrev/c/4545857

* Add banner to be shown to a (not new) supervised profile when seeing the interstitial page for the first time

(cherry picked from commit 2b6bceb)

Bug: b/265151907,1449139
Change-Id: Idf9f50c6d584410c6fe8b94420b952a6082a5458
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4556207
Reviewed-by: John Lee <johntlee@chromium.org>
Reviewed-by: Nohemi Fernandez <fernandex@chromium.org>
Commit-Queue: Liza Bipin <mlbipin@google.com>
Cr-Original-Commit-Position: refs/heads/main@{#1148984}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4574902
Auto-Submit: Liza Bipin <mlbipin@google.com>
Reviewed-by: James Lee <ljjlee@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: John Lee <johntlee@chromium.org>
Cr-Commit-Position: refs/branch-heads/5790@{#166}
Cr-Branched-From: 1d71a33-refs/heads/main@{#1148114}
  • Loading branch information
Liza Bipin authored and Chromium LUCI CQ committed May 31, 2023
1 parent 8c7b56f commit a16cab8
Show file tree
Hide file tree
Showing 12 changed files with 94 additions and 20 deletions.
8 changes: 7 additions & 1 deletion chrome/browser/ui/webui/interstitials/interstitial_ui.cc
Expand Up @@ -617,10 +617,16 @@ std::string InterstitialHTMLSource::GetSupervisedUserInterstitialHTML(
}
}

bool show_banner = false;
std::string show_banner_string;
if (net::GetValueForKeyInQuery(url, "show_banner", &show_banner_string)) {
show_banner = show_banner_string == "1";
}

return supervised_user::BuildErrorPageHtml(
allow_access_requests, profile_image_url, profile_image_url2, custodian,
custodian_email, second_custodian, second_custodian_email, reason,
g_browser_process->GetApplicationLocale(), /*already_sent_request=*/false,
/*is_main_frame=*/true);
/*is_main_frame=*/true, show_banner);
}
#endif
Expand Up @@ -5,6 +5,15 @@
/* This is the stylesheet for the interstitial when the
"WebFilterInterstitialRefresh" flag is enabled. */

.banner {
align-items: center;
box-shadow: 0 0 2px rgba(60, 64, 67, 0.12), 0 0 6px rgba(60, 64, 67, 0.15);
border-radius: 4px;
display: flex;
flex-direction: row;
padding: 16px;
}

body {
--avatar-stroke-color: var(--google-gray-50);
--custodian-name-color: #333333;
Expand All @@ -14,7 +23,7 @@ body {
--paragraph-color: var(--google-gray-700);
--callout-text-color: var(--google-gray-900);
--callout-bg-color: var(--google-gray-100);
font-family: "Roboto", sans-serif;
font-family: 'Roboto', sans-serif;
padding: 24px 24px 20px 24px;
}

Expand Down Expand Up @@ -74,6 +83,23 @@ button:active {
border-color: var(--focused-details-button-border);
}

#family-link-kite {
height: 24px;
width: 24px;
padding: 16px;
}

.banner-header {
color: var(--header-color);
line-height: 24px;
margin-top: 0;
}

.banner-content {
line-height: 20px;
margin-top: 0;
}

h1,
p,
.custodian-contact {
Expand Down
Expand Up @@ -14,6 +14,14 @@
<body class="supervised-user-block">
<div class="frame-blocked" id="frame-blocked" tabindex="-1">
<div class="message-container">
<div class="banner" id="banner">
<img id="family-link-kite"
src="supervised_user_icon.png">
<div id="banner-message">
<p class="banner-header">$i18n{bannerTitle}</p>
<p class="banner-content"> $i18n{bannerMessage}</p>
</div>
</div>
<picture id="error-page-illustration">
<source
srcset="error_page_illustration_dark_theme.svg"
Expand Down
Expand Up @@ -80,6 +80,11 @@ function initialize() {
}
}

const showBanner = loadTimeData.getBoolean('showBanner');
if (!showBanner) {
$('banner').style.display = 'none';
}

const alreadyRequestedAccessRemote =
loadTimeData.getBoolean('alreadySentRemoteRequest');
if (alreadyRequestedAccessRemote) {
Expand Down
Expand Up @@ -74,7 +74,8 @@ std::string BuildErrorPageHtml(bool allow_access_requests,
FilteringBehaviorReason reason,
const std::string& app_locale,
bool already_sent_remote_request,
bool is_main_frame) {
bool is_main_frame,
bool show_banner) {
base::Value::Dict strings;
strings.Set("blockPageTitle",
l10n_util::GetStringUTF8(IDS_BLOCK_INTERSTITIAL_TITLE));
Expand Down Expand Up @@ -102,6 +103,12 @@ std::string BuildErrorPageHtml(bool allow_access_requests,
strings.Set("isLocalWebApprovalsEnabled", local_web_approvals_enabled);
strings.Set("isLocalWebApprovalsPreferred",
supervised_user::IsLocalWebApprovalThePreferredButton());
strings.Set("showBanner", show_banner);
strings.Set("bannerTitle",
l10n_util::GetStringUTF8(IDS_PARENT_BLOCKED_SITE_BANNER_TITLE));
strings.Set("bannerMessage",
l10n_util::GetStringUTF8(IDS_PARENT_BLOCKED_SITE_BANNER_MESSAGE));

bool is_automatically_blocked = ReasonIsAutomatic(reason);

std::string block_header;
Expand Down
Expand Up @@ -23,7 +23,8 @@ std::string BuildErrorPageHtml(bool allow_access_requests,
FilteringBehaviorReason reason,
const std::string& app_locale,
bool already_sent_remote_request,
bool is_main_frame);
bool is_main_frame,
bool show_banner);

} // namespace supervised_user

Expand Down
Expand Up @@ -90,7 +90,8 @@ TEST_P(SupervisedUserErrorPageTest_BuildHtml, BuildHtml) {
param.profile_image_url2, param.custodian, param.custodian_email,
param.second_custodian, param.second_custodian_email, param.reason,
/*app_locale=*/"",
/*already_sent_request=*/false, /*is_main_frame=*/true);
/*already_sent_request=*/false, /*is_main_frame=*/true,
/*show_banner=*/true);
// The result should contain the original HTML (with $i18n{} replacements)
// plus scripts that plug values into it. The test can't easily check that the
// scripts are correct, but can check that the output contains the expected
Expand Down
Expand Up @@ -82,10 +82,13 @@ std::string SupervisedUserInterstitial::GetHTMLContents(
supervised_user_service->remote_web_approvals_manager()
.AreApprovalRequestsEnabled();

bool show_banner =
supervised_user_service->ShouldShowFirstTimeInterstitialBanner();

return BuildErrorPageHtml(
allow_access_requests, profile_image_url, profile_image_url2, custodian,
custodian_email, second_custodian, second_custodian_email, reason,
application_locale, already_sent_request, is_main_frame);
application_locale, already_sent_request, is_main_frame, show_banner);
}

void SupervisedUserInterstitial::GoBack() {
Expand Down
32 changes: 18 additions & 14 deletions components/supervised_user/core/browser/supervised_user_service.cc
Expand Up @@ -70,14 +70,16 @@ void SupervisedUserService::Init() {
static_cast<supervised_user::FirstTimeInterstitialBannerState>(
user_prefs_->GetInteger(prefs::kFirstTimeInterstitialBannerState));
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC) || BUILDFLAG(IS_LINUX)
if (banner_state ==
supervised_user::FirstTimeInterstitialBannerState::kUnknown &&
can_show_first_time_interstitial_banner_) {
banner_state =
supervised_user::FirstTimeInterstitialBannerState::kNeedToShow;
} else {
banner_state =
supervised_user::FirstTimeInterstitialBannerState::kSetupComplete;
if (supervised_user::CanDisplayFirstTimeInterstitialBanner()) {
if (banner_state ==
supervised_user::FirstTimeInterstitialBannerState::kUnknown &&
can_show_first_time_interstitial_banner_) {
banner_state =
supervised_user::FirstTimeInterstitialBannerState::kNeedToShow;
} else {
banner_state =
supervised_user::FirstTimeInterstitialBannerState::kSetupComplete;
}
}
#else
banner_state =
Expand Down Expand Up @@ -414,17 +416,19 @@ void SupervisedUserService::OnSiteListUpdated() {
}

void SupervisedUserService::MarkFirstTimeInterstitialBannerShown() const {
supervised_user::FirstTimeInterstitialBannerState banner_state =
static_cast<supervised_user::FirstTimeInterstitialBannerState>(
user_prefs_->GetInteger(prefs::kFirstTimeInterstitialBannerState));

if (banner_state ==
supervised_user::FirstTimeInterstitialBannerState::kNeedToShow) {
if (ShouldShowFirstTimeInterstitialBanner()) {
user_prefs_->SetInteger(
prefs::kFirstTimeInterstitialBannerState,
static_cast<int>(
supervised_user::FirstTimeInterstitialBannerState::kSetupComplete));
}
}

bool SupervisedUserService::ShouldShowFirstTimeInterstitialBanner() const {
supervised_user::FirstTimeInterstitialBannerState banner_state =
static_cast<supervised_user::FirstTimeInterstitialBannerState>(
user_prefs_->GetInteger(prefs::kFirstTimeInterstitialBannerState));
return banner_state ==
supervised_user::FirstTimeInterstitialBannerState::kNeedToShow;
}
} // namespace supervised_user
Expand Up @@ -145,6 +145,9 @@ class SupervisedUserService : public KeyedService,
// who haven't yet seen the banner.
void MarkFirstTimeInterstitialBannerShown() const;

// Returns true if the interstitial banner needs to be shown to user.
bool ShouldShowFirstTimeInterstitialBanner() const;

// Use |SupervisedUserServiceFactory::GetForProfile(..)| to get
// an instance of this service.
// Public to allow visibility to iOS factory.
Expand Down
6 changes: 6 additions & 0 deletions components/supervised_user/core/common/features.cc
Expand Up @@ -147,6 +147,12 @@ BASE_FEATURE(kEnableExtensionsPermissionsForSupervisedUsersOnDesktop,
BASE_FEATURE(kEnableManagedByParentUi,
"EnableManagedByParentUi",
base::FEATURE_DISABLED_BY_DEFAULT);

bool CanDisplayFirstTimeInterstitialBanner() {
return base::FeatureList::IsEnabled(kEnableSupervisionOnDesktopAndIOS) &&
base::FeatureList::IsEnabled(
kFilterWebsitesForSupervisedUsersOnDesktopAndIOS);
}
// The URL which the "Managed by your parent" UI links to. This is defined as a
// FeatureParam (but with the currently correct default) because:
// * We expect to change this URL in the near-term, this allows us to gradually
Expand Down
4 changes: 4 additions & 0 deletions components/supervised_user/core/common/features.h
Expand Up @@ -26,6 +26,10 @@ BASE_DECLARE_FEATURE(kEnableExtensionsPermissionsForSupervisedUsersOnDesktop);
BASE_DECLARE_FEATURE(kEnableManagedByParentUi);
extern const base::FeatureParam<std::string> kManagedByParentUiMoreInfoUrl;

// Returns whether banner can be displayed to the user after website filtering
// is enabled
bool CanDisplayFirstTimeInterstitialBanner();

BASE_DECLARE_FEATURE(kLocalExtensionApprovalsV2);

BASE_DECLARE_FEATURE(kRetireStaticDenyList);
Expand Down

0 comments on commit a16cab8

Please sign in to comment.