forked from pool/MozillaFirefox
04bdd006c2
OBS-URL: https://build.opensuse.org/package/show/mozilla:Factory/MozillaFirefox?expand=0&rev=ae86e44ea6ef7c7427356a606b2d8390
388 lines
16 KiB
Diff
388 lines
16 KiB
Diff
diff --git a/browser/base/content/browser-menubar.inc b/browser/base/content/browser-menubar.inc
|
|
--- a/browser/base/content/browser-menubar.inc
|
|
+++ b/browser/base/content/browser-menubar.inc
|
|
@@ -64,21 +64,19 @@
|
|
<menuitem id="menu_closeWindow" hidden="true" command="cmd_closeWindow" key="key_closeWindow" label="&closeWindow.label;" accesskey="&closeWindow.accesskey;"/>
|
|
<menuitem id="menu_close" label="&closeCmd.label;" key="key_close" accesskey="&closeCmd.accesskey;" command="cmd_close"/>
|
|
<menuseparator/>
|
|
<menuitem label="&savePageCmd.label;" accesskey="&savePageCmd.accesskey;" key="key_savePage" command="Browser:SavePage"
|
|
id="menu_savePage" />
|
|
<menuitem id="menu_saveFrame" label="&saveFrameCmd.label;" accesskey="&saveFrameCmd.accesskey;" command="Browser:SaveFrame" hidden="true"/>
|
|
<menuitem id="menu_sendLink" label="&sendPageCmd.label;" accesskey="&sendPageCmd.accesskey;" command="Browser:SendLink"/>
|
|
<menuseparator/>
|
|
- <menuitem label="&printSetupCmd.label;" accesskey="&printSetupCmd.accesskey;" command="cmd_pageSetup"
|
|
- id="menu_printSetup" />
|
|
+ <menuitem id="menu_printSetup" label="&printSetupCmd.label;" accesskey="&printSetupCmd.accesskey;" command="cmd_pageSetup"/>
|
|
#ifndef XP_MACOSX
|
|
- <menuitem label="&printPreviewCmd.label;" accesskey="&printPreviewCmd.accesskey;" command="cmd_printPreview"
|
|
- id="menu_printPreview" />
|
|
+ <menuitem id="menu_printPreview" label="&printPreviewCmd.label;" accesskey="&printPreviewCmd.accesskey;" oncommand="PrintUtils.printPreview(onEnterPrintPreview, onExitPrintPreview);"/>
|
|
#endif
|
|
<menuitem label="&printCmd.label;" accesskey="&printCmd.accesskey;" key="printKb" command="cmd_print"
|
|
id="menu_print" />
|
|
<menuseparator/>
|
|
<menuitem label="&import.label;" accesskey="&import.accesskey;" oncommand="BrowserImport();"
|
|
id="menu_import"/>
|
|
#ifndef XP_MACOSX
|
|
<menuseparator/>
|
|
diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js
|
|
--- a/browser/base/content/browser.js
|
|
+++ b/browser/base/content/browser.js
|
|
@@ -1192,32 +1192,186 @@ function prepareForStartup() {
|
|
// setup our MozApplicationManifest listener
|
|
gBrowser.addEventListener("MozApplicationManifest",
|
|
OfflineApps, false);
|
|
|
|
// setup simple gestures support
|
|
gGestureSupport.init(true);
|
|
}
|
|
|
|
+function lockdownElement(ident, disable, hideCompletely)
|
|
+{
|
|
+ var e = document.getElementById(ident);
|
|
+ if (!e) return;
|
|
+ if (hideCompletely) {
|
|
+ e.setAttribute("style", (disable) ? "display: none;" : "");
|
|
+ } else if (disable) {
|
|
+ e.setAttribute("disabled", "true");
|
|
+ } else {
|
|
+ e.removeAttribute("disabled");
|
|
+ }
|
|
+}
|
|
+
|
|
+function applyLockdown(isStartup)
|
|
+{
|
|
+ // It is important to check that Firefox code does not change the
|
|
+ // "disabled" state of these UI elements. Fortunately it mostly hides
|
|
+ // elements rather than disables them.
|
|
+ var disablePrinting = gPrefService.getBoolPref("config.lockdown.printing");
|
|
+ var disablePrintSetup = gPrefService.getBoolPref("config.lockdown.printsetup");
|
|
+ if (!isStartup || disablePrintSetup || disablePrintSetup) {
|
|
+ lockdownElement("cmd_pageSetup", disablePrinting || disablePrintSetup);
|
|
+ lockdownElement("menu_printPreview", disablePrinting || disablePrintSetup);
|
|
+ lockdownElement("cmd_print", disablePrinting);
|
|
+ }
|
|
+
|
|
+ var disableSave = gPrefService.getBoolPref("config.lockdown.savepage");
|
|
+ if (!isStartup || disableSave) {
|
|
+ lockdownElement("Browser:SavePage", disableSave);
|
|
+ lockdownElement("Browser:SaveFrame", disableSave);
|
|
+ lockdownElement("context-savepage", disableSave);
|
|
+ lockdownElement("context-saveframe", disableSave);
|
|
+ lockdownElement("context-savelink", disableSave);
|
|
+ lockdownElement("context-saveimage", disableSave);
|
|
+ lockdownElement("View:PageSource", disableSave);
|
|
+ lockdownElement("context-viewpartialsource-selection", disableSave);
|
|
+ lockdownElement("context-viewpartialsource-mathml", disableSave);
|
|
+ lockdownElement("context-viewsource", disableSave);
|
|
+ lockdownElement("context-viewframesource", disableSave);
|
|
+ lockdownElement("View:PageInfo", disableSave);
|
|
+ lockdownElement("context-viewinfo", disableSave);
|
|
+ lockdownElement("context-viewframeinfo", disableSave);
|
|
+ lockdownElement("Tasks:InspectPage", disableSave); // from DOMInspector extension
|
|
+ }
|
|
+
|
|
+ var disableBookmarks = gPrefService.getBoolPref("config.lockdown.hidebookmark");
|
|
+ var disableBookmarkEditing = gPrefService.getBoolPref("config.lockdown.bookmark");
|
|
+ if (!isStartup || disableBookmarks || disableBookmarkEditing) {
|
|
+ lockdownElement("bookmarksMenu", disableBookmarks, true);
|
|
+ lockdownElement("viewBookmarksSidebar", disableBookmarks);
|
|
+ lockdownElement("PersonalToolbar", disableBookmarks); // XXX check
|
|
+ lockdownElement("Browser:AddBookmarkAs", disableBookmarks || disableBookmarkEditing);
|
|
+ lockdownElement("Browser:ShowAllBookmarks", disableBookmarks || disableBookmarkEditing);
|
|
+ lockdownElement("manBookmark", disableBookmarks || disableBookmarkEditing);
|
|
+ lockdownElement("context-bookmarkpage", disableBookmarks || disableBookmarkEditing);
|
|
+ lockdownElement("context-bookmarklink", disableBookmarks || disableBookmarkEditing);
|
|
+
|
|
+ // hide the personal bookmarks toolbar if necessary
|
|
+ if (disableBookmarks) {
|
|
+ document.getElementById("PersonalToolbar").setAttribute("collapsed", "true");
|
|
+ }
|
|
+ }
|
|
+
|
|
+ var disableHistory = gPrefService.getBoolPref("config.lockdown.history");
|
|
+ if (!isStartup || disableHistory) {
|
|
+ lockdownElement("history-menu", disableHistory, true);
|
|
+ lockdownElement("viewHistorySidebar", disableHistory);
|
|
+ lockdownElement("Browser:ShowAllHistory", disableHistory);
|
|
+ gURLBar.setAttribute("enablehistory", disableHistory ? "false" : "true");
|
|
+ gURLBar.disableAutoComplete = disableHistory;
|
|
+ }
|
|
+
|
|
+ var defaultPrefs = Cc["@mozilla.org/preferences-service;1"]
|
|
+ .getService(Ci.nsIPrefService).getDefaultBranch(null);
|
|
+ if (isStartup && disableHistory) {
|
|
+ if (!defaultPrefs.prefIsLocked("browser.history_expire_days")) {
|
|
+ defaultPrefs.setIntPref("browser.history_expire_days", 0);
|
|
+ defaultPrefs.lockPref("browser.history_expire_days");
|
|
+ }
|
|
+ if (!defaultPrefs.prefIsLocked("browser.formfill.enable")) {
|
|
+ defaultPrefs.setBoolPref("browser.formfill.enable", false);
|
|
+ defaultPrefs.lockPref("browser.formfill.enable");
|
|
+ }
|
|
+ if (!defaultPrefs.prefIsLocked("browser.download.manager.retention")) {
|
|
+ defaultPrefs.setIntPref("browser.download.manager.retention", 0);
|
|
+ defaultPrefs.lockPref("browser.download.manager.retention");
|
|
+ }
|
|
+ gPrefService.setBoolPref("config.lockdown.history.set", true);
|
|
+ } else if (isStartup && gPrefService.prefHasUserValue("config.lockdown.history.set")) {
|
|
+ if (!defaultPrefs.prefIsLocked("browser.history_expire_days")) {
|
|
+ defaultPrefs.clearUserPref("browser.history_expire_days");
|
|
+ }
|
|
+ if (!defaultPrefs.prefIsLocked("browser.formfill.enable")) {
|
|
+ defaultPrefs.clearUserPref("browser.formfill.enable");
|
|
+ }
|
|
+ if (!defaultPrefs.prefIsLocked("browser.download.manager.retention")) {
|
|
+ defaultPrefs.clearUserPref("browser.download.manager.retention");
|
|
+ }
|
|
+ gPrefService.clearUserPref("config.lockdown.history.set");
|
|
+ }
|
|
+
|
|
+ var disableURLBar = gPrefService.getBoolPref("config.lockdown.urlbar");
|
|
+ if (!isStartup || disableURLBar) {
|
|
+ lockdownElement("urlbar", disableURLBar);
|
|
+ lockdownElement("Browser:OpenLocation", disableURLBar);
|
|
+ lockdownElement("Browser:OpenFile", disableURLBar);
|
|
+ }
|
|
+
|
|
+ var disableSearchBar = gPrefService.getBoolPref("config.lockdown.searchbar");
|
|
+ if (!isStartup || disableSearchBar) {
|
|
+ document.getElementById("search-container")
|
|
+ .setAttribute("style", (disableSearchBar) ? "display: none;" : "");
|
|
+ }
|
|
+
|
|
+ var disableToolbarEditing = gPrefService.getBoolPref("config.lockdown.toolbarediting");
|
|
+ if (!isStartup || disableToolbarEditing) {
|
|
+ var e = document.getElementById("cmd_CustomizeToolbars");
|
|
+ if (!e.getAttribute("inCustomization")) {
|
|
+ lockdownElement("cmd_CustomizeToolbars", disableToolbarEditing);
|
|
+ }
|
|
+ }
|
|
+
|
|
+ // Close sidebar if we disabled the command that's currently in use
|
|
+ var sidebarBox = document.getElementById("sidebar-box");
|
|
+ var cmd = sidebarBox.getAttribute("sidebarcommand");
|
|
+ if (cmd) {
|
|
+ var elt = document.getElementById(cmd);
|
|
+ if (elt && elt.getAttribute("disabled") == "true") {
|
|
+ toggleSidebar(cmd, false);
|
|
+ gMustLoadSidebar = false;
|
|
+ }
|
|
+ }
|
|
+}
|
|
+
|
|
+var lockdownObserver = {
|
|
+ observe: function(aSubject, aTopic, aPrefName)
|
|
+ {
|
|
+ try {
|
|
+ applyLockdown(false);
|
|
+ } catch (ex) {
|
|
+ dump("Failed lockdown: " + ex + "\n");
|
|
+ }
|
|
+ }
|
|
+};
|
|
+
|
|
function delayedStartup(isLoadingBlank, mustLoadSidebar) {
|
|
var os = Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService);
|
|
os.addObserver(gSessionHistoryObserver, "browser:purge-session-history", false);
|
|
os.addObserver(gXPInstallObserver, "xpinstall-install-blocked", false);
|
|
|
|
+ try {
|
|
+ // do lockdown stuff in an exception handler so that if it fails
|
|
+ // catastrophically, the browser should still come up and function
|
|
+ applyLockdown(true);
|
|
+ gPrefService.addObserver("config.lockdown.", lockdownObserver, false);
|
|
+ } catch (ex) {
|
|
+ dump("Failed lockdown: " + ex + "\n");
|
|
+ }
|
|
+
|
|
BrowserOffline.init();
|
|
OfflineApps.init();
|
|
|
|
gBrowser.addEventListener("pageshow", function(evt) { setTimeout(pageShowEventHandlers, 0, evt); }, true);
|
|
|
|
// Ensure login manager is up and running.
|
|
Cc["@mozilla.org/login-manager;1"].getService(Ci.nsILoginManager);
|
|
|
|
if (mustLoadSidebar) {
|
|
+ let sidebarBox = document.getElementById("sidebar-box");
|
|
let sidebar = document.getElementById("sidebar");
|
|
- let sidebarBox = document.getElementById("sidebar-box");
|
|
sidebar.setAttribute("src", sidebarBox.getAttribute("src"));
|
|
}
|
|
|
|
UpdateUrlbarSearchSplitterState();
|
|
|
|
PlacesStarButton.init();
|
|
|
|
// called when we go into full screen, even if it is
|
|
@@ -1401,16 +1555,18 @@ function BrowserShutdown()
|
|
Components.utils.reportError(ex);
|
|
}
|
|
|
|
var os = Components.classes["@mozilla.org/observer-service;1"]
|
|
.getService(Components.interfaces.nsIObserverService);
|
|
os.removeObserver(gSessionHistoryObserver, "browser:purge-session-history");
|
|
os.removeObserver(gXPInstallObserver, "xpinstall-install-blocked");
|
|
|
|
+ gPrefService.removeObserver("config.lockdown.", lockdownObserver);
|
|
+
|
|
try {
|
|
gBrowser.removeProgressListener(window.XULBrowserWindow);
|
|
gBrowser.removeTabsProgressListener(window.TabsProgressListener);
|
|
} catch (ex) {
|
|
}
|
|
|
|
PlacesStarButton.uninit();
|
|
|
|
@@ -3200,16 +3356,22 @@ const BrowserSearch = {
|
|
function FillHistoryMenu(aParent) {
|
|
// Remove old entries if any
|
|
var children = aParent.childNodes;
|
|
for (var i = children.length - 1; i >= 0; --i) {
|
|
if (children[i].hasAttribute("index"))
|
|
aParent.removeChild(children[i]);
|
|
}
|
|
|
|
+ // lockdown. Don't display anything if locked down.
|
|
+ var disableHistory = gPrefService.getBoolPref("config.lockdown.history");
|
|
+ if (disableHistory) {
|
|
+ return false;
|
|
+ }
|
|
+
|
|
var webNav = getWebNavigation();
|
|
var sessionHistory = webNav.sessionHistory;
|
|
var bundle_browser = document.getElementById("bundle_browser");
|
|
|
|
var count = sessionHistory.count;
|
|
var index = sessionHistory.index;
|
|
var end;
|
|
|
|
@@ -3346,16 +3508,17 @@ function BrowserCustomizeToolbar()
|
|
{
|
|
// Disable the toolbar context menu items
|
|
var menubar = document.getElementById("main-menubar");
|
|
for (var i = 0; i < menubar.childNodes.length; ++i)
|
|
menubar.childNodes[i].setAttribute("disabled", true);
|
|
|
|
var cmd = document.getElementById("cmd_CustomizeToolbars");
|
|
cmd.setAttribute("disabled", "true");
|
|
+ cmd.setAttribute("inCustomization", "true");
|
|
|
|
var splitter = document.getElementById("urlbar-search-splitter");
|
|
if (splitter)
|
|
splitter.parentNode.removeChild(splitter);
|
|
|
|
var customizeURL = "chrome://global/content/customizeToolbar.xul";
|
|
#ifdef TOOLBAR_CUSTOMIZATION_SHEET
|
|
var sheetFrame = document.getElementById("customizeToolbarSheetIFrame");
|
|
@@ -3381,16 +3544,25 @@ function BrowserCustomizeToolbar()
|
|
#else
|
|
window.openDialog(customizeURL,
|
|
"CustomizeToolbar",
|
|
"chrome,titlebar,toolbar,location,resizable,dependent",
|
|
gNavToolbox);
|
|
#endif
|
|
}
|
|
|
|
+function BrowserRestoreCustomizationDisabledState()
|
|
+{
|
|
+ var cmd = document.getElementById("cmd_CustomizeToolbars");
|
|
+ if (!gPrefService.getBoolPref("config.lockdown.toolbarediting")) {
|
|
+ cmd.removeAttribute("disabled", "true");
|
|
+ }
|
|
+ cmd.removeAttribute("inCustomization");
|
|
+}
|
|
+
|
|
function BrowserToolboxCustomizeDone(aToolboxChanged) {
|
|
#ifdef TOOLBAR_CUSTOMIZATION_SHEET
|
|
document.getElementById("customizeToolbarSheetIFrame").hidden = true;
|
|
document.getElementById("customizeToolbarSheetPopup").hidePopup();
|
|
#endif
|
|
|
|
// Update global UI elements that may have been added or removed
|
|
if (aToolboxChanged) {
|
|
@@ -3398,16 +3570,23 @@ function BrowserToolboxCustomizeDone(aTo
|
|
if (gURLBar)
|
|
gURLBar.emptyText = gURLBarEmptyText.value;
|
|
|
|
gProxyFavIcon = document.getElementById("page-proxy-favicon");
|
|
gHomeButton.updateTooltip();
|
|
gIdentityHandler._cacheElements();
|
|
window.XULBrowserWindow.init();
|
|
|
|
+ // make sure the search bar is not put back if locked down
|
|
+ var disableSearchBar = gPrefService.getBoolPref("config.lockdown.searchbar");
|
|
+ if (disableSearchBar) {
|
|
+ document.getElementById("search-container")
|
|
+ .setAttribute("style", (disableSearchBar) ? "display: none;" : "");
|
|
+ }
|
|
+
|
|
var backForwardDropmarker = document.getElementById("back-forward-dropmarker");
|
|
if (backForwardDropmarker)
|
|
backForwardDropmarker.disabled =
|
|
document.getElementById('Browser:Back').hasAttribute('disabled') &&
|
|
document.getElementById('Browser:Forward').hasAttribute('disabled');
|
|
|
|
// support downgrading to Firefox 2.0
|
|
var navBar = document.getElementById("nav-bar");
|
|
@@ -3432,18 +3611,17 @@ function BrowserToolboxCustomizeDone(aTo
|
|
XULBrowserWindow.asyncUpdateUI();
|
|
PlacesStarButton.updateState();
|
|
}
|
|
|
|
// Re-enable parts of the UI we disabled during the dialog
|
|
var menubar = document.getElementById("main-menubar");
|
|
for (var i = 0; i < menubar.childNodes.length; ++i)
|
|
menubar.childNodes[i].setAttribute("disabled", false);
|
|
- var cmd = document.getElementById("cmd_CustomizeToolbars");
|
|
- cmd.removeAttribute("disabled");
|
|
+ BrowserRestoreCustomizationDisabledState();
|
|
|
|
// XXXmano bug 287105: wallpaper to bug 309953,
|
|
// the reload button isn't in sync with the reload command.
|
|
var reloadButton = document.getElementById("reload-button");
|
|
if (reloadButton) {
|
|
reloadButton.disabled =
|
|
document.getElementById("Browser:Reload").getAttribute("disabled") == "true";
|
|
}
|
|
@@ -4568,16 +4746,19 @@ function onViewToolbarsPopupShowing(aEve
|
|
var toolbar = gNavToolbox.childNodes[i];
|
|
var toolbarName = toolbar.getAttribute("toolbarname");
|
|
var type = toolbar.getAttribute("type");
|
|
if (toolbarName && type != "menubar") {
|
|
var menuItem = document.createElement("menuitem");
|
|
menuItem.setAttribute("toolbarindex", i);
|
|
menuItem.setAttribute("type", "checkbox");
|
|
menuItem.setAttribute("label", toolbarName);
|
|
+ if (toolbar.getAttribute("disabled") == "true") {
|
|
+ menuItem.setAttribute("disabled", "true");
|
|
+ }
|
|
menuItem.setAttribute("accesskey", toolbar.getAttribute("accesskey"));
|
|
menuItem.setAttribute("checked", toolbar.getAttribute("collapsed") != "true");
|
|
popup.insertBefore(menuItem, firstMenuItem);
|
|
|
|
menuItem.addEventListener("command", onViewToolbarCommand, false);
|
|
}
|
|
toolbar = toolbar.nextSibling;
|
|
}
|
|
@@ -6521,17 +6702,17 @@ BookmarkAllTabsHandler.prototype = {
|
|
|
|
_updateCommandState: function BATH__updateCommandState(aTabClose) {
|
|
var numTabs = gBrowser.tabContainer.childNodes.length;
|
|
|
|
// The TabClose event is fired before the tab is removed from the DOM
|
|
if (aTabClose)
|
|
numTabs--;
|
|
|
|
- if (numTabs > 1)
|
|
+ if (numTabs > 1 && !gPrefService.getBoolPref("config.lockdown.bookmark"))
|
|
this._command.removeAttribute("disabled");
|
|
else
|
|
this._command.setAttribute("disabled", "true");
|
|
},
|
|
|
|
doCommand: function BATH_doCommand() {
|
|
PlacesCommandHook.bookmarkCurrentPages();
|
|
},
|