1 # -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 # ***** BEGIN LICENSE BLOCK *****
3 # Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 # The contents of this file are subject to the Mozilla Public License Version
6 # 1.1 (the "License"); you may not use this file except in compliance with
7 # the License. You may obtain a copy of the License at
8 # http://www.mozilla.org/MPL/
10 # Software distributed under the License is distributed on an "AS IS" basis,
11 # WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 # for the specific language governing rights and limitations under the
15 # The Original Code is mozilla.org code.
17 # The Initial Developer of the Original Code is
18 # Netscape Communications Corporation.
19 # Portions created by the Initial Developer are Copyright (C) 1998
20 # the Initial Developer. All Rights Reserved.
23 # Alec Flett <alecf@netscape.com>
24 # Ehsan Akhgari <ehsan.akhgari@gmail.com>
26 # Alternatively, the contents of this file may be used under the terms of
27 # either the GNU General Public License Version 2 or later (the "GPL"), or
28 # the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29 # in which case the provisions of the GPL or the LGPL are applicable instead
30 # of those above. If you wish to allow use of your version of this file only
31 # under the terms of either the GPL or the LGPL, and not to allow others to
32 # use your version of this file under the terms of the MPL, indicate your
33 # decision by deleting the provisions above and replace them with the notice
34 # and other provisions required by the GPL or the LGPL. If you do not delete
35 # the provisions above, a recipient may use your version of this file under
36 # the terms of any one of the MPL, the GPL or the LGPL.
38 # ***** END LICENSE BLOCK *****
51 return "chrome://browser/content/browser.xul";
56 var toolbar = document.getElementById(
id);
57 var
element = document.getElementById(elementID);
60 var isHidden = toolbar.hidden;
61 toolbar.hidden = !isHidden;
62 document.persist(
id,
'hidden');
64 element.setAttribute(
"checked", isHidden ?
"true" :
"false");
65 document.persist(elementID,
'checked');
72 var windowManager = Components.classes[
'@mozilla.org/appshell/window-mediator;1']
73 .getService(Components.interfaces.nsIWindowMediator);
74 return windowManager.getMostRecentWindow(
"navigator:browser");
85 var
pref = Components.classes[
"@mozilla.org/preferences-service;1"]
86 .getService(Components.interfaces.nsIPrefBranch);
87 return pref.getBoolPref(prefname);
102 if (aElement instanceof
Window) {
105 throw "aElement is not a content window";
107 msg =
"focusElement(content) is deprecated. Use gBrowser.selectedBrowser.focus() instead.";
111 msg =
"focusElement(element) is deprecated. Use element.focus() instead.";
114 var scriptError = Components.classes[
"@mozilla.org/scripterror;1"]
115 .createInstance(Components.interfaces.nsIScriptError);
116 scriptError.init(msg, document.location.href,
null,
null,
117 null, scriptError.warningFlag,
"chrome javascript");
118 Components.classes[
"@mozilla.org/consoleservice;1"]
119 .getService(Components.interfaces.nsIConsoleService)
120 .logMessage(scriptError);
124 function openUILink(
url, e, ignoreButton, ignoreAlt, allowKeywordFixup, postData, referrerUrl )
163 var shift = e.shiftKey;
164 var ctrl = e.ctrlKey;
165 var meta = e.metaKey;
166 var alt = e.altKey && !ignoreAlt;
169 var middle = !ignoreButton && e.button == 1;
170 var middleUsesTabs =
getBoolPref(
"browser.tabs.opentabfor.middleclick",
true);
175 if (meta || (middle && middleUsesTabs)) {
177 if (ctrl || (middle && middleUsesTabs)) {
187 else if (shift || (middle && !middleUsesTabs)) {
213 if (where ==
"save") {
217 const Cc = Components.classes;
218 const Ci = Components.interfaces;
222 if (!w || where ==
"window") {
223 var sa =
Cc[
"@mozilla.org/supports-array;1"].
226 var wuri =
Cc[
"@mozilla.org/supports-string;1"].
230 sa.AppendElement(wuri);
231 sa.AppendElement(
null);
232 sa.AppendElement(referrerUrl);
233 sa.AppendElement(postData);
234 sa.AppendElement(allowThirdPartyFixup);
236 var
ww =
Cc[
"@mozilla.org/embedcomp/window-watcher;1"].
239 ww.openWindow(w ||
window,
242 "chrome,dialog=no,all",
248 var loadInBackground =
getBoolPref(
"browser.tabs.loadBookmarksInBackground",
false);
252 w.loadURI(
url, referrerUrl, postData, allowThirdPartyFixup);
255 loadInBackground = !loadInBackground;
259 browser.loadOneTab(
url, {
260 referrerURI: referrerUrl,
262 inBackground: loadInBackground,
263 allowThirdPartyFixup: allowThirdPartyFixup});
270 var fm = Components.classes[
"@mozilla.org/focus-manager;1"].
271 getService(Components.interfaces.nsIFocusManager);
272 if (
window == fm.activeWindow)
275 w.gBrowser.selectedBrowser.focus();
284 if (
node.getAttribute(
"disabled") ==
"true")
287 if (
event.button == 1) {
293 node.ownerDocument.getElementById(
node.getAttribute(
"command"));
294 var
fn =
new Function(
"event", target.getAttribute(
"oncommand"));
295 fn.call(target,
event);
306 if (
"tagName" in
node) {
307 if (node.namespaceURI ==
"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
308 && (node.tagName ==
"menupopup" || node.tagName ==
"popup"))
319 var
node = root.firstChild;
321 while ( node && depth > 0 ) {
323 if ( node.nodeType == Node.TEXT_NODE ) {
325 text +=
" " + node.data;
326 }
else if ( node instanceof HTMLImageElement) {
328 var altText = node.getAttribute(
"alt" );
329 if ( altText && altText !=
"" ) {
336 if ( node.hasChildNodes() ) {
338 node = node.firstChild;
342 if ( node.nextSibling ) {
343 node = node.nextSibling;
346 node = node.parentNode.nextSibling;
352 text = text.replace( /^\s+/,
"" );
354 text = text.replace( /\s+$/,
"" );
356 text = text.replace( /\s+/g,
" " );
364 shell = Components.classes[
"@mozilla.org/browser/shell-service;1"]
365 .getService(Components.interfaces.nsIShellService);
366 }
catch (e) {dump(
"*** e = " + e +
"\n");}
380 var localeService = Components.classes[
"@mozilla.org/intl/nslocaleservice;1"]
381 .getService(Components.interfaces.nsILocaleService);
382 var systemLocale = localeService.getSystemLocale().getCategory(
"NSILOCALE_CTYPE").substr(0,3);
384 switch (systemLocale) {
391 var
pref = Components.classes[
"@mozilla.org/preferences-service;1"]
392 .getService(Components.interfaces.nsIPrefBranch);
393 pref.setBoolPref(
"bidi.browser.ui",
true);
403 var
wm = Components.classes[
"@mozilla.org/appshell/window-mediator;1"]
404 .getService(Components.interfaces.nsIWindowMediator);
405 var
win = wm.getMostRecentWindow(
"Browser:About");
411 window.open(
"chrome://browser/content/aboutDialog.xul",
"About",
412 "chrome, resizable=no, minimizable=no");
415 window.openDialog(
"chrome://browser/content/aboutDialog.xul",
"About",
"centerscreen,chrome,resizable=no");
421 var instantApply =
getBoolPref(
"browser.preferences.instantApply",
false);
422 var features =
"chrome,titlebar,toolbar,centerscreen" + (instantApply ?
",dialog=no" :
",modal");
424 var
wm = Components.classes[
"@mozilla.org/appshell/window-mediator;1"]
425 .getService(Components.interfaces.nsIWindowMediator);
426 var
win = wm.getMostRecentWindow(
"Browser:Preferences");
430 var pane = win.document.getElementById(paneID);
431 win.document.documentElement.showPane(pane);
434 if (extraArgs && extraArgs[
"advancedTab"]) {
435 var advancedPaneTabs = win.document.getElementById(
"advancedPrefs");
436 advancedPaneTabs.selectedTab = win.document.getElementById(extraArgs[
"advancedTab"]);
442 return openDialog(
"chrome://browser/content/preferences/preferences.xul",
443 "Preferences", features, paneID, extraArgs);
456 var formatter = Components.classes[
"@mozilla.org/toolkit/URLFormatterService;1"]
457 .getService(Components.interfaces.nsIURLFormatter);
458 var relnotesURL = formatter.formatURLPref(
"app.releaseNotesURL");
479 Components.classes[
"@mozilla.org/updates/update-manager;1"].
480 getService(Components.interfaces.nsIUpdateManager);
482 Components.classes[
"@mozilla.org/updates/update-prompt;1"].
488 if (um.activeUpdate && um.activeUpdate.state ==
"pending")
489 prompter.showUpdateDownloaded(um.activeUpdate);
491 prompter.checkForUpdates();
504 Components.classes[
"@mozilla.org/updates/update-service;1"].
505 getService(Components.interfaces.nsIApplicationUpdateService2);
507 Components.classes[
"@mozilla.org/updates/update-manager;1"].
508 getService(Components.interfaces.nsIUpdateManager);
513 var canCheckForUpdates = updates.canCheckForUpdates;
514 checkForUpdates.setAttribute(
"disabled", !canCheckForUpdates);
515 if (!canCheckForUpdates)
518 var
strings = document.getElementById(
"bundle_browser");
519 var activeUpdate = um.activeUpdate;
523 function getStringWithUpdateName(
key) {
524 if (activeUpdate && activeUpdate.name)
525 return strings.getFormattedString(
key, [activeUpdate.name]);
526 return strings.getString(
key +
"Fallback");
532 switch (activeUpdate.state) {
537 key = updates.isDownloading ?
"downloading" :
"resume";
546 checkForUpdates.label = getStringWithUpdateName(
"updatesItem_" + key);
547 checkForUpdates.accessKey = strings.getString(
"updatesItem_" + key +
".accesskey");
548 if (um.activeUpdate && updates.isDownloading)
549 checkForUpdates.setAttribute(
"loading",
"true");
551 checkForUpdates.removeAttribute(
"loading");
554 document.getElementById(
"updateSeparator").hidden =
true;
565 var bo = aElement.boxObject;
566 return (bo.height > 0 && bo.width > 0);
577 var browsers = gBrowser.browsers;
578 for (var
i = 0;
i < browsers.length;
i++) {
579 if (browsers[
i].contentWindow == aContentWindow)
610 aAllowThirdPartyFixup, aReferrer)
613 urlSecurityCheck(aURL,
aDocument.nodePrincipal);
615 var
prefSvc = Components.classes[
"@mozilla.org/preferences-service;1"]
616 .getService(Components.interfaces.nsIPrefService);
617 prefSvc = prefSvc.getBranch(
null);
620 var loadInBackground =
true;
622 loadInBackground = prefSvc.getBoolPref(
"browser.tabs.loadInBackground");
627 if (aEvent && aEvent.shiftKey)
628 loadInBackground = !loadInBackground;
632 var wintype = document.documentElement.getAttribute(
"windowtype");
634 if (wintype ==
"navigator:browser")
635 originCharset =
window.content.document.characterSet;
639 var
browser =
top.document.getElementById(
"content");
640 return browser.loadOneTab(aURL, {
641 referrerURI: referrerURI,
644 inBackground: loadInBackground,
645 allowThirdPartyFixup: aAllowThirdPartyFixup});
652 urlSecurityCheck(aURL,
aDocument.nodePrincipal);
658 var charsetArg =
null;
659 var wintype = document.documentElement.getAttribute(
"windowtype");
660 if (wintype ==
"navigator:browser")
661 charsetArg =
"charset=" +
window.content.document.characterSet;
665 aURL, charsetArg, referrerURI, aPostData,
666 aAllowThirdPartyFixup);
682 if (!aLink || !aPrincipal)
685 var type = aLink.type.toLowerCase().replace(/^\s+|\s*(?:;.*)?$/g,
"");
687 aIsFeed = (type ==
"application/rss+xml" ||
688 type ==
"application/atom+xml");
693 urlSecurityCheck(aLink.href, aPrincipal,
694 Components.interfaces.nsIScriptSecurityManager.DISALLOW_INHERIT_PRINCIPAL);
695 return type ||
"application/rss+xml";
706 var
url = Components.classes[
"@mozilla.org/toolkit/URLFormatterService;1"]
707 .getService(Components.interfaces.nsIURLFormatter)
708 .formatURLPref(
"app.support.baseURL");
711 var where = aCalledFromModal ?
"window" :
"tab";
716 var
prefs = Components.classes[
"@mozilla.org/preferences-service;1"]
717 .getService(Components.interfaces.nsIPrefBranch2);
721 var instantApply = prefs.getBoolPref(
"browser.preferences.instantApply");
723 var helpTopic = document.getElementsByTagName(
"prefwindow")[0].currentPane.helpTopic;
function openNewTabWith(aURL, aDocument, aPostData, aEvent, aAllowThirdPartyFixup, aReferrer)
function checkForUpdates()
function gatherTextUnder(root)
function openUILinkIn(url, where, allowThirdPartyFixup, postData, referrerUrl)
function openHelpLink(aHelpTopic, aCalledFromModal)
function checkForMiddleClick(node, event)
function makeURLAbsolute(aBase, aUrl)
function getBoolPref(prefname, def)
function closeMenus(node)
getService(Ci.sbIFaceplateManager)
function getBrowserFromContentWindow(aContentWindow)
function openPreferences(paneID, extraArgs)
function openReleaseNotes()
_collectFormDataForFrame aDocument
function openAboutDialog()
function makeURI(aURLSpec, aCharset)
function goToggleToolbar(id, elementID)
function isElementVisible(aElement)
function focusElement(aElement)
function openUILink(url, e, ignoreButton, ignoreAlt, allowKeywordFixup, postData, referrerUrl)
function isValidFeed(aLink, aPrincipal, aIsFeed)
function openAdvancedPreferences(tabID)
function whereToOpenLink(e, ignoreButton, ignoreAlt)
function openNewWindowWith(aURL, aDocument, aPostData, aAllowThirdPartyFixup, aReferrer)
function openTroubleshootingPage()
function getShellService()
_getSelectedPageStyle s i