Map pending process id to webContents for frame host initiating navigation
This commit is contained in:
parent
34c5abfe43
commit
06e60e5d4d
2 changed files with 13 additions and 19 deletions
|
@ -79,9 +79,10 @@ AtomBrowserClient::~AtomBrowserClient() {
|
||||||
|
|
||||||
content::WebContents* AtomBrowserClient::GetWebContentsFromProcessID(
|
content::WebContents* AtomBrowserClient::GetWebContentsFromProcessID(
|
||||||
int process_id) {
|
int process_id) {
|
||||||
// If the process is a pending process, we should use the old one.
|
// If the process is a pending process, we should use the web contents
|
||||||
|
// for the frame host passed into OverrideSiteInstanceForNavigation.
|
||||||
if (base::ContainsKey(pending_processes_, process_id))
|
if (base::ContainsKey(pending_processes_, process_id))
|
||||||
process_id = pending_processes_[process_id];
|
return pending_processes_[process_id];
|
||||||
|
|
||||||
// Certain render process will be created with no associated render view,
|
// Certain render process will be created with no associated render view,
|
||||||
// for example: ServiceWorker.
|
// for example: ServiceWorker.
|
||||||
|
@ -231,12 +232,12 @@ void AtomBrowserClient::OverrideSiteInstanceForNavigation(
|
||||||
content::BrowserThread::UI, FROM_HERE,
|
content::BrowserThread::UI, FROM_HERE,
|
||||||
base::Bind(&Noop, base::RetainedRef(site_instance)));
|
base::Bind(&Noop, base::RetainedRef(site_instance)));
|
||||||
|
|
||||||
// Remember the original renderer process of the pending renderer process.
|
// Remember the original web contents for the pending renderer process.
|
||||||
auto current_process = current_instance->GetProcess();
|
|
||||||
auto pending_process = (*new_instance)->GetProcess();
|
auto pending_process = (*new_instance)->GetProcess();
|
||||||
pending_processes_[pending_process->GetID()] = current_process->GetID();
|
pending_processes_[pending_process->GetID()] =
|
||||||
|
content::WebContents::FromRenderFrameHost(render_frame_host);;
|
||||||
// Clear the entry in map when process ends.
|
// Clear the entry in map when process ends.
|
||||||
current_process->AddObserver(this);
|
pending_process->AddObserver(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AtomBrowserClient::AppendExtraCommandLineSwitches(
|
void AtomBrowserClient::AppendExtraCommandLineSwitches(
|
||||||
|
@ -277,11 +278,9 @@ void AtomBrowserClient::AppendExtraCommandLineSwitches(
|
||||||
}
|
}
|
||||||
|
|
||||||
content::WebContents* web_contents = GetWebContentsFromProcessID(process_id);
|
content::WebContents* web_contents = GetWebContentsFromProcessID(process_id);
|
||||||
if (!web_contents)
|
if (web_contents)
|
||||||
return;
|
WebContentsPreferences::AppendExtraCommandLineSwitches(
|
||||||
|
web_contents, command_line);
|
||||||
WebContentsPreferences::AppendExtraCommandLineSwitches(
|
|
||||||
web_contents, command_line);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AtomBrowserClient::DidCreatePpapiPlugin(
|
void AtomBrowserClient::DidCreatePpapiPlugin(
|
||||||
|
@ -421,12 +420,7 @@ void AtomBrowserClient::WebNotificationAllowed(
|
||||||
void AtomBrowserClient::RenderProcessHostDestroyed(
|
void AtomBrowserClient::RenderProcessHostDestroyed(
|
||||||
content::RenderProcessHost* host) {
|
content::RenderProcessHost* host) {
|
||||||
int process_id = host->GetID();
|
int process_id = host->GetID();
|
||||||
for (const auto& entry : pending_processes_) {
|
pending_processes_.erase(process_id);
|
||||||
if (entry.first == process_id || entry.second == process_id) {
|
|
||||||
pending_processes_.erase(entry.first);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
RemoveProcessPreferences(process_id);
|
RemoveProcessPreferences(process_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -130,8 +130,8 @@ class AtomBrowserClient : public brightray::BrowserClient,
|
||||||
bool RendererUsesNativeWindowOpen(int process_id);
|
bool RendererUsesNativeWindowOpen(int process_id);
|
||||||
bool RendererDisablesPopups(int process_id);
|
bool RendererDisablesPopups(int process_id);
|
||||||
|
|
||||||
// pending_render_process => current_render_process.
|
// pending_render_process => web contents.
|
||||||
std::map<int, int> pending_processes_;
|
std::map<int, content::WebContents*> pending_processes_;
|
||||||
|
|
||||||
std::map<int, ProcessPreferences> process_preferences_;
|
std::map<int, ProcessPreferences> process_preferences_;
|
||||||
std::map<int, base::ProcessId> render_process_host_pids_;
|
std::map<int, base::ProcessId> render_process_host_pids_;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue