Avoid calling GetWebContentsFromProcessID for twice
authorCheng Zhao <zcbenz@gmail.com>
Sat, 2 Jul 2016 07:54:12 +0000 (16:54 +0900)
committerCheng Zhao <zcbenz@gmail.com>
Sat, 2 Jul 2016 07:54:12 +0000 (16:54 +0900)
atom/browser/atom_browser_client.cc
atom/browser/atom_browser_client.h
vendor/brightray

index 13503ae..add3154 100644 (file)
@@ -287,29 +287,23 @@ brightray::BrowserMainParts* AtomBrowserClient::OverrideCreateBrowserMainParts(
 
 void AtomBrowserClient::WebNotificationAllowed(
     int render_process_id,
-    const base::Callback<void(bool)>& callback) {
+    const base::Callback<void(bool, bool)>& callback) {
   content::WebContents* web_contents =
       WebContentsPreferences::GetWebContentsFromProcessID(render_process_id);
   if (!web_contents) {
-    callback.Run(false);
+    callback.Run(false, false);
     return;
   }
   auto permission_helper =
       WebContentsPermissionHelper::FromWebContents(web_contents);
   if (!permission_helper) {
-    callback.Run(false);
+    callback.Run(false, false);
     return;
   }
-  permission_helper->RequestWebNotificationPermission(callback);
+  permission_helper->RequestWebNotificationPermission(
+      base::Bind(callback, web_contents->IsAudioMuted()));
 }
 
-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();
index 47d7434..a617065 100644 (file)
@@ -100,9 +100,7 @@ class AtomBrowserClient : public brightray::BrowserClient,
       const content::MainFunctionParams&) override;
   void WebNotificationAllowed(
       int render_process_id,
-      const base::Callback<void(bool)>& callback) override;
-  bool WebContentsAudioMuted(
-    int render_process_id) override;
+      const base::Callback<void(bool, bool)>& callback) override;
 
   // content::RenderProcessHostObserver:
   void RenderProcessHostDestroyed(content::RenderProcessHost* host) override;
index f9bc45b..0e8ffb4 160000 (submodule)
@@ -1 +1 @@
-Subproject commit f9bc45b03c94a2db729b53885691db5e04b757df
+Subproject commit 0e8ffb4d653f9e85722bc98df7ddde9a0e6d0650