0

ongoing-processes: Update Update notification contents

Update notification button text so it's compatible with the new pinned
notification view used when `OngoingProcesses` is enabled.
https://screenshot.googleplex.com/A8MwCh8shg5FbG4

These changes will affect notifications overall, even when the new
ongoing process view is not enabled.

go/ongoing-processes-dd

Bug: b:327483977
Change-Id: I707a84898fab18d3fcd07c5f9aa1560fd009d2e5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5623255
Reviewed-by: Jiaming Cheng <jiamingc@chromium.org>
Commit-Queue: Kevin Radtke <kradtke@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1314793}
This commit is contained in:
Kevin Radtke
2024-06-13 19:15:47 +00:00
committed by Chromium LUCI CQ
parent 68e7c63e8e
commit 6bdb7a67a3
7 changed files with 49 additions and 77 deletions

@ -916,19 +916,6 @@ Style notes:
<message name="IDS_ASH_STATUS_TRAY_FOCUS_MODE_SESSION_LESS_THAN_ONE_MINUTE" desc="The tooltip text for the tray bubble and the focus mode feature tile in the quick settings menu when the focus session is less than 1 minute.">
less than 1 min
</message>
<message name="IDS_ASH_STATUS_TRAY_UPDATE" desc="The label used in the tray popup to notify that the user should restart to get system updates.">
Restart to update
</message>
<message name="IDS_ASH_STATUS_TRAY_RESET_TO_UPDATE" desc="The label used in the tray popup to notify that the user should restart and powerwash the device to get system updates.">
Reset to update
</message>
<message name="IDS_ASH_STATUS_TRAY_UPDATE_OVER_CELLULAR_AVAILABLE" desc="The label used in the tray popup to notify that update is available but current connection is cellular.">
Click to view update details
</message>
<message name="IDS_UPDATE_NOTIFICATION_TITLE" desc="The title of the notification to notify that the user should restart to get system updates.">
Update device
</message>
@ -1017,13 +1004,7 @@ Style notes:
Learn more about the latest <ph name="SYSTEM_APP_NAME">$1<ex>ChromiumOS</ex></ph> update
</message>
<message name="IDS_UPDATE_NOTIFICATION_RESTART_BUTTON" meaning="button label" desc="The label used as the button to restart system and update. Displayed as the action button of the notification for system update.">
Restart to update
</message>
<message name="IDS_UPDATE_NOTIFICATION_APPLY_UPDATE_BUTTON" meaning="button label" desc="The label used as the button to apply deferred update. Displayed as the action button of the notification for deferred system update.">
Update
</message>
<message name="IDS_ROLLBACK_NOTIFICATION_RESTART_BUTTON" meaning="button label" desc="The label used as the button to restart system to rollback. Displayed as the action button of the notification for system rollback.">
Reset
Restart
</message>
<message name="IDS_UPDATE_NOTIFICATION_MESSAGE_DEFERRED_UPDATE" desc="The notification message used in the system notification update when update is downloaded but deferred.">
Get the latest features and security improvements. Updates happen in the background.

@ -1 +0,0 @@
5bbda6831cc51621b6f1a7ee2396e80534142acc

@ -1 +0,0 @@
d0b23ad0e5fb5690e4d3d762d81353544f9f3a04

@ -1 +0,0 @@
066986453af2cd1dee319ee0128a03aa1faec13c

@ -0,0 +1 @@
e90ab745dde2bda9a901b958fc3dc6e770cf22a0

@ -8,6 +8,7 @@
#include "ash/constants/notifier_catalogs.h"
#include "ash/public/cpp/notification_utils.h"
#include "ash/public/cpp/system_notification_builder.h"
#include "ash/public/cpp/system_tray_client.h"
#include "ash/public/cpp/update_types.h"
#include "ash/resources/vector_icons/vector_icons.h"
@ -37,8 +38,6 @@ namespace ash {
namespace {
const char kNotifierId[] = "ash.update";
const char kNotificationId[] = "chrome://update";
bool CheckForSlowBoot(const base::FilePath& slow_boot_file_path) {
@ -89,40 +88,34 @@ void UpdateNotificationController::GenerateUpdateNotification(
slow_boot_file_path_exists_ = slow_boot_file_path_exists.value();
}
std::unique_ptr<Notification> notification = CreateSystemNotificationPtr(
message_center::NOTIFICATION_TYPE_SIMPLE, kNotificationId, GetTitle(),
GetMessage(), std::u16string() /* display_source */, GURL(),
message_center::NotifierId(message_center::NotifierType::SYSTEM_COMPONENT,
kNotifierId, NotificationCatalogName::kUpdate),
message_center::RichNotificationData(),
base::MakeRefCounted<message_center::HandleNotificationClickDelegate>(
base::BindRepeating(
&UpdateNotificationController::HandleNotificationClick,
weak_ptr_factory_.GetWeakPtr())),
GetIcon(), GetWarningLevel());
notification->set_pinned(true);
message_center::RichNotificationData data;
data.pinned = true;
if (ShouldShowDeferredUpdate() || model_->update_required()) {
data.buttons.emplace_back(message_center::ButtonInfo(
l10n_util::GetStringUTF16(IDS_UPDATE_NOTIFICATION_RESTART_BUTTON)));
}
std::unique_ptr<Notification> notification =
ash::SystemNotificationBuilder()
.SetId(kNotificationId)
.SetCatalogName(NotificationCatalogName::kUpdate)
.SetTitle(GetTitle())
.SetMessage(GetMessage())
.SetOptionalFields(data)
.SetDelegate(base::MakeRefCounted<
message_center::HandleNotificationClickDelegate>(
base::BindRepeating(
&UpdateNotificationController::HandleNotificationClick,
weak_ptr_factory_.GetWeakPtr())))
.SetSmallImage(GetIcon())
.SetWarningLevel(GetWarningLevel())
.BuildPtr(
/*keep_timestamp=*/false);
if (model_->relaunch_notification_state().requirement_type ==
RelaunchNotificationState::kRequired)
RelaunchNotificationState::kRequired) {
notification->SetSystemPriority();
if (ShouldShowDeferredUpdate()) {
notification->set_buttons(
{message_center::ButtonInfo(l10n_util::GetStringUTF16(
IDS_UPDATE_NOTIFICATION_APPLY_UPDATE_BUTTON))});
} else if (model_->update_required()) {
std::vector<message_center::ButtonInfo> notification_actions;
if (model_->rollback()) {
notification_actions.push_back(message_center::ButtonInfo(
l10n_util::GetStringUTF16(IDS_ROLLBACK_NOTIFICATION_RESTART_BUTTON)));
} else if (model_->factory_reset_required()) {
notification_actions.push_back(message_center::ButtonInfo(
l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_RESET_TO_UPDATE)));
} else {
notification_actions.push_back(message_center::ButtonInfo(
l10n_util::GetStringUTF16(IDS_UPDATE_NOTIFICATION_RESTART_BUTTON)));
}
notification->set_buttons(notification_actions);
}
MessageCenter::Get()->AddNotification(std::move(notification));

@ -113,7 +113,7 @@ class UpdateNotificationControllerTest : public AshTestBase {
return base::UTF16ToUTF8(GetNotification()->message());
}
std::string GetNotificationButton(int index) {
std::string GetNotificationButtonText(int index) {
return base::UTF16ToUTF8(GetNotification()->buttons().at(index).title);
}
@ -181,7 +181,7 @@ TEST_F(UpdateNotificationControllerTest, VisibilityAfterUpdate) {
EXPECT_EQ("Learn more about the latest " +
base::UTF16ToUTF8(system_app_name_) + " update",
GetNotificationMessage());
EXPECT_EQ("Restart to update", GetNotificationButton(0));
EXPECT_EQ("Restart", GetNotificationButtonText(0));
// Click the restart button.
message_center::MessageCenter::Get()->ClickOnNotificationButton(
@ -220,7 +220,7 @@ TEST_F(UpdateNotificationControllerTest, VisibilityAfterUpdateWithSlowReboot) {
" update. This Chromebook needs to restart to apply an update. "
"This can take up to 1 minute.",
GetNotificationMessage());
EXPECT_EQ("Restart to update", GetNotificationButton(0));
EXPECT_EQ("Restart", GetNotificationButtonText(0));
// Ensure Slow Boot Dialog is not open.
EXPECT_FALSE(GetSlowBootConfirmationDialog());
@ -306,8 +306,8 @@ TEST_F(UpdateNotificationControllerTest,
EXPECT_EQ(l10n_util::GetStringFUTF8(IDS_UPDATE_NOTIFICATION_MESSAGE_POWERWASH,
chrome_os_device_name, system_app_name_),
GetNotificationMessage());
EXPECT_EQ(l10n_util::GetStringUTF8(IDS_ASH_STATUS_TRAY_RESET_TO_UPDATE),
GetNotificationButton(0));
EXPECT_EQ(l10n_util::GetStringUTF8(IDS_UPDATE_NOTIFICATION_RESTART_BUTTON),
GetNotificationButtonText(0));
}
TEST_F(UpdateNotificationControllerTest, NoUpdateNotification) {
@ -341,8 +341,8 @@ TEST_F(UpdateNotificationControllerTest, RollbackNotification) {
base::ASCIIToUTF16(kDomain),
chrome_os_device_name),
GetNotificationMessage());
EXPECT_EQ(l10n_util::GetStringUTF8(IDS_ROLLBACK_NOTIFICATION_RESTART_BUTTON),
GetNotificationButton(0));
EXPECT_EQ(l10n_util::GetStringUTF8(IDS_UPDATE_NOTIFICATION_RESTART_BUTTON),
GetNotificationButtonText(0));
}
TEST_F(UpdateNotificationControllerTest, RollbackRecommendedNotification) {
@ -373,8 +373,8 @@ TEST_F(UpdateNotificationControllerTest, RollbackRecommendedNotification) {
base::ASCIIToUTF16(kDomain),
chrome_os_device_name),
GetNotificationMessage());
EXPECT_EQ(l10n_util::GetStringUTF8(IDS_ROLLBACK_NOTIFICATION_RESTART_BUTTON),
GetNotificationButton(0));
EXPECT_EQ(l10n_util::GetStringUTF8(IDS_UPDATE_NOTIFICATION_RESTART_BUTTON),
GetNotificationButtonText(0));
}
TEST_F(UpdateNotificationControllerTest,
@ -405,8 +405,8 @@ TEST_F(UpdateNotificationControllerTest,
IDS_UPDATE_NOTIFICATION_MESSAGE_ROLLBACK_OVERDUE,
base::ASCIIToUTF16(kDomain), chrome_os_device_name),
GetNotificationMessage());
EXPECT_EQ(l10n_util::GetStringUTF8(IDS_ROLLBACK_NOTIFICATION_RESTART_BUTTON),
GetNotificationButton(0));
EXPECT_EQ(l10n_util::GetStringUTF8(IDS_UPDATE_NOTIFICATION_RESTART_BUTTON),
GetNotificationButtonText(0));
}
TEST_F(UpdateNotificationControllerTest, RollbackRequiredNotification) {
@ -441,8 +441,8 @@ TEST_F(UpdateNotificationControllerTest, RollbackRequiredNotification) {
base::ASCIIToUTF16(kDomain),
chrome_os_device_name),
GetNotificationMessage());
EXPECT_EQ(l10n_util::GetStringUTF8(IDS_ROLLBACK_NOTIFICATION_RESTART_BUTTON),
GetNotificationButton(0));
EXPECT_EQ(l10n_util::GetStringUTF8(IDS_UPDATE_NOTIFICATION_RESTART_BUTTON),
GetNotificationButtonText(0));
}
TEST_F(UpdateNotificationControllerTest, SetUpdateNotificationRecommended) {
@ -467,7 +467,7 @@ TEST_F(UpdateNotificationControllerTest, SetUpdateNotificationRecommended) {
EXPECT_EQ(expected_notification_title, GetNotificationTitle());
EXPECT_EQ(expected_notification_body, GetNotificationMessage());
EXPECT_EQ(l10n_util::GetStringUTF8(IDS_UPDATE_NOTIFICATION_RESTART_BUTTON),
GetNotificationButton(0));
GetNotificationButtonText(0));
}
TEST_F(UpdateNotificationControllerTest,
@ -493,7 +493,7 @@ TEST_F(UpdateNotificationControllerTest,
EXPECT_EQ(expected_notification_title, GetNotificationTitle());
EXPECT_EQ(expected_notification_body, GetNotificationMessage());
EXPECT_EQ(l10n_util::GetStringUTF8(IDS_UPDATE_NOTIFICATION_RESTART_BUTTON),
GetNotificationButton(0));
GetNotificationButtonText(0));
}
TEST_F(UpdateNotificationControllerTest, SetUpdateNotificationRequiredDays) {
@ -524,7 +524,7 @@ TEST_F(UpdateNotificationControllerTest, SetUpdateNotificationRequiredDays) {
EXPECT_EQ(expected_notification_title, GetNotificationTitle());
EXPECT_EQ(expected_notification_body, GetNotificationMessage());
EXPECT_EQ(l10n_util::GetStringUTF8(IDS_UPDATE_NOTIFICATION_RESTART_BUTTON),
GetNotificationButton(0));
GetNotificationButtonText(0));
}
TEST_F(UpdateNotificationControllerTest,
@ -595,7 +595,7 @@ TEST_F(UpdateNotificationControllerTest, SetUpdateNotificationRequiredHours) {
EXPECT_EQ(expected_notification_title, GetNotificationTitle());
EXPECT_EQ(expected_notification_body, GetNotificationMessage());
EXPECT_EQ(l10n_util::GetStringUTF8(IDS_UPDATE_NOTIFICATION_RESTART_BUTTON),
GetNotificationButton(0));
GetNotificationButtonText(0));
}
TEST_F(UpdateNotificationControllerTest, SetUpdateNotificationRequiredMinutes) {
@ -626,7 +626,7 @@ TEST_F(UpdateNotificationControllerTest, SetUpdateNotificationRequiredMinutes) {
EXPECT_EQ(expected_notification_title, GetNotificationTitle());
EXPECT_EQ(expected_notification_body, GetNotificationMessage());
EXPECT_EQ(l10n_util::GetStringUTF8(IDS_UPDATE_NOTIFICATION_RESTART_BUTTON),
GetNotificationButton(0));
GetNotificationButtonText(0));
}
TEST_F(UpdateNotificationControllerTest, SetUpdateNotificationRequiredSeconds) {
@ -657,7 +657,7 @@ TEST_F(UpdateNotificationControllerTest, SetUpdateNotificationRequiredSeconds) {
EXPECT_EQ(expected_notification_title, GetNotificationTitle());
EXPECT_EQ(expected_notification_body, GetNotificationMessage());
EXPECT_EQ(l10n_util::GetStringUTF8(IDS_UPDATE_NOTIFICATION_RESTART_BUTTON),
GetNotificationButton(0));
GetNotificationButtonText(0));
}
// Simulates setting the notification back to the default after showing
@ -687,7 +687,7 @@ TEST_F(UpdateNotificationControllerTest, SetBackToDefault) {
IDS_UPDATE_NOTIFICATION_MESSAGE_LEARN_MORE, system_app_name_),
GetNotificationMessage());
EXPECT_EQ(l10n_util::GetStringUTF8(IDS_UPDATE_NOTIFICATION_RESTART_BUTTON),
GetNotificationButton(0));
GetNotificationButtonText(0));
EXPECT_NE(message_center::NotificationPriority::SYSTEM_PRIORITY,
GetNotificationPriority());
}
@ -714,7 +714,7 @@ TEST_F(UpdateNotificationControllerTest,
"Get the latest features and security improvements. Updates happen in "
"the background.",
GetNotificationMessage());
EXPECT_EQ("Update", GetNotificationButton(0));
EXPECT_EQ("Restart", GetNotificationButtonText(0));
}
TEST_F(UpdateNotificationControllerTest,