Browse Source

Implement WebContenstAudioMuted in AtomBrowserClient

Samuel Attard 8 years ago
parent
commit
4f660f3e6f

+ 7 - 0
atom/browser/atom_browser_client.cc

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

+ 2 - 0
atom/browser/atom_browser_client.h

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

+ 0 - 11
lib/renderer/override.js

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