michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: 'use strict'; michael@0: michael@0: const { Class } = require('../core/heritage'); michael@0: const { windowNS } = require('./namespace'); michael@0: const { on, off, once } = require('../event/core'); michael@0: const { method } = require('../lang/functional'); michael@0: const { getWindowTitle } = require('./utils'); michael@0: const unload = require('../system/unload'); michael@0: const { isWindowPrivate } = require('../window/utils'); michael@0: const { EventTarget } = require('../event/target'); michael@0: const { getOwnerWindow: getPBOwnerWindow } = require('../private-browsing/window/utils'); michael@0: const { viewFor } = require('../view/core'); michael@0: const { deprecateUsage } = require('../util/deprecate'); michael@0: michael@0: const ERR_FENNEC_MSG = 'This method is not yet supported by Fennec, consider using require("sdk/tabs") instead'; michael@0: michael@0: const BrowserWindow = Class({ michael@0: initialize: function initialize(options) { michael@0: EventTarget.prototype.initialize.call(this, options); michael@0: windowNS(this).window = options.window; michael@0: }, michael@0: activate: function activate() { michael@0: // TODO michael@0: return null; michael@0: }, michael@0: close: function() { michael@0: throw new Error(ERR_FENNEC_MSG); michael@0: return null; michael@0: }, michael@0: get title() getWindowTitle(windowNS(this).window), michael@0: // NOTE: Fennec only has one window, which is assumed below michael@0: // TODO: remove assumption below michael@0: // NOTE: tabs requires windows michael@0: get tabs() require('../tabs'), michael@0: get activeTab() require('../tabs').activeTab, michael@0: on: method(on), michael@0: removeListener: method(off), michael@0: once: method(once), michael@0: get isPrivateBrowsing() { michael@0: deprecateUsage('`browserWindow.isPrivateBrowsing` is deprecated, please ' + michael@0: 'consider using ' + michael@0: '`require("sdk/private-browsing").isPrivate(browserWindow)` ' + michael@0: 'instead.'); michael@0: return isWindowPrivate(windowNS(this).window); michael@0: } michael@0: }); michael@0: exports.BrowserWindow = BrowserWindow; michael@0: michael@0: const getWindowView = window => windowNS(window).window; michael@0: michael@0: getPBOwnerWindow.define(BrowserWindow, getWindowView); michael@0: viewFor.define(BrowserWindow, getWindowView);