0

cros: Remove forest flag (11/N)

Remove notification code in full_restore_service. It has been replaced
by a dialog in ash/wm/window_restore.

OBSOLETE_HISTOGRAM[Apps.RestoreForCrashNotification]=This histogram is no longer needed.
OBSOLETE_HISTOGRAM[Apps.RestoreNotification]=This histogram is no longer needed.
OBSOLETE_HISTOGRAM[Ash.FullRestore.ShowFullRestoreNotification]=This histogram is no longer needed.

Test: CQ
Bug: 401555376
Change-Id: I7dfe6ff8ed60e2edb258b5f154c6b8274fa4cfbe
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6423743
Reviewed-by: Michele Fan <michelefan@chromium.org>
Reviewed-by: David Yeung <dayeung@chromium.org>
Reviewed-by: Marijn Kruisselbrink <mek@chromium.org>
Reviewed-by: Jiaming Cheng <jiamingc@chromium.org>
Reviewed-by: Xiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Sammie Quon <sammiequon@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1442545}
This commit is contained in:
Sammie Quon
2025-04-03 19:25:58 -07:00
committed by Chromium LUCI CQ
parent 18fbc5aed8
commit ac853e1e33
25 changed files with 37 additions and 565 deletions

@ -136,7 +136,7 @@ enum class NotificationCatalogName {
kNetworkPortalDetector = 117,
kCrostiniPackage = 118,
kCrostiniUpgradeAvailable = 119,
kFullRestore = 120,
// [Deprecated] kFullRestore = 120,
kAdbSideloadingDisallowed = 121,
kAdbSideloadingPowerwashPlanned = 122,
kAdbSideloadingPowerwashOnReboot = 123,

@ -468,7 +468,7 @@ TEST_F(MessageCenterMetricsUtilsTest, RecordSystemNotificationAdded) {
// Create system notifications with a valid catalog name, one for a non-pinned
// notification and one for a pinned one (e.g. Full Restore and Caps Lock).
const NotificationCatalogName catalog_name =
NotificationCatalogName::kFullRestore;
NotificationCatalogName::kNightLight;
const NotificationCatalogName pinned_catalog_name =
NotificationCatalogName::kCapsLock;
auto notification = CreateNotificationWithCatalogName(catalog_name);
@ -495,7 +495,7 @@ TEST_F(MessageCenterMetricsUtilsTest,
// Create a system notification with a valid catalog name (e.g. Full Restore).
const NotificationCatalogName catalog_name =
NotificationCatalogName::kFullRestore;
NotificationCatalogName::kNightLight;
auto notification = CreateNotificationWithCatalogName(catalog_name);
// Add notification to message center.
@ -541,7 +541,7 @@ TEST_F(MessageCenterMetricsUtilsTest, RecordPopupUserJourneyTime) {
// Create a non-pinned system notification with a valid catalog name.
const NotificationCatalogName catalog_name =
NotificationCatalogName::kFullRestore;
NotificationCatalogName::kNightLight;
auto notification = CreateNotificationWithCatalogName(catalog_name);
// Add notification to message center. Use the normal duration for adding the

@ -19,8 +19,6 @@ inline constexpr char kDialogScreenshotVisibility[] =
inline constexpr char kInformedRestoreOnboardingHistogram[] =
"Ash.Pine.OnboardingDialog.TurnRestoreOn";
inline constexpr char kFullRestoreNotificationHistogram[] =
"Ash.FullRestore.ShowFullRestoreNotification";
inline constexpr char kFullRestoreDialogHistogram[] =
"Ash.FullRestore.ShowInformedRestoreDialog";

@ -6775,29 +6775,6 @@ Your <ph name="DEVICE_TYPE">{0}<ex>Chromebook</ex></ph> will be locked now.
<ph name="DOMAIN">$1<ex>example.com</ex></ph> requires you to keep your smart card inserted.
</message>
<!-- Strings for full restore notifications -->
<message name="IDS_RESTORE_NOTIFICATION_RESTORE_BUTTON" desc="The restore button label of the notification for the user to select restore apps and pages on startup.">
Restore
</message>
<message name="IDS_RESTORE_NOTIFICATION_CANCEL_BUTTON" desc="The cancel button label of the notification for the user to select not restore on startup.">
No thanks
</message>
<message name="IDS_RESTORE_NOTIFICATION_SETTINGS_BUTTON" desc="The settings button label of the notification for the user to set the restore setting.">
Settings
</message>
<message name="IDS_RESTORE_NOTIFICATION_TITLE" desc="This is the title of the notification for the user to select restore or not on startup.">
Restore apps?
</message>
<message name="IDS_RESTORE_CRASH_NOTIFICATION_TITLE" desc="This is the title of the notification for the user to select restore or not on startup after crash.">
Your <ph name="DEVICE_TYPE">$1<ex>Chromebook</ex></ph> restarted unexpectedly
</message>
<message name="IDS_RESTORE_NOTIFICATION_MESSAGE" desc="This is the text message of the notification for the user to select restore or not on startup if the 'restore_apps' setting is 'Ask every time', and the system is not crashed before reboot.">
Continue from where you left off. You can set apps to always restore on startup or turn off restore in Settings.
</message>
<message name="IDS_RESTORE_CRASH_NOTIFICATION_MESSAGE" desc="This is the text message of the notification for the user to select restore or not on startup after crash.">
You can restore your previous apps
</message>
<!-- Strings for multi-capture -->
<message name="IDS_MULTI_CAPTURE_NOTIFICATION_TITLE" desc="This is the title of the notification when an application starts capturing multiple surfaces.">
<ph name="APP_ORIGIN">$1</ph> is recording your screen

@ -1 +0,0 @@
f0fe1ec1affd8a7f9d89d2c60af54ce278f840ef

@ -1 +0,0 @@
f0fe1ec1affd8a7f9d89d2c60af54ce278f840ef

@ -1 +0,0 @@
c8ea472bcb8440d7918148a3900890cbd2706c76

@ -1 +0,0 @@
804d68d83343c273f3ca0f0aff112052f509e53e

@ -1 +0,0 @@
657acbf8f413bb610546b27dd5203a59f2b3c4f8

@ -1 +0,0 @@
2604dda7502864bccab676b1dc5d0c4f115d228e

@ -1 +0,0 @@
348f4887e4c7b3a1782f38416dd3b3ae7c51d8a4

@ -2148,13 +2148,6 @@ Chromium is unable to recover your settings.
</message>
</if>
<!-- Strings for full restore notifications -->
<if expr="is_chromeos">
<message name="IDS_RESTORE_NOTIFICATION_DISPLAY_SOURCE" desc="This is the string shown as the display source of the notification for the user to select restore or not on startup.">
ChromiumOS system
</message>
</if>
<!-- Notification quiet permission IPH -->
<message name="IDS_QUIET_NOTIFICATION_IPH_TEXT" desc="Text of the blocked notifications indicator promo, that shows under the blocked notifications indicator in the address bar, when a site requests notifications permission. The promo informs the user that as a result of them usually blocking notifications, the request from the site is automatically blocked, and the user can click on the icon to allow notifications.">
You usually block notifications. To let this site notify you, click here.

@ -1 +0,0 @@
63cab9675eb6764fe65fc2b89c3002538d76dba2

@ -2165,20 +2165,6 @@ Google Chrome is unable to recover your settings.
</message>
</if>
<!-- Strings for full restore notifications -->
<if expr="is_chromeos">
<if expr="reven">
<message name="IDS_RESTORE_NOTIFICATION_DISPLAY_SOURCE" desc="This is the string shown as the display source of the notification for the user to select restore or not on startup.">
ChromeOS Flex system
</message>
</if>
<if expr="not reven">
<message name="IDS_RESTORE_NOTIFICATION_DISPLAY_SOURCE" desc="This is the string shown as the display source of the notification for the user to select restore or not on startup.">
ChromeOS system
</message>
</if>
</if>
<!-- ChromeLabs bubble -->
<message name="IDS_CHROMELABS_RELAUNCH_FOOTER_MESSAGE" desc="Text that shows in the footer of the Chrome Labs bubble when relaunch is needed for changes to take effect.">
Your changes will take effect the next time you relaunch Google Chrome.

@ -1 +0,0 @@
657acbf8f413bb610546b27dd5203a59f2b3c4f8

@ -270,7 +270,6 @@ aggregate_vector_icons("chrome_vector_icons") {
"autocorrect_undo.icon",
"crostini_mascot.icon",
"floating_workspace_notification.icon",
"full_restore_notification.icon",
"game_controls_add.icon",
"game_controls_delete.icon",
"game_controls_done.icon",

@ -1,89 +0,0 @@
// Copyright 2022 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
CANVAS_DIMENSIONS, 20,
MOVE_TO, 11.48, 18,
H_LINE_TO, 8.52,
R_CUBIC_TO, -0.59, 0, -1.09, -0.42, -1.16, -0.99,
R_LINE_TO, -0.22, -1.47,
R_ARC_TO, 7.28, 7.28, 0, 0, 1, -0.63, -0.36,
R_LINE_TO, -1.44, 0.56,
R_CUBIC_TO, -0.56, 0.2, -1.18, -0.02, -1.45, -0.51,
R_LINE_TO, -1.46, -2.47,
R_CUBIC_TO, -0.28, -0.52, -0.16, -1.12, 0.29, -1.47,
R_LINE_TO, 1.22, -0.93,
R_ARC_TO, 5.17, 5.17, 0, 0, 1, -0.02, -0.36,
R_CUBIC_TO, 0, -0.12, 0.01, -0.24, 0.02, -0.36,
R_LINE_TO, -1.22, -0.93,
ARC_TO, 1.11, 1.11, 0, 0, 1, 2.16, 7.24,
R_LINE_TO, 1.48, -2.49,
R_CUBIC_TO, 0.27, -0.48, 0.89, -0.7, 1.43, -0.49,
R_LINE_TO, 1.45, 0.57,
R_ARC_TO, 8.51, 8.51, 0, 0, 1, 0.62, -0.36,
R_LINE_TO, 0.22, -1.49,
CUBIC_TO, 7.43, 2.43, 7.93, 2, 8.51, 2,
R_H_LINE_TO, 2.96,
R_CUBIC_TO, 0.59, 0, 1.09, 0.42, 1.16, 0.99,
R_LINE_TO, 0.22, 1.48,
R_CUBIC_TO, 0.22, 0.11, 0.42, 0.23, 0.63, 0.36,
R_LINE_TO, 1.44, -0.56,
R_CUBIC_TO, 0.57, -0.2, 1.18, 0.02, 1.46, 0.51,
R_LINE_TO, 1.47, 2.48,
R_ARC_TO, 1.13, 1.13, 0, 0, 1, -0.29, 1.47,
R_LINE_TO, -1.22, 0.93,
R_CUBIC_TO, 0.01, 0.12, 0.02, 0.23, 0.02, 0.36,
R_CUBIC_TO, 0, 0.13, -0.01, 0.24, -0.02, 0.36,
R_LINE_TO, 1.22, 0.93,
R_CUBIC_TO, 0.45, 0.35, 0.58, 0.96, 0.3, 1.45,
R_LINE_TO, -1.49, 2.51,
R_CUBIC_TO, -0.27, 0.48, -0.89, 0.7, -1.44, 0.49,
R_LINE_TO, -1.44, -0.56,
R_ARC_TO, 8.54, 8.54, 0, 0, 1, -0.62, 0.36,
R_LINE_TO, -0.22, 1.49,
R_CUBIC_TO, -0.08, 0.53, -0.58, 0.95, -1.17, 0.95,
CLOSE,
R_MOVE_TO, -2.53, -2,
R_H_LINE_TO, 2.11,
R_LINE_TO, 0.28, -1.85,
R_LINE_TO, 0.41, -0.16,
R_CUBIC_TO, 0.34, -0.13, 0.67, -0.32, 1.03, -0.57,
R_LINE_TO, 0.35, -0.25,
R_LINE_TO, 1.82, 0.7,
LINE_TO, 16, 12.12,
R_LINE_TO, -1.55, -1.15,
R_LINE_TO, 0.05, -0.41,
R_CUBIC_TO, 0.02, -0.19, 0.05, -0.37, 0.05, -0.57,
R_CUBIC_TO, 0, -0.2, -0.02, -0.38, -0.05, -0.57,
R_LINE_TO, -0.05, -0.41,
LINE_TO, 16, 7.88,
R_LINE_TO, -1.06, -1.74,
R_LINE_TO, -1.83, 0.7,
R_LINE_TO, -0.34, -0.25,
R_ARC_TO, 4.63, 4.63, 0, 0, 0, -1.02, -0.56,
R_LINE_TO, -0.4, -0.16,
LINE_TO, 11.06, 4,
H_LINE_TO, 8.95,
R_LINE_TO, -0.28, 1.86,
R_LINE_TO, -0.41, 0.15,
R_ARC_TO, 4.91, 4.91, 0, 0, 0, -1.03, 0.57,
R_LINE_TO, -0.34, 0.24,
R_LINE_TO, -1.82, -0.69,
LINE_TO, 4, 7.87,
R_LINE_TO, 1.56, 1.15,
R_LINE_TO, -0.05, 0.41,
R_CUBIC_TO, -0.02, 0.19, -0.05, 0.39, -0.05, 0.57,
R_CUBIC_TO, 0, 0.19, 0.02, 0.39, 0.05, 0.57,
R_LINE_TO, 0.05, 0.41,
LINE_TO, 4, 12.12,
R_LINE_TO, 1.06, 1.75,
R_LINE_TO, 1.83, -0.7,
R_LINE_TO, 0.35, 0.26,
R_CUBIC_TO, 0.33, 0.24, 0.66, 0.42, 1.02, 0.56,
R_LINE_TO, 0.41, 0.16,
LINE_TO, 8.95, 16,
CLOSE,
MOVE_TO, 10, 12.5,
R_ARC_TO, 2.5, 2.5, 0, 1, 0, 0, -5,
R_ARC_TO, 2.5, 2.5, 0, 0, 0, 0, 5,
CLOSE

@ -385,11 +385,6 @@ class FullRestoreAppLaunchHandlerTestBase
l10n_util::GetStringUTF16(IDS_POLICY_DEVICE_POST_REBOOT_TITLE));
}
void SimulateClick(RestoreNotificationButtonIndex action_index) {
FullRestoreServiceFactory::GetForProfile(profile())->Click(
static_cast<int>(action_index), std::nullopt);
}
void ResetRestoreForTesting() { scoped_restore_for_testing_.reset(); }
protected:
@ -643,113 +638,6 @@ IN_PROC_BROWSER_TEST_F(FullRestoreAppLaunchHandlerBrowserTest,
EXPECT_EQ(count + 2, BrowserList::GetInstance()->size());
}
// Verify the restore data is saved when the restore button is clicked and the
// restore finishes.
IN_PROC_BROWSER_TEST_F(FullRestoreAppLaunchHandlerBrowserTest,
RestoreAndLaunchBrowserWithClickRestore) {
// TODO(http://b/328779923): This test tests clicking a notification that will
// not be shown if this feature is enabled. Remove this test once this feature
// can no longer be disabled.
if (ash::features::IsForestFeatureEnabled()) {
GTEST_SKIP() << "Skipping test body for Forest Feature.";
}
base::HistogramTester histogram_tester;
size_t count = BrowserList::GetInstance()->size();
// Add the chrome browser launch info.
SaveBrowserAppLaunchInfo(kWindowId1);
SaveBrowserAppLaunchInfo(kWindowId2, /*app_type_browser=*/true);
AppLaunchInfoSaveWaiter::Wait();
::full_restore::FullRestoreSaveHandler::GetInstance()->ClearForTesting();
// Set the restore pref setting as 'Ask every time'.
profile()->GetPrefs()->SetInteger(
prefs::kRestoreAppsAndPagesPrefName,
static_cast<int>(RestoreOption::kAskEveryTime));
// Create FullRestoreAppLaunchHandler to simulate the system startup.
auto* full_restore_service =
FullRestoreServiceFactory::GetForProfile(profile());
full_restore_service->SetAppLaunchHandlerForTesting(
std::make_unique<FullRestoreAppLaunchHandler>(
profile(), /*should_init_service=*/true));
auto* app_launch_handler1 = full_restore_service->app_launch_handler();
app_launch_handler1->LaunchBrowserWhenReady(/*first_run_full_restore=*/false);
content::RunAllTasksUntilIdle();
EXPECT_TRUE(HasNotificationFor(kRestoreNotificationId));
SimulateClick(RestoreNotificationButtonIndex::kRestore);
content::RunAllTasksUntilIdle();
// Verify there is new browser launched.
EXPECT_EQ(count + 1, BrowserList::GetInstance()->size());
AppLaunchInfoSaveWaiter::Wait(/*allow_save*/ false);
::full_restore::FullRestoreSaveHandler::GetInstance()->ClearForTesting();
// Create FullRestoreAppLaunchHandler to simulate the system startup again.
auto app_launch_handler2 =
std::make_unique<FullRestoreAppLaunchHandler>(profile());
app_launch_handler2->LaunchBrowserWhenReady(/*first_run_full_restore=*/false);
content::RunAllTasksUntilIdle();
SetShouldRestore(app_launch_handler2.get());
content::RunAllTasksUntilIdle();
// Verify there is a new browser launched again.
EXPECT_EQ(count + 2, BrowserList::GetInstance()->size());
histogram_tester.ExpectBucketCount(
"Ash.PostLoginGlanceables.HypotheticalFetchEvent.NoDelay", 0,
/*expected_bucket_count=*/1);
}
// Verify the restore notification is shown with post reboot notification title
// when |kShowPostRebootNotification| pref is set.
IN_PROC_BROWSER_TEST_F(FullRestoreAppLaunchHandlerBrowserTest,
RestoreWithPostRebootTitle) {
// TODO(http://b/328779923): This test tests checking a notification that will
// not be shown if forest feature is enabled. Remove this test once forest
// feature can no longer be disabled.
if (ash::features::IsForestFeatureEnabled()) {
GTEST_SKIP() << "Skipping test body for Forest Feature.";
}
base::HistogramTester histogram_tester;
// Add the chrome browser launch info.
SaveBrowserAppLaunchInfo(kWindowId1);
SaveBrowserAppLaunchInfo(kWindowId2, /*app_type_browser=*/true);
AppLaunchInfoSaveWaiter::Wait();
::full_restore::FullRestoreSaveHandler::GetInstance()->ClearForTesting();
// Set the restore pref setting as 'Ask every time'.
profile()->GetPrefs()->SetInteger(
prefs::kRestoreAppsAndPagesPrefName,
static_cast<int>(RestoreOption::kAskEveryTime));
// Set the pref for showing post reboot notification.
profile()->GetPrefs()->SetBoolean(prefs::kShowPostRebootNotification, true);
// Create FullRestoreAppLaunchHandler to simulate the system startup.
auto* full_restore_service =
FullRestoreServiceFactory::GetForProfile(profile());
full_restore_service->SetAppLaunchHandlerForTesting(
std::make_unique<FullRestoreAppLaunchHandler>(
profile(), /*should_init_service=*/true));
auto* app_launch_handler1 = full_restore_service->app_launch_handler();
app_launch_handler1->LaunchBrowserWhenReady(/*first_run_full_restore=*/false);
content::RunAllTasksUntilIdle();
EXPECT_TRUE(HasNotificationFor(kRestoreNotificationId));
VerifyPostRebootNotificationTitle(kRestoreNotificationId);
EXPECT_FALSE(HasNotificationFor(kPostRebootNotificationId));
histogram_tester.ExpectBucketCount(
"Ash.PostLoginGlanceables.HypotheticalFetchEvent.NoDelay", 0,
/*expected_bucket_count=*/1);
}
IN_PROC_BROWSER_TEST_F(FullRestoreAppLaunchHandlerBrowserTest,
RestoreAndNoBrowserLaunchInfo) {
size_t count = BrowserList::GetInstance()->size();

@ -13,14 +13,10 @@
#include "ash/constants/ash_pref_names.h"
#include "ash/constants/ash_switches.h"
#include "ash/constants/notifier_catalogs.h"
#include "ash/constants/web_app_id_constants.h"
#include "ash/glanceables/post_login_glanceables_metrics_recorder.h"
#include "ash/public/cpp/notification_utils.h"
#include "ash/public/cpp/session/session_controller.h"
#include "ash/shell.h"
#include "ash/webui/settings/public/constants/routes.mojom.h"
#include "ash/webui/settings/public/constants/setting.mojom-shared.h"
#include "ash/wm/desks/templates/saved_desk_controller.h"
#include "ash/wm/window_restore/informed_restore_controller.h"
#include "ash/wm/window_restore/window_restore_metrics.h"
@ -33,23 +29,18 @@
#include "base/trace_event/trace_event.h"
#include "base/version.h"
#include "base/version_info/version_info.h"
#include "chrome/app/vector_icons/vector_icons.h"
#include "chrome/browser/ash/app_restore/app_restore_arc_task_handler.h"
#include "chrome/browser/ash/app_restore/app_restore_arc_task_handler_factory.h"
#include "chrome/browser/ash/app_restore/full_restore_app_launch_handler.h"
#include "chrome/browser/ash/app_restore/full_restore_data_handler.h"
#include "chrome/browser/ash/app_restore/full_restore_prefs.h"
#include "chrome/browser/ash/app_restore/new_user_restore_pref_handler.h"
#include "chrome/browser/ash/policy/scheduled_task_handler/reboot_notifications_scheduler.h"
#include "chrome/browser/ash/profiles/profile_helper.h"
#include "chrome/browser/first_run/first_run.h"
#include "chrome/browser/lifetime/termination_notification.h"
#include "chrome/browser/notifications/notification_display_service.h"
#include "chrome/browser/notifications/notification_display_service_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/sessions/app_session_service_factory.h"
#include "chrome/browser/sessions/session_service_factory.h"
#include "chrome/browser/ui/settings_window_manager_chromeos.h"
#include "chrome/browser/web_applications/web_app_utils.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/grit/branded_strings.h"
@ -69,9 +60,6 @@
#include "components/url_formatter/url_formatter.h"
#include "components/user_manager/user.h"
#include "components/user_manager/user_manager.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/chromeos/devicetype_utils.h"
#include "ui/message_center/public/cpp/notification.h"
// Enable VLOG level 1.
#undef ENABLED_VLOG_LEVEL
@ -96,16 +84,6 @@ constexpr char kRestoreInitSettingHistogramName[] = "Apps.RestoreInitSetting";
constexpr char kFullRestoreWindowCountHistogramName[] =
"Apps.FullRestoreWindowCount2";
// If the reboot occurred due to DeviceScheduledRebootPolicy, change the title
// to notify the user that the device was rebooted by the administrator.
int GetRestoreNotificationTitleId(Profile* profile) {
if (policy::RebootNotificationsScheduler::ShouldShowPostRebootNotification(
profile)) {
return IDS_POLICY_DEVICE_POST_REBOOT_TITLE;
}
return IDS_RESTORE_NOTIFICATION_TITLE;
}
// Returns true if `profile` is the primary user profile.
bool IsPrimaryUser(Profile* profile) {
return ProfileHelper::Get()->GetUserByProfile(profile) ==
@ -122,13 +100,6 @@ void MaybeInitiateAdminTemplateAutoLaunch() {
} // namespace
const char kRestoreForCrashNotificationId[] = "restore_for_crash_notification";
const char kRestoreNotificationId[] = "restore_notification";
const char kRestoreNotificationHistogramName[] = "Apps.RestoreNotification";
const char kRestoreForCrashNotificationHistogramName[] =
"Apps.RestoreForCrashNotification";
class DelegateImpl : public FullRestoreService::Delegate {
public:
DelegateImpl() = default;
@ -277,8 +248,7 @@ void FullRestoreService::Init(bool& show_notification) {
// over update but we do the computations to store the pref for the next
// session here first. The pref may not be registered in certain unit tests.
bool is_update = false;
if (features::IsForestFeatureEnabled() &&
prefs->HasPrefPath(prefs::kInformedRestoreLastVersion)) {
if (prefs->HasPrefPath(prefs::kInformedRestoreLastVersion)) {
const base::Version old_version(
prefs->GetString(prefs::kInformedRestoreLastVersion));
const base::Version current_version = version_info::GetVersion();
@ -293,13 +263,13 @@ void FullRestoreService::Init(bool& show_notification) {
// TODO(crbug.com/388309832): Determine if we should show a notification for
// crashes if always or never restore setting is set for forest.
if (features::IsForestFeatureEnabled() && !IsAskEveryTime(prefs)) {
if (!IsAskEveryTime(prefs)) {
return;
}
// If the system crashed before reboot, show the crash notification.
MaybeShowRestoreNotification(
InformedRestoreContentsData::DialogType::kCrash, show_notification);
MaybeShowRestoreDialog(InformedRestoreContentsData::DialogType::kCrash,
show_notification);
return;
}
@ -343,14 +313,12 @@ void FullRestoreService::Init(bool& show_notification) {
const auto dialog_type =
is_update ? InformedRestoreContentsData::DialogType::kUpdate
: InformedRestoreContentsData::DialogType::kNormal;
MaybeShowRestoreNotification(dialog_type, show_notification);
MaybeShowRestoreDialog(dialog_type, show_notification);
MaybeInitiateAdminTemplateAutoLaunch();
break;
}
case RestoreOption::kDoNotRestore: {
if (features::IsForestFeatureEnabled()) {
MaybeShowInformedRestoreOnboarding(/*restore_on=*/false);
}
MaybeShowInformedRestoreOnboarding(/*restore_on=*/false);
::full_restore::FullRestoreSaveHandler::GetInstance()->AllowSave();
MaybeInitiateAdminTemplateAutoLaunch();
return;
@ -388,12 +356,6 @@ void FullRestoreService::MaybeCloseNotification(bool allow_save) {
// shutdown process.
crashed_lock_.reset();
if (notification_ && !is_shut_down_) {
NotificationDisplayServiceFactory::GetForProfile(profile_)->Close(
NotificationHandler::Type::TRANSIENT, notification_->id());
accelerator_controller_observer_.Reset();
}
if (allow_save) {
// If the user launches an app or clicks the cancel button, start the save
// timer.
@ -406,81 +368,6 @@ void FullRestoreService::Restore() {
app_launch_handler_->SetShouldRestore();
}
void FullRestoreService::Close(bool by_user) {
if (!skip_notification_histogram_) {
RecordRestoreAction(
notification_->id(),
by_user ? RestoreAction::kCloseByUser : RestoreAction::kCloseNotByUser);
}
notification_ = nullptr;
if (by_user) {
// If the user closes the notification, start the save timer. If it is not
// closed by the user, the restore button might be clicked, then we need to
// wait for the restore finish to start the save timer.
::full_restore::FullRestoreSaveHandler::GetInstance()->AllowSave();
}
}
void FullRestoreService::Click(const std::optional<int>& button_index,
const std::optional<std::u16string>& reply) {
DCHECK(notification_);
skip_notification_histogram_ = true;
if (!button_index.has_value() ||
button_index.value() ==
static_cast<int>(RestoreNotificationButtonIndex::kRestore)) {
VLOG(1) << "The restore notification is clicked for "
<< profile_->GetPath();
// Restore if the user clicks the notification body.
RecordRestoreAction(notification_->id(), RestoreAction::kRestore);
Restore();
// If the user selects restore, don't start the save timer. Wait for the
// restore finish.
MaybeCloseNotification(/*allow_save=*/false);
return;
}
if (notification_->id() == kRestoreNotificationId) {
// Show the 'On Startup' OS setting page if the user clicks the settings
// button of the restore notification.
chrome::SettingsWindowManager::GetInstance()->ShowOSSettings(
profile_, chromeos::settings::mojom::kSystemPreferencesSectionPath,
chromeos::settings::mojom::Setting::kRestoreAppsAndPages);
return;
}
VLOG(1) << "The crash restore notification is canceled for "
<< profile_->GetPath();
// Close the crash notification if the user clicks the cancel button of the
// crash notification.
RecordRestoreAction(notification_->id(), RestoreAction::kCancel);
MaybeCloseNotification();
}
void FullRestoreService::OnActionPerformed(AcceleratorAction action) {
switch (action) {
case AcceleratorAction::kNewIncognitoWindow:
case AcceleratorAction::kNewTab:
case AcceleratorAction::kNewWindow:
case AcceleratorAction::kOpenCrosh:
case AcceleratorAction::kOpenDiagnostics:
case AcceleratorAction::kRestoreTab:
MaybeCloseNotification();
return;
default:
return;
}
}
void FullRestoreService::OnAcceleratorControllerWillBeDestroyed(
AcceleratorController* controller) {
accelerator_controller_observer_.Reset();
}
void FullRestoreService::OnSessionStateChanged(
session_manager::SessionState state) {
if (!contents_data_) {
@ -597,9 +484,9 @@ void FullRestoreService::InitInformedRestoreContentsData(
}
}
void FullRestoreService::MaybeShowRestoreNotification(
void FullRestoreService::MaybeShowRestoreDialog(
InformedRestoreContentsData::DialogType dialog_type,
bool& show_notification) {
bool& out_show_notification) {
if (g_last_session_sanitized) {
return;
}
@ -608,12 +495,6 @@ void FullRestoreService::MaybeShowRestoreNotification(
return;
}
// Do not show the notification if we have no restore data.
if (!features::IsForestFeatureEnabled() &&
!app_launch_handler_->HasRestoreData()) {
return;
}
// Do not show the notification if it is the first run or the notification is
// being closed.
if (::first_run::IsChromeFirstRun() || close_notification_) {
@ -631,10 +512,7 @@ void FullRestoreService::MaybeShowRestoreNotification(
return;
}
const std::string id = last_session_crashed ? kRestoreForCrashNotificationId
: kRestoreNotificationId;
if (!app_launch_handler_->HasRestoreData()) {
CHECK(features::IsForestFeatureEnabled());
MaybeShowInformedRestoreOnboarding(/*restore_on=*/true);
return;
}
@ -654,107 +532,34 @@ void FullRestoreService::MaybeShowRestoreNotification(
->RecordPostLoginFullRestoreShown();
}
if (features::IsForestFeatureEnabled()) {
CHECK(delegate_);
CHECK(delegate_);
InitInformedRestoreContentsData(dialog_type);
InitInformedRestoreContentsData(dialog_type);
// Retrieves session service data from browser and app browsers, which
// will be used to display favicons and tab titles.
SessionServiceBase* service =
SessionServiceFactory::GetForProfileForSessionRestore(profile_);
SessionServiceBase* app_service =
AppSessionServiceFactory::GetForProfileForSessionRestore(profile_);
if (service && app_service) {
auto barrier = base::BarrierCallback<SessionWindows>(
/*num_callbacks=*/2u, /*done_callback=*/base::BindOnce(
&FullRestoreService::OnGotAllSessionsAsh,
weak_ptr_factory_.GetWeakPtr()));
// Retrieves session service data from browser and app browsers, which
// will be used to display favicons and tab titles.
SessionServiceBase* service =
SessionServiceFactory::GetForProfileForSessionRestore(profile_);
SessionServiceBase* app_service =
AppSessionServiceFactory::GetForProfileForSessionRestore(profile_);
if (service && app_service) {
auto barrier = base::BarrierCallback<SessionWindows>(
/*num_callbacks=*/2u, /*done_callback=*/base::BindOnce(
&FullRestoreService::OnGotAllSessionsAsh,
weak_ptr_factory_.GetWeakPtr()));
service->GetLastSession(
base::BindOnce(&FullRestoreService::OnGotSessionAsh,
weak_ptr_factory_.GetWeakPtr(), barrier));
app_service->GetLastSession(
base::BindOnce(&FullRestoreService::OnGotSessionAsh,
weak_ptr_factory_.GetWeakPtr(), barrier));
} else {
OnGotAllSessionsAsh(/*all_session_windows=*/{});
}
// Set to true as we might want to show the post reboot notification.
show_notification = true;
return;
}
// For forest, we will handle closing the dialog on the ash side.
if (auto* accelerator_controller = AcceleratorController::Get()) {
CHECK(!accelerator_controller_observer_.IsObserving());
accelerator_controller_observer_.Observe(accelerator_controller);
}
message_center::RichNotificationData notification_data;
message_center::ButtonInfo restore_button(
l10n_util::GetStringUTF16(IDS_RESTORE_NOTIFICATION_RESTORE_BUTTON));
notification_data.buttons.push_back(restore_button);
int button_id;
if (id == kRestoreForCrashNotificationId)
button_id = IDS_RESTORE_NOTIFICATION_CANCEL_BUTTON;
else
button_id = IDS_RESTORE_NOTIFICATION_SETTINGS_BUTTON;
message_center::ButtonInfo cancel_button(
l10n_util::GetStringUTF16(button_id));
notification_data.buttons.push_back(cancel_button);
std::u16string title;
if (id == kRestoreForCrashNotificationId) {
title = l10n_util::GetStringFUTF16(IDS_RESTORE_CRASH_NOTIFICATION_TITLE,
ui::GetChromeOSDeviceName());
VLOG(1) << "Show the restore notification for crash for "
<< profile_->GetPath();
service->GetLastSession(base::BindOnce(&FullRestoreService::OnGotSessionAsh,
weak_ptr_factory_.GetWeakPtr(),
barrier));
app_service->GetLastSession(
base::BindOnce(&FullRestoreService::OnGotSessionAsh,
weak_ptr_factory_.GetWeakPtr(), barrier));
} else {
title = l10n_util::GetStringUTF16(GetRestoreNotificationTitleId(profile_));
VLOG(1) << "Show the restore notification for the normal startup for "
<< profile_->GetPath();
OnGotAllSessionsAsh(/*all_session_windows=*/{});
}
int message_id;
if (id == kRestoreForCrashNotificationId)
message_id = IDS_RESTORE_CRASH_NOTIFICATION_MESSAGE;
else
message_id = IDS_RESTORE_NOTIFICATION_MESSAGE;
notification_ = CreateSystemNotificationPtr(
message_center::NOTIFICATION_TYPE_SIMPLE, id, title,
l10n_util::GetStringUTF16(message_id),
l10n_util::GetStringUTF16(IDS_RESTORE_NOTIFICATION_DISPLAY_SOURCE),
GURL(),
message_center::NotifierId(message_center::NotifierType::SYSTEM_COMPONENT,
id, NotificationCatalogName::kFullRestore),
notification_data,
base::MakeRefCounted<message_center::ThunkNotificationDelegate>(
weak_ptr_factory_.GetWeakPtr()),
kFullRestoreNotificationIcon,
message_center::SystemNotificationWarningLevel::NORMAL);
notification_->set_priority(message_center::SYSTEM_PRIORITY);
auto* notification_display_service =
NotificationDisplayServiceFactory::GetForProfile(profile_);
DCHECK(notification_display_service);
notification_display_service->Display(NotificationHandler::Type::TRANSIENT,
*notification_,
/*metadata=*/nullptr);
base::UmaHistogramBoolean(kFullRestoreNotificationHistogram, true);
show_notification = true;
}
void FullRestoreService::RecordRestoreAction(const std::string& notification_id,
RestoreAction restore_action) {
base::UmaHistogramEnumeration(notification_id == kRestoreNotificationId
? kRestoreNotificationHistogramName
: kRestoreForCrashNotificationHistogramName,
restore_action);
// Set to true as we might want to show the post reboot notification.
out_show_notification = true;
}
void FullRestoreService::OnPreferenceChanged(const std::string& pref_name) {

@ -8,7 +8,6 @@
#include <memory>
#include <optional>
#include "ash/public/cpp/accelerators.h"
#include "ash/public/cpp/session/session_observer.h"
#include "ash/wm/window_restore/informed_restore_contents_data.h"
#include "base/callback_list.h"
@ -20,7 +19,6 @@
#include "components/keyed_service/core/keyed_service.h"
#include "components/prefs/pref_change_registrar.h"
#include "components/sessions/core/session_types.h"
#include "ui/message_center/public/cpp/notification_delegate.h"
class Profile;
@ -28,20 +26,12 @@ namespace app_restore {
class RestoreData;
} // namespace app_restore
namespace message_center {
class Notification;
} // namespace message_center
namespace ash::full_restore {
class FullRestoreAppLaunchHandler;
class FullRestoreDataHandler;
class NewUserRestorePrefHandler;
extern const char kRestoreForCrashNotificationId[];
extern const char kRestoreNotificationId[];
extern const char kSetRestorePrefNotificationId[];
// The restore notification button index.
enum class RestoreNotificationButtonIndex {
kRestore = 0,
@ -64,8 +54,6 @@ enum class RestoreAction {
// The FullRestoreService class calls AppService and Window Management
// interfaces to restore the app launchings and app windows.
class FullRestoreService : public KeyedService,
public message_center::NotificationObserver,
public AcceleratorController::Observer,
public SessionObserver {
public:
// Delegate class that talks to ash shell. Ash shell is not created in
@ -111,16 +99,6 @@ class FullRestoreService : public KeyedService,
// Implement the restoration.
void Restore();
// message_center::NotificationObserver:
void Close(bool by_user) override;
void Click(const std::optional<int>& button_index,
const std::optional<std::u16string>& reply) override;
// AcceleratorController::Observer:
void OnActionPerformed(AcceleratorAction action) override;
void OnAcceleratorControllerWillBeDestroyed(
AcceleratorController* controller) override;
// SessionObserver:
void OnSessionStateChanged(session_manager::SessionState state) override;
@ -153,12 +131,9 @@ class FullRestoreService : public KeyedService,
InformedRestoreContentsData::DialogType dialog_type);
// Shows the restore notification or the informed restore dialog on startup.
void MaybeShowRestoreNotification(
void MaybeShowRestoreDialog(
InformedRestoreContentsData::DialogType dialog_type,
bool& show_notification);
void RecordRestoreAction(const std::string& notification_id,
RestoreAction restore_action);
bool& out_show_notification);
// Callback used when the pref |kRestoreAppsAndPagesPrefName| changes.
void OnPreferenceChanged(const std::string& pref_name);
@ -210,11 +185,6 @@ class FullRestoreService : public KeyedService,
// Specifies whether it is the first time to run the full restore feature.
bool first_run_full_restore_ = false;
// If the user clicks a notification button, set
// |skip_notification_histogram_| as true to skip the notification close
// histogram.
bool skip_notification_histogram_ = false;
std::unique_ptr<NewUserRestorePrefHandler> new_user_pref_handler_;
// |app_launch_handler_| is responsible for launching apps based on the
@ -228,8 +198,6 @@ class FullRestoreService : public KeyedService,
// session.
std::unique_ptr<InformedRestoreContentsData> contents_data_;
std::unique_ptr<message_center::Notification> notification_;
std::unique_ptr<Delegate> delegate_;
base::CallbackListSubscription on_app_terminating_subscription_;
@ -238,10 +206,6 @@ class FullRestoreService : public KeyedService,
// system is restored from crash to help set the browser saving flag.
std::unique_ptr<ExitTypeService::CrashedLock> crashed_lock_;
base::ScopedObservation<AcceleratorController,
AcceleratorController::Observer>
accelerator_controller_observer_{this};
base::WeakPtrFactory<FullRestoreService> weak_ptr_factory_{this};
};

@ -174,14 +174,6 @@ void RebootNotificationsScheduler::RegisterProfilePrefs(
registry->RegisterBooleanPref(ash::prefs::kShowPostRebootNotification, false);
}
// static
bool RebootNotificationsScheduler::ShouldShowPostRebootNotification(
Profile* profile) {
DCHECK(profile);
PrefService* prefs = user_prefs::UserPrefs::Get(profile);
return IsPostRebootPrefSet(prefs);
}
void RebootNotificationsScheduler::SchedulePendingRebootNotifications(
RebootButtonCallback reboot_button_callback,
const base::Time& reboot_time,

@ -60,10 +60,6 @@ class RebootNotificationsScheduler
// Registers boolean pref for showing post reboot notification.
static void RegisterProfilePrefs(PrefRegistrySimple* registry);
// Returns true if the pref for showing the post reboot notification is set
// for the |profile|.
static bool ShouldShowPostRebootNotification(Profile* profile);
// Schedules timers for showing pending reboot notification and dialog or
// shows them right away if the scheduled reboot time is soon. If there
// already is a scheduled notification, either reschedules notification or

@ -20893,7 +20893,7 @@ Called by update_net_error_codes.py.-->
<int value="117" label="Network Portal Detector"/>
<int value="118" label="Crostini Package"/>
<int value="119" label="Crostini Upgrade Available"/>
<int value="120" label="Full Restore"/>
<int value="120" label="(deprecated) Full Restore"/>
<int value="121" label="Adb Sideloading Disallowed"/>
<int value="122" label="Adb Sideloading Powerwash Planned"/>
<int value="123" label="Adb Sideloading Powerwash On Reboot"/>

@ -2825,17 +2825,6 @@ chromium-metrics-reviews@google.com.
</summary>
</histogram>
<histogram name="Apps.RestoreForCrashNotification" enum="RestoreAction"
expires_after="2025-10-15">
<owner>dandersson@chromium.org</owner>
<owner>fanafan@chromium.org</owner>
<owner>chromeos-wm-corexp@google.com</owner>
<summary>
Records user actions on the full restore for crash notification, when the
notification is closed.
</summary>
</histogram>
<histogram name="Apps.RestoreInitSetting" enum="RestoreSetting"
expires_after="2025-10-15">
<owner>dandersson@chromium.org</owner>
@ -2847,16 +2836,6 @@ chromium-metrics-reviews@google.com.
</summary>
</histogram>
<histogram name="Apps.RestoreNotification" enum="RestoreAction"
expires_after="2025-09-14">
<owner>nancylingwang@chromium.org</owner>
<owner>dandersson@chromium.org</owner>
<summary>
Records user actions on the full restore notification, when the notification
is closed.
</summary>
</histogram>
<histogram name="Apps.RestoreSetting" enum="RestoreSetting"
expires_after="2025-10-15">
<owner>dandersson@chromium.org</owner>

@ -4071,13 +4071,6 @@ chromium-metrics-reviews@google.com.
</summary>
</histogram>
<histogram name="Ash.FullRestore.ShowFullRestoreNotification" enum="BooleanHit"
expires_after="2025-09-21">
<owner>dandersson@chromium.org</owner>
<owner>xdai@chromium.org</owner>
<summary>Emitted every time the full restore notification shows up.</summary>
</histogram>
<histogram name="Ash.FullRestore.ShowInformedRestoreDialog" enum="BooleanHit"
expires_after="2025-09-21">
<owner>hewer@chromium.org</owner>