Loading toolkit/content/TopLevelVideoDocument.js +13 −7 Original line number Diff line number Diff line Loading @@ -29,18 +29,24 @@ setFocusToVideoElement(); // Opt out of moving focus away if the DOM tree changes (from add-on or web content) let observer = new MutationObserver( () => { let observer = new MutationObserver(() => { observer.disconnect(); document.removeEventListener("focus", setFocusToVideoElement, true); }); observer.observe(document.documentElement, { childList: true, subtree: true }); observer.observe(document.documentElement, { childList: true, subtree: true, }); // Handle fullscreen mode document.addEventListener("keypress", ev => { // Maximize the standalone video when pressing F11, // but ignore audio elements if (ev.key == "F11" && videoElement.videoWidth != 0 && videoElement.videoHeight != 0) { if ( ev.key == "F11" && videoElement.videoWidth != 0 && videoElement.videoHeight != 0 ) { // If we're in browser fullscreen mode, it means the user pressed F11 // while browser chrome or another tab had focus. // Don't break leaving that mode, so do nothing here. Loading toolkit/content/about.js +4 −2 Original line number Diff line number Diff line Loading @@ -5,7 +5,9 @@ const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm"); // get release notes and vendor URL from prefs var releaseNotesURL = Services.urlFormatter.formatURLPref("app.releaseNotesURL"); var releaseNotesURL = Services.urlFormatter.formatURLPref( "app.releaseNotesURL" ); if (releaseNotesURL != "about:blank") { var relnotes = document.getElementById("releaseNotesURL"); relnotes.setAttribute("href", releaseNotesURL); Loading toolkit/content/aboutAbout.js +3 −1 Original line number Diff line number Diff line Loading @@ -2,7 +2,9 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ const {AboutPagesUtils} = ChromeUtils.import("resource://gre/modules/AboutPagesUtils.jsm"); const { AboutPagesUtils } = ChromeUtils.import( "resource://gre/modules/AboutPagesUtils.jsm" ); var gContainer; window.onload = function() { Loading toolkit/content/aboutNetworking.js +61 −49 Original line number Diff line number Diff line Loading @@ -5,31 +5,36 @@ "use strict"; const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm"); const FileUtils = ChromeUtils.import("resource://gre/modules/FileUtils.jsm").FileUtils; const gEnv = Cc["@mozilla.org/process/environment;1"] .getService(Ci.nsIEnvironment); const gDashboard = Cc["@mozilla.org/network/dashboard;1"] .getService(Ci.nsIDashboard); const gDirServ = Cc["@mozilla.org/file/directory_service;1"] .getService(Ci.nsIDirectoryServiceProvider); const gNetLinkSvc = Cc["@mozilla.org/network/network-link-service;1"] .getService(Ci.nsINetworkLinkService); const FileUtils = ChromeUtils.import("resource://gre/modules/FileUtils.jsm") .FileUtils; const gEnv = Cc["@mozilla.org/process/environment;1"].getService( Ci.nsIEnvironment ); const gDashboard = Cc["@mozilla.org/network/dashboard;1"].getService( Ci.nsIDashboard ); const gDirServ = Cc["@mozilla.org/file/directory_service;1"].getService( Ci.nsIDirectoryServiceProvider ); const gNetLinkSvc = Cc[ "@mozilla.org/network/network-link-service;1" ].getService(Ci.nsINetworkLinkService); const gRequestNetworkingData = { "http": gDashboard.requestHttpConnections, "sockets": gDashboard.requestSockets, "dns": gDashboard.requestDNSInfo, "websockets": gDashboard.requestWebsocketConnections, "dnslookuptool": () => {}, "logging": () => {}, "rcwn": gDashboard.requestRcwnStats, http: gDashboard.requestHttpConnections, sockets: gDashboard.requestSockets, dns: gDashboard.requestDNSInfo, websockets: gDashboard.requestWebsocketConnections, dnslookuptool: () => {}, logging: () => {}, rcwn: gDashboard.requestRcwnStats, }; const gDashboardCallbacks = { "http": displayHttp, "sockets": displaySockets, "dns": displayDns, "websockets": displayWebsockets, "rcwn": displayRcwnStats, http: displayHttp, sockets: displaySockets, dns: displayDns, websockets: displayWebsockets, rcwn: displayRcwnStats, }; const REFRESH_INTERVAL_MS = 3000; Loading Loading @@ -130,10 +135,14 @@ function displayWebsockets(data) { function displayRcwnStats(data) { let status = Services.prefs.getBoolPref("network.http.rcwn.enabled"); let linkType = gNetLinkSvc.linkType; if (!(linkType == Ci.nsINetworkLinkService.LINK_TYPE_UNKNOWN || if ( !( linkType == Ci.nsINetworkLinkService.LINK_TYPE_UNKNOWN || linkType == Ci.nsINetworkLinkService.LINK_TYPE_ETHERNET || linkType == Ci.nsINetworkLinkService.LINK_TYPE_USB || linkType == Ci.nsINetworkLinkService.LINK_TYPE_WIFI)) { linkType == Ci.nsINetworkLinkService.LINK_TYPE_WIFI ) ) { status = false; } Loading @@ -151,32 +160,28 @@ function displayRcwnStats(data) { document.getElementById("rcwn_cache_not_slow").innerText = cacheNotSlow; // Keep in sync with CachePerfStats::EDataType in CacheFileUtils.h const perfStatTypes = [ "open", "read", "write", "entryopen", ]; const perfStatFieldNames = [ "avgShort", "avgLong", "stddevLong", ]; const perfStatTypes = ["open", "read", "write", "entryopen"]; const perfStatFieldNames = ["avgShort", "avgLong", "stddevLong"]; for (let typeIndex in perfStatTypes) { for (let statFieldIndex in perfStatFieldNames) { document.getElementById("rcwn_perfstats_" + perfStatTypes[typeIndex] + "_" + perfStatFieldNames[statFieldIndex]).innerText = document.getElementById( "rcwn_perfstats_" + perfStatTypes[typeIndex] + "_" + perfStatFieldNames[statFieldIndex] ).innerText = data.perfStats[typeIndex][perfStatFieldNames[statFieldIndex]]; } } } function requestAllNetworkingData() { for (let id in gRequestNetworkingData) for (let id in gRequestNetworkingData) { requestNetworkingDataForTab(id); } } function requestNetworkingDataForTab(id) { gRequestNetworkingData[id](gDashboardCallbacks[id]); Loading @@ -199,8 +204,9 @@ function init() { requestAllNetworkingData(); let autoRefresh = document.getElementById("autorefcheck"); if (autoRefresh.checked) if (autoRefresh.checked) { setAutoRefreshInterval(autoRefresh); } autoRefresh.addEventListener("click", function() { let refrButton = document.getElementById("refreshButton"); Loading @@ -215,14 +221,16 @@ function init() { let refr = document.getElementById("refreshButton"); refr.addEventListener("click", requestAllNetworkingData); if (document.getElementById("autorefcheck").checked) if (document.getElementById("autorefcheck").checked) { refr.disabled = "disabled"; } // Event delegation on #categories element let menu = document.getElementById("categories"); menu.addEventListener("click", function click(e) { if (e.target && e.target.parentNode == menu) if (e.target && e.target.parentNode == menu) { show(e.target); } }); let dnsLookupButton = document.getElementById("dnsLookupButton"); Loading Loading @@ -264,7 +272,9 @@ function init() { } if (location.hash) { let sectionButton = document.getElementById("category-" + location.hash.substring(1)); let sectionButton = document.getElementById( "category-" + location.hash.substring(1) ); if (sectionButton) { sectionButton.click(); } Loading Loading @@ -292,7 +302,8 @@ function updateLogFile() { function updateLogModules() { // Try to get the environment variable for the log file let logModules = gEnv.get("MOZ_LOG") || let logModules = gEnv.get("MOZ_LOG") || gEnv.get("MOZ_LOG_MODULES") || gEnv.get("NSPR_LOG_MODULES"); let currentLogModules = document.getElementById("current-log-modules"); Loading Loading @@ -415,8 +426,9 @@ function show(button) { let current_tab = document.querySelector(".active"); let category = button.getAttribute("id").substring("category-".length); let content = document.getElementById(category); if (current_tab == content) if (current_tab == content) { return; } current_tab.classList.remove("active"); current_tab.hidden = true; content.classList.add("active"); Loading toolkit/content/aboutProfiles.js +113 −60 Original line number Diff line number Diff line Loading @@ -5,7 +5,9 @@ "use strict"; const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm"); const {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm"); const { XPCOMUtils } = ChromeUtils.import( "resource://gre/modules/XPCOMUtils.jsm" ); XPCOMUtils.defineLazyServiceGetter( this, Loading @@ -21,17 +23,28 @@ async function flush() { } catch (e) { let [title, msg, button] = await document.l10n.formatValues([ { id: "profiles-flush-fail-title" }, { id: e.result == Cr.NS_ERROR_DATABASE_CHANGED ? "profiles-flush-conflict" : "profiles-flush-failed" }, { id: e.result == Cr.NS_ERROR_DATABASE_CHANGED ? "profiles-flush-conflict" : "profiles-flush-failed", }, { id: "profiles-flush-restart-button" }, ]); const PS = Ci.nsIPromptService; let result = Services.prompt.confirmEx(window, title, msg, (PS.BUTTON_POS_0 * PS.BUTTON_TITLE_CANCEL) + (PS.BUTTON_POS_1 * PS.BUTTON_TITLE_IS_STRING), null, button, null, null, {}); let result = Services.prompt.confirmEx( window, title, msg, PS.BUTTON_POS_0 * PS.BUTTON_TITLE_CANCEL + PS.BUTTON_POS_1 * PS.BUTTON_TITLE_IS_STRING, null, button, null, null, {} ); if (result == 1) { restart(false); } Loading Loading @@ -59,9 +72,11 @@ function rebuildProfileList() { let lock = profile.lock({}); lock.unlock(); } catch (e) { if (e.result != Cr.NS_ERROR_FILE_TARGET_DOES_NOT_EXIST && if ( e.result != Cr.NS_ERROR_FILE_TARGET_DOES_NOT_EXIST && e.result != Cr.NS_ERROR_FILE_NOT_DIRECTORY && e.result != Cr.NS_ERROR_FILE_NOT_FOUND) { e.result != Cr.NS_ERROR_FILE_NOT_FOUND ) { isInUse = true; } } Loading @@ -84,8 +99,9 @@ function display(profileData) { let name = document.createElement("h2"); div.appendChild(name); document.l10n.setAttributes(name, "profiles-name", { name: profileData.profile.name }); document.l10n.setAttributes(name, "profiles-name", { name: profileData.profile.name, }); if (profileData.isCurrentProfile) { let currentProfile = document.createElement("h3"); Loading Loading @@ -134,8 +150,10 @@ function display(profileData) { } } createItem("profiles-is-default", profileData.isDefault ? "profiles-yes" : "profiles-no"); createItem( "profiles-is-default", profileData.isDefault ? "profiles-yes" : "profiles-no" ); createItem("profiles-rootdir", profileData.profile.rootDir, true); Loading Loading @@ -190,9 +208,12 @@ function CreateProfile(profile) { function createProfileWizard() { // This should be rewritten in HTML eventually. window.openDialog("chrome://mozapps/content/profile/createProfileWizard.xul", "", "centerscreen,chrome,modal,titlebar", ProfileService); window.openDialog( "chrome://mozapps/content/profile/createProfileWizard.xul", "", "centerscreen,chrome,modal,titlebar", ProfileService ); } async function renameProfile(profile) { Loading @@ -202,8 +223,7 @@ async function renameProfile(profile) { { id: "profiles-rename-profile", args: { name: profile.name } }, ]); if (Services.prompt.prompt(window, title, msg, newName, null, { value: 0 })) { if (Services.prompt.prompt(window, title, msg, newName, null, { value: 0 })) { newName = newName.value; if (newName == profile.name) { Loading @@ -230,20 +250,33 @@ async function removeProfile(profile) { let deleteFiles = false; if (profile.rootDir.exists()) { let [title, msg, dontDeleteStr, deleteStr] = await document.l10n.formatValues([ let [ title, msg, dontDeleteStr, deleteStr, ] = await document.l10n.formatValues([ { id: "profiles-delete-profile-title" }, { id: "profiles-delete-profile-confirm", args: { dir: profile.rootDir.path } }, { id: "profiles-delete-profile-confirm", args: { dir: profile.rootDir.path }, }, { id: "profiles-dont-delete-files" }, { id: "profiles-delete-files" }, ]); let buttonPressed = Services.prompt.confirmEx(window, title, msg, (Services.prompt.BUTTON_TITLE_IS_STRING * Services.prompt.BUTTON_POS_0) + (Services.prompt.BUTTON_TITLE_CANCEL * Services.prompt.BUTTON_POS_1) + (Services.prompt.BUTTON_TITLE_IS_STRING * Services.prompt.BUTTON_POS_2), let buttonPressed = Services.prompt.confirmEx( window, title, msg, Services.prompt.BUTTON_TITLE_IS_STRING * Services.prompt.BUTTON_POS_0 + Services.prompt.BUTTON_TITLE_CANCEL * Services.prompt.BUTTON_POS_1 + Services.prompt.BUTTON_TITLE_IS_STRING * Services.prompt.BUTTON_POS_2, dontDeleteStr, null, deleteStr, null, {value: 0}); null, { value: 0 } ); if (buttonPressed == 1) { return; } Loading Loading @@ -310,9 +343,14 @@ async function defaultProfile(profile) { } function openProfile(profile) { let cancelQuit = Cc["@mozilla.org/supports-PRBool;1"] .createInstance(Ci.nsISupportsPRBool); Services.obs.notifyObservers(cancelQuit, "quit-application-requested", "restart"); let cancelQuit = Cc["@mozilla.org/supports-PRBool;1"].createInstance( Ci.nsISupportsPRBool ); Services.obs.notifyObservers( cancelQuit, "quit-application-requested", "restart" ); if (cancelQuit.data) { return; Loading @@ -322,9 +360,14 @@ function openProfile(profile) { } function restart(safeMode) { let cancelQuit = Cc["@mozilla.org/supports-PRBool;1"] .createInstance(Ci.nsISupportsPRBool); Services.obs.notifyObservers(cancelQuit, "quit-application-requested", "restart"); let cancelQuit = Cc["@mozilla.org/supports-PRBool;1"].createInstance( Ci.nsISupportsPRBool ); Services.obs.notifyObservers( cancelQuit, "quit-application-requested", "restart" ); if (cancelQuit.data) { return; Loading @@ -339,19 +382,27 @@ function restart(safeMode) { } } window.addEventListener("DOMContentLoaded", function() { window.addEventListener( "DOMContentLoaded", function() { let createButton = document.getElementById("create-button"); createButton.addEventListener("click", createProfileWizard); let restartSafeModeButton = document.getElementById("restart-in-safe-mode-button"); let restartSafeModeButton = document.getElementById( "restart-in-safe-mode-button" ); if (!Services.policies || Services.policies.isAllowed("safeMode")) { restartSafeModeButton.addEventListener("click", () => { restart(true); }); restartSafeModeButton.addEventListener("click", () => { restart(true); }); } else { restartSafeModeButton.setAttribute("disabled", "true"); } let restartNormalModeButton = document.getElementById("restart-button"); restartNormalModeButton.addEventListener("click", () => { restart(false); }); restartNormalModeButton.addEventListener("click", () => { restart(false); }); if (ProfileService.isListOutdated) { document.getElementById("owned").hidden = true; Loading @@ -359,4 +410,6 @@ window.addEventListener("DOMContentLoaded", function() { document.getElementById("conflict").hidden = true; rebuildProfileList(); } }, {once: true}); }, { once: true } ); Loading
toolkit/content/TopLevelVideoDocument.js +13 −7 Original line number Diff line number Diff line Loading @@ -29,18 +29,24 @@ setFocusToVideoElement(); // Opt out of moving focus away if the DOM tree changes (from add-on or web content) let observer = new MutationObserver( () => { let observer = new MutationObserver(() => { observer.disconnect(); document.removeEventListener("focus", setFocusToVideoElement, true); }); observer.observe(document.documentElement, { childList: true, subtree: true }); observer.observe(document.documentElement, { childList: true, subtree: true, }); // Handle fullscreen mode document.addEventListener("keypress", ev => { // Maximize the standalone video when pressing F11, // but ignore audio elements if (ev.key == "F11" && videoElement.videoWidth != 0 && videoElement.videoHeight != 0) { if ( ev.key == "F11" && videoElement.videoWidth != 0 && videoElement.videoHeight != 0 ) { // If we're in browser fullscreen mode, it means the user pressed F11 // while browser chrome or another tab had focus. // Don't break leaving that mode, so do nothing here. Loading
toolkit/content/about.js +4 −2 Original line number Diff line number Diff line Loading @@ -5,7 +5,9 @@ const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm"); // get release notes and vendor URL from prefs var releaseNotesURL = Services.urlFormatter.formatURLPref("app.releaseNotesURL"); var releaseNotesURL = Services.urlFormatter.formatURLPref( "app.releaseNotesURL" ); if (releaseNotesURL != "about:blank") { var relnotes = document.getElementById("releaseNotesURL"); relnotes.setAttribute("href", releaseNotesURL); Loading
toolkit/content/aboutAbout.js +3 −1 Original line number Diff line number Diff line Loading @@ -2,7 +2,9 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ const {AboutPagesUtils} = ChromeUtils.import("resource://gre/modules/AboutPagesUtils.jsm"); const { AboutPagesUtils } = ChromeUtils.import( "resource://gre/modules/AboutPagesUtils.jsm" ); var gContainer; window.onload = function() { Loading
toolkit/content/aboutNetworking.js +61 −49 Original line number Diff line number Diff line Loading @@ -5,31 +5,36 @@ "use strict"; const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm"); const FileUtils = ChromeUtils.import("resource://gre/modules/FileUtils.jsm").FileUtils; const gEnv = Cc["@mozilla.org/process/environment;1"] .getService(Ci.nsIEnvironment); const gDashboard = Cc["@mozilla.org/network/dashboard;1"] .getService(Ci.nsIDashboard); const gDirServ = Cc["@mozilla.org/file/directory_service;1"] .getService(Ci.nsIDirectoryServiceProvider); const gNetLinkSvc = Cc["@mozilla.org/network/network-link-service;1"] .getService(Ci.nsINetworkLinkService); const FileUtils = ChromeUtils.import("resource://gre/modules/FileUtils.jsm") .FileUtils; const gEnv = Cc["@mozilla.org/process/environment;1"].getService( Ci.nsIEnvironment ); const gDashboard = Cc["@mozilla.org/network/dashboard;1"].getService( Ci.nsIDashboard ); const gDirServ = Cc["@mozilla.org/file/directory_service;1"].getService( Ci.nsIDirectoryServiceProvider ); const gNetLinkSvc = Cc[ "@mozilla.org/network/network-link-service;1" ].getService(Ci.nsINetworkLinkService); const gRequestNetworkingData = { "http": gDashboard.requestHttpConnections, "sockets": gDashboard.requestSockets, "dns": gDashboard.requestDNSInfo, "websockets": gDashboard.requestWebsocketConnections, "dnslookuptool": () => {}, "logging": () => {}, "rcwn": gDashboard.requestRcwnStats, http: gDashboard.requestHttpConnections, sockets: gDashboard.requestSockets, dns: gDashboard.requestDNSInfo, websockets: gDashboard.requestWebsocketConnections, dnslookuptool: () => {}, logging: () => {}, rcwn: gDashboard.requestRcwnStats, }; const gDashboardCallbacks = { "http": displayHttp, "sockets": displaySockets, "dns": displayDns, "websockets": displayWebsockets, "rcwn": displayRcwnStats, http: displayHttp, sockets: displaySockets, dns: displayDns, websockets: displayWebsockets, rcwn: displayRcwnStats, }; const REFRESH_INTERVAL_MS = 3000; Loading Loading @@ -130,10 +135,14 @@ function displayWebsockets(data) { function displayRcwnStats(data) { let status = Services.prefs.getBoolPref("network.http.rcwn.enabled"); let linkType = gNetLinkSvc.linkType; if (!(linkType == Ci.nsINetworkLinkService.LINK_TYPE_UNKNOWN || if ( !( linkType == Ci.nsINetworkLinkService.LINK_TYPE_UNKNOWN || linkType == Ci.nsINetworkLinkService.LINK_TYPE_ETHERNET || linkType == Ci.nsINetworkLinkService.LINK_TYPE_USB || linkType == Ci.nsINetworkLinkService.LINK_TYPE_WIFI)) { linkType == Ci.nsINetworkLinkService.LINK_TYPE_WIFI ) ) { status = false; } Loading @@ -151,32 +160,28 @@ function displayRcwnStats(data) { document.getElementById("rcwn_cache_not_slow").innerText = cacheNotSlow; // Keep in sync with CachePerfStats::EDataType in CacheFileUtils.h const perfStatTypes = [ "open", "read", "write", "entryopen", ]; const perfStatFieldNames = [ "avgShort", "avgLong", "stddevLong", ]; const perfStatTypes = ["open", "read", "write", "entryopen"]; const perfStatFieldNames = ["avgShort", "avgLong", "stddevLong"]; for (let typeIndex in perfStatTypes) { for (let statFieldIndex in perfStatFieldNames) { document.getElementById("rcwn_perfstats_" + perfStatTypes[typeIndex] + "_" + perfStatFieldNames[statFieldIndex]).innerText = document.getElementById( "rcwn_perfstats_" + perfStatTypes[typeIndex] + "_" + perfStatFieldNames[statFieldIndex] ).innerText = data.perfStats[typeIndex][perfStatFieldNames[statFieldIndex]]; } } } function requestAllNetworkingData() { for (let id in gRequestNetworkingData) for (let id in gRequestNetworkingData) { requestNetworkingDataForTab(id); } } function requestNetworkingDataForTab(id) { gRequestNetworkingData[id](gDashboardCallbacks[id]); Loading @@ -199,8 +204,9 @@ function init() { requestAllNetworkingData(); let autoRefresh = document.getElementById("autorefcheck"); if (autoRefresh.checked) if (autoRefresh.checked) { setAutoRefreshInterval(autoRefresh); } autoRefresh.addEventListener("click", function() { let refrButton = document.getElementById("refreshButton"); Loading @@ -215,14 +221,16 @@ function init() { let refr = document.getElementById("refreshButton"); refr.addEventListener("click", requestAllNetworkingData); if (document.getElementById("autorefcheck").checked) if (document.getElementById("autorefcheck").checked) { refr.disabled = "disabled"; } // Event delegation on #categories element let menu = document.getElementById("categories"); menu.addEventListener("click", function click(e) { if (e.target && e.target.parentNode == menu) if (e.target && e.target.parentNode == menu) { show(e.target); } }); let dnsLookupButton = document.getElementById("dnsLookupButton"); Loading Loading @@ -264,7 +272,9 @@ function init() { } if (location.hash) { let sectionButton = document.getElementById("category-" + location.hash.substring(1)); let sectionButton = document.getElementById( "category-" + location.hash.substring(1) ); if (sectionButton) { sectionButton.click(); } Loading Loading @@ -292,7 +302,8 @@ function updateLogFile() { function updateLogModules() { // Try to get the environment variable for the log file let logModules = gEnv.get("MOZ_LOG") || let logModules = gEnv.get("MOZ_LOG") || gEnv.get("MOZ_LOG_MODULES") || gEnv.get("NSPR_LOG_MODULES"); let currentLogModules = document.getElementById("current-log-modules"); Loading Loading @@ -415,8 +426,9 @@ function show(button) { let current_tab = document.querySelector(".active"); let category = button.getAttribute("id").substring("category-".length); let content = document.getElementById(category); if (current_tab == content) if (current_tab == content) { return; } current_tab.classList.remove("active"); current_tab.hidden = true; content.classList.add("active"); Loading
toolkit/content/aboutProfiles.js +113 −60 Original line number Diff line number Diff line Loading @@ -5,7 +5,9 @@ "use strict"; const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm"); const {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm"); const { XPCOMUtils } = ChromeUtils.import( "resource://gre/modules/XPCOMUtils.jsm" ); XPCOMUtils.defineLazyServiceGetter( this, Loading @@ -21,17 +23,28 @@ async function flush() { } catch (e) { let [title, msg, button] = await document.l10n.formatValues([ { id: "profiles-flush-fail-title" }, { id: e.result == Cr.NS_ERROR_DATABASE_CHANGED ? "profiles-flush-conflict" : "profiles-flush-failed" }, { id: e.result == Cr.NS_ERROR_DATABASE_CHANGED ? "profiles-flush-conflict" : "profiles-flush-failed", }, { id: "profiles-flush-restart-button" }, ]); const PS = Ci.nsIPromptService; let result = Services.prompt.confirmEx(window, title, msg, (PS.BUTTON_POS_0 * PS.BUTTON_TITLE_CANCEL) + (PS.BUTTON_POS_1 * PS.BUTTON_TITLE_IS_STRING), null, button, null, null, {}); let result = Services.prompt.confirmEx( window, title, msg, PS.BUTTON_POS_0 * PS.BUTTON_TITLE_CANCEL + PS.BUTTON_POS_1 * PS.BUTTON_TITLE_IS_STRING, null, button, null, null, {} ); if (result == 1) { restart(false); } Loading Loading @@ -59,9 +72,11 @@ function rebuildProfileList() { let lock = profile.lock({}); lock.unlock(); } catch (e) { if (e.result != Cr.NS_ERROR_FILE_TARGET_DOES_NOT_EXIST && if ( e.result != Cr.NS_ERROR_FILE_TARGET_DOES_NOT_EXIST && e.result != Cr.NS_ERROR_FILE_NOT_DIRECTORY && e.result != Cr.NS_ERROR_FILE_NOT_FOUND) { e.result != Cr.NS_ERROR_FILE_NOT_FOUND ) { isInUse = true; } } Loading @@ -84,8 +99,9 @@ function display(profileData) { let name = document.createElement("h2"); div.appendChild(name); document.l10n.setAttributes(name, "profiles-name", { name: profileData.profile.name }); document.l10n.setAttributes(name, "profiles-name", { name: profileData.profile.name, }); if (profileData.isCurrentProfile) { let currentProfile = document.createElement("h3"); Loading Loading @@ -134,8 +150,10 @@ function display(profileData) { } } createItem("profiles-is-default", profileData.isDefault ? "profiles-yes" : "profiles-no"); createItem( "profiles-is-default", profileData.isDefault ? "profiles-yes" : "profiles-no" ); createItem("profiles-rootdir", profileData.profile.rootDir, true); Loading Loading @@ -190,9 +208,12 @@ function CreateProfile(profile) { function createProfileWizard() { // This should be rewritten in HTML eventually. window.openDialog("chrome://mozapps/content/profile/createProfileWizard.xul", "", "centerscreen,chrome,modal,titlebar", ProfileService); window.openDialog( "chrome://mozapps/content/profile/createProfileWizard.xul", "", "centerscreen,chrome,modal,titlebar", ProfileService ); } async function renameProfile(profile) { Loading @@ -202,8 +223,7 @@ async function renameProfile(profile) { { id: "profiles-rename-profile", args: { name: profile.name } }, ]); if (Services.prompt.prompt(window, title, msg, newName, null, { value: 0 })) { if (Services.prompt.prompt(window, title, msg, newName, null, { value: 0 })) { newName = newName.value; if (newName == profile.name) { Loading @@ -230,20 +250,33 @@ async function removeProfile(profile) { let deleteFiles = false; if (profile.rootDir.exists()) { let [title, msg, dontDeleteStr, deleteStr] = await document.l10n.formatValues([ let [ title, msg, dontDeleteStr, deleteStr, ] = await document.l10n.formatValues([ { id: "profiles-delete-profile-title" }, { id: "profiles-delete-profile-confirm", args: { dir: profile.rootDir.path } }, { id: "profiles-delete-profile-confirm", args: { dir: profile.rootDir.path }, }, { id: "profiles-dont-delete-files" }, { id: "profiles-delete-files" }, ]); let buttonPressed = Services.prompt.confirmEx(window, title, msg, (Services.prompt.BUTTON_TITLE_IS_STRING * Services.prompt.BUTTON_POS_0) + (Services.prompt.BUTTON_TITLE_CANCEL * Services.prompt.BUTTON_POS_1) + (Services.prompt.BUTTON_TITLE_IS_STRING * Services.prompt.BUTTON_POS_2), let buttonPressed = Services.prompt.confirmEx( window, title, msg, Services.prompt.BUTTON_TITLE_IS_STRING * Services.prompt.BUTTON_POS_0 + Services.prompt.BUTTON_TITLE_CANCEL * Services.prompt.BUTTON_POS_1 + Services.prompt.BUTTON_TITLE_IS_STRING * Services.prompt.BUTTON_POS_2, dontDeleteStr, null, deleteStr, null, {value: 0}); null, { value: 0 } ); if (buttonPressed == 1) { return; } Loading Loading @@ -310,9 +343,14 @@ async function defaultProfile(profile) { } function openProfile(profile) { let cancelQuit = Cc["@mozilla.org/supports-PRBool;1"] .createInstance(Ci.nsISupportsPRBool); Services.obs.notifyObservers(cancelQuit, "quit-application-requested", "restart"); let cancelQuit = Cc["@mozilla.org/supports-PRBool;1"].createInstance( Ci.nsISupportsPRBool ); Services.obs.notifyObservers( cancelQuit, "quit-application-requested", "restart" ); if (cancelQuit.data) { return; Loading @@ -322,9 +360,14 @@ function openProfile(profile) { } function restart(safeMode) { let cancelQuit = Cc["@mozilla.org/supports-PRBool;1"] .createInstance(Ci.nsISupportsPRBool); Services.obs.notifyObservers(cancelQuit, "quit-application-requested", "restart"); let cancelQuit = Cc["@mozilla.org/supports-PRBool;1"].createInstance( Ci.nsISupportsPRBool ); Services.obs.notifyObservers( cancelQuit, "quit-application-requested", "restart" ); if (cancelQuit.data) { return; Loading @@ -339,19 +382,27 @@ function restart(safeMode) { } } window.addEventListener("DOMContentLoaded", function() { window.addEventListener( "DOMContentLoaded", function() { let createButton = document.getElementById("create-button"); createButton.addEventListener("click", createProfileWizard); let restartSafeModeButton = document.getElementById("restart-in-safe-mode-button"); let restartSafeModeButton = document.getElementById( "restart-in-safe-mode-button" ); if (!Services.policies || Services.policies.isAllowed("safeMode")) { restartSafeModeButton.addEventListener("click", () => { restart(true); }); restartSafeModeButton.addEventListener("click", () => { restart(true); }); } else { restartSafeModeButton.setAttribute("disabled", "true"); } let restartNormalModeButton = document.getElementById("restart-button"); restartNormalModeButton.addEventListener("click", () => { restart(false); }); restartNormalModeButton.addEventListener("click", () => { restart(false); }); if (ProfileService.isListOutdated) { document.getElementById("owned").hidden = true; Loading @@ -359,4 +410,6 @@ window.addEventListener("DOMContentLoaded", function() { document.getElementById("conflict").hidden = true; rebuildProfileList(); } }, {once: true}); }, { once: true } );