38 if (typeof(
Ci) ==
"undefined")
39 var
Ci = Components.interfaces;
40 if (typeof(
Cc) ==
"undefined")
41 var
Cc = Components.classes;
42 if (typeof(
Cr) ==
"undefined")
43 var
Cr = Components.results;
49 throw(
"browserUtilities.js: : getBrowserURL() is not implemented in Songbird!");
54 var toolbar = document.getElementById(
id);
55 var
element = document.getElementById(elementID);
58 var isHidden = toolbar.hidden;
59 toolbar.hidden = !isHidden;
60 document.persist(
id,
'hidden');
62 element.setAttribute(
"checked", isHidden ?
"true" :
"false");
63 document.persist(elementID,
'checked');
70 var windowManager = Components.classes[
'@mozilla.org/appshell/window-mediator;1']
71 .getService(Components.interfaces.nsIWindowMediator);
72 return windowManager.getMostRecentWindow(
"Songbird:Main");
83 var
pref = Components.classes[
"@mozilla.org/preferences-service;1"]
84 .getService(Components.interfaces.nsIPrefBranch);
85 return pref.getBoolPref(prefname);
96 var
ww = Components.classes[
"@mozilla.org/embedcomp/window-watcher;1"]
97 .getService(Components.interfaces.nsIWindowWatcher);
98 if (
window == ww.activeWindow)
103 var cmdDispatcher = document.commandDispatcher;
104 if (aElement instanceof
Window) {
105 cmdDispatcher.focusedWindow = aElement;
106 cmdDispatcher.focusedElement =
null;
108 else if (aElement instanceof
Element) {
109 cmdDispatcher.focusedWindow = aElement.ownerDocument.defaultView;
110 cmdDispatcher.focusedElement = aElement;
116 function openUILink(
url, e, ignoreButton, ignoreAlt, allowKeywordFixup, postData, referrerUrl )
150 e = { shiftKey:
false,
ctrlKey:
false, metaKey:
false, altKey:
false, button:0 };
152 var shift = e.shiftKey;
153 var ctrl = e.ctrlKey;
154 var meta = e.metaKey;
155 var alt = e.altKey && !ignoreAlt;
158 var middle = !ignoreButton && e.button == 1;
159 var middleUsesTabs =
getBoolPref(
"browser.tabs.opentabfor.middleclick",
true);
163 Components.classes[
"@mozilla.org/system-info;1"]
164 .getService(Components.interfaces.nsIPropertyBag2);
165 var
os = sysInfo.getProperty(
"name");
167 var modifier = (os ==
"Darwin") ? meta : ctrl;
168 if (modifier || (middle && middleUsesTabs)) {
177 else if (shift || (middle && !middleUsesTabs)) {
203 if (where ==
"save") {
215 if (where ==
"window") {
216 dump(
"browserUtilities.js.openUILinkIn() Warning: Songbird does not support where=window.\n");
220 var loadInBackground =
getBoolPref(
"browser.tabs.loadBookmarksInBackground",
false);
226 if (typeof(browser) ==
"undefined") {
227 dump(
"\n\n\nbrowserUtilities.openUILinkIn() Error: no browser available!\n\n\n");
234 browser.loadURI(
url, referrerUrl, postData, allowThirdPartyFixup);
237 loadInBackground = !loadInBackground;
241 browser.loadOneTab(
url, referrerUrl,
null, postData, loadInBackground,
242 allowThirdPartyFixup ||
false);
259 if (
node.getAttribute(
"disabled") ==
"true")
262 if (
event.button == 1) {
267 var
fn =
new Function(
"event",
node.getAttribute(
"oncommand"));
279 if (
"tagName" in
node) {
280 if (node.namespaceURI ==
"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
281 && (node.tagName ==
"menupopup" || node.tagName ==
"popup"))
292 var
node = root.firstChild;
294 while ( node && depth > 0 ) {
296 if ( node.nodeType == Node.TEXT_NODE ) {
298 text +=
" " + node.data;
299 }
else if ( node instanceof HTMLImageElement) {
301 var altText = node.getAttribute(
"alt" );
302 if ( altText && altText !=
"" ) {
309 if ( node.hasChildNodes() ) {
311 node = node.firstChild;
315 if ( node.nextSibling ) {
316 node = node.nextSibling;
319 node = node.parentNode.nextSibling;
325 text = text.replace( /^\s+/,
"" );
327 text = text.replace( /\s+$/,
"" );
329 text = text.replace( /\s+/g,
" " );
337 shell = Components.classes[
"@mozilla.org/browser/shell-service;1"]
338 .getService(Components.interfaces.nsIShellService);
339 }
catch (e) {dump(
"*** e = " + e +
"\n");}
347 var localeService = Components.classes[
"@mozilla.org/intl/nslocaleservice;1"]
348 .getService(Components.interfaces.nsILocaleService);
349 var systemLocale = localeService.getSystemLocale().getCategory(
"NSILOCALE_CTYPE").substr(0,3);
351 switch (systemLocale) {
377 SBOpenPreferences(paneID);
389 throw(
"browserUtilities.js: openReleaseNotes() is not implemented in Songbird!");
398 Components.classes[
"@mozilla.org/updates/update-manager;1"].
399 getService(Components.interfaces.nsIUpdateManager);
401 Components.classes[
"@mozilla.org/updates/update-prompt;1"].
407 if (um.activeUpdate && um.activeUpdate.state ==
"pending")
408 prompter.showUpdateDownloaded(um.activeUpdate);
410 prompter.checkForUpdates();
418 var bo = aElement.boxObject;
419 return (bo.height != 0 && bo.width != 0 &&
421 .getComputedStyle(aElement,
null).visibility ==
"visible");
426 var browsers = gBrowser.browsers;
427 for (var
i = 0;
i < browsers.length;
i++) {
428 if (browsers[
i].contentWindow == aContentWindow)
456 aAllowThirdPartyFixup)
459 urlSecurityCheck(aURL,
aDocument.nodePrincipal);
461 var
prefSvc = Components.classes[
"@mozilla.org/preferences-service;1"]
462 .getService(Components.interfaces.nsIPrefService);
463 prefSvc = prefSvc.getBranch(
null);
466 var loadInBackground =
true;
468 loadInBackground = prefSvc.getBoolPref(
"browser.tabs.loadInBackground");
473 if (aEvent && aEvent.shiftKey)
474 loadInBackground = !loadInBackground;
487 if (typeof(gBrowser) ==
"undefined") {
488 dump(
"\n\n\nbrowserUtilities.openNewTabWith() Error: no browser available!\n\n\n");
491 gBrowser.loadOneTab(aURL, referrerURI, originCharset, aPostData,
492 loadInBackground, aAllowThirdPartyFixup ||
false);
497 dump(
"\n\n\nbrowserUtilities.openNewWindowWith() Warning: Songbird does not support new windows.\n\n\n");
508 function loadURI(
uri, referrer, postData, allowThirdPartyFixup)
511 if (postData === undefined)
513 var
flags = Components.interfaces.nsIWebNavigation.LOAD_FLAGS_NONE;
514 if (allowThirdPartyFixup) {
515 flags = Components.interfaces.nsIWebNavigation.LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP;
526 return gBrowser.selectedBrowser.webNavigation;
535 const WM_CID =
"@mozilla.org/appshell/window-mediator;1";
536 const nsIWM = Components.interfaces.nsIWindowMediator;
538 var windowManager = Components.classes[WM_CID].getService();
539 var windowManagerInterface = windowManager.QueryInterface(nsIWM);
540 var topWindow = windowManagerInterface.getMostRecentWindow(inType);
541 var winFeatures = features ? features :
"chrome,extrachrome,menubar," +
542 "resizable,scrollbars,status," +
556 if (where ==
"current") {
565 var currentIndex = sessionHistory.index;
566 var
entry = sessionHistory.getEntryAtIndex(currentIndex + 1,
false);
567 var
url = entry.URI.spec;
577 if (where ==
"current") {
586 var currentIndex = sessionHistory.index;
587 var
entry = sessionHistory.getEntryAtIndex(currentIndex - 1,
false);
588 var
url = entry.URI.spec;
596 if (aEvent.button == 2)
599 var homePage = gBrowser.homePage;
606 urls = homePage.split(
"|");
615 urls = homePage.split(
"|");
616 var loadInBackground =
getBoolPref(
"browser.tabs.loadBookmarksInBackground",
false);
617 gBrowser.loadTabs(urls, loadInBackground);
631 gBrowser.loadTabs(aURIString.split(
"|"),
false,
true);
649 Components.classes[
"@songbirdnest.com/Songbird/Mediacore/TypeSniffer;1"]
650 .createInstance(Components.interfaces.sbIMediacoreTypeSniffer);
651 this.
ios = Components.classes[
"@mozilla.org/network/io-service;1"]
652 .getService(Components.interfaces.nsIIOService);
661 jsDefaultStatus :
"",
669 if (aIID.equals(Ci.nsIWebProgressListener) ||
670 aIID.equals(Ci.nsIWebProgressListener2) ||
671 aIID.equals(Ci.nsISupportsWeakReference) ||
672 aIID.equals(Ci.nsIXULBrowserWindow) ||
673 aIID.equals(Ci.nsISupports))
675 throw Cr.NS_NOINTERFACE;
678 setJSStatus :
function(status)
680 this.jsStatus = status;
681 this.updateStatusField();
684 setJSDefaultStatus :
function(status)
686 this.jsDefaultStatus = status;
687 this.updateStatusField();
690 setDefaultStatus :
function(status)
692 this.defaultStatus = status;
693 this.updateStatusField();
696 setOverLink :
function(link, b)
700 this.overLink = link.replace(/[\u200e\u200f\u202a\u202b\u202c\u202d\u202e]/g,
702 this.updateStatusField();
705 updateStatusField :
function()
707 var text = this.overLink || this.status || this.jsStatus || this.jsDefaultStatus || this.defaultStatus;
711 if (this.statusText != text) {
720 if (uri && (this.typeSniffer.isValidMediaURL(uri) ||
721 this.typeSniffer.isValidPlaylistURL(uri))) {
728 this.statusText = text;
736 window.QueryInterface(Ci.nsIInterfaceRequestor)
737 .getInterface(Ci.nsIWebNavigation)
738 .QueryInterface(Ci.nsIDocShellTreeItem).treeOwner
739 .QueryInterface(Ci.nsIInterfaceRequestor)
740 .getInterface(Ci.nsIXULWindow)
741 .XULBrowserWindow =
window.XULBrowserWindow;
752 const kMaxSelectionLen = 150;
753 const charLen = Math.min(aCharLen || kMaxSelectionLen, kMaxSelectionLen);
755 var focusedWindow = document.commandDispatcher.focusedWindow;
756 var selection = focusedWindow.getSelection().toString();
759 if (selection.length > charLen) {
761 var pattern =
new RegExp(
"^(?:\\s*.){0," + charLen +
"}");
762 pattern.test(selection);
763 selection = RegExp.lastMatch;
766 selection = selection.replace(/^\s+/,
"")
768 .replace(/\s+/g,
" ");
770 if (selection.length > charLen)
771 selection = selection.substr(0, charLen);
778 return /^text\/|\+xml$/.test(aMimeType) ||
779 aMimeType ==
"application/x-javascript" ||
780 aMimeType ==
"application/javascript" ||
781 aMimeType ==
"application/xml" ||
782 aMimeType ==
"mozilla.application/cached-xul";
808 var sh = webNav.sessionHistory;
815 webNav.reload(reloadFlags);
821 var formatter = Cc[
"@mozilla.org/toolkit/URLFormatterService;1"]
822 .getService(Ci.nsIURLFormatter);
824 formatter.formatURLPref(aFormat) : formatter.formatURL(aFormat);
829 evt.stopPropagation();
830 switch (evt.command) {
835 gBrowser.goForward();
844 BrowserSearch.webSearch();
872 if (tipElement.namespaceURI ==
"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul")
875 const XLinkNS =
"http://www.w3.org/1999/xlink";
878 var titleText =
null;
879 var XLinkTitleText =
null;
880 var direction = tipElement.ownerDocument.dir;
882 while (!titleText && !XLinkTitleText && tipElement) {
883 if (tipElement.nodeType == Node.ELEMENT_NODE) {
884 titleText = tipElement.getAttribute(
"title");
885 XLinkTitleText = tipElement.getAttributeNS(
XLinkNS,
"title");
886 var defView = tipElement.ownerDocument.defaultView;
891 direction = defView.getComputedStyle(tipElement,
"")
892 .getPropertyValue(
"direction");
894 tipElement = tipElement.parentNode;
897 var tipNode = document.getElementById(
"aHTMLTooltip");
898 tipNode.style.direction = direction;
900 for each (var
t in [titleText, XLinkTitleText]) {
901 if (t && /\S/.
test(t)) {
908 t = t.replace(/[\r\t]/g,
' ');
909 t = t.replace(/\n/g,
'');
911 tipNode.setAttribute(
"label", t);
925 gNavigatorBundle = document.getElementById(
"bundle_browser");
926 var gPrefService = Components.classes[
"@mozilla.org/preferences-service;1"]
927 .getService(Components.interfaces.nsIPrefBranch2);
944 index = gBrowser.tabContainer.childNodes.length - 1;
945 }
else if (index >= gBrowser.tabContainer.childNodes.length) {
949 var oldTab = gBrowser.selectedTab;
950 var newTab = gBrowser.tabContainer.childNodes[index];
951 if (newTab != oldTab) {
952 gBrowser.selectedTab = newTab;
955 event.preventDefault();
956 event.stopPropagation();
961 switch (
Application.prefs.getValue(
"browser.backspace_action", 2)) {
966 goDoCommand(
"cmd_scrollPageUp");
973 switch (
Application.prefs.getValue(
"browser.backspace_action", 2)) {
975 gBrowser.goForward();
978 goDoCommand(
"cmd_scrollPageDown");
function BrowserHomeClick(aEvent)
function closeMenus(node)
function checkForUpdates()
function getBrowserSelection(aCharLen)
function FillInHTMLTooltip(tipElement)
nsString encodeURIComponent(const nsString &c)
window QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIWebNavigation).QueryInterface(Ci.nsIDocShellTreeItem).treeOwner.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIXULWindow).XULBrowserWindow
function BrowserReloadSkipCache()
function getBoolPref(prefname, def)
function gatherTextUnder(root)
function getWebNavigation()
sbDeviceFirmwareAutoCheckForUpdate prototype flags
function mimeTypeIsTextBased(aMimeType)
function BrowserBack(aEvent, aIgnoreAlt)
function BrowserHandleShiftBackspace()
function HandleAppCommandEvent(evt)
function makeURLAbsolute(aBase, aUrl)
function openAboutDialog()
function loadURI(uri, referrer, postData, allowThirdPartyFixup)
getService(Ci.sbIFaceplateManager)
function BrowserNumberTabSelection(event, index)
function loadOneOrMoreURIs(aURIString)
_collectFormDataForFrame aDocument
function makeURI(aURLSpec, aCharset)
function openUILink(url, e, ignoreButton, ignoreAlt, allowKeywordFixup, postData, referrerUrl)
return e ctrlKey(chr<' '||!chars||chars.indexOf(chr)>-1)
function formatURL(aFormat, aIsPref)
function onInitBrowserUtilities()
function BrowserForward(aEvent, aIgnoreAlt)
function openPreferences(paneID)
function BrowserReloadWithFlags(reloadFlags)
function checkForMiddleClick(node, event)
function onShutdownBrowserUtilities()
function openReleaseNotes(event)
function BrowserHandleBackspace()
function openNewWindowWith(aURL, aDocument, aPostData, aAllowThirdPartyFixup)
function goToggleToolbar(id, elementID)
function openNewTabWith(aURL, aDocument, aPostData, aEvent, aAllowThirdPartyFixup)
function getBrowserFromContentWindow(aContentWindow)
function nsBrowserStatusHandler()
function SBDataSetStringValue(aKey, aStringValue)
Set a string value. Changes the value of the data remote to the boolean passed in, regardless of its value before.
function openUILinkIn(url, where, allowThirdPartyFixup, postData, referrerUrl)
function getShellService()
function isElementVisible(aElement)
_getSelectedPageStyle s i
function whereToOpenLink(e, ignoreButton, ignoreAlt)
function focusElement(aElement)
function toOpenWindowByType(inType, uri, features)