aboutsummaryrefslogtreecommitdiffstats
path: root/src/models/Service.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/models/Service.js')
-rw-r--r--src/models/Service.js26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/models/Service.js b/src/models/Service.js
index dc8febe0b..5b3ad7bd8 100644
--- a/src/models/Service.js
+++ b/src/models/Service.js
@@ -1,4 +1,5 @@
1import { autorun, computed, observable } from 'mobx'; 1import { autorun, computed, observable } from 'mobx';
2import { ipcRenderer } from 'electron';
2import normalizeUrl from 'normalize-url'; 3import normalizeUrl from 'normalize-url';
3import path from 'path'; 4import path from 'path';
4 5
@@ -139,6 +140,17 @@ export default class Service {
139 140
140 this.recipe = recipe; 141 this.recipe = recipe;
141 142
143 // Check if "Hibernate on Startup" is enabled and hibernate all services except active one
144 const {
145 hibernate,
146 hibernateOnStartup,
147 } = window.ferdi.stores.settings.app;
148 // The service store is probably not loaded yet so we need to use localStorage data to get active service
149 const isActive = window.localStorage.service && JSON.parse(window.localStorage.service).activeService === this.id;
150 if (hibernate && hibernateOnStartup && !isActive) {
151 this.isHibernating = true;
152 }
153
142 autorun(() => { 154 autorun(() => {
143 if (!this.isEnabled) { 155 if (!this.isEnabled) {
144 this.webview = null; 156 this.webview = null;
@@ -213,9 +225,23 @@ export default class Service {
213 return ua; 225 return ua;
214 } 226 }
215 227
228
216 initializeWebViewEvents({ handleIPCMessage, openWindow, stores }) { 229 initializeWebViewEvents({ handleIPCMessage, openWindow, stores }) {
217 const webContents = this.webview.getWebContents(); 230 const webContents = this.webview.getWebContents();
218 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
219 const handleUserAgent = (url, forwardingHack = false) => { 245 const handleUserAgent = (url, forwardingHack = false) => {
220 if (url.startsWith('https://accounts.google.com')) { 246 if (url.startsWith('https://accounts.google.com')) {
221 if (!this.chromelessUserAgent) { 247 if (!this.chromelessUserAgent) {