diff options
Diffstat (limited to 'ext/bg/js/backend.js')
| -rw-r--r-- | ext/bg/js/backend.js | 71 | 
1 files changed, 52 insertions, 19 deletions
diff --git a/ext/bg/js/backend.js b/ext/bg/js/backend.js index 11a17381..d5e5b086 100644 --- a/ext/bg/js/backend.js +++ b/ext/bg/js/backend.js @@ -818,25 +818,12 @@ class Backend {          // Create a new window          const options = this.getOptions({current: true}); -        const {popupWidth, popupHeight} = options.general; -        const popupWindow = await new Promise((resolve, reject) => { -            chrome.windows.create( -                { -                    url: baseUrl, -                    width: popupWidth, -                    height: popupHeight, -                    type: 'popup' -                }, -                (result) => { -                    const error = chrome.runtime.lastError; -                    if (error) { -                        reject(new Error(error.message)); -                    } else { -                        resolve(result); -                    } -                } -            ); -        }); +        const createData = this._getSearchPopupWindowCreateData(baseUrl, options); +        const {popupWindow: {windowState}} = options; +        const popupWindow = await this._createWindow(createData); +        if (windowState !== 'normal') { +            await this._updateWindow(popupWindow.id, {state: windowState}); +        }          const {tabs} = popupWindow;          if (tabs.length === 0) { @@ -856,6 +843,52 @@ class Backend {          return {tab, created: true};      } +    _getSearchPopupWindowCreateData(url, options) { +        const {popupWindow: {width, height, left, top, useLeft, useTop, windowType}} = options; +        return { +            url, +            width, +            height, +            left: useLeft ? left : void 0, +            top: useTop ? top : void 0, +            type: windowType, +            state: 'normal' +        }; +    } + +    _createWindow(createData) { +        return new Promise((resolve, reject) => { +            chrome.windows.create( +                createData, +                (result) => { +                    const error = chrome.runtime.lastError; +                    if (error) { +                        reject(new Error(error.message)); +                    } else { +                        resolve(result); +                    } +                } +            ); +        }); +    } + +    _updateWindow(windowId, updateInfo) { +        return new Promise((resolve, reject) => { +            chrome.windows.update( +                windowId, +                updateInfo, +                (result) => { +                    const error = chrome.runtime.lastError; +                    if (error) { +                        reject(new Error(error.message)); +                    } else { +                        resolve(result); +                    } +                } +            ); +        }); +    } +      _updateSearchQuery(tabId, text, animate) {          return this._sendMessageTabPromise(              tabId,  |