0

Add a "Settings" Call to Action for ErrorMessageToast

Adding a new action to the error message if we need to open settings.
For Focus Mode, the action will be to initiate an OS update.

Bug: b:372029553
Change-Id: I82c82d1e75da3df0fde05c51869ae2f6b1fc068d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5926582
Commit-Queue: Sean Kau <skau@chromium.org>
Reviewed-by: Xiaoqian Dai <xdai@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1368398}
This commit is contained in:
Sean Kau
2024-10-14 19:56:40 +00:00
committed by Chromium LUCI CQ
parent c1c377e97e
commit 73c7f9f454
6 changed files with 16 additions and 1 deletions

@ -8816,6 +8816,9 @@ To shut down the device, press and hold the power button on the device again.
<message name="IDS_ASH_ERROR_MESSAGE_TOAST_RELOAD" desc="An error message toast is a notification that shows up when an error occurs. This is the text that is displayed on the button within said notification in order to reload the contents.">
Reload
</message>
<message name="IDS_ASH_ERROR_MESSAGE_TOAST_SETTINGS" desc="An error message toast is a notification that shows up when an error occurs. This is the text that is displayed on the button when the action is to upgrade the operating system (by opening settings).">
Settings
</message>
</messages>
</release>
</grit>

@ -0,0 +1 @@
18e03c809cb40307af0644b249263ba59725b0a2

@ -743,6 +743,8 @@ void GlanceablesTasksView::ShowErrorMessageWithType(
base::Unretained(this),
ListShownContext::kInitialList);
break;
case ErrorMessageToast::ButtonActionType::kSettings:
NOTREACHED();
}
ShowErrorMessage(GetErrorString(error_type), std::move(callback),
button_type);

@ -47,6 +47,9 @@ class ActionLabelButton : public views::LabelButton {
case ErrorMessageToast::ButtonActionType::kReload:
string_id = IDS_ASH_ERROR_MESSAGE_TOAST_RELOAD;
break;
case ErrorMessageToast::ButtonActionType::kSettings:
string_id = IDS_ASH_ERROR_MESSAGE_TOAST_SETTINGS;
break;
}
SetText(l10n_util::GetStringUTF16(string_id));
SetHorizontalAlignment(gfx::HorizontalAlignment::ALIGN_RIGHT);

@ -28,7 +28,7 @@ class ASH_EXPORT ErrorMessageToast : public views::FlexLayoutView {
public:
// Used for `action_button_` that indicates what to expect on click.
enum class ButtonActionType { kDismiss, kReload };
enum class ButtonActionType { kDismiss, kReload, kSettings };
ErrorMessageToast(
views::Button::PressedCallback callback,

@ -317,6 +317,9 @@ constexpr std::partial_ordering FocusModeSoundsView::ToastData::operator<=>(
return std::partial_ordering::less;
}
break;
case ErrorMessageToast::ButtonActionType::kSettings:
// TODO(crbug.com/372029553): Reimplement prioritization.
NOTREACHED();
}
if (message != other.message) {
@ -625,6 +628,9 @@ void FocusModeSoundsView::ShowErrorMessageForType(
base::BindRepeating(&FocusModeSoundsView::DownloadPlaylistsForType,
weak_factory_.GetWeakPtr(), is_soundscape_type);
break;
case ErrorMessageToast::ButtonActionType::kSettings:
// TODO(crbug.com/372029553): Change this to open settings.
NOTREACHED();
}
error_message_ = AddChildView(std::make_unique<ErrorMessageToast>(