(newUrl: string, oldUrl: string)
| 172 | this.manager.recreatedWCV(this) |
| 173 | } |
| 174 | loadRightPreload(newUrl: string, oldUrl: string) { |
| 175 | log.log('[main] webcontentsview: check if we need to re-create WCV', newUrl, oldUrl) |
| 176 | |
| 177 | if (!oldUrl) { |
| 178 | log.log('[main] webcontentsview: no old URL to compare against') |
| 179 | return |
| 180 | } |
| 181 | |
| 182 | const newIsSurfUrl = checkIfSurfProtocolUrl(newUrl) && !newUrl.startsWith(PDFViewerEntryPoint) |
| 183 | const oldIsSurfUrl = checkIfSurfProtocolUrl(oldUrl) && !oldUrl.startsWith(PDFViewerEntryPoint) |
| 184 | |
| 185 | // if we load a surf:// URL, we need to re-create the WebContentsView with a different preload |
| 186 | if (newIsSurfUrl && !oldIsSurfUrl) { |
| 187 | log.log( |
| 188 | '[main] webcontentsview: loading surf:// URL, re-creating WCV with resource view preload' |
| 189 | ) |
| 190 | this.recreateWCVWithDifferentWebPreferences({ |
| 191 | sandbox: false, |
| 192 | nodeIntegration: false, |
| 193 | contextIsolation: true, |
| 194 | preload: path.resolve(__dirname, '../preload/resource.js') |
| 195 | }) |
| 196 | } else if (!newIsSurfUrl && oldIsSurfUrl) { |
| 197 | log.log( |
| 198 | '[main] webcontentsview: loading non-surf:// URL, re-creating WCV with webcontents preload' |
| 199 | ) |
| 200 | this.recreateWCVWithDifferentWebPreferences({ |
| 201 | preload: path.resolve(__dirname, '../preload/webcontents.js') |
| 202 | }) |
| 203 | } |
| 204 | } |
| 205 | |
| 206 | async loadURL(url: string) { |
| 207 | try { |
no test coverage detected