Implement WebContenstAudioMuted in AtomBrowserClient
This commit is contained in:
parent
54f06b0ba9
commit
4f660f3e6f
3 changed files with 9 additions and 11 deletions
|
@ -303,6 +303,13 @@ void AtomBrowserClient::WebNotificationAllowed(
|
|||
permission_helper->RequestWebNotificationPermission(callback);
|
||||
}
|
||||
|
||||
bool AtomBrowserClient::WebContentsAudioMuted(
|
||||
int render_process_id) {
|
||||
content::WebContents* web_contents =
|
||||
WebContentsPreferences::GetWebContentsFromProcessID(render_process_id);
|
||||
return web_contents->IsAudioMuted();
|
||||
}
|
||||
|
||||
void AtomBrowserClient::RenderProcessHostDestroyed(
|
||||
content::RenderProcessHost* host) {
|
||||
int process_id = host->GetID();
|
||||
|
|
|
@ -101,6 +101,8 @@ class AtomBrowserClient : public brightray::BrowserClient,
|
|||
void WebNotificationAllowed(
|
||||
int render_process_id,
|
||||
const base::Callback<void(bool)>& callback) override;
|
||||
bool WebContentsAudioMuted(
|
||||
int render_process_id) override;
|
||||
|
||||
// content::RenderProcessHostObserver:
|
||||
void RenderProcessHostDestroyed(content::RenderProcessHost* host) override;
|
||||
|
|
|
@ -248,14 +248,3 @@ Object.defineProperty(document, 'visibilityState', {
|
|||
return cachedVisibilityState
|
||||
}
|
||||
})
|
||||
|
||||
// Make notifications silent if the the current webContents is muted
|
||||
const NativeNotification = window.Notification
|
||||
class Notification extends NativeNotification {
|
||||
constructor (title, opts) {
|
||||
super(title, Object.assign({
|
||||
silent: remote.getCurrentWebContents().isAudioMuted()
|
||||
}, opts))
|
||||
}
|
||||
}
|
||||
window.Notification = Notification
|
||||
|
|
Loading…
Add table
Reference in a new issue