From f7a8aa12ac228d6d14c997805083e1fda5e1b764 Mon Sep 17 00:00:00 2001 From: Samuel Attard Date: Sat, 2 Jul 2016 13:26:58 +1200 Subject: [PATCH] Patch OnWebNotificationAllowed to mark notifications as silent in muted WebContents --- brightray/browser/browser_client.h | 4 ++++ brightray/browser/platform_notification_service.cc | 8 +++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/brightray/browser/browser_client.h b/brightray/browser/browser_client.h index 46ce320bac7f..21360ba04a80 100644 --- a/brightray/browser/browser_client.h +++ b/brightray/browser/browser_client.h @@ -33,6 +33,10 @@ class BrowserClient : public content::ContentBrowserClient { callback.Run(true); } + virtual bool WebContentsAudioMuted(int render_process_id) { + return false; + } + // Subclasses that override this (e.g., to provide their own protocol // handlers) should call this implementation after doing their own work. content::BrowserMainParts* CreateBrowserMainParts( diff --git a/brightray/browser/platform_notification_service.cc b/brightray/browser/platform_notification_service.cc index 023f0a2a131c..873e82df27f1 100644 --- a/brightray/browser/platform_notification_service.cc +++ b/brightray/browser/platform_notification_service.cc @@ -22,6 +22,7 @@ void RemoveNotification(base::WeakPtr notification) { } void OnWebNotificationAllowed( + int render_process_id, brightray::BrowserClient* browser_client, const SkBitmap& icon, const content::PlatformNotificationData& data, @@ -37,8 +38,12 @@ void OnWebNotificationAllowed( new NotificationDelegateAdapter(std::move(delegate))); auto notification = presenter->CreateNotification(adapter.get()); if (notification) { + bool silent = data.silent; + if (!silent) { + silent = browser_client->WebContentsAudioMuted(render_process_id); + } ignore_result(adapter.release()); // it will release itself automatically. - notification->Show(data.title, data.body, data.tag, data.icon, icon, data.silent); + notification->Show(data.title, data.body, data.tag, data.icon, icon, silent); *cancel_callback = base::Bind(&RemoveNotification, notification); } } @@ -78,6 +83,7 @@ void PlatformNotificationService::DisplayNotification( browser_client_->WebNotificationAllowed( render_process_id_, base::Bind(&OnWebNotificationAllowed, + render_process_id_, browser_client_, notification_resources.notification_icon, notification_data,