diff options
Diffstat (limited to 'src/models/Service.js')
-rw-r--r-- | src/models/Service.js | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/src/models/Service.js b/src/models/Service.js index 94b907d4e..9f345375f 100644 --- a/src/models/Service.js +++ b/src/models/Service.js | |||
@@ -14,7 +14,8 @@ import { | |||
14 | ifUndefinedNumber, | 14 | ifUndefinedNumber, |
15 | } from '../jsUtils'; | 15 | } from '../jsUtils'; |
16 | 16 | ||
17 | const debug = require('debug')('Ferdium:Service'); | 17 | // TODO: Go back to 'debug' from 'console.log' when https://github.com/electron/electron/issues/31689 is fixed |
18 | // const debug = require('debug')('Ferdium:Service'); | ||
18 | 19 | ||
19 | export default class Service { | 20 | export default class Service { |
20 | id = ''; | 21 | id = ''; |
@@ -305,25 +306,25 @@ export default class Service { | |||
305 | // Send those headers to ipcMain so that it can be set in session | 306 | // Send those headers to ipcMain so that it can be set in session |
306 | if (typeof this.recipe.modifyRequestHeaders === 'function') { | 307 | if (typeof this.recipe.modifyRequestHeaders === 'function') { |
307 | const modifiedRequestHeaders = this.recipe.modifyRequestHeaders(); | 308 | const modifiedRequestHeaders = this.recipe.modifyRequestHeaders(); |
308 | debug(this.name, 'modifiedRequestHeaders', modifiedRequestHeaders); | 309 | console.log(this.name, 'modifiedRequestHeaders', modifiedRequestHeaders); |
309 | ipcRenderer.send('modifyRequestHeaders', { | 310 | ipcRenderer.send('modifyRequestHeaders', { |
310 | modifiedRequestHeaders, | 311 | modifiedRequestHeaders, |
311 | serviceId: this.id, | 312 | serviceId: this.id, |
312 | }); | 313 | }); |
313 | } else { | 314 | } else { |
314 | debug(this.name, 'modifyRequestHeaders is not defined in the recipe'); | 315 | console.log(this.name, 'modifyRequestHeaders is not defined in the recipe'); |
315 | } | 316 | } |
316 | 317 | ||
317 | // if the recipe has implemented 'knownCertificateHosts' | 318 | // if the recipe has implemented 'knownCertificateHosts' |
318 | if (typeof this.recipe.knownCertificateHosts === 'function') { | 319 | if (typeof this.recipe.knownCertificateHosts === 'function') { |
319 | const knownHosts = this.recipe.knownCertificateHosts(); | 320 | const knownHosts = this.recipe.knownCertificateHosts(); |
320 | debug(this.name, 'knownCertificateHosts', knownHosts); | 321 | console.log(this.name, 'knownCertificateHosts', knownHosts); |
321 | ipcRenderer.send('knownCertificateHosts', { | 322 | ipcRenderer.send('knownCertificateHosts', { |
322 | knownHosts, | 323 | knownHosts, |
323 | serviceId: this.id, | 324 | serviceId: this.id, |
324 | }); | 325 | }); |
325 | } else { | 326 | } else { |
326 | debug(this.name, 'knownCertificateHosts is not defined in the recipe'); | 327 | console.log(this.name, 'knownCertificateHosts is not defined in the recipe'); |
327 | } | 328 | } |
328 | 329 | ||
329 | this.webview.addEventListener('ipc-message', async e => { | 330 | this.webview.addEventListener('ipc-message', async e => { |
@@ -347,7 +348,7 @@ export default class Service { | |||
347 | this.webview.addEventListener( | 348 | this.webview.addEventListener( |
348 | 'new-window', | 349 | 'new-window', |
349 | (event, url, frameName, options) => { | 350 | (event, url, frameName, options) => { |
350 | debug('new-window', event, url, frameName, options); | 351 | console.log('new-window', event, url, frameName, options); |
351 | if (!isValidExternalURL(event.url)) { | 352 | if (!isValidExternalURL(event.url)) { |
352 | return; | 353 | return; |
353 | } | 354 | } |
@@ -371,7 +372,7 @@ export default class Service { | |||
371 | ); | 372 | ); |
372 | 373 | ||
373 | this.webview.addEventListener('did-start-loading', event => { | 374 | this.webview.addEventListener('did-start-loading', event => { |
374 | debug('Did start load', this.name, event); | 375 | console.log('Did start load', this.name, event); |
375 | 376 | ||
376 | this.hasCrashed = false; | 377 | this.hasCrashed = false; |
377 | this.isLoading = true; | 378 | this.isLoading = true; |
@@ -390,7 +391,7 @@ export default class Service { | |||
390 | this.webview.addEventListener('did-navigate', didLoad.bind(this)); | 391 | this.webview.addEventListener('did-navigate', didLoad.bind(this)); |
391 | 392 | ||
392 | this.webview.addEventListener('did-fail-load', event => { | 393 | this.webview.addEventListener('did-fail-load', event => { |
393 | debug('Service failed to load', this.name, event); | 394 | console.log('Service failed to load', this.name, event); |
394 | if ( | 395 | if ( |
395 | event.isMainFrame && | 396 | event.isMainFrame && |
396 | event.errorCode !== -21 && | 397 | event.errorCode !== -21 && |
@@ -403,33 +404,33 @@ export default class Service { | |||
403 | }); | 404 | }); |
404 | 405 | ||
405 | this.webview.addEventListener('crashed', () => { | 406 | this.webview.addEventListener('crashed', () => { |
406 | debug('Service crashed', this.name); | 407 | console.log('Service crashed', this.name); |
407 | this.hasCrashed = true; | 408 | this.hasCrashed = true; |
408 | }); | 409 | }); |
409 | 410 | ||
410 | this.webview.addEventListener('found-in-page', ({ result }) => { | 411 | this.webview.addEventListener('found-in-page', ({ result }) => { |
411 | debug('Found in page', result); | 412 | console.log('Found in page', result); |
412 | this.webview.send('found-in-page', result); | 413 | this.webview.send('found-in-page', result); |
413 | }); | 414 | }); |
414 | 415 | ||
415 | webviewWebContents.on('login', (event, request, authInfo, callback) => { | 416 | webviewWebContents.on('login', (event, request, authInfo, callback) => { |
416 | // const authCallback = callback; | 417 | // const authCallback = callback; |
417 | debug('browser login event', authInfo); | 418 | console.log('browser login event', authInfo); |
418 | event.preventDefault(); | 419 | event.preventDefault(); |
419 | 420 | ||
420 | if (authInfo.isProxy && authInfo.scheme === 'basic') { | 421 | if (authInfo.isProxy && authInfo.scheme === 'basic') { |
421 | debug('Sending service echo ping'); | 422 | console.log('Sending service echo ping'); |
422 | webviewWebContents.send('get-service-id'); | 423 | webviewWebContents.send('get-service-id'); |
423 | 424 | ||
424 | debug('Received service id', this.id); | 425 | console.log('Received service id', this.id); |
425 | 426 | ||
426 | const ps = stores.settings.proxy[this.id]; | 427 | const ps = stores.settings.proxy[this.id]; |
427 | 428 | ||
428 | if (ps) { | 429 | if (ps) { |
429 | debug('Sending proxy auth callback for service', this.id); | 430 | console.log('Sending proxy auth callback for service', this.id); |
430 | callback(ps.user, ps.password); | 431 | callback(ps.user, ps.password); |
431 | } else { | 432 | } else { |
432 | debug('No proxy auth config found for', this.id); | 433 | console.log('No proxy auth config found for', this.id); |
433 | } | 434 | } |
434 | } | 435 | } |
435 | }); | 436 | }); |