Configure local approval error screen with new strings and appearance
Screenshot: https://screenshot.googleplex.com/BbUg6cacdbukTFh Mock: https://screenshot.googleplex.com/5TZsj36S7sju5GR Further demos in crbug.com/394842701#comment17 Bug: 394842701 Change-Id: I793412ae8cb5b231e0eb2ce98dd7c560ccb3dca8 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6330264 Reviewed-by: Duong Dac <ddac@chromium.org> Commit-Queue: Anthi Orfanou <anthie@google.com> Cr-Commit-Position: refs/heads/main@{#1431027}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
1b644f55d1
commit
354385b712
chrome/browser/supervised_user/linux_mac_windows
parent_access_view.ccsupervised_user_web_content_handler_impl.ccsupervised_user_web_content_handler_impl.h
components
@ -5,6 +5,7 @@
|
||||
#include "chrome/browser/supervised_user/linux_mac_windows/parent_access_view.h"
|
||||
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
#include "base/functional/bind.h"
|
||||
#include "base/functional/callback_forward.h"
|
||||
@ -22,16 +23,23 @@
|
||||
#include "third_party/blink/public/common/page/page_zoom.h"
|
||||
#include "ui/base/l10n/l10n_util.h"
|
||||
#include "ui/base/metadata/metadata_impl_macros.h"
|
||||
#include "ui/color/color_id.h"
|
||||
#include "ui/gfx/geometry/rounded_corners_f.h"
|
||||
#include "ui/gfx/geometry/size.h"
|
||||
#include "ui/gfx/vector_icon_utils.h"
|
||||
#include "ui/views/bubble/bubble_frame_view.h"
|
||||
#include "ui/views/controls/button/label_button.h"
|
||||
#include "ui/views/controls/button/md_text_button.h"
|
||||
#include "ui/views/controls/image_view.h"
|
||||
#include "ui/views/controls/label.h"
|
||||
#include "ui/views/controls/webview/webview.h"
|
||||
#include "ui/views/layout/box_layout.h"
|
||||
#include "ui/views/layout/box_layout_view.h"
|
||||
#include "ui/views/layout/flex_layout.h"
|
||||
#include "ui/views/layout/flex_layout_view.h"
|
||||
#include "ui/views/layout/layout_types.h"
|
||||
#include "ui/views/style/typography.h"
|
||||
#include "ui/views/view.h"
|
||||
#include "ui/views/view_class_properties.h"
|
||||
#include "ui/views/widget/widget.h"
|
||||
#include "ui/views/widget/widget_delegate.h"
|
||||
@ -224,18 +232,13 @@ void ParentAccessView::DisplayErrorMessage(content::WebContents* web_contents) {
|
||||
std::move(dialog_result_reset_callback_).Run();
|
||||
}
|
||||
|
||||
views::Widget* widget = GetWidget();
|
||||
CHECK(widget);
|
||||
// Note: We cannot remove the existing "X" close button,
|
||||
// but we add buttons to dismiss the dialog.
|
||||
widget->widget_delegate()->AsDialogDelegate()->SetButtons(
|
||||
static_cast<int>(ui::mojom::DialogButton::kOk));
|
||||
|
||||
// Remove the web view that displays the PACP widget content, and replace it
|
||||
// with a view that displays the error message.
|
||||
// Assume ownership of the removed view but do not destruct yet,
|
||||
// as there may be still content observers for it, which can lead to a
|
||||
// crash.
|
||||
views::Widget* widget = GetWidget();
|
||||
CHECK(widget);
|
||||
CHECK(web_view_);
|
||||
removed_view_holder_ = RemoveChildViewT(web_view_);
|
||||
web_view_ = nullptr;
|
||||
@ -246,19 +249,70 @@ void ParentAccessView::DisplayErrorMessage(content::WebContents* web_contents) {
|
||||
error_view->SetProperty(views::kElementIdentifierKey,
|
||||
kLocalWebParentApprovalDialogErrorId);
|
||||
|
||||
auto layout = std::make_unique<views::BoxLayout>();
|
||||
layout->SetOrientation(views::LayoutOrientation::kVertical);
|
||||
layout->set_main_axis_alignment(views::LayoutAlignment::kCenter);
|
||||
layout->set_cross_axis_alignment(views::LayoutAlignment::kCenter);
|
||||
const int border_inset_size = 24;
|
||||
auto layout = std::make_unique<views::BoxLayout>(
|
||||
views::LayoutOrientation::kVertical,
|
||||
/*inside_border_insets=*/
|
||||
gfx::Insets()
|
||||
.set_top_bottom(border_inset_size, border_inset_size)
|
||||
.set_left_right(border_inset_size, border_inset_size));
|
||||
layout->set_main_axis_alignment(views::BoxLayout::MainAxisAlignment::kStart);
|
||||
layout->set_cross_axis_alignment(
|
||||
views::BoxLayout::CrossAxisAlignment::kCenter);
|
||||
auto* layout_ptr = layout.get();
|
||||
error_view->SetLayoutManager(std::move(layout));
|
||||
|
||||
error_view->AddChildView(
|
||||
// Add error icon.
|
||||
int top_margin = 60;
|
||||
auto error_icon_view =
|
||||
std::make_unique<views::ImageView>(ui::ImageModel::FromVectorIcon(
|
||||
vector_icons::kErrorIcon, ui::kColorAlertHighSeverity,
|
||||
gfx::GetDefaultSizeOfVectorIcon(vector_icons::kErrorIcon))));
|
||||
// TODO(crbug.com/394842701): Provide new appropriate strings.
|
||||
error_view->AddChildView(views::BubbleFrameView::CreateDefaultTitleLabel(
|
||||
l10n_util::GetStringUTF16(IDS_PARENT_WEBSITE_LOCAL_WEB_APPROVAL_ERROR)));
|
||||
vector_icons::kErrorOutlineIcon, ui::kColorAlertHighSeverity,
|
||||
gfx::GetDefaultSizeOfVectorIcon(vector_icons::kErrorOutlineIcon)));
|
||||
error_view->SetProperty(views::kMarginsKey,
|
||||
gfx::Insets().set_top(top_margin));
|
||||
error_view->AddChildView(std::move(error_icon_view));
|
||||
|
||||
// Add title.
|
||||
top_margin = 16;
|
||||
auto title_label = std::make_unique<views::Label>(
|
||||
l10n_util::GetStringUTF16(
|
||||
IDS_PARENTAL_LOCAL_APPROVAL_DIALOG_GENERIC_ERROR_TITLE),
|
||||
views::style::CONTEXT_DIALOG_TITLE, views::style::STYLE_PRIMARY);
|
||||
title_label->SetProperty(views::kMarginsKey,
|
||||
gfx::Insets().set_top(top_margin));
|
||||
error_view->AddChildView(std::move(title_label));
|
||||
|
||||
// Add dialog body text.
|
||||
auto description_label = std::make_unique<views::Label>(
|
||||
l10n_util::GetStringUTF16(
|
||||
IDS_PARENTAL_LOCAL_APPROVAL_DIALOG_GENERIC_ERROR_DESCRIPTION),
|
||||
views::style::CONTEXT_DIALOG_BODY_TEXT, views::style::STYLE_SECONDARY);
|
||||
description_label->SetProperty(views::kMarginsKey,
|
||||
gfx::Insets().set_top(top_margin));
|
||||
error_view->AddChildView(std::move(description_label));
|
||||
|
||||
// Create a flexible view, to push the back button towards the bottom of the
|
||||
// view.
|
||||
auto spacer = std::make_unique<views::View>();
|
||||
views::View* spacer_ptr = spacer.get();
|
||||
error_view->AddChildView(std::move(spacer));
|
||||
layout_ptr->SetFlexForView(spacer_ptr, 1);
|
||||
|
||||
// Add Back button that closes the dialog.
|
||||
auto back_button = std::make_unique<views::MdTextButton>(
|
||||
base::BindRepeating(&ParentAccessView::CloseView, GetWeakPtr()),
|
||||
l10n_util::GetStringUTF16(
|
||||
IDS_PARENTAL_LOCAL_APPROVAL_DIALOG_GENERIC_ERROR_BACK_BUTTON));
|
||||
back_button->SetStyle(ui::ButtonStyle::kProminent);
|
||||
// Pad the button size on the side.
|
||||
const int preferred_button_width = 155;
|
||||
const int preferred_button_height = 40;
|
||||
back_button->SetPreferredSize(gfx::Size(
|
||||
std::max(back_button->GetPreferredSize().width(), preferred_button_width),
|
||||
std::max(back_button->GetPreferredSize().height(),
|
||||
preferred_button_height)));
|
||||
back_button->SizeToPreferredSize();
|
||||
error_view->AddChildView(std::move(back_button));
|
||||
|
||||
error_view_ = AddChildView(std::move(error_view));
|
||||
// Triggers the dialog resizing.
|
||||
|
@ -58,7 +58,7 @@ void SupervisedUserWebContentHandlerImpl::RequestLocalApproval(
|
||||
|
||||
// Observer web contents for the parent approval dialog.
|
||||
auto create_observer_callback = base::BindOnce(
|
||||
&SupervisedUserWebContentHandlerImpl::StartObervingPacpContents,
|
||||
&SupervisedUserWebContentHandlerImpl::StartObservingPacpContents,
|
||||
weak_ptr_factory_.GetWeakPtr());
|
||||
auto abort_dialog_callback = base::BindOnce(
|
||||
&SupervisedUserWebContentHandlerImpl::AbortUrlApprovalDialogOnTimeout,
|
||||
@ -86,7 +86,7 @@ void SupervisedUserWebContentHandlerImpl::MaybeCloseLocalApproval() {
|
||||
CloseDialog();
|
||||
}
|
||||
|
||||
void SupervisedUserWebContentHandlerImpl::StartObervingPacpContents(
|
||||
void SupervisedUserWebContentHandlerImpl::StartObservingPacpContents(
|
||||
content::WebContents* contents) {
|
||||
CHECK(contents);
|
||||
CHECK(dialog_web_contents_observer_);
|
||||
|
@ -56,7 +56,7 @@ class SupervisedUserWebContentHandlerImpl
|
||||
}
|
||||
|
||||
private:
|
||||
void StartObervingPacpContents(content::WebContents* contents);
|
||||
void StartObservingPacpContents(content::WebContents* contents);
|
||||
|
||||
void CompleteUrlApprovalAndCloseOrUpdateDialog(
|
||||
const GURL& target_url,
|
||||
|
@ -98,8 +98,14 @@
|
||||
<message name="IDS_PARENT_WEBSITE_APPROVAL_MANUAL_URL" desc="This text displayed as a subtitle in a bottom sheet asking a parent to allow or not allow a website. This informs the parent that this site was blocked due to a manual blocklist entry.">
|
||||
You previously blocked <ph name="BLOCKED_URL">$1<ex>example.com</ex></ph>
|
||||
</message>
|
||||
<message name="IDS_PARENT_WEBSITE_LOCAL_WEB_APPROVAL_ERROR" desc="Error message in case of a local web approval failure." translateable="false">
|
||||
An error occurred. Try again later.
|
||||
<message name="IDS_PARENTAL_LOCAL_APPROVAL_DIALOG_GENERIC_ERROR_TITLE" desc="Title of the error dialog that is shown when a supervised user asks for local parental approval, but during the request something went wrong.">
|
||||
Something went wrong
|
||||
</message>
|
||||
<message name="IDS_PARENTAL_LOCAL_APPROVAL_DIALOG_GENERIC_ERROR_DESCRIPTION" desc="Description of the error dialog that is shown when a supervised user asks for local parental approval, but the request failed. In this scenario, we don't know why the request didn't work, so they need to try again.">
|
||||
Try again
|
||||
</message>
|
||||
<message name="IDS_PARENTAL_LOCAL_APPROVAL_DIALOG_GENERIC_ERROR_BACK_BUTTON" desc="Button of the error dialog that is shown when a supervised user asks for local parental approval, but the request failed. In this scenario, we don't know why the request didn't work, so they need to go back to the previous screen and try again.">
|
||||
Back
|
||||
</message>
|
||||
<message name="IDS_PARENTAL_LOCAL_APPROVAL_SNACKBAR_GENERIC_ERROR_TITLE" desc="Description of the error snackbar that is shown when a supervised user asks for parental approval, but the request couldn’t be sent. In this scenario, we don’t know why the request didn’t work, so they need to try again.">
|
||||
Something went wrong. Try again.
|
||||
|
1
components/supervised_user_strings_grdp/IDS_PARENTAL_LOCAL_APPROVAL_DIALOG_GENERIC_ERROR_BACK_BUTTON.png.sha1
Normal file
1
components/supervised_user_strings_grdp/IDS_PARENTAL_LOCAL_APPROVAL_DIALOG_GENERIC_ERROR_BACK_BUTTON.png.sha1
Normal file
@ -0,0 +1 @@
|
||||
91b7d2e92bb2b3fa94742e8db79a1037863a9962
|
1
components/supervised_user_strings_grdp/IDS_PARENTAL_LOCAL_APPROVAL_DIALOG_GENERIC_ERROR_DESCRIPTION.png.sha1
Normal file
1
components/supervised_user_strings_grdp/IDS_PARENTAL_LOCAL_APPROVAL_DIALOG_GENERIC_ERROR_DESCRIPTION.png.sha1
Normal file
@ -0,0 +1 @@
|
||||
91b7d2e92bb2b3fa94742e8db79a1037863a9962
|
1
components/supervised_user_strings_grdp/IDS_PARENTAL_LOCAL_APPROVAL_DIALOG_GENERIC_ERROR_TITLE.png.sha1
Normal file
1
components/supervised_user_strings_grdp/IDS_PARENTAL_LOCAL_APPROVAL_DIALOG_GENERIC_ERROR_TITLE.png.sha1
Normal file
@ -0,0 +1 @@
|
||||
91b7d2e92bb2b3fa94742e8db79a1037863a9962
|
Reference in New Issue
Block a user