diff --git a/chrome/browser/chromeos/chrome_browser_main_chromeos.cc b/chrome/browser/chromeos/chrome_browser_main_chromeos.cc index 1a0253548f6f42..2c5ceb55572d6c 100644 --- a/chrome/browser/chromeos/chrome_browser_main_chromeos.cc +++ b/chrome/browser/chromeos/chrome_browser_main_chromeos.cc @@ -738,6 +738,9 @@ void ChromeBrowserMainPartsChromeos::PreMainMessageLoopRun() { chromeos::ResourceReporter::GetInstance()->StartMonitoring( task_manager::TaskManagerInterface::GetTaskManager()); + if (!base::FeatureList::IsEnabled(features::kNativeNotifications)) + notification_client_.reset(NotificationPlatformBridge::Create()); + ChromeBrowserMainPartsLinux::PreMainMessageLoopRun(); } @@ -886,9 +889,6 @@ void ChromeBrowserMainPartsChromeos::PreProfileInit() { message_center::MessageCenter::Get()->SetProductOSName( l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_OS_NAME)); - if (!base::FeatureList::IsEnabled(features::kNativeNotifications)) - notification_client_.reset(NotificationPlatformBridge::Create()); - // Register all installed components for regular update. base::PostTaskWithTraitsAndReplyWithResult( FROM_HERE, {base::MayBlock()}, @@ -1193,6 +1193,9 @@ void ChromeBrowserMainPartsChromeos::PostMainMessageLoopRun() { g_browser_process->platform_part()->browser_policy_connector_chromeos()-> PreShutdown(); + // Close the notification client before destroying the profile manager. + notification_client_.reset(); + // NOTE: Closes ash and destroys ash::Shell. ChromeBrowserMainPartsLinux::PostMainMessageLoopRun(); diff --git a/chrome/browser/notifications/arc_application_notifier_controller_chromeos.cc b/chrome/browser/notifications/arc_application_notifier_controller_chromeos.cc index ef2a540ef5d9e1..8623f6b24013dc 100644 --- a/chrome/browser/notifications/arc_application_notifier_controller_chromeos.cc +++ b/chrome/browser/notifications/arc_application_notifier_controller_chromeos.cc @@ -7,9 +7,7 @@ #include #include "base/strings/utf_string_conversions.h" -#include "chrome/browser/browser_process.h" #include "chrome/browser/profiles/profile.h" -#include "chrome/browser/profiles/profile_manager.h" #include "ui/base/layout.h" #include "ui/display/display.h" #include "ui/display/screen.h" @@ -33,6 +31,7 @@ ArcApplicationNotifierControllerChromeOS:: std::vector ArcApplicationNotifierControllerChromeOS::GetNotifierList(Profile* profile) { + DCHECK(!profile->IsOffTheRecord()); package_to_app_ids_.clear(); icons_.clear(); StopObserving(); @@ -112,14 +111,8 @@ void ArcApplicationNotifierControllerChromeOS::OnIconUpdated(ArcAppIcon* icon) { void ArcApplicationNotifierControllerChromeOS::StopObserving() { if (!last_profile_) return; - - // This is also called from the destructor during shutdown. In that case, the - // profile manager and the profiles are already destroyed. (see Issue 783538) - if (g_browser_process->profile_manager() && - g_browser_process->profile_manager()->IsValidProfile(last_profile_)) { - ArcAppListPrefs* const app_list = ArcAppListPrefs::Get(last_profile_); - app_list->RemoveObserver(this); - } + ArcAppListPrefs* const app_list = ArcAppListPrefs::Get(last_profile_); + app_list->RemoveObserver(this); last_profile_ = nullptr; }