diff options
author | Sampath Kumar Krishnan <sampathBlam@users.noreply.github.com> | 2020-04-24 22:20:54 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-24 16:50:54 +0000 |
commit | 35cc75d177064c8154b9d56c549a6335963efe74 (patch) | |
tree | 1fe0a9b476e70bd1baf26dc2564dd5c39324922e /src/models | |
parent | Release 5.5.0-gm.2 (#625) (diff) | |
download | ferdium-app-35cc75d177064c8154b9d56c549a6335963efe74.tar.gz ferdium-app-35cc75d177064c8154b9d56c549a6335963efe74.tar.zst ferdium-app-35cc75d177064c8154b9d56c549a6335963efe74.zip |
Add modifyRequestHeaders, enable properly setting headers for services
Co-Authored-By: Mahadevan Sreenivasan <mahadevan_sv@yahoo.com>
Diffstat (limited to 'src/models')
-rw-r--r-- | src/models/Service.js | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/models/Service.js b/src/models/Service.js index 2f2b4572d..5b3ad7bd8 100644 --- a/src/models/Service.js +++ b/src/models/Service.js | |||
@@ -1,4 +1,5 @@ | |||
1 | import { autorun, computed, observable } from 'mobx'; | 1 | import { autorun, computed, observable } from 'mobx'; |
2 | import { ipcRenderer } from 'electron'; | ||
2 | import normalizeUrl from 'normalize-url'; | 3 | import normalizeUrl from 'normalize-url'; |
3 | import path from 'path'; | 4 | import path from 'path'; |
4 | 5 | ||
@@ -224,9 +225,23 @@ export default class Service { | |||
224 | return ua; | 225 | return ua; |
225 | } | 226 | } |
226 | 227 | ||
228 | |||
227 | initializeWebViewEvents({ handleIPCMessage, openWindow, stores }) { | 229 | initializeWebViewEvents({ handleIPCMessage, openWindow, stores }) { |
228 | const webContents = this.webview.getWebContents(); | 230 | const webContents = this.webview.getWebContents(); |
229 | 231 | ||
232 | // If the recipe has implemented modifyRequestHeaders, | ||
233 | // Send those headers to ipcMain so that it can be set in session | ||
234 | if (typeof this.recipe.modifyRequestHeaders === 'function') { | ||
235 | const modifiedRequestHeaders = this.recipe.modifyRequestHeaders(); | ||
236 | debug(this.name, 'modifiedRequestHeaders', modifiedRequestHeaders); | ||
237 | ipcRenderer.send('modifyRequestHeaders', { | ||
238 | modifiedRequestHeaders, | ||
239 | serviceId: this.id, | ||
240 | }); | ||
241 | } else { | ||
242 | debug(this.name, 'modifyRequestHeaders is not defined in the recipe'); | ||
243 | } | ||
244 | |||
230 | const handleUserAgent = (url, forwardingHack = false) => { | 245 | const handleUserAgent = (url, forwardingHack = false) => { |
231 | if (url.startsWith('https://accounts.google.com')) { | 246 | if (url.startsWith('https://accounts.google.com')) { |
232 | if (!this.chromelessUserAgent) { | 247 | if (!this.chromelessUserAgent) { |