Avoid calling GetWebContentsFromProcessID for twice
This commit is contained in:
parent
b0faa62f76
commit
14c4be50c1
3 changed files with 7 additions and 15 deletions
|
@ -287,29 +287,23 @@ brightray::BrowserMainParts* AtomBrowserClient::OverrideCreateBrowserMainParts(
|
||||||
|
|
||||||
void AtomBrowserClient::WebNotificationAllowed(
|
void AtomBrowserClient::WebNotificationAllowed(
|
||||||
int render_process_id,
|
int render_process_id,
|
||||||
const base::Callback<void(bool)>& callback) {
|
const base::Callback<void(bool, bool)>& callback) {
|
||||||
content::WebContents* web_contents =
|
content::WebContents* web_contents =
|
||||||
WebContentsPreferences::GetWebContentsFromProcessID(render_process_id);
|
WebContentsPreferences::GetWebContentsFromProcessID(render_process_id);
|
||||||
if (!web_contents) {
|
if (!web_contents) {
|
||||||
callback.Run(false);
|
callback.Run(false, false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto permission_helper =
|
auto permission_helper =
|
||||||
WebContentsPermissionHelper::FromWebContents(web_contents);
|
WebContentsPermissionHelper::FromWebContents(web_contents);
|
||||||
if (!permission_helper) {
|
if (!permission_helper) {
|
||||||
callback.Run(false);
|
callback.Run(false, false);
|
||||||
return;
|
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(
|
void AtomBrowserClient::RenderProcessHostDestroyed(
|
||||||
content::RenderProcessHost* host) {
|
content::RenderProcessHost* host) {
|
||||||
int process_id = host->GetID();
|
int process_id = host->GetID();
|
||||||
|
|
|
@ -100,9 +100,7 @@ class AtomBrowserClient : public brightray::BrowserClient,
|
||||||
const content::MainFunctionParams&) override;
|
const content::MainFunctionParams&) override;
|
||||||
void WebNotificationAllowed(
|
void WebNotificationAllowed(
|
||||||
int render_process_id,
|
int render_process_id,
|
||||||
const base::Callback<void(bool)>& callback) override;
|
const base::Callback<void(bool, bool)>& callback) override;
|
||||||
bool WebContentsAudioMuted(
|
|
||||||
int render_process_id) override;
|
|
||||||
|
|
||||||
// content::RenderProcessHostObserver:
|
// content::RenderProcessHostObserver:
|
||||||
void RenderProcessHostDestroyed(content::RenderProcessHost* host) override;
|
void RenderProcessHostDestroyed(content::RenderProcessHost* host) override;
|
||||||
|
|
2
vendor/brightray
vendored
2
vendor/brightray
vendored
|
@ -1 +1 @@
|
||||||
Subproject commit f9bc45b03c94a2db729b53885691db5e04b757df
|
Subproject commit 0e8ffb4d653f9e85722bc98df7ddde9a0e6d0650
|
Loading…
Add table
Add a link
Reference in a new issue