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: module.metadata = { michael@0: "stability": "unstable", michael@0: "engines": { michael@0: "Firefox": "*", michael@0: "Fennec": "*" michael@0: } michael@0: }; michael@0: michael@0: const { modelFor } = require("./model/core"); michael@0: const { viewFor } = require("./view/core"); michael@0: const { isTab } = require("./tabs/utils"); michael@0: michael@0: michael@0: if (require("./system/xul-app").is("Fennec")) { michael@0: module.exports = require("./windows/tabs-fennec").tabs; michael@0: } michael@0: else { michael@0: module.exports = require("./tabs/tabs-firefox"); michael@0: } michael@0: michael@0: const tabs = module.exports; michael@0: michael@0: // Implement `modelFor` function for the Tab instances. michael@0: // Finds a right model by iterating over all tab models michael@0: // and finding one that wraps given `view`. michael@0: modelFor.when(isTab, view => { michael@0: for (let model of tabs) { michael@0: if (viewFor(model) === view) michael@0: return model; michael@0: } michael@0: return null; michael@0: });