Avoid calling GetWebContentsFromProcessID for twice

This commit is contained in:
Cheng Zhao 2016-07-02 16:54:12 +09:00
parent b0faa62f76
commit 14c4be50c1
3 changed files with 7 additions and 15 deletions

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