1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- 'use strict';
- const { browserWindows: windows } = require('../windows');
- const { tabs } = require('../windows/tabs-firefox');
- const { isPrivate } = require('../private-browsing');
- const { isWindowPBSupported } = require('../private-browsing/utils')
- const { isPrivateBrowsingSupported } = require('sdk/self');
- const supportPrivateTabs = isPrivateBrowsingSupported && isWindowPBSupported;
- function newTabWindow(options) {
-
- return windows.open({
- tabs: [ options ],
- isPrivate: options.isPrivate
- });
- }
- Object.defineProperties(tabs, {
- open: { value: function open(options) {
- if (options.inNewWindow) {
- newTabWindow(options);
- return undefined;
- }
- let activeWindow = windows.activeWindow;
- let privateState = (supportPrivateTabs && (options.isPrivate || isPrivate(activeWindow))) || false;
-
- if (activeWindow && (!supportPrivateTabs || privateState === isPrivate(activeWindow))) {
- activeWindow.tabs.open(options);
- }
- else {
-
- let window = getWindow(privateState);
- if (window) {
- window.tabs.open(options);
- }
-
- else {
- newTabWindow(options);
- }
- }
- return undefined;
- }}
- });
- function getWindow(privateState) {
- for each (let window in windows) {
- if (privateState === isPrivate(window)) {
- return window;
- }
- }
- return null;
- }
- module.exports = Object.create(tabs, {
- isPrototypeOf: { value: Object.prototype.isPrototypeOf }
- });
|