Merge pull request #231 from MarshallOfSound/master

Patch OnWebNotificationAllowed to mark notifications as silent in muted WebContents
This commit is contained in:
Cheng Zhao 2016-07-02 07:44:30 +00:00 committed by GitHub
commit b217fb07a6
2 changed files with 11 additions and 1 deletions

View file

@ -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(

View file

@ -22,6 +22,7 @@ void RemoveNotification(base::WeakPtr<Notification> 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,