Commit bcd84b82 authored by Finnur Thorarinsson's avatar Finnur Thorarinsson Committed by Commit Bot

Windows Native Notifications: Fix crash in startup.

The Ready callback passed to SetReadyCallback is executed
on the task runner thread, and not the UI thread.

This causes a crash in startup when launching Chrome.

Also adding a DCHECK to catch this in tests in the
future.

Bug: 820925, 734095
Change-Id: I59d2b152bbc6538d857f3e6884544217b347885e
Reviewed-on: https://chromium-review.googlesource.com/959017
Commit-Queue: Finnur Thorarinsson <finnur@chromium.org>
Reviewed-by: default avatarPeter Beverloo <peter@chromium.org>
Cr-Commit-Position: refs/heads/master@{#542532}
parent f523bbad
...@@ -289,6 +289,7 @@ void NotificationDisplayServiceImpl::ProfileLoadedCallback( ...@@ -289,6 +289,7 @@ void NotificationDisplayServiceImpl::ProfileLoadedCallback(
void NotificationDisplayServiceImpl::OnNotificationPlatformBridgeReady( void NotificationDisplayServiceImpl::OnNotificationPlatformBridgeReady(
bool success) { bool success) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
if (base::FeatureList::IsEnabled(features::kNativeNotifications)) { if (base::FeatureList::IsEnabled(features::kNativeNotifications)) {
UMA_HISTOGRAM_BOOLEAN("Notifications.UsingNativeNotificationCenter", UMA_HISTOGRAM_BOOLEAN("Notifications.UsingNativeNotificationCenter",
success); success);
......
...@@ -480,9 +480,12 @@ class NotificationPlatformBridgeWinImpl ...@@ -480,9 +480,12 @@ class NotificationPlatformBridgeWinImpl
void SetReadyCallback( void SetReadyCallback(
NotificationPlatformBridge::NotificationBridgeReadyCallback callback) { NotificationPlatformBridge::NotificationBridgeReadyCallback callback) {
DCHECK(task_runner_->RunsTasksInCurrentSequence()); DCHECK(task_runner_->RunsTasksInCurrentSequence());
std::move(callback).Run( bool enabled = com_functions_initialized_ && IsToastActivatorRegistered() &&
com_functions_initialized_ && IsToastActivatorRegistered() && InstallUtil::IsStartMenuShortcutWithActivatorGuidInstalled();
InstallUtil::IsStartMenuShortcutWithActivatorGuidInstalled()); bool success = content::BrowserThread::PostTask(
content::BrowserThread::UI, FROM_HERE,
base::BindOnce(std::move(callback), enabled));
DCHECK(success);
} }
void HandleEvent(winui::Notifications::IToastNotification* notification, void HandleEvent(winui::Notifications::IToastNotification* notification,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment