mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
fix: make devtools extensions load correctly (#17616)
This commit is contained in:
@@ -1673,13 +1673,24 @@ bool WebContents::SendIPCMessageWithSender(bool internal,
|
||||
const std::string& channel,
|
||||
const base::ListValue& args,
|
||||
int32_t sender_id) {
|
||||
auto* frame_host = web_contents()->GetMainFrame();
|
||||
if (frame_host) {
|
||||
return frame_host->Send(new AtomFrameMsg_Message(frame_host->GetRoutingID(),
|
||||
internal, send_to_all,
|
||||
channel, args, sender_id));
|
||||
std::vector<content::RenderFrameHost*> target_hosts;
|
||||
if (!send_to_all) {
|
||||
auto* frame_host = web_contents()->GetMainFrame();
|
||||
if (frame_host) {
|
||||
target_hosts.push_back(frame_host);
|
||||
}
|
||||
} else {
|
||||
target_hosts = web_contents()->GetAllFrames();
|
||||
}
|
||||
return false;
|
||||
|
||||
bool handled = false;
|
||||
for (auto* frame_host : target_hosts) {
|
||||
handled = frame_host->Send(
|
||||
new AtomFrameMsg_Message(frame_host->GetRoutingID(), internal,
|
||||
false, channel, args, sender_id)) ||
|
||||
handled;
|
||||
}
|
||||
return handled;
|
||||
}
|
||||
|
||||
bool WebContents::SendIPCMessageToFrame(bool internal,
|
||||
|
||||
@@ -207,6 +207,7 @@ void AtomRenderFrameObserver::OnBrowserMessage(bool internal,
|
||||
EmitIPCEvent(frame, internal, channel, args, sender_id);
|
||||
|
||||
// Also send the message to all sub-frames.
|
||||
// TODO(MarshallOfSound): Completely move this logic to the main process
|
||||
if (send_to_all) {
|
||||
for (blink::WebFrame* child = frame->FirstChild(); child;
|
||||
child = child->NextSibling())
|
||||
|
||||
@@ -298,7 +298,7 @@ const loadDevToolsExtensions = function (win, manifests) {
|
||||
extensionInfoArray.forEach((extension) => {
|
||||
win.devToolsWebContents._grantOriginAccess(extension.startPage)
|
||||
})
|
||||
win.devToolsWebContents.executeJavaScript(`DevToolsAPI.addExtensions(${JSON.stringify(extensionInfoArray)})`)
|
||||
win.devToolsWebContents.executeJavaScript(`InspectorFrontendAPI.addExtensions(${JSON.stringify(extensionInfoArray)})`)
|
||||
}
|
||||
|
||||
app.on('web-contents-created', function (event, webContents) {
|
||||
|
||||
Reference in New Issue
Block a user