1 # -*- Mode: javascript; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
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 # Blake Ross <blake@cs.stanford.edu>
24 # David Hyatt <hyatt@mozilla.org>
25 # Peter Annema <disttsc@bart.nl>
26 # Dean Tessman <dean_tessman@hotmail.com>
27 # Kevin Puetz <puetzk@iastate.edu>
28 # Ben Goodger <ben@netscape.com>
29 # Pierre Chanial <chanial@noos.fr>
30 # Jason Eager <jce2@po.cwru.edu>
31 # Joe Hewitt <hewitt@netscape.com>
32 # Alec Flett <alecf@netscape.com>
33 # Asaf Romano <mozilla.mano@sent.com>
34 # Jason Barnabe <jason_barnabe@fastmail.fm>
35 # Peter Parente <parente@cs.unc.edu>
36 # Giorgio Maone <g.maone@informaction.com>
37 # Tom Germeau <tom.germeau@epigoon.com>
38 # Jesse Ruderman <jruderman@gmail.com>
39 # Joe Hughes <joe@retrovirus.com>
40 # Pamela Greene <pamg.bugs@gmail.com>
41 # Michael Ventnor <m.ventnor@gmail.com>
42 # Simon Bünzli <zeniko@gmail.com>
43 # Johnathan Nightingale <johnath@mozilla.com>
44 # Ehsan Akhgari <ehsan.akhgari@gmail.com>
45 # Dão Gottwald <dao@mozilla.com>
46 # Thomas K. Dyas <tdyas@zecador.org>
47 # Edward Lee <edward.lee@engineering.uiuc.edu>
48 # Paul O’Shannessy <paul@oshannessy.com>
49 # Nils Maier <maierman@web.de>
50 # Rob Arnold <robarnold@cmu.edu>
51 # Dietrich Ayala <dietrich@mozilla.com>
53 # Alternatively, the contents of this file may be used under the terms of
54 # either the GNU General Public License Version 2 or later (the "GPL"), or
55 # the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
56 # in which case the provisions of the GPL or the LGPL are applicable instead
57 # of those above. If you wish to allow use of your version of this file only
58 # under the terms of either the GPL or the LGPL, and not to allow others to
59 # use your version of this file under the terms of the MPL, indicate your
60 # decision by deleting the provisions above and replace them with the notice
61 # and other provisions required by the GPL or the LGPL. If you do not delete
62 # the provisions above, a recipient may use your version of this file under
63 # the terms of any one of the MPL, the GPL or the LGPL.
65 # ***** END LICENSE BLOCK *****
67 let
Ci = Components.interfaces;
68 let
Cu = Components.utils;
69 Cu.import(
"resource://gre/modules/XPCOMUtils.jsm");
96 [
"gBrowser",
"content"],
97 [
"gNavToolbox",
"navigator-toolbox"],
98 [
"gURLBar",
"urlbar"],
99 [
"gNavigatorBundle",
"bundle_browser"],
100 [
"gProgressMeterPanel",
"statusbar-progresspanel"],
101 [
"gFindBar",
"FindToolbar"]
102 ].forEach(
function (elementGlobal) {
103 var [
name,
id] = elementGlobal;
104 window.__defineGetter__(name,
function () {
105 var
element = document.getElementById(
id);
111 window.__defineSetter__(name,
function (
val) {
119 return this.
gPrefService =
Cc[
"@mozilla.org/preferences-service;1"]
120 .getService(
Ci.nsIPrefBranch2)
121 .QueryInterface(
Ci.nsIPrefService);
125 Cu.import(
"resource://gre/modules/PluralForm.jsm");
126 return this.PluralForm;
129 delete this.PluralForm;
130 return this.PluralForm =
val;
133 #ifdef MOZ_CRASHREPORTER
135 delete this.gCrashReporter;
136 return this.gCrashReporter =
Cc[
"@mozilla.org/xre/app-info;1"].
143 "about:privatebrowsing",
144 "about:sessionrestore"
153 if (
event.originalTarget == content.document) {
165 var saveFrameItem = document.getElementById(
"menu_saveFrame");
166 if (!content || !content.frames.length || !isContentFrame(document.commandDispatcher.focusedWindow))
167 saveFrameItem.setAttribute(
"hidden",
"true");
169 saveFrameItem.removeAttribute(
"hidden");
173 var backBroadcaster = document.getElementById(
"Browser:Back");
174 var forwardBroadcaster = document.getElementById(
"Browser:Forward");
181 var backDisabled = backBroadcaster.hasAttribute(
"disabled");
182 var forwardDisabled = forwardBroadcaster.hasAttribute(
"disabled");
183 if (backDisabled == aWebNavigation.canGoBack) {
185 backBroadcaster.removeAttribute(
"disabled");
187 backBroadcaster.setAttribute(
"disabled",
true);
190 if (forwardDisabled == aWebNavigation.canGoForward) {
192 forwardBroadcaster.removeAttribute(
"disabled");
194 forwardBroadcaster.setAttribute(
"disabled",
true);
203 function SetClickAndHoldHandlers() {
206 function timerCallback(aButton) {
207 aButton.firstChild.hidden =
false;
212 function mousedownHandler(aEvent) {
213 if (aEvent.button != 0 ||
214 aEvent.currentTarget.open ||
215 aEvent.currentTarget.disabled)
219 aEvent.currentTarget.firstChild.hidden =
true;
221 timer =
setTimeout(timerCallback, 500, aEvent.currentTarget);
225 if (aEvent.button == 0 &&
226 aEvent.target == aEvent.currentTarget &&
227 !aEvent.currentTarget.open &&
228 !aEvent.currentTarget.disabled) {
229 let cmdEvent = document.createEvent(
"xulcommandevent");
230 cmdEvent.initCommandEvent(
"command",
true,
true,
window, 0,
231 aEvent.ctrlKey, aEvent.altKey, aEvent.shiftKey,
232 aEvent.metaKey,
null);
233 aEvent.currentTarget.dispatchEvent(cmdEvent);
237 function stopTimer(aEvent) {
244 function _addClickAndHoldListenersOnElement(aElm) {
245 aElm.addEventListener(
"mousedown", mousedownHandler,
true);
246 aElm.addEventListener(
"mouseup", stopTimer,
false);
247 aElm.addEventListener(
"mouseout", stopTimer,
false);
253 var unifiedButton = document.getElementById(
"unified-back-forward-button");
254 if (unifiedButton && !unifiedButton._clickHandlersAttached) {
255 var popup = document.getElementById(
"back-forward-dropmarker")
256 .firstChild.cloneNode(
true);
257 var backButton = document.getElementById(
"back-button");
258 backButton.setAttribute(
"type",
"menu");
259 backButton.appendChild(popup);
260 _addClickAndHoldListenersOnElement(backButton);
261 var forwardButton = document.getElementById(
"forward-button");
262 popup = popup.cloneNode(
true);
263 forwardButton.setAttribute(
"type",
"menu");
264 forwardButton.appendChild(popup);
265 _addClickAndHoldListenersOnElement(forwardButton);
266 unifiedButton._clickHandlersAttached =
true;
272 PlacesCommandHook.bookmarkPage(gBrowser.mContextTab.linkedBrowser,
273 PlacesUtils.bookmarksMenuFolderId,
true);
279 if (topic !=
"browser:purge-session-history")
282 var backCommand = document.getElementById(
"Browser:Back");
283 backCommand.setAttribute(
"disabled",
"true");
284 var fwdCommand = document.getElementById(
"Browser:Forward");
285 fwdCommand.setAttribute(
"disabled",
"true");
289 gURLBar.editor.transactionManager.clear()
307 aDocShell.QueryInterface(Components.interfaces.nsIWebNavigation);
308 aDocShell.QueryInterface(Components.interfaces.nsIInterfaceRequestor);
309 var
doc =
aDocShell.getInterface(Components.interfaces.nsIDOMDocument);
311 (aSoughtURI && aSoughtURI.spec ==
aDocShell.currentURI.spec))
314 var
node =
aDocShell.QueryInterface(Components.interfaces.nsIDocShellTreeNode);
315 for (var
i = 0;
i < node.childCount; ++
i) {
326 _kIPM: Components.interfaces.nsIPermissionManager,
328 onUpdatePageReport:
function (aEvent)
330 if (aEvent.originalTarget != gBrowser.selectedBrowser)
333 if (!this._reportButton)
334 this._reportButton = document.getElementById(
"page-report-button");
336 if (!gBrowser.pageReport) {
338 this._reportButton.hidden =
true;
343 this._reportButton.hidden =
false;
348 if (!gBrowser.pageReport.reported) {
349 if (
gPrefService.getBoolPref(
"privacy.popups.showBrowserMessage")) {
350 var
brandBundle = document.getElementById(
"bundle_brand");
351 var brandShortName = brandBundle.getString(
"brandShortName");
353 var popupCount = gBrowser.pageReport.length;
356 var popupButtonAccesskey =
gNavigatorBundle.getString(
"popupWarningButton.accesskey");
359 var popupButtonAccesskey =
gNavigatorBundle.getString(
"popupWarningButtonUnix.accesskey");
362 message =
gNavigatorBundle.getFormattedString(
"popupWarningMultiple", [brandShortName, popupCount]);
364 message =
gNavigatorBundle.getFormattedString(
"popupWarning", [brandShortName]);
366 var notificationBox = gBrowser.getNotificationBox();
367 var notification = notificationBox.getNotificationWithValue(
"popup-blocked");
373 label: popupButtonText,
374 accessKey: popupButtonAccesskey,
375 popup:
"blockedPopupOptions",
379 const priority = notificationBox.PRIORITY_WARNING_MEDIUM;
380 notificationBox.appendNotification(message,
"popup-blocked",
381 "chrome://browser/skin/Info.png",
388 gBrowser.pageReport.reported =
true;
392 toggleAllowPopupsForSite:
function (aEvent)
394 var currentURI = gBrowser.selectedBrowser.webNavigation.currentURI;
395 var pm = Components.classes[
"@mozilla.org/permissionmanager;1"]
396 .getService(this._kIPM);
397 var shouldBlock = aEvent.target.getAttribute(
"block") ==
"true";
398 var perm = shouldBlock ? this._kIPM.DENY_ACTION : this._kIPM.ALLOW_ACTION;
399 pm.add(currentURI,
"popup", perm);
401 gBrowser.getNotificationBox().removeCurrentNotification();
404 fillPopupList:
function (aEvent)
415 var
uri = gBrowser.selectedBrowser.webNavigation.currentURI;
416 var blockedPopupAllowSite = document.getElementById(
"blockedPopupAllowSite");
418 blockedPopupAllowSite.removeAttribute(
"hidden");
420 var pm =
Cc[
"@mozilla.org/permissionmanager;1"].getService(this._kIPM);
421 if (pm.testPermission(uri,
"popup") == this._kIPM.ALLOW_ACTION) {
424 let blockString =
gNavigatorBundle.getFormattedString(
"popupBlock", [uri.host]);
425 blockedPopupAllowSite.setAttribute(
"label", blockString);
426 blockedPopupAllowSite.setAttribute(
"block",
"true");
430 let allowString =
gNavigatorBundle.getFormattedString(
"popupAllow", [uri.host]);
431 blockedPopupAllowSite.setAttribute(
"label", allowString);
432 blockedPopupAllowSite.removeAttribute(
"block");
436 blockedPopupAllowSite.setAttribute(
"hidden",
"true");
440 blockedPopupAllowSite.setAttribute(
"disabled",
"true");
442 var item = aEvent.target.lastChild;
443 while (item && item.getAttribute(
"observes") !=
"blockedPopupsSeparator") {
444 var
next = item.previousSibling;
445 item.parentNode.removeChild(item);
449 var foundUsablePopupURI =
false;
450 var pageReport = gBrowser.pageReport;
452 for (var
i = 0;
i < pageReport.length; ++
i) {
453 var popupURIspec = pageReport[
i].popupWindowURI.spec;
460 if (popupURIspec ==
"" || popupURIspec ==
"about:blank" ||
461 popupURIspec == uri.spec)
469 foundUsablePopupURI =
true;
471 var menuitem = document.createElement(
"menuitem");
474 menuitem.setAttribute(
"label", label);
475 menuitem.setAttribute(
"popupWindowURI", popupURIspec);
476 menuitem.setAttribute(
"popupWindowFeatures", pageReport[
i].popupWindowFeatures);
477 menuitem.setAttribute(
"popupWindowName", pageReport[
i].popupWindowName);
478 menuitem.setAttribute(
"oncommand",
"gPopupBlockerObserver.showBlockedPopup(event);");
479 menuitem.requestingWindow = pageReport[
i].requestingWindow;
480 menuitem.requestingDocument = pageReport[
i].requestingDocument;
481 aEvent.target.appendChild(menuitem);
487 var blockedPopupsSeparator =
488 document.getElementById(
"blockedPopupsSeparator");
489 if (foundUsablePopupURI)
490 blockedPopupsSeparator.removeAttribute(
"hidden");
492 blockedPopupsSeparator.setAttribute(
"hidden",
true);
494 var blockedPopupDontShowMessage = document.getElementById(
"blockedPopupDontShowMessage");
495 var showMessage =
gPrefService.getBoolPref(
"privacy.popups.showBrowserMessage");
496 blockedPopupDontShowMessage.setAttribute(
"checked", !showMessage);
497 if (aEvent.target.localName ==
"popup")
498 blockedPopupDontShowMessage.setAttribute(
"label",
gNavigatorBundle.getString(
"popupWarningDontShowFromMessage"));
500 blockedPopupDontShowMessage.setAttribute(
"label",
gNavigatorBundle.getString(
"popupWarningDontShowFromStatusbar"));
503 showBlockedPopup:
function (aEvent)
505 var
target = aEvent.target;
506 var popupWindowURI = target.getAttribute(
"popupWindowURI");
507 var features = target.getAttribute(
"popupWindowFeatures");
508 var
name = target.getAttribute(
"popupWindowName");
510 var dwi = target.requestingWindow;
514 if (dwi && dwi.document == target.requestingDocument) {
515 dwi.open(popupWindowURI, name, features);
519 editPopupSettings:
function ()
523 var
uri = gBrowser.selectedBrowser.webNavigation.currentURI;
528 var bundlePreferences = document.getElementById(
"bundle_preferences");
529 var params = { blockVisible :
false,
530 sessionVisible :
false,
532 prefilledHost : host,
533 permissionType :
"popup",
534 windowTitle : bundlePreferences.getString(
"popuppermissionstitle"),
535 introText : bundlePreferences.getString(
"popuppermissionstext") };
536 var
wm = Components.classes[
"@mozilla.org/appshell/window-mediator;1"]
537 .getService(Components.interfaces.nsIWindowMediator);
538 var existingWindow = wm.getMostRecentWindow(
"Browser:Permissions");
539 if (existingWindow) {
540 existingWindow.initWithParams(params);
541 existingWindow.focus();
544 window.openDialog(
"chrome://browser/content/preferences/permissions.xul",
545 "_blank",
"resizable,dialog=no,centerscreen", params);
548 dontShowMessage:
function ()
550 var showMessage =
gPrefService.getBoolPref(
"privacy.popups.showBrowserMessage");
556 if (showMessage && firstTime)
557 this._displayPageReportFirstTime();
559 gPrefService.setBoolPref(
"privacy.popups.showBrowserMessage", !showMessage);
561 gBrowser.getNotificationBox().removeCurrentNotification();
564 _displayPageReportFirstTime:
function ()
566 window.openDialog(
"chrome://browser/content/pageReportFirstTime.xul",
"_blank",
572 _findChildShell:
function (
aDocShell, aSoughtShell)
577 var
node =
aDocShell.QueryInterface(Components.interfaces.nsIDocShellTreeNode);
578 for (var
i = 0;
i < node.childCount; ++
i) {
580 docShell = this._findChildShell(docShell, aSoughtShell);
581 if (docShell == aSoughtShell)
589 for (var
i = 0;
i < gBrowser.browsers.length; ++
i) {
590 var
browser = gBrowser.getBrowserAtIndex(
i);
591 if (this._findChildShell(browser.docShell,
aDocShell))
599 var
brandBundle = document.getElementById(
"bundle_brand");
601 case "xpinstall-install-blocked":
602 var installInfo = aSubject.QueryInterface(Components.interfaces.nsIXPIInstallInfo);
603 var
win = installInfo.originatingWindow;
604 var shell = win.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
605 .getInterface(Components.interfaces.nsIWebNavigation)
606 .QueryInterface(Components.interfaces.nsIDocShell);
607 var
browser = this._getBrowser(shell);
609 var host = installInfo.originatingURI.host;
610 var brandShortName = brandBundle.getString(
"brandShortName");
611 var notificationName, messageString, buttons;
613 notificationName =
"xpinstall-disabled"
615 messageString =
gNavigatorBundle.getString(
"xpinstallDisabledMessageLocked");
619 messageString =
gNavigatorBundle.getFormattedString(
"xpinstallDisabledMessage",
620 [brandShortName, host]);
634 notificationName =
"xpinstall"
635 messageString =
gNavigatorBundle.getFormattedString(
"xpinstallPromptWarning",
636 [brandShortName, host]);
640 accessKey:
gNavigatorBundle.getString(
"xpinstallPromptAllowButton.accesskey"),
643 var mgr = Components.classes[
"@mozilla.org/xpinstall/install-manager;1"]
644 .createInstance(Components.interfaces.nsIXPInstallManager);
645 mgr.initManagerWithInstallInfo(installInfo);
651 var notificationBox = gBrowser.getNotificationBox(browser);
652 if (!notificationBox.getNotificationWithValue(notificationName)) {
653 const priority = notificationBox.PRIORITY_WARNING_MEDIUM;
654 const iconURL =
"chrome://mozapps/skin/update/update.png";
655 notificationBox.appendNotification(messageString, notificationName,
656 iconURL, priority, buttons);
682 init:
function GS_init(aAddListener) {
683 const gestureEvents = [
"SwipeGesture",
684 "MagnifyGestureStart",
"MagnifyGestureUpdate",
"MagnifyGesture",
685 "RotateGestureStart",
"RotateGestureUpdate",
"RotateGesture",
686 "TapGesture",
"PressTapGesture"];
688 let addRemove = aAddListener ?
window.addEventListener :
689 window.removeEventListener;
691 gestureEvents.forEach(
function (
event) addRemove(
"Moz" +
event,
this,
true),
703 handleEvent:
function GS_handleEvent(aEvent) {
704 aEvent.stopPropagation();
707 let def =
function(aThreshold, aLatched)
708 ({ threshold: aThreshold, latched: !!aLatched });
710 switch (aEvent.type) {
711 case "MozSwipeGesture":
712 aEvent.preventDefault();
713 return this.onSwipe(aEvent);
714 case "MozMagnifyGestureStart":
715 aEvent.preventDefault();
717 return this._setupGesture(aEvent,
"pinch", def(25, 0),
"out",
"in");
719 return this._setupGesture(aEvent,
"pinch", def(150, 1),
"out",
"in");
721 case "MozRotateGestureStart":
722 aEvent.preventDefault();
723 return this._setupGesture(aEvent,
"twist", def(25, 0),
"right",
"left");
724 case "MozMagnifyGestureUpdate":
725 case "MozRotateGestureUpdate":
726 aEvent.preventDefault();
727 return this._doUpdate(aEvent);
728 case "MozTapGesture":
729 aEvent.preventDefault();
730 return this._doAction(aEvent, [
"tap"]);
731 case "MozPressTapGesture":
752 _setupGesture:
function GS__setupGesture(aEvent, aGesture, aPref, aInc, aDec) {
754 for (let [
pref, def] in Iterator(aPref))
755 aPref[
pref] = this._getPref(aGesture +
"." + pref, def);
759 let latchDir = aEvent.delta > 0 ? 1 : -1;
760 let isLatched =
false;
763 this._doUpdate =
function GS__doUpdate(aEvent) {
765 offset += aEvent.delta;
768 if (Math.abs(offset) > aPref[
"threshold"]) {
772 let sameDir = (latchDir ^
offset) >= 0;
773 if (!aPref[
"latched"] || (isLatched ^ sameDir)) {
774 this._doAction(aEvent, [aGesture, offset > 0 ? aInc : aDec]);
777 isLatched = !isLatched;
786 this._doUpdate(aEvent);
797 _power:
function GS__power(aArray) {
799 let
num = 1 << aArray.length;
802 yield aArray.reduce(
function(aPrev, aCurr, aIndex) {
803 if (num & 1 << aIndex)
820 _doAction:
function GS__doAction(aEvent, aGesture) {
822 let fakeEvent = { shiftKey: aEvent.shiftKey,
ctrlKey: aEvent.ctrlKey,
823 metaKey: aEvent.metaKey, altKey: aEvent.altKey, button: 0 };
829 const keys = [
"shift",
"alt",
"ctrl",
"meta"];
830 for each (let
key in keys)
831 if (aEvent[key +
"Key"])
836 for (let subCombo in this._power(keyCombos)) {
840 let command = this._getPref(aGesture.concat(subCombo).join(
"."));
844 let
node = document.getElementById(command);
846 if (node && node.hasAttribute(
"oncommand")) {
848 if (node.getAttribute(
"disabled") !=
"true")
849 new Function(
"event", node.getAttribute(
"oncommand")).
850 call(node, fakeEvent);
854 goDoCommand(command);
872 _doUpdate:
function(aEvent) {},
880 onSwipe:
function GS_onSwipe(aEvent) {
882 [
"UP",
"RIGHT",
"DOWN",
"LEFT"].forEach(
function (
dir) {
883 if (aEvent.direction == aEvent[
"DIRECTION_" +
dir])
884 return this._doAction(aEvent, [
"swipe",
dir.toLowerCase()]);
896 _getPref:
function GS__getPref(aPref, aDef) {
898 const branch =
"browser.gesture.";
902 let type = typeof aDef;
903 let getFunc =
"get" + (type ==
"boolean" ?
"Bool" :
904 type ==
"number" ?
"Int" :
"Char") +
"Pref";
914 var uriToLoad =
null;
926 uriToLoad =
window.arguments[0];
928 var isLoadingBlank = uriToLoad ==
"about:blank";
929 var mustLoadSidebar =
false;
933 if (uriToLoad && !isLoadingBlank) {
934 if (uriToLoad instanceof
Ci.nsISupportsArray) {
935 let
count = uriToLoad.Count();
938 let urisstring = uriToLoad.GetElementAt(
i).QueryInterface(
Ci.nsISupportsString);
939 specs.push(urisstring.data);
945 gBrowser.loadTabs(specs,
false,
true);
948 else if (uriToLoad instanceof XULElement) {
953 gBrowser.selectedBrowser.stop();
955 gBrowser.selectedBrowser.docShell;
957 gBrowser.swapBrowsersAndCloseOther(gBrowser.selectedTab, uriToLoad);
959 else if (
window.arguments.length >= 3) {
961 window.arguments[4] ||
false);
971 let openerFindBar =
window.opener.gFindBar;
972 if (openerFindBar && !openerFindBar.hidden &&
973 openerFindBar.findMode == gFindBar.FIND_NORMAL)
976 let openerSidebarBox =
window.opener.document.getElementById(
"sidebar-box");
980 if (openerSidebarBox && !openerSidebarBox.hidden) {
981 let sidebarCmd = openerSidebarBox.getAttribute(
"sidebarcommand");
982 let sidebarCmdElem = document.getElementById(sidebarCmd);
985 if (sidebarCmdElem) {
986 let sidebarBox = document.getElementById(
"sidebar-box");
987 let sidebarTitle = document.getElementById(
"sidebar-title");
989 sidebarTitle.setAttribute(
990 "value",
window.opener.document.getElementById(
"sidebar-title").getAttribute(
"value"));
991 sidebarBox.setAttribute(
"width", openerSidebarBox.boxObject.width);
993 sidebarBox.setAttribute(
"sidebarcommand", sidebarCmd);
997 sidebarBox.setAttribute(
998 "src",
window.opener.document.getElementById(
"sidebar").getAttribute(
"src"));
999 mustLoadSidebar =
true;
1001 sidebarBox.hidden =
false;
1002 document.getElementById(
"sidebar-splitter").hidden =
false;
1003 sidebarCmdElem.setAttribute(
"checked",
"true");
1008 let box = document.getElementById(
"sidebar-box");
1009 if (box.hasAttribute(
"sidebarcommand")) {
1010 let commandID = box.getAttribute(
"sidebarcommand");
1012 let command = document.getElementById(commandID);
1014 mustLoadSidebar =
true;
1016 document.getElementById(
"sidebar-splitter").hidden =
false;
1017 command.setAttribute(
"checked",
"true");
1023 box.removeAttribute(
"sidebarcommand");
1031 Cc[
"@mozilla.org/observer-service;1"]
1032 .getService(
Ci.nsIObserverService)
1033 .notifyObservers(
null,
"browser-window-before-show",
"");
1036 if (!document.documentElement.hasAttribute(
"width")) {
1037 let defaultWidth = 994;
1039 if (screen.availHeight <= 600) {
1040 document.documentElement.setAttribute(
"sizemode",
"maximized");
1042 defaultHeight = 450;
1047 if (screen.availWidth >= 1600)
1048 defaultWidth = (screen.availWidth / 2) - 20;
1049 defaultHeight = screen.availHeight - 10;
1050 #ifdef MOZ_WIDGET_GTK2
1053 defaultHeight -= 28;
1056 document.documentElement.setAttribute(
"width", defaultWidth);
1057 document.documentElement.setAttribute(
"height", defaultHeight);
1061 document.documentElement.getAttribute(
"chromehidden").indexOf(
"toolbar") != -1) {
1062 gURLBar.setAttribute(
"readonly",
"true");
1063 gURLBar.setAttribute(
"enablehistory",
"false");
1072 evt.stopPropagation();
1073 switch (evt.command) {
1087 BrowserSearch.webSearch();
1090 toggleSidebar(
'viewBookmarksSidebar');
1104 gBrowser.addEventListener(
"PluginNotFound", gMissingPluginInstaller.newMissingPlugin,
true,
true);
1105 gBrowser.addEventListener(
"PluginBlocklisted", gMissingPluginInstaller.newMissingPlugin,
true,
true);
1106 gBrowser.addEventListener(
"PluginOutdated", gMissingPluginInstaller.newMissingPlugin,
true,
true);
1107 gBrowser.addEventListener(
"PluginDisabled", gMissingPluginInstaller.newDisabledPlugin,
true,
true);
1108 gBrowser.addEventListener(
"NewPluginInstalled", gMissingPluginInstaller.refreshBrowser,
false);
1109 gBrowser.addEventListener(
"NewTab", BrowserOpenTab,
false);
1116 throw "no XBL binding for browser";
1118 alert(
"Error launching browser window:" + e);
1126 window.QueryInterface(
Ci.nsIInterfaceRequestor)
1128 .QueryInterface(
Ci.nsIDocShellTreeItem).treeOwner
1129 .QueryInterface(
Ci.nsIInterfaceRequestor)
1130 .getInterface(
Ci.nsIXULWindow)
1131 .XULBrowserWindow =
window.XULBrowserWindow;
1132 window.QueryInterface(
Ci.nsIDOMChromeWindow).browserDOMWindow =
1133 new nsBrowserAccess();
1137 if (
window.arguments[1].indexOf(
"charset=") != -1) {
1138 var arrayArgComponents =
window.arguments[1].split(
"=");
1139 if (arrayArgComponents) {
1151 webNavigation.sessionHistory = Components.classes[
"@mozilla.org/browser/shistory;1"]
1152 .createInstance(Components.interfaces.nsISHistory);
1153 var
os = Components.classes[
"@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService);
1154 os.addObserver(gBrowser.browsers[0],
"browser:purge-session-history",
false);
1158 gBrowser.browsers[0].removeAttribute(
"disablehistory");
1162 gBrowser.docShell.QueryInterface(Components.interfaces.nsIDocShellHistory).useGlobalHistory =
true;
1164 Components.utils.reportError(
"Places database may be locked: " + ex);
1168 gBrowser.addProgressListener(
window.XULBrowserWindow, Components.interfaces.nsIWebProgress.NOTIFY_ALL);
1169 gBrowser.addTabsProgressListener(
window.TabsProgressListener);
1172 gBrowser.addEventListener(
"DOMLinkAdded", DOMLinkHandler,
false);
1175 gBrowser.addEventListener(
"MozApplicationManifest",
1179 gGestureSupport.init(
true);
1183 var
os =
Cc[
"@mozilla.org/observer-service;1"].getService(
Ci.nsIObserverService);
1193 Cc[
"@mozilla.org/login-manager;1"].getService(
Ci.nsILoginManager);
1195 if (mustLoadSidebar) {
1196 let
sidebar = document.getElementById(
"sidebar");
1197 let sidebarBox = document.getElementById(
"sidebar-box");
1198 sidebar.setAttribute(
"src", sidebarBox.getAttribute(
"src"));
1212 gBrowser.selectedBrowser.focus();
1221 initializeSanitizer();
1225 gPrefService.addObserver(gAutoHideTabbarPrefListener.domain,
1226 gAutoHideTabbarPrefListener,
false);
1228 gPrefService.addObserver(gHomeButton.prefDomain, gHomeButton,
false);
1232 var homeButton = document.getElementById(
"home-button");
1233 gHomeButton.updateTooltip(homeButton);
1234 gHomeButton.updatePersonalToolbarStyle(homeButton);
1236 #ifdef HAVE_SHELL_SERVICE
1240 var shouldCheck = shell.shouldCheckDefaultBrowser;
1241 var willRecoverSession =
false;
1243 var ss =
Cc[
"@mozilla.org/browser/sessionstartup;1"].
1245 willRecoverSession =
1246 (ss.sessionType ==
Ci.nsISessionStartup.RECOVER_SESSION);
1249 if (shouldCheck && !shell.isDefaultBrowser(
true) && !willRecoverSession) {
1250 var
brandBundle = document.getElementById(
"bundle_brand");
1251 var shellBundle = document.getElementById(
"bundle_shell");
1253 var brandShortName = brandBundle.getString(
"brandShortName");
1254 var promptTitle = shellBundle.getString(
"setDefaultBrowserTitle");
1255 var promptMessage = shellBundle.getFormattedString(
"setDefaultBrowserMessage",
1257 var checkboxLabel = shellBundle.getFormattedString(
"setDefaultBrowserDontAsk",
1259 const IPS = Components.interfaces.nsIPromptService;
1260 var
ps = Components.classes[
"@mozilla.org/embedcomp/prompt-service;1"]
1262 var checkEveryTime = {
value: shouldCheck };
1263 var rv = ps.confirmEx(
window, promptTitle, promptMessage,
1264 IPS.STD_YES_NO_BUTTONS,
1267 shell.setDefaultBrowser(
true,
false);
1268 shell.shouldCheckDefaultBrowser = checkEveryTime.value;
1276 document.getElementById(
"documentDirection-separator").hidden =
false;
1277 document.getElementById(
"documentDirection-swap").hidden =
false;
1278 document.getElementById(
"textfieldDirection-separator").hidden =
false;
1279 document.getElementById(
"textfieldDirection-swap").hidden =
false;
1285 if (!
getBoolPref(
"ui.click_hold_context_menus",
false))
1286 SetClickAndHoldHandlers();
1296 Components.utils.reportError(
"Failed to init content pref service:\n" + ex);
1300 Cu.import(
"resource:///modules/NetworkPrioritizer.jsm", NP);
1301 NP.trackBrowserWindow(
window);
1304 if (document.documentElement.getAttribute(
"windowtype") ==
"navigator:browser") {
1306 var ss =
Cc[
"@mozilla.org/browser/sessionstore;1"].
1310 dump(
"nsSessionStore could not be initialized: " + ex +
"\n");
1333 Cc[
"@mozilla.org/microsummary/service;1"].getService(
Ci.nsIMicrosummaryService);
1335 Components.utils.reportError(
"Failed to init microsummary service:\n" + ex);
1344 setTimeout(
function() PlacesUtils.livemarks.start(), 5000);
1352 gDownloadMgr =
Cc[
"@mozilla.org/download-manager;1"].
1362 setTimeout(
function() PlacesUtils.startPlacesDBUtils(), 15000);
1366 let placesContext = document.getElementById(
"placesContext");
1367 placesContext.addEventListener(
"popupshowing", updateEditUIVisibility,
false);
1368 placesContext.addEventListener(
"popuphiding", updateEditUIVisibility,
false);
1374 gBrowser.mPanelContainer.addEventListener(
"InstallBrowserTheme", LightWeightThemeWebInstaller,
false,
true);
1375 gBrowser.mPanelContainer.addEventListener(
"PreviewBrowserTheme", LightWeightThemeWebInstaller,
false,
true);
1376 gBrowser.mPanelContainer.addEventListener(
"ResetBrowserThemePreview", LightWeightThemeWebInstaller,
false,
true);
1379 Win7Features.onOpenWindow();
1385 Win7Features.onCloseWindow();
1393 gGestureSupport.init(
false);
1399 Components.utils.reportError(ex);
1402 var
os = Components.classes[
"@mozilla.org/observer-service;1"]
1403 .getService(Components.interfaces.nsIObserverService);
1408 gBrowser.removeProgressListener(
window.XULBrowserWindow);
1409 gBrowser.removeTabsProgressListener(
window.TabsProgressListener);
1416 gPrefService.removeObserver(gAutoHideTabbarPrefListener.domain,
1417 gAutoHideTabbarPrefListener);
1418 gPrefService.removeObserver(gHomeButton.prefDomain, gHomeButton);
1421 Components.utils.reportError(ex);
1429 var windowManager = Components.classes[
'@mozilla.org/appshell/window-mediator;1'].getService();
1430 var windowManagerInterface = windowManager.QueryInterface(Components.interfaces.nsIWindowMediator);
1431 var enumerator = windowManagerInterface.getEnumerator(
null);
1432 enumerator.getNext();
1433 if (!enumerator.hasMoreElements()) {
1434 document.persist(
"sidebar-box",
"sidebarcommand");
1435 document.persist(
"sidebar-box",
"width");
1436 document.persist(
"sidebar-box",
"src");
1437 document.persist(
"sidebar-title",
"value");
1440 window.XULBrowserWindow.destroy();
1442 window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
1443 .getInterface(Components.interfaces.nsIWebNavigation)
1444 .QueryInterface(Components.interfaces.nsIDocShellTreeItem).treeOwner
1445 .QueryInterface(Components.interfaces.nsIInterfaceRequestor)
1446 .getInterface(Components.interfaces.nsIXULWindow)
1447 .XULBrowserWindow =
null;
1448 window.QueryInterface(
Ci.nsIDOMChromeWindow).browserDOMWindow =
null;
1455 function nonBrowserWindowStartup()
1458 var disabledItems = [
'Browser:SavePage',
1459 'Browser:SendLink',
'cmd_pageSetup',
'cmd_print',
'cmd_find',
'cmd_findAgain',
1460 'viewToolbarsMenu',
'cmd_toggleTaskbar',
'viewSidebarMenuMenu',
'Browser:Reload',
1461 'viewFullZoomMenu',
'pageStyleMenu',
'charsetMenu',
'View:PageSource',
'View:FullScreen',
1462 'viewHistorySidebar',
'Browser:AddBookmarkAs',
'View:PageInfo',
'Tasks:InspectPage'];
1465 for (var
id in disabledItems)
1467 element = document.getElementById(disabledItems[
id]);
1469 element.setAttribute(
"disabled",
"true");
1474 if (
window.location.href ==
"chrome://browser/content/hiddenWindow.xul")
1476 var hiddenWindowDisabledItems = [
'cmd_close',
'minimizeWindow',
'zoomWindow'];
1477 for (var
id in hiddenWindowDisabledItems)
1479 element = document.getElementById(hiddenWindowDisabledItems[
id]);
1481 element.setAttribute(
"disabled",
"true");
1485 element = document.getElementById(
"sep-window-list");
1486 element.setAttribute(
"hidden",
"true");
1490 setTimeout(nonBrowserWindowDelayedStartup, 0);
1493 function nonBrowserWindowDelayedStartup()
1499 initializeSanitizer();
1505 function nonBrowserWindowShutdown()
1515 this.toggleAutoHideTabbar();
1520 domain:
"browser.tabs.autoHide",
1521 observe:
function (aSubject, aTopic, aPrefName)
1523 if (aTopic !=
"nsPref:changed" || aPrefName != this.domain)
1526 this.toggleAutoHideTabbar();
1529 toggleAutoHideTabbar:
function ()
1531 if (gBrowser.tabContainer.childNodes.length == 1 &&
1532 window.toolbar.visible) {
1533 var aVisible =
false;
1539 gBrowser.setStripVisibilityTo(aVisible);
1544 function initializeSanitizer()
1548 document.getElementById(
"sanitizeItem").setAttribute(
"label", label);
1550 const kDidSanitizeDomain =
"privacy.sanitize.didShutdownSanitize";
1551 if (
gPrefService.prefHasUserValue(kDidSanitizeDomain)) {
1564 if (!
gPrefService.getBoolPref(
"privacy.sanitize.migrateFx3Prefs")) {
1565 let itemBranch =
gPrefService.getBranch(
"privacy.item.");
1566 let itemCount = {
value: 0 };
1567 let itemArray = itemBranch.getChildList(
"", itemCount);
1570 let doMigrate = itemArray.some(
function (
name) itemBranch.prefHasUserValue(
name));
1573 doMigrate =
gPrefService.getBoolPref(
"privacy.sanitize.sanitizeOnShutdown");
1576 let cpdBranch =
gPrefService.getBranch(
"privacy.cpd.");
1577 let clearOnShutdownBranch =
gPrefService.getBranch(
"privacy.clearOnShutdown.");
1578 itemArray.forEach(
function (
name) {
1582 if (
name !=
"passwords" &&
name !=
"offlineApps")
1583 cpdBranch.setBoolPref(
name, itemBranch.getBoolPref(
name));
1584 clearOnShutdownBranch.setBoolPref(
name, itemBranch.getBoolPref(
name));
1587 Cu.reportError(
"Exception thrown during privacy pref migration: " + e);
1592 gPrefService.setBoolPref(
"privacy.sanitize.migrateFx3Prefs",
true);
1596 function gotoHistoryIndex(aEvent)
1598 var index = aEvent.target.getAttribute(
"index");
1604 if (where ==
"current") {
1608 gBrowser.gotoIndex(index);
1620 var
entry = sessionHistory.getEntryAtIndex(index,
false);
1621 var
url = entry.URI.spec;
1630 if (where ==
"current") {
1632 gBrowser.goForward();
1639 var currentIndex = sessionHistory.index;
1640 var
entry = sessionHistory.getEntryAtIndex(currentIndex + 1,
false);
1641 var
url = entry.URI.spec;
1649 if (where ==
"current") {
1658 var currentIndex = sessionHistory.index;
1659 var
entry = sessionHistory.getEntryAtIndex(currentIndex - 1,
false);
1660 var
url = entry.URI.spec;
1667 switch (
gPrefService.getIntPref(
"browser.backspace_action")) {
1672 goDoCommand(
"cmd_scrollPageUp");
1679 switch (
gPrefService.getIntPref(
"browser.backspace_action")) {
1684 goDoCommand(
"cmd_scrollPageDown");
1689 function BrowserStop()
1699 function BrowserReloadOrDuplicate(aEvent) {
1700 var backgroundTabModifier = aEvent.button == 1 ||
1706 if (aEvent.shiftKey && !backgroundTabModifier) {
1712 if (where ==
"current")
1729 function BrowserHome()
1731 var homePage = gHomeButton.getHomePage();
1735 function BrowserGoHome(aEvent) {
1736 if (aEvent &&
"button" in aEvent &&
1740 var homePage = gHomeButton.getHomePage();
1751 urls = homePage.split(
"|");
1752 var loadInBackground =
getBoolPref(
"browser.tabs.loadBookmarksInBackground",
false);
1753 gBrowser.loadTabs(urls, loadInBackground);
1756 OpenBrowserWindow();
1774 gBrowser.loadTabs(aURIString.split(
"|"),
false,
true);
1780 function focusAndSelectUrlBar() {
1781 if (gURLBar && !gURLBar.readOnly) {
1793 function openLocation() {
1794 if (focusAndSelectUrlBar())
1807 win =
window.openDialog(
"chrome://browser/content/",
"_blank",
1808 "chrome,all,dialog=no",
"about:blank");
1809 win.addEventListener(
"load", openLocationCallback,
false);
1814 openDialog(
"chrome://browser/content/openLocation.xul",
"_blank",
1815 "chrome,modal,titlebar",
window);
1818 function openLocationCallback()
1821 setTimeout(
function() { this.openLocation(); }, 0);
1824 function BrowserOpenTab()
1828 window.openDialog(
"chrome://browser/content/",
"_blank",
1829 "chrome,all,dialog=no",
"about:blank");
1832 gBrowser.loadOneTab(
"about:blank", {inBackground:
false});
1833 focusAndSelectUrlBar();
1840 function delayedOpenWindow(chrome,
flags,
href, postData)
1852 function delayedOpenTab(aUrl, aReferrer, aCharset, aPostData, aAllowThirdPartyFixup)
1854 gBrowser.loadOneTab(aUrl, {
1855 referrerURI: aReferrer,
1857 postData: aPostData,
1858 inBackground:
false,
1859 allowThirdPartyFixup: aAllowThirdPartyFixup});
1862 var gLastOpenDirectory = {
1865 if (!this._lastDir || !this._lastDir.exists()) {
1867 this._lastDir =
gPrefService.getComplexValue(
"browser.open.lastDir",
1869 if (!this._lastDir.exists())
1870 this._lastDir =
null;
1874 return this._lastDir;
1877 if (!
val || !
val.exists() || !
val.isDirectory())
1879 this._lastDir =
val.clone();
1883 gPrefService.setComplexValue(
"browser.open.lastDir",
Ci.nsILocalFile,
1887 this._lastDir =
null;
1896 var fp = Components.classes[
"@mozilla.org/filepicker;1"].createInstance(
nsIFilePicker);
1900 fp.displayDirectory = gLastOpenDirectory.path;
1903 if (fp.file && fp.file.exists())
1904 gLastOpenDirectory.path = fp.file.parent.QueryInterface(
Ci.nsILocalFile);
1921 gBrowser.removeCurrentTab();
1928 gBrowser.mPanelContainer.removeEventListener(
"mousemove",
1930 document.removeEventListener(
"keypress",
FullScreen._keyToggleCallback,
false);
1931 document.removeEventListener(
"popupshown",
FullScreen._setPopupOpen,
false);
1932 document.removeEventListener(
"popuphidden",
FullScreen._setPopupOpen,
false);
1935 var fullScrToggler = document.getElementById(
"fullscr-toggler");
1936 if (fullScrToggler) {
1937 fullScrToggler.removeEventListener(
"mouseover",
FullScreen._expandCallback,
false);
1938 fullScrToggler.removeEventListener(
"dragenter",
FullScreen._expandCallback,
false);
1949 if (postData === undefined)
1952 if (allowThirdPartyFixup) {
1955 gBrowser.loadURIWithFlags(
uri, flags, referrer,
null, postData);
1961 var shortcutURL =
null;
1964 var searchService =
Cc[
"@mozilla.org/browser/search-service;1"].
1967 var
offset = aURL.indexOf(
" ");
1969 keyword = aURL.substr(0, offset);
1970 param = aURL.substr(offset + 1);
1976 var engine = searchService.getEngineByAlias(keyword);
1978 var submission = engine.getSubmission(param,
null);
1979 aPostDataRef.value = submission.postData;
1980 return submission.uri.spec;
1983 [shortcutURL, aPostDataRef.value] =
1984 PlacesUtils.getURLAndPostDataForKeyword(keyword);
1990 if (aPostDataRef.value)
1991 postData = unescape(aPostDataRef.value);
1993 if (/%s/
i.test(shortcutURL) || /%s/
i.test(postData)) {
1995 const re = /^(.*)\&mozcharset=([a-zA-Z][
_\-a-zA-Z0-9]+)\s*$/;
1996 var matches = shortcutURL.match(re);
1998 [, shortcutURL,
charset] = matches;
2004 charset = PlacesUtils.history.getCharsetForURI(
makeURI(shortcutURL));
2008 var encodedParam =
"";
2014 shortcutURL = shortcutURL.replace(/%s/g, encodedParam).replace(/%S/g, param);
2016 if (/%s/
i.test(postData))
2018 "application/x-www-form-urlencoded");
2023 aPostDataRef.value =
null;
2032 var dataStream =
Cc[
"@mozilla.org/io/string-input-stream;1"].
2034 aStringData = aStringData.replace(/%s/g, aEncKeyword).replace(/%S/g, aKeyword);
2035 dataStream.data = aStringData;
2037 var mimeStream =
Cc[
"@mozilla.org/network/mime-input-stream;1"].
2039 mimeStream.addHeader(
"Content-Type", aType);
2040 mimeStream.addContentLength =
true;
2041 mimeStream.setData(dataStream);
2042 return mimeStream.QueryInterface(
Ci.nsIInputStream);
2051 var clipboard = Components.classes[
"@mozilla.org/widget/clipboard;1"]
2052 .getService(Components.interfaces.nsIClipboard);
2055 var trans = Components.classes[
"@mozilla.org/widget/transferable;1"]
2056 .createInstance(Components.interfaces.nsITransferable);
2058 trans.addDataFlavor(
"text/unicode");
2061 if (clipboard.supportsSelectionClipboard())
2062 clipboard.getData(trans, clipboard.kSelectionClipboard);
2064 clipboard.getData(trans, clipboard.kGlobalClipboard);
2068 trans.getTransferData(
"text/unicode", data, dataLen);
2071 data = data.value.QueryInterface(Components.interfaces.nsISupportsString);
2072 url = data.data.substring(0, dataLen.value / 2);
2086 var docCharset =
"charset=" +
aDocument.characterSet;
2101 ifRequestor = win.QueryInterface(Components.interfaces.nsIInterfaceRequestor);
2115 var PageLoader = webNav.QueryInterface(Components.interfaces.nsIWebPageDescriptor);
2117 pageCookie = PageLoader.currentDescriptor;
2122 top.gViewSourceUtils.viewSource(webNav.currentURI.spec, pageCookie,
aDocument);
2129 var
args = {
doc:
doc, initialTab: initialTab, imageElement: imageElement};
2130 var
windows =
Cc[
'@mozilla.org/appshell/window-mediator;1']
2131 .getService(
Ci.nsIWindowMediator)
2132 .getEnumerator(
"Browser:page-info");
2134 var documentURL =
doc ?
doc.location :
window.content.document.location;
2137 while (windows.hasMoreElements()) {
2138 var currentWindow = windows.getNext();
2139 if (currentWindow.document.documentElement.getAttribute(
"relatedUrl") == documentURL) {
2140 currentWindow.focus();
2141 currentWindow.resetPageInfo(args);
2142 return currentWindow;
2147 return openDialog(
"chrome://browser/content/pageinfo/pageInfo.xul",
"",
2148 "chrome,toolbar,dialog=no,resizable", args);
2153 function LeakDetector(verbose)
2155 this.verbose = verbose;
2158 const NS_LEAKDETECTOR_CONTRACTID =
"@mozilla.org/xpcom/leakdetector;1";
2160 if (NS_LEAKDETECTOR_CONTRACTID in Components.classes) {
2162 LeakDetector.prototype = Components.classes[NS_LEAKDETECTOR_CONTRACTID]
2163 .createInstance(Components.interfaces.nsILeakDetector);
2165 LeakDetector.prototype = Object.prototype;
2168 LeakDetector.prototype = Object.prototype;
2171 var leakDetector =
new LeakDetector(
false);
2174 function dumpMemoryLeaks()
2176 leakDetector.dumpLeaks();
2180 function traceChrome()
2182 leakDetector.traceObject(document, leakDetector.verbose);
2186 function traceDocument()
2189 leakDetector.markObject(document,
true);
2190 leakDetector.traceObject(content, leakDetector.verbose);
2191 leakDetector.markObject(document,
false);
2195 function traceVerbose(verbose)
2197 leakDetector.verbose = (verbose ==
"true");
2202 var
value = gBrowser.userTypedValue;
2205 if (value ==
null) {
2210 if (gInitialPages.indexOf(uri.spec) != -1)
2211 value = content.opener ? uri.spec :
"";
2215 let isBlank = (uri.spec ==
"about:blank");
2216 valid = !isBlank && (!aURI || aValid);
2219 gURLBar.value =
value;
2224 var
value = aURI.spec;
2226 if (!/%25(?:3
B|2
F|3
F|3
A|40|26|3
D|2
B|24|2
C|23)/
i.test(value))
2228 value = decodeURI(value)
2236 .replace(/%(?!3
B|2
F|3
F|3
A|40|26|3
D|2
B|24|2
C|23)|[\r\n\
t]/ig,
2243 value = value.replace(/[\v\x0c\x1c\x1d\x1e\x1f\u00ad\u200b\ufeff\u2028\u2029\u2060\u2062\u2063\ufffc]/g,
2248 value = value.replace(/[\u200e\u200f\u202a\u202b\u202c\u202d\u202e]/g,
2255 var splitter = document.getElementById(
"urlbar-search-splitter");
2256 var urlbar = document.getElementById(
"urlbar-container");
2257 var searchbar = document.getElementById(
"search-container");
2260 if (urlbar && searchbar) {
2261 if (urlbar.nextSibling == searchbar)
2262 ibefore = searchbar;
2263 else if (searchbar.nextSibling == urlbar)
2269 splitter = document.createElement(
"splitter");
2270 splitter.id =
"urlbar-search-splitter";
2271 splitter.setAttribute(
"resizebefore",
"flex");
2272 splitter.setAttribute(
"resizeafter",
"flex");
2273 splitter.className =
"chromeclass-toolbar-additional";
2275 urlbar.parentNode.insertBefore(splitter, ibefore);
2276 }
else if (splitter)
2277 splitter.parentNode.removeChild(splitter);
2283 _searchBegin:
function LocBar_searchBegin() {
2284 function delayedBegin(
self) {
2285 self._timeoutID =
null;
2286 document.getElementById(
"urlbar-throbber").setAttribute(
"busy",
"true");
2289 this._timeoutID =
setTimeout(delayedBegin, 500,
this);
2292 _searchComplete:
function LocBar_searchComplete() {
2294 if (this._timeoutID) {
2295 clearTimeout(this._timeoutID);
2296 this._timeoutID =
null;
2298 document.getElementById(
"urlbar-throbber").removeAttribute(
"busy");
2304 if (gURLBar && gURLBar.value != gLastValidURLStr)
2314 gProxyFavIcon = document.getElementById(
"page-proxy-favicon");
2316 gURLBar.setAttribute(
"pageproxystate",
aState);
2317 gProxyFavIcon.setAttribute(
"pageproxystate",
aState);
2322 gLastValidURLStr = gURLBar.value;
2326 }
else if (
aState ==
"invalid") {
2339 else if (gProxyFavIcon.getAttribute(
"src") != aURL)
2340 gProxyFavIcon.setAttribute(
"src", aURL);
2345 gProxyFavIcon.removeAttribute(
"src");
2350 if (aEvent.button == 1 &&
gPrefService.getBoolPref(
"middlemouse.paste"))
2357 var
wm = Components.classes[
"@mozilla.org/appshell/window-mediator;1"]
2358 .getService(Components.interfaces.nsIWindowMediator);
2359 var win = wm.getMostRecentWindow(
"Browser:MigrationWizard");
2363 window.openDialog(
"chrome://browser/content/migration/migration.xul",
2364 "migration",
"centerscreen,chrome,resizable=no");
2367 window.openDialog(
"chrome://browser/content/migration/migration.xul",
2368 "migration",
"modal,centerscreen,chrome,resizable=no");
2377 if (!
event.isTrusted)
2380 var ot =
event.originalTarget;
2381 var errorDoc = ot.ownerDocument;
2385 if (/^about:certerror/.
test(errorDoc.documentURI)) {
2386 if (ot == errorDoc.getElementById(
'exceptionDialogButton')) {
2387 var params = { exceptionAdded :
false, handlePrivateBrowsing :
true };
2390 switch (
gPrefService.getIntPref(
"browser.ssl_override_behavior")) {
2392 params.prefetchCert =
true;
2394 params.location = errorDoc.location.href;
2397 Components.utils.reportError(
"Couldn't get ssl_override pref: " + e);
2400 window.openDialog(
'chrome://pippki/content/exceptionDialog.xul',
2401 '',
'chrome,centerscreen,modal', params);
2404 if (params.exceptionAdded)
2405 errorDoc.location.reload();
2407 else if (ot == errorDoc.getElementById(
'getMeOutOfHereButton')) {
2411 else if (/^about:blocked/.
test(errorDoc.documentURI)) {
2415 var isMalware = /e=malwareBlocked/.test(errorDoc.documentURI);
2417 if (ot == errorDoc.getElementById(
'getMeOutButton')) {
2420 else if (ot == errorDoc.getElementById(
'reportButton')) {
2424 var formatter =
Cc[
"@mozilla.org/toolkit/URLFormatterService;1"]
2425 .getService(Components.interfaces.nsIURLFormatter);
2431 var reportURL = formatter.formatURLPref(
"browser.safebrowsing.malware.reportURL");
2432 reportURL += errorDoc.location.href;
2433 content.location = reportURL;
2435 Components.utils.reportError(
"Couldn't get malware report URL: " + e);
2440 content.location = formatter.formatURLPref(
"browser.safebrowsing.warning.infoURL");
2442 Components.utils.reportError(
"Couldn't get phishing info URL: " + e);
2446 else if (ot == errorDoc.getElementById(
'ignoreWarningButton')) {
2450 gBrowser.loadURIWithFlags(content.location.href,
2454 label:
gNavigatorBundle.getString(
"safebrowsing.getMeOutOfHereButton.label"),
2455 accessKey:
gNavigatorBundle.getString(
"safebrowsing.getMeOutOfHereButton.accessKey"),
2463 accessKey:
gNavigatorBundle.getString(
"safebrowsing.notAnAttackButton.accessKey"),
2472 accessKey:
gNavigatorBundle.getString(
"safebrowsing.notAForgeryButton.accessKey"),
2479 var notificationBox = gBrowser.getNotificationBox();
2480 notificationBox.appendNotification(
2482 "blocked-badware-page",
2483 "chrome://global/skin/icons/blacklist_favicon.png",
2484 notificationBox.PRIORITY_CRITICAL_HIGH,
2489 else if (/^about:privatebrowsing/.
test(errorDoc.documentURI)) {
2490 if (ot == errorDoc.getElementById(
"startPrivateBrowsing")) {
2505 var
prefs =
Cc[
"@mozilla.org/preferences-service;1"]
2506 .getService(
Ci.nsIPrefService).getDefaultBranch(
null);
2507 var
url =
"about:blank";
2509 url = prefs.getComplexValue(
"browser.startup.homepage",
2510 Ci.nsIPrefLocalizedString).data;
2512 if (url.indexOf(
"|") != -1)
2513 url = url.split(
"|")[0];
2515 Components.utils.reportError(
"Couldn't get homepage pref: " + e);
2517 content.location =
url;
2533 return gBrowser.webNavigation;
2548 var sh = webNav.sessionHistory;
2555 webNav.reload(reloadFlags);
2572 gNavToolbox.hidden = aHide;
2576 var
sidebar = document.getElementById(
"sidebar-box");
2577 gChromeState.sidebarOpen = !sidebar.hidden;
2578 gSidebarCommand = sidebar.getAttribute(
"sidebarcommand");
2580 gChromeState.hadTabStrip = gBrowser.getStripVisibility();
2581 gBrowser.setStripVisibilityTo(
false);
2583 var notificationBox = gBrowser.getNotificationBox();
2584 gChromeState.notificationsOpen = !notificationBox.notificationsHidden;
2585 notificationBox.notificationsHidden = aHide;
2587 document.getElementById(
"sidebar").setAttribute(
"src",
"about:blank");
2588 var statusbar = document.getElementById(
"status-bar");
2589 gChromeState.statusbarOpen = !statusbar.hidden;
2590 statusbar.hidden = aHide;
2592 gChromeState.findOpen = !gFindBar.hidden;
2596 if (gChromeState.hadTabStrip) {
2597 gBrowser.setStripVisibilityTo(
true);
2600 if (gChromeState.notificationsOpen) {
2601 gBrowser.getNotificationBox().notificationsHidden = aHide;
2604 if (gChromeState.statusbarOpen) {
2605 var statusbar = document.getElementById(
"status-bar");
2606 statusbar.hidden = aHide;
2609 if (gChromeState.findOpen)
2613 if (gChromeState.sidebarOpen)
2614 toggleSidebar(gSidebarCommand);
2619 gInPrintPreviewMode =
true;
2626 gInPrintPreviewMode =
false;
2637 return gBrowser.markupDocumentViewer;
2656 if (tipElement.namespaceURI ==
"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul")
2659 const XLinkNS =
"http://www.w3.org/1999/xlink";
2662 var titleText =
null;
2663 var XLinkTitleText =
null;
2664 var direction = tipElement.ownerDocument.dir;
2666 while (!titleText && !XLinkTitleText && tipElement) {
2667 if (tipElement.nodeType == Node.ELEMENT_NODE) {
2668 titleText = tipElement.getAttribute(
"title");
2669 XLinkTitleText = tipElement.getAttributeNS(
XLinkNS,
"title");
2670 var defView = tipElement.ownerDocument.defaultView;
2675 direction = defView.getComputedStyle(tipElement,
"")
2676 .getPropertyValue(
"direction");
2678 tipElement = tipElement.parentNode;
2681 var tipNode = document.getElementById(
"aHTMLTooltip");
2682 tipNode.style.direction = direction;
2684 [titleText, XLinkTitleText].forEach(
function (
t) {
2692 t =
t.replace(/[\r\
t]/g,
' ');
2693 t =
t.replace(/\n/g,
'');
2695 tipNode.setAttribute(
"label",
t);
2704 getDragURLFromDataTransfer :
function (dt)
2706 var
types = dt.types;
2707 for (var
t = 0;
t < types.length;
t++) {
2708 var type = types[
t];
2710 case "text/uri-list":
2711 var
url = dt.getData(
"URL").replace(/^\s+|\s+$/g,
"");
2714 case "text/x-moz-text-internal":
2715 var url = dt.getData(type).replace(/^\s+|\s+$/g,
"");
2717 case "text/x-moz-url":
2718 var split = dt.getData(type).split(
"\n");
2719 return [split[0], split[1]];
2726 var
file = dt.mozGetDataAt(
"application/x-moz-file", 0);
2728 var
name = file instanceof
Ci.nsIFile ? file.leafName :
"";
2729 var fileHandler = ContentAreaUtils.ioService
2730 .getProtocolHandler(
"file")
2731 .QueryInterface(
Ci.nsIFileProtocolHandler);
2732 return [fileHandler.getURLSpecFromFile(file),
name];
2738 dragOver :
function (aEvent, statusString)
2740 var
types = aEvent.dataTransfer.types;
2741 if (types.contains(
"application/x-moz-file") ||
2742 types.contains(
"text/x-moz-url") ||
2743 types.contains(
"text/uri-list") ||
2744 types.contains(
"text/x-moz-text-internal") ||
2745 types.contains(
"text/plain")) {
2746 aEvent.preventDefault();
2749 var statusTextFld = document.getElementById(
"statusbar-display");
2757 var proxyIconDNDObserver = {
2758 onDragStart:
function (aEvent, aXferData, aDragAction)
2760 if (gProxyFavIcon.getAttribute(
"pageproxystate") !=
"valid")
2763 var
value = content.location.href;
2764 var urlString = value +
"\n" + content.document.title;
2765 var htmlString =
"<a href=\"" + value +
"\">" + value +
"</a>";
2767 var dt = aEvent.dataTransfer;
2768 dt.setData(
"text/x-moz-url", urlString);
2769 dt.setData(
"text/uri-list", value);
2770 dt.setData(
"text/plain", value);
2771 dt.setData(
"text/html", htmlString);
2775 var homeButtonObserver = {
2776 onDrop:
function (aEvent)
2778 let
url = browserDragAndDrop.getDragURLFromDataTransfer(aEvent.dataTransfer)[0];
2784 browserDragAndDrop.dragOver(aEvent,
"droponhomebutton");
2785 aEvent.dropEffect =
"link";
2787 onDragLeave:
function (aEvent)
2789 var statusTextFld = document.getElementById(
"statusbar-display");
2790 statusTextFld.label =
"";
2794 function openHomeDialog(aURL)
2796 var
promptService = Components.classes[
"@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService);
2799 var pressedVal = promptService.confirmEx(
window, promptTitle, promptMsg,
2800 promptService.STD_YES_NO_BUTTONS,
2803 if (pressedVal == 0) {
2805 var
str = Components.classes[
"@mozilla.org/supports-string;1"]
2806 .createInstance(Components.interfaces.nsISupportsString);
2808 gPrefService.setComplexValue(
"browser.startup.homepage",
2809 Components.interfaces.nsISupportsString, str);
2810 var homeButton = document.getElementById(
"home-button");
2811 homeButton.setAttribute(
"tooltiptext", aURL);
2813 dump(
"Failed to set the home page.\n"+ex+
"\n");
2818 var bookmarksButtonObserver = {
2819 onDrop:
function (aEvent)
2821 let [
url,
name] = browserDragAndDrop.getDragURLFromDataTransfer(aEvent.dataTransfer);
2829 browserDragAndDrop.dragOver(aEvent,
"droponbookmarksbutton");
2830 aEvent.dropEffect =
"link";
2833 onDragLeave:
function (aEvent)
2835 var statusTextFld = document.getElementById(
"statusbar-display");
2836 statusTextFld.label =
"";
2840 var newTabButtonObserver = {
2843 browserDragAndDrop.dragOver(aEvent,
"droponnewtabbutton");
2846 onDragLeave:
function (aEvent)
2848 var statusTextFld = document.getElementById(
"statusbar-display");
2849 statusTextFld.label =
"";
2852 onDrop:
function (aEvent)
2854 let url = browserDragAndDrop.getDragURLFromDataTransfer(aEvent.dataTransfer)[0];
2858 nsDragAndDrop.dragDropSecurityCheck(aEvent,
null, url);
2865 var newWindowButtonObserver = {
2868 browserDragAndDrop.dragOver(aEvent,
"droponnewwindowbutton");
2870 onDragLeave:
function (aEvent)
2872 var statusTextFld = document.getElementById(
"statusbar-display");
2873 statusTextFld.label =
"";
2875 onDrop:
function (aEvent)
2877 let url = browserDragAndDrop.getDragURLFromDataTransfer(aEvent.dataTransfer)[0];
2881 nsDragAndDrop.dragDropSecurityCheck(aEvent,
null, url);
2888 var DownloadsButtonDNDObserver = {
2893 var statusTextFld = document.getElementById(
"statusbar-display");
2895 var
types = aEvent.dataTransfer.types;
2896 if (types.contains(
"text/x-moz-url") ||
2897 types.contains(
"text/uri-list") ||
2898 types.contains(
"text/plain"))
2899 aEvent.preventDefault();
2902 onDragLeave:
function (aEvent)
2904 var statusTextFld = document.getElementById(
"statusbar-display");
2905 statusTextFld.label =
"";
2908 onDrop:
function (aEvent)
2910 let [
url,
name] = browserDragAndDrop.getDragURLFromDataTransfer(aEvent.dataTransfer);
2911 nsDragAndDrop.dragDropSecurityCheck(aEvent,
null, url);
2912 saveURL(url,
name,
null,
true,
true);
2916 const DOMLinkHandler = {
2917 handleEvent:
function (
event) {
2918 switch (
event.type) {
2919 case "DOMLinkAdded":
2920 this.onLinkAdded(
event);
2924 onLinkAdded:
function (
event) {
2925 var link =
event.originalTarget;
2926 var rel = link.rel && link.rel.toLowerCase();
2927 if (!link || !link.ownerDocument || !rel || !link.href)
2930 var feedAdded =
false;
2931 var iconAdded =
false;
2932 var searchAdded =
false;
2933 var relStrings = rel.split(/\s+/);
2935 for (let
i = 0;
i < relStrings.length;
i++)
2936 rels[relStrings[
i]] =
true;
2938 for (let relVal in rels) {
2943 if (!rels.feed && rels.alternate && rels.stylesheet)
2946 if (
isValidFeed(link, link.ownerDocument.nodePrincipal, rels.feed)) {
2954 if (!
gPrefService.getBoolPref(
"browser.chrome.site_icons"))
2957 var targetDoc = link.ownerDocument;
2958 var
uri =
makeURI(link.href, targetDoc.characterSet);
2960 if (gBrowser.isFailedIcon(uri))
2966 const aboutNeterr = /^about:neterror\?/;
2967 const aboutBlocked = /^about:blocked\?/;
2968 const aboutCert = /^about:certerror\?/;
2969 if (!(aboutNeterr.test(targetDoc.documentURI) ||
2970 aboutBlocked.test(targetDoc.documentURI) ||
2971 aboutCert.test(targetDoc.documentURI)) ||
2972 !uri.schemeIs(
"chrome")) {
2973 var ssm =
Cc[
"@mozilla.org/scriptsecuritymanager;1"].
2976 ssm.checkLoadURIWithPrincipal(targetDoc.nodePrincipal, uri,
2977 Ci.nsIScriptSecurityManager.DISALLOW_SCRIPT);
2984 var contentPolicy =
Cc[
"@mozilla.org/layout/content-policy;1"].
2991 if (contentPolicy.shouldLoad(
Ci.nsIContentPolicy.TYPE_IMAGE,
2992 uri, targetDoc.documentURIObject,
2993 link, link.type,
null)
2994 !=
Ci.nsIContentPolicy.ACCEPT)
2997 var browserIndex = gBrowser.getBrowserIndexForDocument(targetDoc);
2999 if (browserIndex == -1)
3002 var
tab = gBrowser.mTabContainer.childNodes[browserIndex];
3003 gBrowser.setIcon(tab, link.href);
3009 var type = link.type && link.type.toLowerCase();
3010 type = type.replace(/^\s+|\s*(?:;.*)?$/g,
"");
3012 if (type ==
"application/opensearchdescription+xml" && link.title &&
3013 /^(?:https?|ftp):/
i.test(link.href)) {
3014 var engine = { title: link.title,
href: link.href };
3015 BrowserSearch.addEngine(engine, link.ownerDocument);
3025 const BrowserSearch = {
3026 addEngine:
function(engine, targetDoc) {
3027 if (!this.searchBar)
3030 var
browser = gBrowser.getBrowserForDocument(targetDoc);
3036 if (browser.engines) {
3037 if (browser.engines.some(function (e) e.title == engine.title))
3045 if (gBrowser.shouldLoadFavIcon(targetDoc.documentURIObject))
3046 iconURL = targetDoc.documentURIObject.prePath +
"/favicon.ico";
3053 var searchService =
Cc[
"@mozilla.org/browser/search-service;1"].
3055 if (searchService.getEngineByName(engine.title))
3058 var engines = (
hidden ? browser.hiddenEngines : browser.engines) || [];
3060 engines.push({ uri: engine.href,
3061 title: engine.title,
3065 browser.hiddenEngines = engines;
3067 browser.engines = engines;
3068 if (browser == gBrowser.mCurrentBrowser)
3069 this.updateSearchButton();
3078 updateSearchButton:
function() {
3079 var searchBar = this.searchBar;
3084 if (!searchBar || !searchBar.searchButton)
3087 var engines = gBrowser.mCurrentBrowser.engines;
3088 if (engines && engines.length > 0)
3089 searchBar.searchButton.setAttribute(
"addengines",
"true");
3091 searchBar.searchButton.removeAttribute(
"addengines");
3099 webSearch:
function BrowserSearch_webSearch() {
3106 win.BrowserSearch.webSearch();
3112 function webSearchCallback() {
3116 win =
window.openDialog(
"chrome://browser/content/",
"_blank",
3117 "chrome,all,dialog=no",
"about:blank");
3118 win.addEventListener(
"load", webSearchCallback,
false);
3126 var searchBar = this.searchBar;
3131 var ss =
Cc[
"@mozilla.org/browser/search-service;1"].
3133 var searchForm = ss.defaultEngine.searchForm;
3149 loadSearch:
function BrowserSearch_search(searchText, useNewTab) {
3150 var ss =
Cc[
"@mozilla.org/browser/search-service;1"].
3157 engine = ss.currentEngine;
3159 engine = ss.defaultEngine;
3161 var submission = engine.getSubmission(searchText,
null);
3171 gBrowser.loadOneTab(submission.uri.spec, {
3172 postData: submission.postData,
3173 relatedToCurrent:
true});
3175 loadURI(submission.uri.spec,
null, submission.postData,
false);
3182 return document.getElementById(
"searchbar");
3185 loadAddEngines:
function BrowserSearch_loadAddEngines() {
3186 var newWindowPref =
gPrefService.getIntPref(
"browser.link.open_newwindow");
3187 var where = newWindowPref == 3 ?
"tab" :
"window";
3188 var regionBundle = document.getElementById(
"bundle_browser_region");
3189 var searchEnginesURL =
formatURL(
"browser.search.searchEnginesURL",
true);
3194 function FillHistoryMenu(aParent) {
3196 if (!aParent.hasStatusListener) {
3198 aParent.addEventListener(
"DOMMenuItemActive",
function(aEvent) {
3200 if (!aEvent.target.hasAttribute(
"checked"))
3203 aParent.addEventListener(
"DOMMenuItemInactive",
function() {
3207 aParent.hasStatusListener =
true;
3211 var children = aParent.childNodes;
3212 for (var
i = children.length - 1;
i >= 0; --
i) {
3213 if (children[
i].hasAttribute(
"index"))
3214 aParent.removeChild(children[
i]);
3218 var sessionHistory = webNav.sessionHistory;
3220 var
count = sessionHistory.count;
3224 const MAX_HISTORY_MENU_ITEMS = 15;
3225 var index = sessionHistory.index;
3226 var half_length = Math.floor(MAX_HISTORY_MENU_ITEMS / 2);
3227 var
start = Math.max(index - half_length, 0);
3228 var end = Math.min(start == 0 ? MAX_HISTORY_MENU_ITEMS : index + half_length + 1, count);
3230 start = Math.max(count - MAX_HISTORY_MENU_ITEMS, 0);
3236 for (var j = end - 1; j >=
start; j--) {
3237 let item = document.createElement(
"menuitem");
3238 let
entry = sessionHistory.getEntryAtIndex(j,
false);
3239 let uri = entry.URI.spec;
3241 item.setAttribute(
"uri", uri);
3242 item.setAttribute(
"label", entry.title || uri);
3243 item.setAttribute(
"index", j);
3247 let iconURL =
Cc[
"@mozilla.org/browser/favicon-service;1"]
3248 .getService(
Ci.nsIFaviconService)
3249 .getFaviconForPage(entry.URI).spec;
3250 item.style.listStyleImage =
"url(" + iconURL +
")";
3255 item.className =
"unified-nav-back menuitem-iconic";
3256 item.setAttribute(
"tooltiptext", tooltipBack);
3257 }
else if (j == index) {
3258 item.setAttribute(
"type",
"radio");
3259 item.setAttribute(
"checked",
"true");
3260 item.className =
"unified-nav-current";
3261 item.setAttribute(
"tooltiptext", tooltipCurrent);
3263 item.className =
"unified-nav-forward menuitem-iconic";
3264 item.setAttribute(
"tooltiptext", tooltipForward);
3267 aParent.appendChild(item);
3272 function addToUrlbarHistory(aUrlToAdd) {
3274 aUrlToAdd.indexOf(
" ") == -1 &&
3275 !/[\x00-\x1F]/.test(aUrlToAdd))
3279 function toJavaScriptConsole()
3284 function BrowserDownloadsUI()
3286 Cc[
"@mozilla.org/download-manager-ui;1"].
3292 var windowManager = Components.classes[
'@mozilla.org/appshell/window-mediator;1'].getService();
3293 var windowManagerInterface = windowManager.QueryInterface(Components.interfaces.nsIWindowMediator);
3294 var topWindow = windowManagerInterface.getMostRecentWindow(inType);
3299 window.open(uri,
"_blank", features);
3301 window.open(uri,
"_blank",
"chrome,extrachrome,menubar,resizable,scrollbars,status,toolbar");
3304 function toOpenDialogByTypeAndUrl(inType, relatedUrl, windowUri, features, extraArgument)
3306 var windowManager = Components.classes[
'@mozilla.org/appshell/window-mediator;1'].getService();
3307 var windowManagerInterface = windowManager.QueryInterface(Components.interfaces.nsIWindowMediator);
3308 var
windows = windowManagerInterface.getEnumerator(inType);
3311 while (windows.hasMoreElements()) {
3312 var currentWindow = windows.getNext();
3313 if (currentWindow.document.documentElement.getAttribute(
"relatedUrl") == relatedUrl) {
3314 currentWindow.focus();
3321 return window.openDialog(windowUri,
"_blank", features, extraArgument);
3323 return window.openDialog(windowUri,
"_blank",
"chrome,extrachrome,menubar,resizable,scrollbars,status,toolbar", extraArgument);
3326 function OpenBrowserWindow()
3328 var charsetArg =
new String();
3329 var
handler = Components.classes[
"@mozilla.org/browser/clh;1"]
3330 .getService(Components.interfaces.nsIBrowserHandler);
3331 var defaultArgs = handler.defaultArgs;
3332 var wintype = document.documentElement.getAttribute(
'windowtype');
3338 if (
window && (wintype ==
"navigator:browser") &&
window.content &&
window.content.document)
3340 var DocCharset =
window.content.document.characterSet;
3341 charsetArg =
"charset="+DocCharset;
3344 win =
window.openDialog(
"chrome://browser/content/",
"_blank",
"chrome,all,dialog=no", defaultArgs, charsetArg);
3348 win =
window.openDialog(
"chrome://browser/content/",
"_blank",
"chrome,all,dialog=no", defaultArgs);
3354 var gCustomizeSheet =
false;
3360 var menubar = document.getElementById(
"main-menubar");
3361 for (var
i = 0;
i < menubar.childNodes.length; ++
i)
3362 menubar.childNodes[
i].setAttribute(
"disabled",
true);
3364 var cmd = document.getElementById(
"cmd_CustomizeToolbars");
3365 cmd.setAttribute(
"disabled",
"true");
3367 var splitter = document.getElementById(
"urlbar-search-splitter");
3369 splitter.parentNode.removeChild(splitter);
3371 var customizeURL =
"chrome://global/content/customizeToolbar.xul";
3372 gCustomizeSheet =
getBoolPref(
"toolbar.customization.usesheet",
false);
3374 if (gCustomizeSheet) {
3375 var sheetFrame = document.getElementById(
"customizeToolbarSheetIFrame");
3376 sheetFrame.hidden =
false;
3377 sheetFrame.toolbox = gNavToolbox;
3382 if (sheetFrame.getAttribute(
"src") == customizeURL)
3383 sheetFrame.contentWindow.location.reload()
3385 sheetFrame.setAttribute(
"src", customizeURL);
3389 var sheetWidth = sheetFrame.style.width.match(/([0-9]+)
px/)[1];
3390 document.getElementById(
"customizeToolbarSheetPopup")
3391 .openPopup(gNavToolbox,
"after_start",
3392 (
window.innerWidth - sheetWidth) / 2, 0);
3394 return sheetFrame.contentWindow;
3396 return window.openDialog(customizeURL,
3398 "chrome,titlebar,toolbar,location,resizable,dependent",
3404 if (gCustomizeSheet) {
3405 document.getElementById(
"customizeToolbarSheetIFrame").hidden =
true;
3406 document.getElementById(
"customizeToolbarSheetPopup").hidePopup();
3410 if (aToolboxChanged) {
3411 gURLBar = document.getElementById(
"urlbar");
3415 gProxyFavIcon = document.getElementById(
"page-proxy-favicon");
3416 gHomeButton.updateTooltip();
3418 window.XULBrowserWindow.init();
3420 var backForwardDropmarker = document.getElementById(
"back-forward-dropmarker");
3421 if (backForwardDropmarker)
3422 backForwardDropmarker.disabled =
3423 document.getElementById(
'Browser:Back').hasAttribute(
'disabled') &&
3424 document.getElementById(
'Browser:Forward').hasAttribute(
'disabled');
3427 var navBar = document.getElementById(
"nav-bar");
3428 navBar.setAttribute(
"currentset",
3429 navBar.getAttribute(
"currentset")
3430 .replace(
"unified-back-forward-button",
3431 "unified-back-forward-button,back-button,forward-button"));
3432 document.persist(navBar.id,
"currentset");
3441 gHomeButton.updatePersonalToolbarStyle();
3451 var menubar = document.getElementById(
"main-menubar");
3452 for (var
i = 0;
i < menubar.childNodes.length; ++
i)
3453 menubar.childNodes[
i].setAttribute(
"disabled",
false);
3454 var cmd = document.getElementById(
"cmd_CustomizeToolbars");
3455 cmd.removeAttribute(
"disabled");
3459 if (!
getBoolPref(
"ui.click_hold_context_menus",
false))
3460 SetClickAndHoldHandlers();
3464 if (!gCustomizeSheet)
3470 gHomeButton.updatePersonalToolbarStyle();
3496 let editMenuPopupState = document.getElementById(
"menu_EditPopup").state;
3497 let contextMenuPopupState = document.getElementById(
"contentAreaContextMenu").state;
3498 let placesContextMenuPopupState = document.getElementById(
"placesContext").state;
3503 gEditUIVisible = editMenuPopupState ==
"showing" ||
3504 editMenuPopupState ==
"open" ||
3505 contextMenuPopupState ==
"showing" ||
3506 contextMenuPopupState ==
"open" ||
3507 placesContextMenuPopupState ==
"showing" ||
3508 placesContextMenuPopupState ==
"open" ||
3509 document.getElementById(
"cut-button") ||
3510 document.getElementById(
"copy-button") ||
3511 document.getElementById(
"paste-button") ?
true :
false;
3516 goUpdateGlobalEditMenuItems();
3522 goSetCommandEnabled(
"cmd_undo",
true);
3523 goSetCommandEnabled(
"cmd_redo",
true);
3524 goSetCommandEnabled(
"cmd_cut",
true);
3525 goSetCommandEnabled(
"cmd_copy",
true);
3526 goSetCommandEnabled(
"cmd_paste",
true);
3527 goSetCommandEnabled(
"cmd_selectAll",
true);
3528 goSetCommandEnabled(
"cmd_delete",
true);
3529 goSetCommandEnabled(
"cmd_switchTextDirection",
true);
3536 _XULNS:
"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
3540 this.showXULChrome(
"toolbar",
window.fullScreen);
3541 this.showXULChrome(
"statusbar",
window.fullScreen);
3542 document.getElementById(
"View:FullScreen").setAttribute(
"checked", !
window.fullScreen);
3544 var fullScrToggler = document.getElementById(
"fullscr-toggler");
3545 if (!
window.fullScreen) {
3549 if (!fullScrToggler) {
3550 fullScrToggler = document.createElement(
"toolbar");
3551 fullScrToggler.id =
"fullscr-toggler";
3552 fullScrToggler.setAttribute(
"customizable",
"false");
3553 fullScrToggler.setAttribute(
"moz-collapsed",
"true");
3554 var navBar = document.getElementById(
"nav-bar");
3555 navBar.parentNode.insertBefore(fullScrToggler, navBar);
3557 fullScrToggler.addEventListener(
"mouseover", this._expandCallback,
false);
3558 fullScrToggler.addEventListener(
"dragenter", this._expandCallback,
false);
3560 if (
gPrefService.getBoolPref(
"browser.fullscreen.autohide"))
3561 gBrowser.mPanelContainer.addEventListener(
"mousemove",
3562 this._collapseCallback,
false);
3564 document.addEventListener(
"keypress", this._keyToggleCallback,
false);
3565 document.addEventListener(
"popupshown", this._setPopupOpen,
false);
3566 document.addEventListener(
"popuphidden", this._setPopupOpen,
false);
3567 this._shouldAnimate =
true;
3568 this.mouseoverToggle(
false);
3571 gPrefService.addObserver(
"browser.fullscreen",
this,
false);
3574 document.removeEventListener(
"keypress", this._keyToggleCallback,
false);
3575 document.removeEventListener(
"popupshown", this._setPopupOpen,
false);
3576 document.removeEventListener(
"popuphidden", this._setPopupOpen,
false);
3577 gPrefService.removeObserver(
"browser.fullscreen",
this);
3579 if (fullScrToggler) {
3580 fullScrToggler.removeEventListener(
"mouseover", this._expandCallback,
false);
3581 fullScrToggler.removeEventListener(
"dragenter", this._expandCallback,
false);
3585 clearInterval(this._animationInterval);
3586 clearTimeout(this._animationTimeout);
3587 gNavToolbox.style.marginTop =
"0px";
3588 if (this._isChromeCollapsed)
3589 this.mouseoverToggle(
true);
3590 this._isAnimating =
false;
3592 this._isPopupOpen =
false;
3594 gBrowser.mPanelContainer.removeEventListener(
"mousemove",
3595 this._collapseCallback,
false);
3601 if (
aData ==
"browser.fullscreen.autohide") {
3602 if (
gPrefService.getBoolPref(
"browser.fullscreen.autohide")) {
3603 gBrowser.mPanelContainer.addEventListener(
"mousemove",
3604 this._collapseCallback,
false);
3607 gBrowser.mPanelContainer.removeEventListener(
"mousemove",
3608 this._collapseCallback,
false);
3614 _expandCallback:
function()
3616 FullScreen.mouseoverToggle(
true);
3618 _collapseCallback:
function()
3620 FullScreen.mouseoverToggle(
false);
3622 _keyToggleCallback:
function(aEvent)
3626 if (aEvent.keyCode == aEvent.DOM_VK_ESCAPE) {
3627 FullScreen._shouldAnimate =
false;
3628 FullScreen.mouseoverToggle(
false,
true);
3631 else if (aEvent.keyCode == aEvent.DOM_VK_F6)
3632 FullScreen.mouseoverToggle(
true);
3636 _isPopupOpen:
false,
3637 _isChromeCollapsed:
false,
3638 _safeToCollapse:
function(forceHide)
3640 if (!
gPrefService.getBoolPref(
"browser.fullscreen.autohide"))
3644 if (!forceHide && this._isPopupOpen)
3648 if (document.commandDispatcher.focusedElement &&
3649 document.commandDispatcher.focusedElement.ownerDocument == document &&
3650 document.commandDispatcher.focusedElement.localName ==
"input") {
3653 document.commandDispatcher.focusedElement.blur();
3660 _setPopupOpen:
function(aEvent)
3666 if (aEvent.type ==
"popupshown" && !FullScreen._isChromeCollapsed &&
3667 aEvent.target.localName !=
"tooltip" && aEvent.target.localName !=
"window")
3668 FullScreen._isPopupOpen =
true;
3669 else if (aEvent.type ==
"popuphidden" && aEvent.target.localName !=
"tooltip" &&
3670 aEvent.target.localName !=
"window")
3671 FullScreen._isPopupOpen =
false;
3675 getAutohide:
function(aItem)
3677 aItem.setAttribute(
"checked",
gPrefService.getBoolPref(
"browser.fullscreen.autohide"));
3679 setAutohide:
function()
3685 _shouldAnimate:
true,
3686 _isAnimating:
false,
3687 _animationTimeout:
null,
3688 _animationInterval:
null,
3689 _animateUp:
function()
3692 if (!
window.fullScreen || !FullScreen._safeToCollapse(
false)) {
3693 FullScreen._isAnimating =
false;
3694 FullScreen._shouldAnimate =
true;
3698 var animateFrameAmount = 2;
3699 function animateUpFrame() {
3700 animateFrameAmount *= 2;
3701 if (animateFrameAmount >=
3702 (gNavToolbox.boxObject.height + gBrowser.mStrip.boxObject.height)) {
3704 clearInterval(FullScreen._animationInterval);
3705 gNavToolbox.style.marginTop =
"0px";
3706 FullScreen._isAnimating =
false;
3707 FullScreen._shouldAnimate =
false;
3708 FullScreen.mouseoverToggle(
false);
3711 gNavToolbox.style.marginTop = (animateFrameAmount * -1) +
"px";
3714 FullScreen._animationInterval = setInterval(animateUpFrame, 70);
3717 mouseoverToggle:
function(aShow, forceHide)
3723 if (aShow != this._isChromeCollapsed || (!aShow && this._isAnimating) ||
3724 (!aShow && !this._safeToCollapse(forceHide)))
3731 if (
gPrefService.getIntPref(
"browser.fullscreen.animateUp") == 0)
3732 this._shouldAnimate =
false;
3734 if (!aShow && this._shouldAnimate) {
3735 this._isAnimating =
true;
3736 this._shouldAnimate =
false;
3737 this._animationTimeout =
setTimeout(this._animateUp, 800);
3743 gBrowser.mPanelContainer.addEventListener(
"mousemove",
3744 this._collapseCallback,
false);
3747 gBrowser.mPanelContainer.removeEventListener(
"mousemove",
3748 this._collapseCallback,
false);
3751 gBrowser.mStrip.setAttribute(
"moz-collapsed", !aShow);
3752 var allFSToolbars = document.getElementsByTagNameNS(this._XULNS,
"toolbar");
3753 for (var
i = 0;
i < allFSToolbars.length;
i++) {
3754 if (allFSToolbars[
i].
getAttribute(
"fullscreentoolbar") ==
"true")
3755 allFSToolbars[
i].setAttribute(
"moz-collapsed", !aShow);
3757 document.getElementById(
"fullscr-toggler").setAttribute(
"moz-collapsed", aShow);
3758 this._isChromeCollapsed = !aShow;
3759 if (
gPrefService.getIntPref(
"browser.fullscreen.animateUp") == 2)
3760 this._shouldAnimate =
true;
3763 showXULChrome:
function(aTag, aShow)
3765 var els = document.getElementsByTagNameNS(this._XULNS, aTag);
3767 for (var
i = 0;
i < els.length; ++
i) {
3772 var toolbarMode = els[
i].getAttribute(
"mode");
3773 if (toolbarMode !=
"text") {
3774 els[
i].setAttribute(
"saved-mode", toolbarMode);
3775 els[
i].setAttribute(
"saved-iconsize",
3777 els[
i].setAttribute(
"mode",
"icons");
3778 els[
i].setAttribute(
"iconsize",
"small");
3783 els[
i].setAttribute(
"saved-context",
3785 if (els[
i].
id ==
"nav-bar")
3786 els[
i].setAttribute(
"context",
"autohide-context");
3788 els[
i].removeAttribute(
"context");
3792 els[
i].setAttribute(
"inFullscreen",
true);
3795 function restoreAttr(attrName) {
3796 var savedAttr =
"saved-" + attrName;
3797 if (els[
i].hasAttribute(savedAttr)) {
3799 els[
i].removeAttribute(savedAttr);
3803 restoreAttr(
"mode");
3804 restoreAttr(
"iconsize");
3805 restoreAttr(
"context");
3807 els[
i].removeAttribute(
"inFullscreen");
3813 els[
i].removeAttribute(
"moz-collapsed");
3815 els[
i].setAttribute(
"moz-collapsed",
"true");
3820 gNavToolbox.removeAttribute(
"inFullscreen");
3822 gNavToolbox.setAttribute(
"inFullscreen",
true);
3824 var controls = document.getElementsByAttribute(
"fullscreencontrol",
"true");
3825 for (var
i = 0;
i < controls.length; ++
i)
3841 return /^text\/|\+xml$/.test(aMimeType) ||
3842 aMimeType ==
"application/x-javascript" ||
3843 aMimeType ==
"application/javascript" ||
3844 aMimeType ==
"application/xml" ||
3845 aMimeType ==
"mozilla.application/cached-xul";
3853 jsDefaultStatus:
"",
3860 statusTimeoutInEffect:
false,
3863 if (aIID.equals(
Ci.nsIWebProgressListener) ||
3864 aIID.equals(
Ci.nsIWebProgressListener2) ||
3865 aIID.equals(
Ci.nsISupportsWeakReference) ||
3866 aIID.equals(
Ci.nsIXULBrowserWindow) ||
3867 aIID.equals(
Ci.nsISupports))
3869 throw Cr.NS_NOINTERFACE;
3872 get statusMeter () {
3873 delete this.statusMeter;
3874 return this.statusMeter = document.getElementById(
"statusbar-icon");
3876 get stopCommand () {
3877 delete this.stopCommand;
3878 return this.stopCommand = document.getElementById(
"Browser:Stop");
3880 get reloadCommand () {
3881 delete this.reloadCommand;
3882 return this.reloadCommand = document.getElementById(
"Browser:Reload");
3884 get statusTextField () {
3885 delete this.statusTextField;
3886 return this.statusTextField = document.getElementById(
"statusbar-display");
3888 get securityButton () {
3889 delete this.securityButton;
3890 return this.securityButton = document.getElementById(
"security-button");
3893 delete this.isImage;
3894 return this.isImage = document.getElementById(
"isImage");
3897 delete this._uriFixup;
3898 return this._uriFixup =
Cc[
"@mozilla.org/docshell/urifixup;1"]
3899 .getService(
Ci.nsIURIFixup);
3903 this.throbberElement = document.getElementById(
"navigator-throbber");
3907 var securityUI = gBrowser.securityUI;
3908 this._hostChanged =
true;
3909 this.onSecurityChange(
null,
null, securityUI.state);
3912 destroy:
function () {
3914 delete this.throbberElement;
3915 delete this.statusMeter;
3916 delete this.stopCommand;
3917 delete this.reloadCommand;
3918 delete this.statusTextField;
3919 delete this.securityButton;
3920 delete this.statusText;
3921 delete this.lastURI;
3924 setJSStatus:
function (status) {
3925 this.jsStatus = status;
3926 this.updateStatusField();
3929 setJSDefaultStatus:
function (status) {
3930 this.jsDefaultStatus = status;
3931 this.updateStatusField();
3934 setDefaultStatus:
function (status) {
3935 this.defaultStatus = status;
3936 this.updateStatusField();
3939 setOverLink:
function (link, b) {
3942 this.overLink = link.replace(/[\u200e\u200f\u202a\u202b\u202c\u202d\u202e]/g,
3944 this.updateStatusField();
3947 updateStatusField:
function () {
3948 var text = this.overLink || this.status || this.jsStatus || this.jsDefaultStatus || this.defaultStatus;
3952 if (this.statusText != text) {
3953 this.statusTextField.label = text;
3954 this.statusText = text;
3958 onLinkIconAvailable:
function (
aBrowser) {
3959 if (gProxyFavIcon && gBrowser.userTypedValue ===
null)
3963 onProgressChange:
function (aWebProgress, aRequest,
3964 aCurSelfProgress, aMaxSelfProgress,
3965 aCurTotalProgress, aMaxTotalProgress) {
3968 if (aMaxTotalProgress > 0 && this._busyUI) {
3972 let percentage = (aCurTotalProgress * 100) / aMaxTotalProgress;
3973 this.statusMeter.value = percentage;
3977 onProgressChange64:
function (aWebProgress, aRequest,
3978 aCurSelfProgress, aMaxSelfProgress,
3979 aCurTotalProgress, aMaxTotalProgress) {
3980 return this.onProgressChange(aWebProgress, aRequest,
3981 aCurSelfProgress, aMaxSelfProgress, aCurTotalProgress,
3985 onStateChange:
function (aWebProgress, aRequest, aStateFlags, aStatus) {
3986 const nsIWebProgressListener =
Ci.nsIWebProgressListener;
3988 if (aStateFlags & nsIWebProgressListener.STATE_START) {
3994 if (aStateFlags & nsIWebProgressListener.STATE_IS_NETWORK &&
3995 aRequest && aWebProgress.DOMWindow == content)
3996 this.startDocumentLoad(aRequest);
4000 if (!(aStateFlags & nsIWebProgressListener.STATE_RESTORING)) {
4001 this._busyUI =
true;
4004 if (this.throbberElement)
4005 this.throbberElement.setAttribute(
"busy",
"true");
4008 this.statusMeter.value = 0;
4009 if (gProgressCollapseTimer) {
4010 window.clearTimeout(gProgressCollapseTimer);
4011 gProgressCollapseTimer =
null;
4014 this.statusMeter.parentNode.collapsed =
false;
4017 this.stopCommand.removeAttribute(
"disabled");
4020 else if (aStateFlags & nsIWebProgressListener.STATE_STOP) {
4021 if (aStateFlags & nsIWebProgressListener.STATE_IS_NETWORK) {
4022 if (aWebProgress.DOMWindow == content) {
4024 this.endDocumentLoad(aRequest, aStatus);
4025 if (!gBrowser.mTabbedMode && !gBrowser.mCurrentBrowser.mIconURL)
4026 gBrowser.useDefaultIcon(gBrowser.mCurrentTab);
4037 if (aRequest instanceof
nsIChannel ||
"URI" in aRequest) {
4038 location = aRequest.URI;
4041 if (location.scheme ==
"keyword" && aWebProgress.DOMWindow == content)
4042 gBrowser.userTypedValue =
null;
4044 if (location.spec !=
"about:blank") {
4046 case Components.results.NS_BINDING_ABORTED:
4049 case Components.results.NS_ERROR_NET_TIMEOUT:
4057 if (!msg && (!location || location.spec !=
"about:blank"))
4061 this.setDefaultStatus(msg);
4065 this.isImage.removeAttribute(
'disabled');
4067 this.isImage.setAttribute(
'disabled',
'true');
4070 this.isBusy =
false;
4073 this._busyUI =
false;
4076 gProgressCollapseTimer =
window.setTimeout(
function () {
4077 gProgressMeterPanel.collapsed =
true;
4078 gProgressCollapseTimer =
null;
4081 if (this.throbberElement)
4082 this.throbberElement.removeAttribute(
"busy");
4084 this.stopCommand.setAttribute(
"disabled",
"true");
4089 onLocationChange:
function (aWebProgress, aRequest, aLocationURI) {
4090 var location = aLocationURI ? aLocationURI.spec :
"";
4091 this._hostChanged =
true;
4093 if (document.tooltipNode) {
4095 if (aWebProgress.DOMWindow == content) {
4096 document.getElementById(
"aHTMLTooltip").hidePopup();
4097 document.tooltipNode =
null;
4100 for (let tooltipWindow =
4101 document.tooltipNode.ownerDocument.defaultView;
4102 tooltipWindow != tooltipWindow.parent;
4103 tooltipWindow = tooltipWindow.parent) {
4104 if (tooltipWindow == aWebProgress.DOMWindow) {
4105 document.getElementById(
"aHTMLTooltip").hidePopup();
4106 document.tooltipNode =
null;
4121 var selectedBrowser = gBrowser.selectedBrowser;
4122 if (selectedBrowser.lastURI) {
4123 let oldSpec = selectedBrowser.lastURI.spec;
4124 let oldIndexOfHash = oldSpec.indexOf(
"#");
4125 if (oldIndexOfHash != -1)
4126 oldSpec = oldSpec.substr(0, oldIndexOfHash);
4127 let newSpec = location;
4128 let newIndexOfHash = newSpec.indexOf(
"#");
4129 if (newIndexOfHash != -1)
4130 newSpec = newSpec.substr(0, newSpec.indexOf(
"#"));
4131 if (newSpec != oldSpec) {
4134 let nBox = gBrowser.getNotificationBox(selectedBrowser);
4135 nBox.removeTransientNotifications();
4138 selectedBrowser.lastURI = aLocationURI;
4142 this.isImage.removeAttribute(
'disabled');
4144 this.isImage.setAttribute(
'disabled',
'true');
4146 this.setOverLink(
"",
null);
4153 var browser = gBrowser.selectedBrowser;
4154 if (aWebProgress.DOMWindow == content) {
4155 if ((location ==
"about:blank" && !content.opener) ||
4158 this.reloadCommand.setAttribute(
"disabled",
"true");
4160 this.reloadCommand.removeAttribute(
"disabled");
4163 if (!gBrowser.mTabbedMode && aWebProgress.isLoadingDocument)
4164 gBrowser.setIcon(gBrowser.mCurrentTab,
null);
4168 let uri = aLocationURI;
4170 uri = this._uriFixup.createExposableURI(uri);
4180 if (gFindBar.findMode != gFindBar.FIND_NORMAL) {
4189 gFindBar.getElement(
"highlight").checked =
false;
4194 setTimeout(
function () { XULBrowserWindow.asyncUpdateUI(); }, 0);
4196 this.asyncUpdateUI();
4199 asyncUpdateUI:
function () {
4201 BrowserSearch.updateSearchButton();
4204 onStatusChange:
function (aWebProgress, aRequest, aStatus, aMessage) {
4205 this.status = aMessage;
4206 this.updateStatusField();
4212 _hostChanged:
false,
4214 onSecurityChange:
function (aWebProgress, aRequest,
aState) {
4217 if (this._state ==
aState &&
4218 this._tooltipText == gBrowser.securityUI.tooltipText &&
4219 !
this._hostChanged) {
4222 var contentHost = gBrowser.contentWindow.location.host;
4223 if (this._host !== undefined && this._host != contentHost) {
4224 Components.utils.reportError(
4225 "ASSERTION: browser.js host is inconsistent. Content window has " +
4226 "<" + contentHost +
"> but cached host is <" + this._host +
">.\n"
4237 this._host = gBrowser.contentWindow.location.host;
4243 this._hostChanged =
false;
4244 this._tooltipText = gBrowser.securityUI.tooltipText
4248 const wpl = Components.interfaces.nsIWebProgressListener;
4249 const wpl_security_bits = wpl.STATE_IS_SECURE |
4250 wpl.STATE_IS_BROKEN |
4251 wpl.STATE_IS_INSECURE |
4252 wpl.STATE_SECURE_HIGH |
4253 wpl.STATE_SECURE_MED |
4254 wpl.STATE_SECURE_LOW;
4257 switch (this._state & wpl_security_bits) {
4258 case wpl.STATE_IS_SECURE | wpl.STATE_SECURE_HIGH:
4261 case wpl.STATE_IS_SECURE | wpl.STATE_SECURE_MED:
4262 case wpl.STATE_IS_SECURE | wpl.STATE_SECURE_LOW:
4265 case wpl.STATE_IS_BROKEN:
4271 this.securityButton.setAttribute(
"level", level);
4272 this.securityButton.hidden =
false;
4276 gURLBar.setAttribute(
"level", level);
4278 this.securityButton.hidden =
true;
4279 this.securityButton.removeAttribute(
"level");
4281 gURLBar.removeAttribute(
"level");
4284 this.securityButton.setAttribute(
"tooltiptext", this._tooltipText);
4289 var location = gBrowser.contentWindow.location;
4290 var locationObj = {};
4292 locationObj.host = location.host;
4293 locationObj.hostname = location.hostname;
4294 locationObj.port = location.port;
4304 onUpdateCurrentBrowser:
function (aStateFlags, aStatus, aMessage, aTotalProgress) {
4306 FullZoom.onLocationChange(gBrowser.currentURI,
true);
4307 var nsIWebProgressListener = Components.interfaces.nsIWebProgressListener;
4308 var loadingDone = aStateFlags & nsIWebProgressListener.STATE_STOP;
4313 gBrowser.webProgress,
4314 { URI: gBrowser.currentURI },
4315 loadingDone ? nsIWebProgressListener.STATE_STOP : nsIWebProgressListener.STATE_START,
4321 this.onStatusChange(gBrowser.webProgress,
null, 0, aMessage);
4322 this.onProgressChange(gBrowser.webProgress, 0, 0, aTotalProgress, 1);
4325 startDocumentLoad:
function (aRequest) {
4327 gBrowser.mCurrentBrowser.feeds =
null;
4330 gBrowser.mCurrentBrowser.engines =
null;
4332 var uri = aRequest.QueryInterface(
Ci.nsIChannel).URI;
4334 .getService(
Ci.nsIObserverService);
4337 gURLBar.value ==
"" &&
4342 observerService.notifyObservers(content,
"StartDocumentLoad", uri.spec);
4347 endDocumentLoad:
function (aRequest, aStatus) {
4348 var urlStr = aRequest.QueryInterface(
Ci.nsIChannel).originalURI.spec;
4350 var observerService =
Cc[
"@mozilla.org/observer-service;1"]
4351 .getService(
Ci.nsIObserverService);
4353 var notification = Components.isSuccessCode(aStatus) ?
"EndDocumentLoad" :
"FailDocumentLoad";
4355 observerService.notifyObservers(content, notification, urlStr);
4361 var TabsProgressListener = {
4362 onProgressChange:
function (
aBrowser, aWebProgress, aRequest,
4363 aCurSelfProgress, aMaxSelfProgress,
4364 aCurTotalProgress, aMaxTotalProgress) {
4368 #ifdef MOZ_CRASHREPORTER
4369 if (aRequest instanceof
Ci.nsIChannel &&
4370 aStateFlags &
Ci.nsIWebProgressListener.STATE_START &&
4371 aStateFlags &
Ci.nsIWebProgressListener.STATE_IS_DOCUMENT) {
4372 gCrashReporter.annotateCrashReport(
"URL", aRequest.URI.spec);
4377 onLocationChange:
function (
aBrowser, aWebProgress, aRequest, aLocationURI) {
4379 if (
aBrowser.contentWindow == aWebProgress.DOMWindow)
4383 onStatusChange:
function (
aBrowser, aWebProgress, aRequest, aStatus, aMessage) {
4386 onRefreshAttempted:
function (
aBrowser, aWebProgress, aURI,
aDelay, aSameURI) {
4387 if (
gPrefService.getBoolPref(
"accessibility.blockautorefresh")) {
4388 let
brandBundle = document.getElementById(
"bundle_brand");
4389 let brandShortName = brandBundle.getString(
"brandShortName");
4390 let refreshButtonText =
4392 let refreshButtonAccesskey =
4395 gNavigatorBundle.getFormattedString(aSameURI ?
"refreshBlocked.refreshLabel"
4396 :
"refreshBlocked.redirectLabel",
4398 let
docShell = aWebProgress.DOMWindow
4399 .QueryInterface(
Ci.nsIInterfaceRequestor)
4400 .getInterface(
Ci.nsIWebNavigation)
4401 .QueryInterface(
Ci.nsIDocShell);
4402 let notificationBox = gBrowser.getNotificationBox(
aBrowser);
4403 let notification = notificationBox.getNotificationWithValue(
"refresh-blocked");
4406 notification.refreshURI = aURI;
4407 notification.delay =
aDelay;
4411 label: refreshButtonText,
4412 accessKey: refreshButtonAccesskey,
4413 callback:
function (aNotification, aButton) {
4414 var refreshURI = aNotification.docShell
4415 .QueryInterface(
Ci.nsIRefreshURI);
4416 refreshURI.forceRefreshURI(aNotification.refreshURI,
4417 aNotification.delay,
true);
4421 notificationBox.appendNotification(message,
"refresh-blocked",
4422 "chrome://browser/skin/Info.png",
4423 notificationBox.PRIORITY_INFO_MEDIUM,
4425 notification.refreshURI = aURI;
4426 notification.delay =
aDelay;
4434 onSecurityChange:
function (
aBrowser, aWebProgress, aRequest,
aState) {
4438 function nsBrowserAccess()
4442 nsBrowserAccess.prototype =
4446 if (aIID.equals(
Ci.nsIBrowserDOMWindow) ||
4447 aIID.equals(
Ci.nsISupports))
4449 throw Components.results.NS_NOINTERFACE;
4452 openURI :
function(aURI, aOpener, aWhere, aContext)
4454 var newWindow =
null;
4455 var isExternal = (aContext ==
Ci.nsIBrowserDOMWindow.OPEN_EXTERNAL);
4457 if (isExternal && aURI && aURI.schemeIs(
"chrome")) {
4458 dump(
"use -chrome command-line option to load external chrome urls\n");
4462 var loadflags = isExternal ?
4463 Ci.nsIWebNavigation.LOAD_FLAGS_FROM_EXTERNAL :
4464 Ci.nsIWebNavigation.LOAD_FLAGS_NONE;
4465 if (aWhere ==
Ci.nsIBrowserDOMWindow.OPEN_DEFAULTWINDOW)
4466 aWhere =
gPrefService.getIntPref(
"browser.link.open_newwindow");
4468 case Ci.nsIBrowserDOMWindow.OPEN_NEWWINDOW :
4471 var url = aURI ? aURI.spec :
"about:blank";
4476 case Ci.nsIBrowserDOMWindow.OPEN_NEWTAB :
4477 let
win, needToFocusWin;
4480 if (!
window.document.documentElement.getAttribute(
"chromehidden"))
4483 win =
Cc[
"@mozilla.org/browser/browserglue;1"]
4484 .getService(
Ci.nsIBrowserGlue)
4485 .getMostRecentBrowserWindow();
4486 needToFocusWin =
true;
4494 let loadInBackground =
gPrefService.getBoolPref(
"browser.tabs.loadDivertedInBackground");
4495 let referrer = aOpener ?
makeURI(aOpener.location.href) :
null;
4499 let loadBlankFirst = !aURI || isExternal;
4500 let tab = win.gBrowser.loadOneTab(loadBlankFirst ?
"about:blank" : aURI.spec,
4501 referrer,
null,
null, loadInBackground,
false);
4502 let browser = win.gBrowser.getBrowserForTab(tab);
4504 if (loadBlankFirst && aURI)
4505 browser.loadURIWithFlags(aURI.spec, loadflags, referrer,
null,
null);
4507 newWindow = browser.contentWindow;
4508 if (needToFocusWin || (!loadInBackground && isExternal))
4512 newWindow = content;
4514 let referrer = aOpener ?
makeURI(aOpener.location.href) :
null;
4515 gBrowser.loadURIWithFlags(aURI.spec, loadflags, referrer,
null,
null);
4517 if (!
gPrefService.getBoolPref(
"browser.tabs.loadDivertedInBackground"))
4523 isTabContentWindow :
function(aWindow)
4525 return gBrowser.browsers.some(
function (browser) browser.contentWindow == aWindow);
4529 function onViewToolbarsPopupShowing(aEvent)
4531 var popup = aEvent.target;
4535 for (i = popup.childNodes.length-1; i >= 0; --i) {
4536 var deadItem = popup.childNodes[
i];
4537 if (deadItem.hasAttribute(
"toolbarindex"))
4538 popup.removeChild(deadItem);
4541 var firstMenuItem = popup.firstChild;
4543 for (i = 0; i < gNavToolbox.childNodes.length; ++
i) {
4544 var toolbar = gNavToolbox.childNodes[
i];
4545 var toolbarName = toolbar.getAttribute(
"toolbarname");
4547 let
menuItem = document.createElement(
"menuitem");
4548 let hidingAttribute = toolbar.getAttribute(
"type") ==
"menubar" ?
4549 "autohide" :
"collapsed";
4550 menuItem.setAttribute(
"toolbarindex", i);
4551 menuItem.setAttribute(
"type",
"checkbox");
4552 menuItem.setAttribute(
"label", toolbarName);
4553 menuItem.setAttribute(
"accesskey", toolbar.getAttribute(
"accesskey"));
4554 menuItem.setAttribute(
"checked", toolbar.getAttribute(hidingAttribute) !=
"true");
4555 popup.insertBefore(menuItem, firstMenuItem);
4557 menuItem.addEventListener(
"command", onViewToolbarCommand,
false);
4559 toolbar = toolbar.nextSibling;
4563 function onViewToolbarCommand(aEvent)
4565 var index = aEvent.originalTarget.getAttribute(
"toolbarindex");
4566 var toolbar = gNavToolbox.childNodes[index];
4567 var hidingAttribute = toolbar.getAttribute(
"type") ==
"menubar" ?
4568 "autohide" :
"collapsed";
4570 toolbar.setAttribute(hidingAttribute,
4571 aEvent.originalTarget.getAttribute(
"checked") !=
"true");
4572 document.persist(toolbar.id, hidingAttribute);
4575 function displaySecurityInfo()
4600 function toggleSidebar(commandID, forceOpen) {
4602 var sidebarBox = document.getElementById(
"sidebar-box");
4604 commandID = sidebarBox.getAttribute(
"sidebarcommand");
4606 var sidebarBroadcaster = document.getElementById(commandID);
4607 var
sidebar = document.getElementById(
"sidebar");
4608 var sidebarTitle = document.getElementById(
"sidebar-title");
4609 var sidebarSplitter = document.getElementById(
"sidebar-splitter");
4611 if (sidebarBroadcaster.getAttribute(
"checked") ==
"true") {
4613 sidebarBroadcaster.removeAttribute(
"checked");
4614 sidebarBox.setAttribute(
"sidebarcommand",
"");
4615 sidebarTitle.value =
"";
4616 sidebar.setAttribute(
"src",
"about:blank");
4617 sidebarBox.hidden =
true;
4618 sidebarSplitter.hidden =
true;
4621 fireSidebarFocusedEvent();
4629 var broadcasters = document.getElementsByAttribute(
"group",
"sidebar");
4630 for (var i = 0; i < broadcasters.length; ++
i) {
4633 if (broadcasters[i].localName !=
"broadcaster")
4636 if (broadcasters[i] != sidebarBroadcaster)
4637 broadcasters[
i].removeAttribute(
"checked");
4639 sidebarBroadcaster.setAttribute(
"checked",
"true");
4642 sidebarBox.hidden =
false;
4643 sidebarSplitter.hidden =
false;
4645 var url = sidebarBroadcaster.getAttribute(
"sidebarurl");
4646 var title = sidebarBroadcaster.getAttribute(
"sidebartitle");
4648 title = sidebarBroadcaster.getAttribute(
"label");
4649 sidebar.setAttribute(
"src", url);
4650 sidebarBox.setAttribute(
"sidebarcommand", sidebarBroadcaster.id);
4651 sidebarTitle.value = title;
4658 sidebarBox.setAttribute(
"src", url);
4660 if (sidebar.contentDocument.location.href != url)
4661 sidebar.addEventListener(
"load", sidebarOnLoad,
true);
4663 fireSidebarFocusedEvent();
4666 function sidebarOnLoad(
event) {
4667 var sidebar = document.getElementById(
"sidebar");
4668 sidebar.removeEventListener(
"load", sidebarOnLoad,
true);
4681 function fireSidebarFocusedEvent() {
4682 var sidebar = document.getElementById(
"sidebar");
4683 var
event = document.createEvent(
"Events");
4684 event.initEvent(
"SidebarFocused",
true,
false);
4685 sidebar.contentWindow.dispatchEvent(
event);
4690 observe:
function (aSubject, aTopic, aPrefName)
4692 if (aTopic !=
"nsPref:changed" || aPrefName != this.
prefDomain)
4695 this.updateTooltip();
4698 updateTooltip:
function (homeButton)
4701 homeButton = document.getElementById(
"home-button");
4703 var homePage = this.getHomePage();
4704 homePage = homePage.replace(/\|/g,
', ');
4705 homeButton.setAttribute(
"tooltiptext", homePage);
4709 getHomePage:
function ()
4714 Components.interfaces.nsIPrefLocalizedString).data;
4720 var SBS =
Cc[
"@mozilla.org/intl/stringbundle;1"].getService(
Ci.nsIStringBundleService);
4721 var configBundle = SBS.createBundle(
"resource:/browserconfig.properties");
4722 url = configBundle.GetStringFromName(this.
prefDomain);
4728 updatePersonalToolbarStyle:
function (homeButton)
4731 homeButton = document.getElementById(
"home-button");
4733 homeButton.className = homeButton.parentNode.id ==
"PersonalToolbar"
4734 || homeButton.parentNode.parentNode.id ==
"PersonalToolbar" ?
4735 homeButton.className.replace(
"toolbarbutton-1",
"bookmark-item") :
4736 homeButton.className.replace(
"bookmark-item",
"toolbarbutton-1");
4751 const kMaxSelectionLen = 150;
4752 const charLen = Math.min(aCharLen || kMaxSelectionLen, kMaxSelectionLen);
4754 var focusedWindow = document.commandDispatcher.focusedWindow;
4755 var selection = focusedWindow.getSelection().toString();
4758 if (selection.length > charLen) {
4760 var pattern =
new RegExp(
"^(?:\\s*.){0," + charLen +
"}");
4761 pattern.test(selection);
4762 selection = RegExp.lastMatch;
4765 selection = selection.replace(/^\s+/,
"")
4766 .replace(/\s+$/,
"")
4767 .replace(/\s+/g,
" ");
4769 if (selection.length > charLen)
4770 selection = selection.substr(0, charLen);
4779 toggleSidebar(
'viewWebPanelsSidebar',
true);
4782 document.getElementById(
"sidebar-title").value = aTitle;
4785 var sidebar = document.getElementById(
"sidebar");
4786 if (sidebar.docShell && sidebar.contentDocument && sidebar.contentDocument.getElementById(
'web-panels-browser')) {
4787 sidebar.contentWindow.loadWebPanel(aURI);
4797 gWebPanelURI = aURI;
4803 var sidebar = document.getElementById(
"sidebar");
4804 if (gWebPanelURI && sidebar.contentDocument && sidebar.contentDocument.getElementById(
'web-panels-browser'))
4805 sidebar.contentWindow.loadWebPanel(gWebPanelURI);
4821 if (!
event.isTrusted ||
event.getPreventDefault()) {
4825 var
target =
event.target;
4828 if (target instanceof HTMLAnchorElement ||
4829 target instanceof HTMLAreaElement ||
4830 target instanceof HTMLLinkElement) {
4831 if (target.hasAttribute(
"href"))
4837 var parent = target.parentNode;
4839 if (parent instanceof HTMLAnchorElement ||
4840 parent instanceof HTMLAreaElement ||
4841 parent instanceof HTMLLinkElement) {
4842 if (parent.hasAttribute(
"href"))
4845 parent = parent.parentNode;
4849 linkNode =
event.originalTarget;
4850 while (linkNode && !(linkNode instanceof HTMLAnchorElement))
4851 linkNode = linkNode.parentNode;
4854 if (linkNode && !linkNode.hasAttribute(
"href"))
4867 target = wrapper.getAttribute(
"target");
4868 if (fieldNormalClicks &&
4869 (!target || target ==
"_content" || target ==
"_main"))
4874 if (wrapper.getAttribute(
"onclick"))
4877 if (wrapper.href.substr(0, 11) ===
"javascript:")
4880 if (wrapper.href.substr(0, 5) ===
"data:")
4884 urlSecurityCheck(wrapper.href, wrapper.ownerDocument.nodePrincipal);
4895 event.preventDefault();
4898 else if (linkNode.getAttribute(
"rel") ==
"sidebar") {
4903 wrapper.getAttribute(
"title"),
4905 event.preventDefault();
4916 var
href, realHref, baseURI;
4919 if (linkNode.nodeType == Node.ELEMENT_NODE) {
4922 realHref = wrapper.getAttributeNS(
"http://www.w3.org/1999/xlink",
"href");
4925 baseURI = wrapper.baseURI
4928 linkNode = linkNode.parentNode;
4936 if (
event.button == 1 &&
4937 gPrefService.getBoolPref(
"middlemouse.contentLoadURL") &&
4946 var
doc =
event.target.ownerDocument;
4948 switch (
event.button) {
4951 if (
event.metaKey) {
4953 if (
event.ctrlKey) {
4956 event.stopPropagation();
4962 Cc[
"@mozilla.org/browser/feeds/result-service;1"].
4964 feedService.forcePreviewPage =
true;
4969 if (
event.shiftKey) {
4971 event.stopPropagation();
4977 true, doc.documentURIObject);
4983 var tab =
gPrefService.getBoolPref(
"browser.tabs.opentabfor.middleclick");
4988 event.stopPropagation();
5006 addToUrlbarHistory(url);
5017 event.stopPropagation();
5030 onDrop:
function (aEvent)
5032 if (aEvent.getPreventDefault())
5035 var types = aEvent.dataTransfer.types;
5036 if (!types.contains(
"application/x-moz-file") &&
5037 !types.contains(
"text/x-moz-url") &&
5038 !types.contains(
"text/uri-list") &&
5039 !types.contains(
"text/plain")) {
5040 aEvent.preventDefault();
5044 let [
url,
name] = browserDragAndDrop.getDragURLFromDataTransfer(aEvent.dataTransfer);
5049 if (!url || !url.length || url.indexOf(
" ", 0) != -1 ||
5050 /^\s*(javascript|
data):/.
test(url))
5053 nsDragAndDrop.dragDropSecurityCheck(aEvent,
null, url);
5055 switch (document.documentElement.getAttribute(
'windowtype')) {
5056 case "navigator:browser":
5061 case "navigator:view-source":
5068 aEvent.preventDefault();
5074 var
node =
event.target;
5075 var
name = node.getAttribute(
'name');
5077 if (name ==
'detectorGroup') {
5080 }
else if (name ==
'charsetGroup') {
5081 var
charset = node.getAttribute(
'id');
5082 charset = charset.substring(
'charset.'.length, charset.length)
5084 }
else if (name ==
'charsetCustomize') {
5089 }
catch(ex) { alert(ex); }
5094 var uri =
event.target.getAttribute(
"id");
5095 var prefvalue = uri.substring(
'chardet.'.length, uri.length);
5096 if (
"off" == prefvalue) {
5101 var
pref = Components.classes[
"@mozilla.org/preferences-service;1"]
5102 .getService(Components.interfaces.nsIPrefBranch);
5103 var str = Components.classes[
"@mozilla.org/supports-string;1"]
5104 .createInstance(Components.interfaces.nsISupportsString);
5106 str.data = prefvalue;
5107 pref.setComplexValue(
"intl.charset.detector",
5108 Components.interfaces.nsISupportsString, str);
5109 if (doReload)
window.content.location.reload();
5112 dump(
"Failed to set the intl.charset.detector preference.\n");
5128 var docCharset = gBrowser.docShell.QueryInterface(
Ci.nsIDocCharset);
5129 docCharset.charset = aCharset;
5131 PlacesUtils.history.setCharsetForURI(
getWebNavigation().currentURI, aCharset);
5137 gBrowser.documentCharsetInfo.forcedDetector =
true;
5145 var wnd = document.commandDispatcher.focusedWindow;
5150 var pref_item = document.getElementById(
'charset.' + gPrevCharset);
5152 pref_item.setAttribute(
'checked',
'false');
5155 var menuitem = document.getElementById(
'charset.' + wnd.document.characterSet);
5157 menuitem.setAttribute(
'checked',
'true');
5166 var
pref = Components.classes[
"@mozilla.org/preferences-service;1"]
5167 .getService(Components.interfaces.nsIPrefBranch);
5168 prefvalue = pref.getComplexValue(
"intl.charset.detector",
5169 Components.interfaces.nsIPrefLocalizedString).data;
5175 if (prefvalue ==
"") prefvalue =
"off";
5176 dump(
"intl.charset.detector = "+ prefvalue +
"\n");
5178 prefvalue =
'chardet.' + prefvalue;
5179 var menuitem = document.getElementById(prefvalue);
5182 menuitem.setAttribute(
'checked',
'true');
5199 var observerService = Components.classes[
"@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService);
5200 observerService.notifyObservers(
null,
"charsetmenu-selected",
node);
5207 if (charset.length > 0 && (charset != gLastBrowserCharset)) {
5209 gCharsetMenu = Components.classes[
'@mozilla.org/rdf/datasource;1?name=charset-menu'].getService().QueryInterface(Components.interfaces.nsICurrentCharsetListener);
5210 gCharsetMenu.SetCurrentCharset(charset);
5212 gLastBrowserCharset =
charset;
5218 var styleSheetsArray =
Array.slice(frameset.document.styleSheets);
5219 for (let i = 0; i < frameset.frames.length; i++) {
5221 styleSheetsArray = styleSheetsArray.concat(frameSheets);
5223 return styleSheetsArray;
5227 var noStyle = menuPopup.firstChild;
5228 var persistentOnly = noStyle.nextSibling;
5229 var sep = persistentOnly.nextSibling;
5230 while (sep.nextSibling)
5231 menuPopup.removeChild(sep.nextSibling);
5234 var currentStyleSheets = {};
5236 var haveAltSheets =
false;
5237 var altStyleSelected =
false;
5239 for (let i = 0; i < styleSheets.length; ++
i) {
5240 let currentStyleSheet = styleSheets[
i];
5242 if (!currentStyleSheet.title)
5246 let (media = currentStyleSheet.media.mediaText.toLowerCase()) {
5247 if (media && (media.indexOf(
"screen") == -1) && (media.indexOf(
"all") == -1))
5251 if (!currentStyleSheet.disabled)
5252 altStyleSelected =
true;
5254 haveAltSheets =
true;
5256 let lastWithSameTitle =
null;
5257 if (currentStyleSheet.title in currentStyleSheets)
5258 lastWithSameTitle = currentStyleSheets[currentStyleSheet.title];
5260 if (!lastWithSameTitle) {
5261 let menuItem = document.createElement(
"menuitem");
5262 menuItem.setAttribute(
"type",
"radio");
5263 menuItem.setAttribute(
"label", currentStyleSheet.title);
5264 menuItem.setAttribute(
"data", currentStyleSheet.title);
5265 menuItem.setAttribute(
"checked", !currentStyleSheet.disabled && !styleDisabled);
5266 menuPopup.appendChild(menuItem);
5267 currentStyleSheets[currentStyleSheet.title] =
menuItem;
5268 }
else if (currentStyleSheet.disabled) {
5269 lastWithSameTitle.removeAttribute(
"checked");
5273 noStyle.setAttribute(
"checked", styleDisabled);
5274 persistentOnly.setAttribute(
"checked", !altStyleSelected && !styleDisabled);
5275 persistentOnly.hidden = (
window.content.document.preferredStyleSheetSet) ? haveAltSheets :
false;
5276 sep.hidden = (noStyle.hidden && persistentOnly.hidden) || !haveAltSheets;
5281 return Array.some(frame.document.styleSheets,
5282 function (stylesheet) stylesheet.title == title);
5286 var docStyleSheets = frame.document.styleSheets;
5288 for (let i = 0; i < docStyleSheets.length; ++
i) {
5289 let docStyleSheet = docStyleSheets[
i];
5291 if (title ==
"_nostyle")
5292 docStyleSheet.disabled =
true;
5293 else if (docStyleSheet.title)
5294 docStyleSheet.disabled = (docStyleSheet.title != title);
5295 else if (docStyleSheet.disabled)
5296 docStyleSheet.disabled =
false;
5304 for (let i = 0; i < frameset.frames.length; i++)
5318 if (!this._uiElement)
5319 this._uiElement = document.getElementById(
"goOfflineMenuitem");
5321 var
os = Components.classes[
"@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService);
5322 os.addObserver(
this,
"network:offline-status-changed",
false);
5324 var
ioService = Components.classes[
"@mozilla.org/network/io-service;1"].
5325 getService(Components.interfaces.nsIIOService2);
5331 if (!ioService.manageOfflineStatus) {
5333 var isOffline =
false;
5335 isOffline =
gPrefService.getBoolPref(
"browser.offline");
5338 ioService.offline = isOffline;
5341 this._updateOfflineUI(ioService.offline);
5347 var
os = Components.classes[
"@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService);
5348 os.removeObserver(
this,
"network:offline-status-changed");
5353 toggleOfflineStatus:
function ()
5355 var
ioService = Components.classes[
"@mozilla.org/network/io-service;1"].
5356 getService(Components.interfaces.nsIIOService2);
5360 ioService.manageOfflineStatus =
false;
5364 if (!ioService.offline && !
this._canGoOffline()) {
5365 this._updateOfflineUI(
false);
5369 ioService.offline = !ioService.offline;
5373 gPrefService.setBoolPref(
"browser.offline", ioService.offline);
5380 if (aTopic !=
"network:offline-status-changed")
5383 this._updateOfflineUI(
aState ==
"offline");
5388 _canGoOffline:
function ()
5390 var
os = Components.classes[
"@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService);
5393 var cancelGoOffline = Components.classes[
"@mozilla.org/supports-PRBool;1"].createInstance(Components.interfaces.nsISupportsPRBool);
5394 os.notifyObservers(cancelGoOffline,
"offline-requested",
null);
5397 if (cancelGoOffline.data)
5407 _updateOfflineUI:
function (aOffline)
5409 var offlineLocked =
gPrefService.prefIsLocked(
"network.online");
5411 this._uiElement.setAttribute(
"disabled",
"true");
5413 this._uiElement.setAttribute(
"checked", aOffline);
5422 var obs =
Cc[
"@mozilla.org/observer-service;1"].
5424 obs.addObserver(
this,
"dom-storage-warn-quota-exceeded",
false);
5425 obs.addObserver(
this,
"offline-cache-update-completed",
false);
5430 var obs =
Cc[
"@mozilla.org/observer-service;1"].
5432 obs.removeObserver(
this,
"dom-storage-warn-quota-exceeded");
5433 obs.removeObserver(
this,
"offline-cache-update-completed");
5436 handleEvent:
function(
event) {
5437 if (
event.type ==
"MozApplicationManifest") {
5438 this.offlineAppRequested(
event.originalTarget.defaultView);
5447 _getBrowserWindowForContentWindow:
function(aContentWindow) {
5448 return aContentWindow.QueryInterface(
Ci.nsIInterfaceRequestor)
5449 .getInterface(
Ci.nsIWebNavigation)
5450 .QueryInterface(
Ci.nsIDocShellTreeItem)
5452 .QueryInterface(
Ci.nsIInterfaceRequestor)
5453 .getInterface(
Ci.nsIDOMWindow)
5457 _getBrowserForContentWindow:
function(aBrowserWindow, aContentWindow) {
5459 aContentWindow = aContentWindow.top;
5460 var browsers = aBrowserWindow.getBrowser().browsers;
5461 for (var i = 0; i < browsers.length; ++
i) {
5462 if (browsers[i].contentWindow == aContentWindow)
5467 _getManifestURI:
function(aWindow) {
5468 if (!aWindow.document.documentElement)
return null;
5469 var attr = aWindow.document.documentElement.getAttribute(
"manifest");
5470 if (!attr)
return null;
5474 return makeURI(attr, aWindow.document.characterSet, contentURI);
5482 _getBrowserForCacheUpdate:
function(aCacheUpdate) {
5484 var uri = this._getManifestURI(gBrowser.mCurrentBrowser.contentWindow);
5485 if (uri && uri.equals(aCacheUpdate.manifestURI)) {
5486 return gBrowser.mCurrentBrowser;
5489 var browsers = gBrowser.browsers;
5490 for (var i = 0; i < browsers.length; ++
i) {
5491 uri = this._getManifestURI(browsers[i].contentWindow);
5492 if (uri && uri.equals(aCacheUpdate.manifestURI)) {
5500 _warnUsage:
function(
aBrowser, aURI) {
5504 var notificationBox = gBrowser.getNotificationBox(
aBrowser);
5505 var notification = notificationBox.getNotificationWithValue(
"offline-app-usage");
5506 if (!notification) {
5513 var warnQuota =
gPrefService.getIntPref(
"offline-apps.quota.warn");
5514 const priority = notificationBox.PRIORITY_WARNING_MEDIUM;
5517 warnQuota / 1024 ]);
5519 notificationBox.appendNotification(message,
"offline-app-usage",
5520 "chrome://browser/skin/Info.png",
5526 var pm =
Cc[
"@mozilla.org/permissionmanager;1"].
5528 pm.add(aURI,
"offline-app",
5529 Ci.nsIOfflineCacheUpdateService.ALLOW_NO_WARN);
5533 _getOfflineAppUsage:
function (host, groups)
5535 var
cacheService = Components.classes[
"@mozilla.org/network/application-cache-service;1"].
5536 getService(Components.interfaces.nsIApplicationCacheService);
5538 groups = cacheService.getGroups({});
5540 var
ios = Components.classes[
"@mozilla.org/network/io-service;1"].
5541 getService(Components.interfaces.nsIIOService);
5544 for (var i = 0; i < groups.length; i++) {
5545 var uri = ios.newURI(groups[i],
null,
null);
5546 if (uri.asciiHost == host) {
5547 var cache = cacheService.getActiveCache(groups[i]);
5548 usage += cache.usage;
5552 var storageManager = Components.classes[
"@mozilla.org/dom/storagemanager;1"].
5553 getService(Components.interfaces.nsIDOMStorageManager);
5554 usage += storageManager.getUsage(host);
5559 _checkUsage:
function(aURI) {
5560 var pm =
Cc[
"@mozilla.org/permissionmanager;1"].
5564 if (pm.testExactPermission(aURI,
"offline-app") !=
5565 Ci.nsIOfflineCacheUpdateService.ALLOW_NO_WARN) {
5566 var usage = this._getOfflineAppUsage(aURI.asciiHost);
5567 var warnQuota =
gPrefService.getIntPref(
"offline-apps.quota.warn");
5568 if (usage >= warnQuota * 1024) {
5576 offlineAppRequested:
function(aContentWindow) {
5577 if (!
gPrefService.getBoolPref(
"browser.offline-apps.notify")) {
5581 var browserWindow = this._getBrowserWindowForContentWindow(aContentWindow);
5582 var browser = this._getBrowserForContentWindow(browserWindow,
5585 var currentURI = aContentWindow.document.documentURIObject;
5586 var pm =
Cc[
"@mozilla.org/permissionmanager;1"].
5590 if (pm.testExactPermission(currentURI,
"offline-app") !=
5591 Ci.nsIPermissionManager.UNKNOWN_ACTION)
5595 if (
gPrefService.getBoolPref(
"offline-apps.allow_by_default")) {
5603 var host = currentURI.asciiHost;
5604 var notificationBox = gBrowser.getNotificationBox(browser);
5605 var notificationID =
"offline-app-requested-" + host;
5606 var notification = notificationBox.getNotificationWithValue(notificationID);
5609 notification.documents.push(aContentWindow.document);
5615 for (var i = 0; i < notification.documents.length; i++) {
5616 OfflineApps.allowSite(notification.documents[i]);
5623 for (var i = 0; i < notification.documents.length; i++) {
5624 OfflineApps.disallowSite(notification.documents[i]);
5633 const priority = notificationBox.PRIORITY_INFO_LOW;
5637 notificationBox.appendNotification(message, notificationID,
5638 "chrome://browser/skin/Info.png",
5640 notification.documents = [ aContentWindow.document ];
5645 var pm =
Cc[
"@mozilla.org/permissionmanager;1"].
5647 pm.add(
aDocument.documentURIObject,
"offline-app",
5648 Ci.nsIPermissionManager.ALLOW_ACTION);
5657 var pm =
Cc[
"@mozilla.org/permissionmanager;1"].
5659 pm.add(
aDocument.documentURIObject,
"offline-app",
5660 Ci.nsIPermissionManager.DENY_ACTION);
5663 manage:
function() {
5671 var manifest =
aDocument.documentElement.getAttribute(
"manifest");
5678 var updateService =
Cc[
"@mozilla.org/offlinecacheupdate-service;1"].
5680 updateService.scheduleUpdate(manifestURI,
aDocument.documentURIObject);
5687 if (aTopic ==
"dom-storage-warn-quota-exceeded") {
5689 var uri =
makeURI(aSubject.location.href);
5691 if (OfflineApps._checkUsage(uri)) {
5693 this._getBrowserWindowForContentWindow(aSubject);
5694 var browser = this._getBrowserForContentWindow(browserWindow,
5696 OfflineApps._warnUsage(browser, uri);
5699 }
else if (aTopic ==
"offline-cache-update-completed") {
5700 var cacheUpdate = aSubject.QueryInterface(
Ci.nsIOfflineCacheUpdate);
5702 var uri = cacheUpdate.manifestURI;
5703 if (OfflineApps._checkUsage(uri)) {
5704 var browser = this._getBrowserForCacheUpdate(cacheUpdate);
5706 OfflineApps._warnUsage(browser, cacheUpdate.manifestURI);
5719 var numBrowsers = gBrowser.browsers.length;
5720 for (let i = 0; reallyClose && i < numBrowsers; ++
i) {
5721 let ds = gBrowser.browsers[
i].docShell;
5723 if (ds.contentViewer && !ds.contentViewer.permitUnload())
5724 reallyClose =
false;
5737 if (!toolbar.visible)
5738 return gBrowser.warnAboutClosingTabs(
true);
5741 let foundOtherBrowserWindow =
false;
5742 let
wm =
Cc[
"@mozilla.org/appshell/window-mediator;1"].getService(
Ci.nsIWindowMediator);
5743 let e = wm.getEnumerator(
"navigator:browser");
5744 while (e.hasMoreElements() && !foundOtherBrowserWindow) {
5745 let win = e.getNext();
5746 if (win !=
window && win.toolbar.visible)
5747 foundOtherBrowserWindow =
true;
5749 if (foundOtherBrowserWindow)
5750 return gBrowser.warnAboutClosingTabs(
true);
5752 let
os =
Cc[
"@mozilla.org/observer-service;1"].getService(
Ci.nsIObserverService);
5754 let closingCanceled =
Cc[
"@mozilla.org/supports-PRBool;1"].
5756 os.notifyObservers(closingCanceled,
5757 "browser-lastwindow-close-requested",
null);
5758 if (closingCanceled.data)
5761 os.notifyObservers(
null,
"browser-lastwindow-close-granted",
null);
5767 return gBrowser.warnAboutClosingTabs(
true);
5774 sendLinkForWindow:
function (aWindow) {
5775 this.sendMessage(aWindow.location.href,
5776 aWindow.document.title);
5779 sendMessage:
function (aBody, aSubject) {
5781 var mailtoUrl =
"mailto:";
5790 this._launchExternalUrl(uri);
5796 _launchExternalUrl:
function (aURL) {
5797 var extProtocolSvc =
5798 Components.classes[
"@mozilla.org/uriloader/external-protocol-service;1"]
5799 .getService(Components.interfaces.nsIExternalProtocolService);
5801 extProtocolSvc.loadUrl(aURL);
5807 const EMTYPE =
"Extension:Manager";
5808 var
wm = Components.classes[
"@mozilla.org/appshell/window-mediator;1"]
5809 .getService(Components.interfaces.nsIWindowMediator);
5810 var theEM = wm.getMostRecentWindow(EMTYPE);
5814 theEM.showView(aPane);
5818 const EMURL =
"chrome://mozapps/content/extensions/extensions.xul";
5819 const EMFEATURES =
"chrome,menubar,extra-chrome,toolbar,dialog=no,resizable";
5821 window.openDialog(EMURL,
"", EMFEATURES, aPane);
5823 window.openDialog(EMURL,
"", EMFEATURES);
5828 if (aIsFormUrlEncoded)
5836 var
node = document.popupNode;
5838 var
charset = node.ownerDocument.characterSet;
5840 var docURI =
makeURI(node.ownerDocument.URL,
5843 var formURI =
makeURI(node.form.getAttribute(
"action"),
5847 var spec = formURI.spec;
5850 (node.form.method.toUpperCase() ==
"POST"
5851 && (node.form.enctype ==
"application/x-www-form-urlencoded" ||
5852 node.form.enctype ==
""));
5855 [node.ownerDocument.title]);
5856 var description =
PlacesUIUtils.getDescriptionFromDocument(node.ownerDocument);
5861 for (var i=0; i < node.form.elements.length; i++) {
5862 el = node.form.elements[
i];
5874 type = el.type.toLowerCase();
5876 if ((type ==
"text" || type ==
"hidden" || type ==
"textarea") ||
5877 ((type ==
"checkbox" || type ==
"radio") && el.checked)) {
5879 }
else if (el instanceof HTMLSelectElement && el.selectedIndex >= 0) {
5880 for (var j=0; j < el.options.length; j++) {
5881 if (el.options[j].selected)
5891 postData = formData.join(
"&");
5893 spec +=
"?" + formData.join(
"&");
5896 null,
null,
"", postData, charset);
5900 aWindow.document.dir = (aWindow.document.dir ==
"ltr" ?
"rtl" :
"ltr");
5901 for (var run = 0; run < aWindow.frames.length; run++)
5909 if (pluginElement instanceof HTMLAppletElement) {
5910 tagMimetype =
"application/x-java-vm";
5912 if (pluginElement instanceof HTMLObjectElement) {
5913 pluginsPage = pluginElement.getAttribute(
"codebase");
5915 pluginsPage = pluginElement.getAttribute(
"pluginspage");
5920 var doc = pluginElement.ownerDocument;
5923 pluginsPage =
makeURI(pluginsPage, doc.characterSet, docShell.currentURI).spec;
5929 tagMimetype = pluginElement.QueryInterface(Components.interfaces.nsIObjectLoadingContent)
5932 if (tagMimetype ==
"") {
5933 tagMimetype = pluginElement.type;
5937 return {mimetype: tagMimetype, pluginsPage: pluginsPage};
5944 var missingPluginsArray = {};
5947 missingPluginsArray[pluginInfo.mimetype] = pluginInfo;
5949 if (missingPluginsArray) {
5950 window.openDialog(
"chrome://mozapps/content/plugins/pluginInstallerWizard.xul",
5951 "PFSWindow",
"chrome,centerscreen,resizable=yes",
5952 {plugins: missingPluginsArray, browser: gBrowser.selectedBrowser});
5955 aEvent.stopPropagation();
5960 aEvent.stopPropagation();
5966 if (!(aEvent.target instanceof Components.interfaces.nsIObjectLoadingContent))
5974 if (aEvent.type !=
"PluginBlocklisted" &&
5975 aEvent.type !=
"PluginOutdated" &&
5976 !(aEvent.target instanceof HTMLObjectElement)) {
5977 aEvent.target.addEventListener(
"click",
5978 gMissingPluginInstaller.installSinglePlugin,
5982 let hideBarPrefName = aEvent.type ==
"PluginOutdated" ?
5983 "plugins.hide_infobar_for_outdated_plugin" :
5984 "plugins.hide_infobar_for_missing_plugin";
5990 var browser = gBrowser.getBrowserForDocument(aEvent.target.ownerDocument
5991 .defaultView.top.document);
5992 if (!browser.missingPlugins)
5993 browser.missingPlugins = {};
5997 browser.missingPlugins[pluginInfo.mimetype] = pluginInfo;
5999 var notificationBox = gBrowser.getNotificationBox(browser);
6005 if (notificationBox.getNotificationWithValue(
"outdated-plugins"))
6007 var blockedNotification = notificationBox.getNotificationWithValue(
"blocked-plugins");
6008 var missingNotification = notificationBox.getNotificationWithValue(
"missing-plugins");
6009 var priority = notificationBox.PRIORITY_WARNING_MEDIUM;
6011 function showBlocklistInfo() {
6012 var formatter =
Cc[
"@mozilla.org/toolkit/URLFormatterService;1"].
6014 var url = formatter.formatURLPref(
"extensions.blocklist.detailsURL");
6015 gBrowser.loadOneTab(url, {inBackground:
false});
6019 function showOutdatedPluginsInfo() {
6020 gPrefService.setBoolPref(
"plugins.update.notifyUser",
false);
6021 var formatter =
Cc[
"@mozilla.org/toolkit/URLFormatterService;1"].
6023 var url = formatter.formatURLPref(
"plugins.update.url");
6024 gBrowser.loadOneTab(url, {inBackground:
false});
6028 function showPluginsMissing() {
6030 var missingPluginsArray = gBrowser.selectedBrowser.missingPlugins;
6031 if (missingPluginsArray) {
6032 window.openDialog(
"chrome://mozapps/content/plugins/pluginInstallerWizard.xul",
6033 "PFSWindow",
"chrome,centerscreen,resizable=yes",
6034 {plugins: missingPluginsArray, browser: gBrowser.selectedBrowser});
6038 if (aEvent.type ==
"PluginBlocklisted") {
6039 if (blockedNotification || missingNotification)
6042 let iconURL =
"chrome://mozapps/skin/plugins/pluginBlocked-16.png";
6043 let messageString =
gNavigatorBundle.getString(
"blockedpluginsMessage.title");
6045 label:
gNavigatorBundle.getString(
"blockedpluginsMessage.infoButton.label"),
6046 accessKey:
gNavigatorBundle.getString(
"blockedpluginsMessage.infoButton.accesskey"),
6050 label:
gNavigatorBundle.getString(
"blockedpluginsMessage.searchButton.label"),
6051 accessKey:
gNavigatorBundle.getString(
"blockedpluginsMessage.searchButton.accesskey"),
6056 notificationBox.appendNotification(messageString,
"blocked-plugins",
6057 iconURL, priority, buttons);
6059 else if (aEvent.type ==
"PluginOutdated") {
6061 if (blockedNotification)
6062 blockedNotification.close();
6063 if (missingNotification)
6064 missingNotification.close();
6066 let iconURL =
"chrome://mozapps/skin/plugins/pluginOutdated-16.png";
6067 let messageString =
gNavigatorBundle.getString(
"outdatedpluginsMessage.title");
6069 label:
gNavigatorBundle.getString(
"outdatedpluginsMessage.updateButton.label"),
6070 accessKey:
gNavigatorBundle.getString(
"outdatedpluginsMessage.updateButton.accesskey"),
6075 notificationBox.appendNotification(messageString,
"outdated-plugins",
6076 iconURL, priority, buttons);
6078 else if (aEvent.type ==
"PluginNotFound") {
6079 if (missingNotification)
6083 if (blockedNotification)
6084 blockedNotification.close();
6086 let iconURL =
"chrome://mozapps/skin/plugins/pluginGeneric-16.png";
6087 let messageString =
gNavigatorBundle.getString(
"missingpluginsMessage.title");
6090 accessKey:
gNavigatorBundle.getString(
"missingpluginsMessage.button.accesskey"),
6095 notificationBox.appendNotification(messageString,
"missing-plugins",
6096 iconURL, priority, buttons);
6103 if (!(aEvent.target instanceof Components.interfaces.nsIObjectLoadingContent))
6106 aEvent.target.addEventListener(
"click",
6107 gMissingPluginInstaller.managePlugins,
6113 var browser = aEvent.originalTarget;
6114 var notificationBox = gBrowser.getNotificationBox(browser);
6115 var notification = notificationBox.getNotificationWithValue(
"missing-plugins");
6118 browser.missingPlugins =
null;
6121 notificationBox.removeNotification(notification);
6132 var unicodeConverter = Components
6133 .classes[
"@mozilla.org/intl/scriptableunicodeconverter"]
6134 .createInstance(Components.interfaces.nsIScriptableUnicodeConverter);
6135 unicodeConverter.charset =
charset;
6136 str = unicodeConverter.ConvertFromUnicode(str);
6137 return str + unicodeConverter.Finish();
6154 onFeedButtonClick:
function(
event) {
6155 event.stopPropagation();
6157 if (
event.target.hasAttribute(
"feed") &&
6158 event.eventPhase ==
Event.AT_TARGET &&
6159 (
event.button == 0 ||
event.button == 1)) {
6174 buildFeedList:
function(menuPopup) {
6175 var feeds = gBrowser.selectedBrowser.feeds;
6176 if (feeds ==
null) {
6183 menuPopup.parentNode.removeAttribute(
"open");
6187 while (menuPopup.firstChild)
6188 menuPopup.removeChild(menuPopup.firstChild);
6190 if (feeds.length == 1) {
6191 var feedButton = document.getElementById(
"feed-button");
6193 feedButton.setAttribute(
"feed", feeds[0].
href);
6198 for (var i = 0; i < feeds.length; ++
i) {
6199 var feedInfo = feeds[
i];
6200 var menuItem = document.createElement(
"menuitem");
6201 var baseTitle = feedInfo.title || feedInfo.href;
6202 var labelStr =
gNavigatorBundle.getFormattedString(
"feedShowFeedNew", [baseTitle]);
6203 menuItem.setAttribute(
"class",
"feed-menuitem");
6204 menuItem.setAttribute(
"label", labelStr);
6205 menuItem.setAttribute(
"feed", feedInfo.href);
6206 menuItem.setAttribute(
"tooltiptext", feedInfo.href);
6207 menuItem.setAttribute(
"crop",
"center");
6208 menuPopup.appendChild(menuItem);
6226 subscribeToFeed:
function(
href,
event) {
6230 href =
event.target.getAttribute(
"feed");
6231 urlSecurityCheck(
href, gBrowser.contentPrincipal,
6232 Ci.nsIScriptSecurityManager.DISALLOW_INHERIT_PRINCIPAL);
6233 var feedURI =
makeURI(
href, document.characterSet);
6236 if (/^https?/.
test(feedURI.scheme))
6242 var feeds = gBrowser.selectedBrowser.feeds;
6249 gBrowser.selectedBrowser.feeds = feeds;
6257 updateFeeds:
function() {
6258 var feedButton = document.getElementById(
"feed-button");
6259 if (!this._feedMenuitem)
6260 this._feedMenuitem = document.getElementById(
"subscribeToPageMenuitem");
6261 if (!this._feedMenupopup)
6262 this._feedMenupopup = document.getElementById(
"subscribeToPageMenupopup");
6264 var feeds = gBrowser.mCurrentBrowser.feeds;
6265 if (!feeds || feeds.length == 0) {
6267 feedButton.collapsed =
true;
6268 feedButton.removeAttribute(
"feed");
6270 this._feedMenuitem.setAttribute(
"disabled",
"true");
6271 this._feedMenupopup.setAttribute(
"hidden",
"true");
6272 this._feedMenuitem.removeAttribute(
"hidden");
6275 feedButton.collapsed =
false;
6277 if (feeds.length > 1) {
6278 this._feedMenuitem.setAttribute(
"hidden",
"true");
6279 this._feedMenupopup.removeAttribute(
"hidden");
6281 feedButton.removeAttribute(
"feed");
6284 feedButton.setAttribute(
"feed", feeds[0].
href);
6286 this._feedMenuitem.setAttribute(
"feed", feeds[0].href);
6287 this._feedMenuitem.removeAttribute(
"disabled");
6288 this._feedMenuitem.removeAttribute(
"hidden");
6289 this._feedMenupopup.setAttribute(
"hidden",
"true");
6294 addFeed:
function(link, targetDoc) {
6296 var browserForLink = gBrowser.getBrowserForDocument(targetDoc);
6297 if (!browserForLink) {
6302 if (!browserForLink.feeds)
6303 browserForLink.feeds = [];
6305 browserForLink.feeds.push({
href: link.href, title: link.title });
6307 if (browserForLink == gBrowser.mCurrentBrowser) {
6308 var feedButton = document.getElementById(
"feed-button");
6310 feedButton.collapsed =
false;
6315 #include browser-places.js
6317 #include browser-textZoom.js
6319 #include browser-tabPreviews.js
6321 XPCOMUtils.defineLazyGetter(
this,
"Win7Features",
function () {
6328 Cu.import(
"resource://gre/modules/WindowsPreviewPerTab.jsm", temp);
6329 let AeroPeek = temp.AeroPeek;
6331 onOpenWindow:
function () {
6332 AeroPeek.onOpenWindow(
window);
6334 onCloseWindow:
function () {
6335 AeroPeek.onCloseWindow(
window);
6352 var blankTabToRemove =
null;
6353 if (gBrowser.tabContainer.childNodes.length == 1 &&
6355 gBrowser.selectedBrowser.sessionHistory.count < 2 &&
6356 gBrowser.selectedBrowser.currentURI.spec ==
"about:blank" &&
6357 !gBrowser.selectedBrowser.contentDocument.body.hasChildNodes() &&
6358 !gBrowser.selectedTab.hasAttribute(
"busy"))
6359 blankTabToRemove = gBrowser.selectedTab;
6362 var ss =
Cc[
"@mozilla.org/browser/sessionstore;1"].
6364 if (ss.getClosedTabCount(
window) > (aIndex || 0)) {
6365 tab = ss.undoCloseTab(
window, aIndex || 0);
6367 if (blankTabToRemove)
6368 gBrowser.removeTab(blankTabToRemove);
6381 let ss =
Cc[
"@mozilla.org/browser/sessionstore;1"].
6384 if (ss.getClosedWindowCount() > (aIndex || 0))
6385 window = ss.undoCloseWindow(aIndex || 0);
6399 var formatter =
Cc[
"@mozilla.org/toolkit/URLFormatterService;1"].getService(
Ci.nsIURLFormatter);
6400 return aIsPref ? formatter.formatURLPref(aFormat) : formatter.formatURL(aFormat);
6408 this._command = document.getElementById(
"Browser:BookmarkAllTabs");
6409 gBrowser.addEventListener(
"TabOpen",
this,
true);
6410 gBrowser.addEventListener(
"TabClose",
this,
true);
6411 this._updateCommandState();
6416 if (aIID.equals(
Ci.nsIDOMEventListener) ||
6417 aIID.equals(
Ci.nsISupports))
6420 throw Cr.NS_NOINTERFACE;
6423 _updateCommandState:
function BATH__updateCommandState(aTabClose) {
6424 var numTabs = gBrowser.tabContainer.childNodes.length;
6431 this._command.removeAttribute(
"disabled");
6433 this._command.setAttribute(
"disabled",
"true");
6436 doCommand:
function BATH_doCommand() {
6437 PlacesCommandHook.bookmarkCurrentPages();
6441 handleEvent:
function(aEvent) {
6442 this._updateCommandState(aEvent.type ==
"TabClose");
6451 IDENTITY_MODE_IDENTIFIED :
"verifiedIdentity",
6452 IDENTITY_MODE_DOMAIN_VERIFIED :
"verifiedDomain",
6453 IDENTITY_MODE_UNKNOWN :
"unknownIdentity",
6454 IDENTITY_MODE_MIXED_CONTENT :
"unknownIdentity mixedContent",
6458 _lastLocation :
null,
6461 get _encryptionLabel () {
6462 delete this._encryptionLabel;
6463 this._encryptionLabel = {};
6464 this._encryptionLabel[this.IDENTITY_MODE_DOMAIN_VERIFIED] =
6466 this._encryptionLabel[this.IDENTITY_MODE_IDENTIFIED] =
6468 this._encryptionLabel[this.IDENTITY_MODE_UNKNOWN] =
6470 this._encryptionLabel[this.IDENTITY_MODE_MIXED_CONTENT] =
6472 return this._encryptionLabel;
6474 get _identityPopup () {
6475 delete this._identityPopup;
6476 return this._identityPopup = document.getElementById(
"identity-popup");
6478 get _identityBox () {
6479 delete this._identityBox;
6480 return this._identityBox = document.getElementById(
"identity-box");
6482 get _identityPopupContentBox () {
6483 delete this._identityPopupContentBox;
6484 return this._identityPopupContentBox =
6485 document.getElementById(
"identity-popup-content-box");
6487 get _identityPopupContentHost () {
6488 delete this._identityPopupContentHost;
6489 return this._identityPopupContentHost =
6490 document.getElementById(
"identity-popup-content-host");
6492 get _identityPopupContentOwner () {
6493 delete this._identityPopupContentOwner;
6494 return this._identityPopupContentOwner =
6495 document.getElementById(
"identity-popup-content-owner");
6497 get _identityPopupContentSupp () {
6498 delete this._identityPopupContentSupp;
6499 return this._identityPopupContentSupp =
6500 document.getElementById(
"identity-popup-content-supplemental");
6502 get _identityPopupContentVerif () {
6503 delete this._identityPopupContentVerif;
6504 return this._identityPopupContentVerif =
6505 document.getElementById(
"identity-popup-content-verifier");
6507 get _identityPopupEncLabel () {
6508 delete this._identityPopupEncLabel;
6509 return this._identityPopupEncLabel =
6510 document.getElementById(
"identity-popup-encryption-label");
6512 get _identityIconLabel () {
6513 delete this._identityIconLabel;
6514 return this._identityIconLabel = document.getElementById(
"identity-icon-label");
6516 get _overrideService () {
6517 delete this._overrideService;
6518 return this._overrideService =
Cc[
"@mozilla.org/security/certoverride;1"]
6519 .getService(
Ci.nsICertOverrideService);
6526 _cacheElements :
function() {
6527 delete this._identityBox;
6528 delete this._identityIconLabel;
6529 this._identityBox = document.getElementById(
"identity-box");
6530 this._identityIconLabel = document.getElementById(
"identity-icon-label");
6537 handleMoreInfoClick :
function(
event) {
6538 displaySecurityInfo();
6539 event.stopPropagation();
6546 getIdentityData :
function() {
6548 var status = this._lastStatus.QueryInterface(Components.interfaces.nsISSLStatus);
6549 var cert = status.serverCert;
6552 result.subjectOrg = cert.organization;
6555 if (cert.subjectName) {
6556 result.subjectNameFields = {};
6557 cert.subjectName.split(
",").forEach(
function(v) {
6558 var field = v.split(
"=");
6559 this[field[0]] = field[1];
6560 }, result.subjectNameFields);
6563 result.city = result.subjectNameFields.L;
6564 result.state = result.subjectNameFields.ST;
6565 result.country = result.subjectNameFields.C;
6569 result.caOrg = cert.issuerOrganization || cert.issuerCommonName;
6584 checkIdentity :
function(state, location) {
6585 var currentStatus = gBrowser.securityUI
6586 .QueryInterface(Components.interfaces.nsISSLStatusProvider)
6588 this._lastStatus = currentStatus;
6589 this._lastLocation = location;
6591 let nsIWebProgressListener =
Ci.nsIWebProgressListener;
6592 if (state & nsIWebProgressListener.STATE_IDENTITY_EV_TOPLEVEL)
6593 this.setMode(this.IDENTITY_MODE_IDENTIFIED);
6594 else if (state & nsIWebProgressListener.STATE_SECURE_HIGH)
6595 this.setMode(this.IDENTITY_MODE_DOMAIN_VERIFIED);
6596 else if (state & nsIWebProgressListener.STATE_IS_BROKEN)
6597 this.setMode(this.IDENTITY_MODE_MIXED_CONTENT);
6599 this.setMode(this.IDENTITY_MODE_UNKNOWN);
6605 getEffectiveHost :
function() {
6607 if (!this._eTLDService)
6608 this._eTLDService =
Cc[
"@mozilla.org/network/effective-tld-service;1"]
6609 .getService(
Ci.nsIEffectiveTLDService);
6611 return this._eTLDService.getBaseDomainFromHost(this._lastLocation.hostname);
6615 return this._lastLocation.hostname;
6623 setMode :
function(newMode) {
6624 if (!this._identityBox) {
6630 this._identityBox.className = newMode;
6631 this.setIdentityMessages(newMode);
6634 if (this._identityPopup.state ==
"open")
6635 this.setPopupMessages(newMode);
6644 setIdentityMessages :
function(newMode) {
6645 if (newMode == this.IDENTITY_MODE_DOMAIN_VERIFIED) {
6646 var iData = this.getIdentityData();
6654 var icon_label =
"";
6655 switch (
gPrefService.getIntPref(
"browser.identity.ssl_domain_display")) {
6657 icon_label = this._lastLocation.hostname;
6660 icon_label = this.getEffectiveHost();
6665 var lookupHost = this._lastLocation.host;
6666 if (lookupHost.indexOf(
':') < 0)
6667 lookupHost +=
":443";
6671 var tooltip =
gNavigatorBundle.getFormattedString(
"identity.identified.verifier",
6678 if (this._overrideService.hasMatchingOverride(
this._lastLocation.hostname,
6679 (
this._lastLocation.port || 443),
6680 iData.cert, {}, {}))
6681 tooltip =
gNavigatorBundle.getString(
"identity.identified.verified_by_you");
6683 else if (newMode == this.IDENTITY_MODE_IDENTIFIED) {
6685 iData = this.getIdentityData();
6686 tooltip =
gNavigatorBundle.getFormattedString(
"identity.identified.verifier",
6689 icon_label =
gNavigatorBundle.getFormattedString(
"identity.identified.title_with_country",
6690 [iData.subjectOrg, iData.country]);
6692 icon_label = iData.subjectOrg;
6700 this._identityBox.tooltipText = tooltip;
6701 this._identityIconLabel.value = icon_label;
6711 setPopupMessages :
function(newMode) {
6713 this._identityPopup.className = newMode;
6714 this._identityPopupContentBox.className = newMode;
6717 this._identityPopupEncLabel.textContent = this._encryptionLabel[newMode];
6720 var supplemental =
"";
6723 if (newMode == this.IDENTITY_MODE_DOMAIN_VERIFIED) {
6724 var iData = this.getIdentityData();
6725 var host = this.getEffectiveHost();
6727 verifier = this._identityBox.tooltipText;
6730 else if (newMode == this.IDENTITY_MODE_IDENTIFIED) {
6732 iData = this.getIdentityData();
6733 host = this.getEffectiveHost();
6734 owner = iData.subjectOrg;
6735 verifier = this._identityBox.tooltipText;
6739 supplemental += iData.city +
"\n";
6740 if (iData.state && iData.country)
6741 supplemental +=
gNavigatorBundle.getFormattedString(
"identity.identified.state_and_country",
6742 [iData.state, iData.country]);
6743 else if (iData.state)
6744 supplemental += iData.state;
6745 else if (iData.country)
6746 supplemental += iData.country;
6755 this._identityPopupContentHost.textContent = host;
6756 this._identityPopupContentOwner.textContent =
owner;
6757 this._identityPopupContentSupp.textContent = supplemental;
6758 this._identityPopupContentVerif.textContent = verifier;
6761 hideIdentityPopup :
function() {
6762 this._identityPopup.hidePopup();
6768 handleIdentityButtonEvent :
function(
event) {
6770 event.stopPropagation();
6772 if ((
event.type ==
"click" &&
event.button != 0) ||
6773 (
event.type ==
"keypress" &&
event.charCode != KeyEvent.DOM_VK_SPACE &&
6774 event.keyCode != KeyEvent.DOM_VK_RETURN))
6778 gURLBar.handleRevert();
6782 this._identityPopup.hidden =
false;
6785 this._identityPopup.popupBoxObject
6786 .setConsumeRollupEvent(
Ci.nsIPopupBoxObject.ROLLUP_CONSUME);
6789 this.setPopupMessages(this._identityBox.className);
6793 var
position = (getComputedStyle(gNavToolbox,
"").direction ==
"rtl") ?
'after_end' :
'after_start';
6796 this._identityBox.setAttribute(
"open",
"true");
6798 this._identityPopup.addEventListener(
"popuphidden",
function (e) {
6799 e.currentTarget.removeEventListener(
"popuphidden",
arguments.callee,
false);
6800 self._identityBox.removeAttribute(
"open");
6804 this._identityPopup.openPopup(this._identityBox, position);
6815 _lastTime: Infinity,
6818 get DownloadUtils() {
6819 delete this.DownloadUtils;
6820 Cu.import(
"resource://gre/modules/DownloadUtils.jsm",
this);
6821 return this.DownloadUtils;
6830 init:
function DMP_init() {
6832 this._panel = document.getElementById(
"download-monitor");
6838 gDownloadMgr.addListener(
this);
6839 this._listening =
true;
6841 this.updateStatus();
6844 uninit:
function DMP_uninit() {
6845 if (this._listening)
6846 gDownloadMgr.removeListener(
this);
6849 inited:
function DMP_inited() {
6850 return this._panel !=
null;
6856 updateStatus:
function DMP_updateStatus() {
6860 let numActive = gDownloadMgr.activeDownloadCount;
6863 if (numActive == 0) {
6864 this._panel.hidden =
true;
6865 this._lastTime = Infinity;
6872 let maxTime = -Infinity;
6873 let dls = gDownloadMgr.activeDownloads;
6874 while (dls.hasMoreElements()) {
6875 let dl = dls.getNext().QueryInterface(
Ci.nsIDownload);
6876 if (dl.state == gDownloadMgr.DOWNLOAD_DOWNLOADING) {
6878 if (dl.speed > 0 && dl.size > 0)
6879 maxTime = Math.max(maxTime, (dl.size - dl.amountTransferred) / dl.speed);
6883 else if (dl.state == gDownloadMgr.DOWNLOAD_PAUSED)
6889 [timeLeft, this._lastTime] =
6890 this.DownloadUtils.getTimeLeft(maxTime, this._lastTime);
6893 let numDls = numActive - numPaused;
6894 let status = this._activeStr;
6899 status = this._pausedStr;
6904 status = PluralForm.get(numDls, status);
6905 status = status.replace(
"#1", numDls);
6906 status = status.replace(
"#2", timeLeft);
6909 this._panel.label = status;
6910 this._panel.hidden =
false;
6919 onProgressChange:
function() {
6920 this.updateStatus();
6926 onDownloadStateChange:
function() {
6927 this.updateStatus();
6930 onStateChange:
function(aWebProgress, aRequest, aStateFlags, aStatus, aDownload) {
6933 onSecurityChange:
function(aWebProgress, aRequest,
aState, aDownload) {
6943 var foundBrowser = gBrowser.getBrowserForDocument(aWindow.document);
6945 return gBrowser.getNotificationBox(foundBrowser)
6954 _observerService:
null,
6955 _privateBrowsingService:
null,
6956 _searchBarValue:
null,
6957 _findBarValue:
null,
6959 init:
function PBUI_init() {
6960 this._observerService =
Cc[
"@mozilla.org/observer-service;1"].
6962 this._observerService.addObserver(
this,
"private-browsing",
false);
6963 this._observerService.addObserver(
this,
"private-browsing-transition-complete",
false);
6965 this._privateBrowsingService =
Cc[
"@mozilla.org/privatebrowsing;1"].
6968 if (this.privateBrowsingEnabled)
6969 this.onEnterPrivateBrowsing(
true);
6972 uninit:
function PBUI_unint() {
6973 this._observerService.removeObserver(
this,
"private-browsing");
6974 this._observerService.removeObserver(
this,
"private-browsing-transition-complete");
6977 get _disableUIOnToggle PBUI__disableUIOnTogle() {
6978 if (this._privateBrowsingService.autoStarted)
6982 return !
gPrefService.getBoolPref(
"browser.privatebrowsing.keep_current_session");
6989 observe:
function PBUI_observe(aSubject, aTopic,
aData) {
6990 if (aTopic ==
"private-browsing") {
6991 if (
aData ==
"enter")
6992 this.onEnterPrivateBrowsing();
6993 else if (
aData ==
"exit")
6994 this.onExitPrivateBrowsing();
6996 else if (aTopic ==
"private-browsing-transition-complete") {
6997 if (this._disableUIOnToggle) {
7000 document.getElementById(
"Tools:PrivateBrowsing")
7001 .removeAttribute(
"disabled");
7007 _shouldEnter:
function PBUI__shouldEnter() {
7011 if (
gPrefService.getBoolPref(
"browser.privatebrowsing.dont_prompt_on_enter") ||
7012 gPrefService.getBoolPref(
"browser.privatebrowsing.keep_current_session"))
7017 var bundleService =
Cc[
"@mozilla.org/intl/stringbundle;1"].
7019 var pbBundle = bundleService.createBundle(
"chrome://browser/locale/browser.properties");
7020 var brandBundle = bundleService.createBundle(
"chrome://branding/locale/brand.properties");
7022 var appName = brandBundle.GetStringFromName(
"brandShortName");
7023 # On Mac, use the header as the title.
7025 var dialogTitle = pbBundle.GetStringFromName(
"privateBrowsingMessageHeader");
7028 var dialogTitle = pbBundle.GetStringFromName(
"privateBrowsingDialogTitle");
7029 var header = pbBundle.GetStringFromName(
"privateBrowsingMessageHeader") +
"\n\n";
7031 var message = pbBundle.formatStringFromName(
"privateBrowsingMessage", [appName], 1);
7033 var promptService =
Cc[
"@mozilla.org/embedcomp/prompt-service;1"].
7036 var
flags = promptService.BUTTON_TITLE_IS_STRING * promptService.BUTTON_POS_0 +
7037 promptService.BUTTON_TITLE_IS_STRING * promptService.BUTTON_POS_1 +
7038 promptService.BUTTON_POS_0_DEFAULT;
7040 var neverAsk = {value:
false};
7041 var button0Title = pbBundle.GetStringFromName(
"privateBrowsingYesTitle");
7042 var button1Title = pbBundle.GetStringFromName(
"privateBrowsingNoTitle");
7043 var neverAskText = pbBundle.GetStringFromName(
"privateBrowsingNeverAsk");
7046 var choice = promptService.confirmEx(
null, dialogTitle, header + message,
7047 flags, button0Title, button1Title,
null,
7048 neverAskText, neverAsk);
7054 gPrefService.setBoolPref(
"browser.privatebrowsing.dont_prompt_on_enter",
true);
7064 onEnterPrivateBrowsing:
function PBUI_onEnterPrivateBrowsing(aOnWindowOpen) {
7065 if (BrowserSearch.searchBar)
7066 this._searchBarValue = BrowserSearch.searchBar.textbox.value;
7069 this._findBarValue = gFindBar.getElement(
"findbar-textbox").value;
7071 this._setPBMenuTitle(
"stop");
7073 document.getElementById(
"menu_import").setAttribute(
"disabled",
"true");
7077 document.getElementById(
"Tools:Sanitize").setAttribute(
"disabled",
"true");
7079 if (this._privateBrowsingService.autoStarted) {
7081 document.getElementById(
"privateBrowsingItem")
7082 .setAttribute(
"disabled",
"true");
7083 document.getElementById(
"Tools:PrivateBrowsing")
7084 .setAttribute(
"disabled",
"true");
7088 let docElement = document.documentElement;
7089 docElement.setAttribute(
"title",
7090 docElement.getAttribute(
"title_privatebrowsing"));
7091 docElement.setAttribute(
"titlemodifier",
7092 docElement.getAttribute(
"titlemodifier_privatebrowsing"));
7093 docElement.setAttribute(
"browsingmode",
"private");
7094 gBrowser.updateTitlebar();
7098 DownloadMonitorPanel.updateStatus();
7101 if (!aOnWindowOpen && this._disableUIOnToggle)
7102 document.getElementById(
"Tools:PrivateBrowsing")
7103 .setAttribute(
"disabled",
"true");
7106 onExitPrivateBrowsing:
function PBUI_onExitPrivateBrowsing() {
7107 if (BrowserSearch.searchBar) {
7108 let searchBox = BrowserSearch.searchBar.textbox;
7110 if (this._searchBarValue) {
7111 searchBox.value = this._searchBarValue;
7112 this._searchBarValue =
null;
7116 document.getElementById(
"menu_import").removeAttribute(
"disabled");
7120 document.getElementById(
"Tools:Sanitize").removeAttribute(
"disabled");
7123 let findbox = gFindBar.getElement(
"findbar-textbox");
7125 if (this._findBarValue) {
7126 findbox.value = this._findBarValue;
7127 this._findBarValue =
null;
7131 this._setPBMenuTitle(
"start");
7135 let docElement = document.documentElement;
7136 docElement.setAttribute(
"title",
7137 docElement.getAttribute(
"title_normal"));
7138 docElement.setAttribute(
"titlemodifier",
7139 docElement.getAttribute(
"titlemodifier_normal"));
7140 docElement.setAttribute(
"browsingmode",
"normal");
7144 document.getElementById(
"privateBrowsingItem")
7145 .removeAttribute(
"disabled");
7146 document.getElementById(
"Tools:PrivateBrowsing")
7147 .removeAttribute(
"disabled");
7149 gLastOpenDirectory.reset();
7152 DownloadMonitorPanel.updateStatus();
7155 if (this._disableUIOnToggle)
7156 document.getElementById(
"Tools:PrivateBrowsing")
7157 .setAttribute(
"disabled",
"true");
7160 _setPBMenuTitle:
function PBUI__setPBMenuTitle(aMode) {
7161 let pbMenuItem = document.getElementById(
"privateBrowsingItem");
7162 pbMenuItem.setAttribute(
"label", pbMenuItem.getAttribute(aMode +
"label"));
7163 pbMenuItem.setAttribute(
"accesskey", pbMenuItem.getAttribute(aMode +
"accesskey"));
7166 toggleMode:
function PBUI_toggleMode() {
7168 if (!this.privateBrowsingEnabled)
7169 if (!this._shouldEnter())
7172 this._privateBrowsingService.privateBrowsingEnabled =
7173 !this.privateBrowsingEnabled;
7176 get privateBrowsingEnabled PBUI_get_privateBrowsingEnabled() {
7177 return this._privateBrowsingService.privateBrowsingEnabled;
7182 domain:
"browser.urlbar.",
7184 observe:
function UBET_observe(aSubject, aTopic, aPrefName) {
7185 if (aTopic ==
"nsPref:changed") {
7186 switch (aPrefName) {
7187 case "browser.urlbar.autocomplete.enabled":
7188 case "browser.urlbar.default.behavior":
7189 gURLBar.emptyText = this.
value;
7195 get value UBET_get_value() {
7197 if (
gPrefService.getBoolPref(
"browser.urlbar.autocomplete.enabled")) {
7199 switch (
gPrefService.getIntPref(
"browser.urlbar.default.behavior") & 3) {
7201 type =
"bookmarkhistory";
7211 return gURLBar.getAttribute(type +
"emptytext");
7215 var LightWeightThemeWebInstaller = {
7216 handleEvent:
function (
event) {
7217 switch (
event.type) {
7218 case "InstallBrowserTheme":
7219 case "PreviewBrowserTheme":
7220 case "ResetBrowserThemePreview":
7222 if (
event.target.ownerDocument.defaultView.top != content)
7225 switch (
event.type) {
7226 case "InstallBrowserTheme":
7227 this._installRequest(
event);
7229 case "PreviewBrowserTheme":
7230 this._preview(
event);
7232 case "ResetBrowserThemePreview":
7233 this._resetPreview(
event);
7237 this._resetPreview();
7244 Cu.import(
"resource://gre/modules/LightweightThemeManager.jsm", temp);
7245 delete this._manager;
7246 return this._manager = temp.LightweightThemeManager;
7249 _installRequest:
function (
event) {
7250 var
node =
event.target;
7251 var
data = this._getThemeFromNode(node);
7255 if (this._isAllowed(node)) {
7256 this._install(data);
7260 var allowButtonText =
7262 var allowButtonAccesskey =
7266 [node.ownerDocument.location.host]);
7268 label: allowButtonText,
7269 accessKey: allowButtonAccesskey,
7271 LightWeightThemeWebInstaller._install(data);
7275 this._removePreviousNotifications();
7277 var notificationBox = gBrowser.getNotificationBox();
7278 var notificationBar =
7279 notificationBox.appendNotification(message,
"lwtheme-install-request",
"",
7280 notificationBox.PRIORITY_INFO_MEDIUM,
7282 notificationBar.persistence = 1;
7285 _install:
function (newTheme) {
7286 var previousTheme = this._manager.currentTheme;
7287 this._manager.currentTheme = newTheme;
7288 if (this._manager.currentTheme &&
7289 this._manager.currentTheme.id == newTheme.id)
7290 this._postInstallNotification(newTheme, previousTheme);
7293 _postInstallNotification:
function (newTheme, previousTheme) {
7299 label: text(
"undoButton"),
7300 accessKey: text(
"undoButton.accesskey"),
7302 LightWeightThemeWebInstaller._manager.forgetUsedTheme(newTheme.id);
7303 LightWeightThemeWebInstaller._manager.currentTheme = previousTheme;
7306 label: text(
"manageButton"),
7307 accessKey: text(
"manageButton.accesskey"),
7313 this._removePreviousNotifications();
7315 var notificationBox = gBrowser.getNotificationBox();
7316 var notificationBar =
7317 notificationBox.appendNotification(text(
"message"),
7318 "lwtheme-install-notification",
"",
7319 notificationBox.PRIORITY_INFO_MEDIUM,
7321 notificationBar.persistence = 1;
7322 notificationBar.timeout = Date.now() + 20000;
7325 _removePreviousNotifications:
function () {
7326 var box = gBrowser.getNotificationBox();
7328 [
"lwtheme-install-request",
7329 "lwtheme-install-notification"].forEach(
function (value) {
7330 var notification = box.getNotificationWithValue(value);
7332 box.removeNotification(notification);
7336 _previewWindow:
null,
7337 _preview:
function (
event) {
7338 if (!this._isAllowed(
event.target))
7341 var data = this._getThemeFromNode(
event.target);
7345 this._resetPreview();
7347 this._previewWindow =
event.target.ownerDocument.defaultView;
7348 this._previewWindow.addEventListener(
"pagehide",
this,
true);
7349 gBrowser.tabContainer.addEventListener(
"TabSelect",
this,
false);
7351 this._manager.previewTheme(data);
7354 _resetPreview:
function (
event) {
7355 if (!this._previewWindow ||
7359 this._previewWindow.removeEventListener(
"pagehide",
this,
true);
7360 this._previewWindow =
null;
7361 gBrowser.tabContainer.removeEventListener(
"TabSelect",
this,
false);
7363 this._manager.resetPreview();
7366 _isAllowed:
function (
node) {
7367 var pm =
Cc[
"@mozilla.org/permissionmanager;1"].getService(
Ci.nsIPermissionManager);
7369 var
prefs = [[
"xpinstall.whitelist.add", pm.ALLOW_ACTION],
7370 [
"xpinstall.whitelist.add.36", pm.ALLOW_ACTION],
7371 [
"xpinstall.blacklist.add", pm.DENY_ACTION]];
7372 prefs.forEach(
function ([
pref, permission]) {
7378 hosts.split(
",").forEach(
function (host) {
7379 pm.add(
makeURI(
"http://" + host),
"install", permission);
7386 var uri = node.ownerDocument.documentURIObject;
7387 return pm.testPermission(uri,
"install") == pm.ALLOW_ACTION;
7390 _getThemeFromNode:
function (
node) {
7391 return this._manager.parseTheme(node.getAttribute(
"data-browsertheme"),
function CreateMenu(node)
function UpdateBackForwardCommands(aWebNavigation)
function BrowserCustomizeToolbar()
function PageProxySetIcon(aURL)
function BrowserTryToCloseWindow()
function openNewTabWith(aURL, aDocument, aPostData, aEvent, aAllowThirdPartyFixup, aReferrer)
function PageProxyClickHandler(aEvent)
function warnAboutClosingWindow()
nsString encodeURIComponent(const nsString &c)
const WINTASKBAR_CONTRACTID
static nsCOMPtr< nsIObserverService > observerService
function MultiplexHandler(event)
function getShortcutOrURI(aURL, aPostDataRef)
function UpdatePageProxyState()
function mimeTypeIsTextBased(aMimeType)
function gatherTextUnder(root)
function getAllStyleSheets(frameset)
function openUILinkIn(url, where, allowThirdPartyFixup, postData, referrerUrl)
function BrowserShutdown()
const gSessionHistoryObserver
function BrowserFullScreen()
function missingPluginInstaller()
function asyncOpenWebPanel(event)
function doc() browser.contentDocument
function BrowserReloadSkipCache()
sbDeviceFirmwareAutoCheckForUpdate prototype flags
function BrowserBack(aEvent, aIgnoreAlt)
function BrowserHandleShiftBackspace()
dndDefaultHandler_module onDragOver
function getMarkupDocumentViewer()
__defineSetter__("PluralForm", function(val){delete this.PluralForm;return this.PluralForm=val;})
function BrowserCloseTabOrWindow()
function makeURLAbsolute(aBase, aUrl)
var gProgressCollapseTimer
function UpdateUrlbarSearchSplitterState()
function undoCloseWindow(aIndex)
function formatURL(aFormat, aIsPref)
function getBoolPref(prefname, def)
function stylesheetFillPopup(menuPopup)
function stylesheetSwitchFrame(frame, title)
sbOSDControlService prototype QueryInterface
function stylesheetInFrame(frame, title)
function getBrowserSelection(aCharLen)
function updateEditUIVisibility()
function BrowserOpenAddonsMgr(aPane)
__defineGetter__("gPrefService", function(){delete this.gPrefService;return this.gPrefService=Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch2).QueryInterface(Ci.nsIPrefService);})
function convertFromUnicode(charset, str)
function getBrowser() gBrowser
function contentAreaClick(event, fieldNormalClicks)
function HandleAppCommandEvent(evt)
function getContentAreaFrameCount()
function BrowserPageInfo(doc, initialTab, imageElement)
getService(Ci.sbIFaceplateManager)
function pageShowEventHandlers(event)
function SelectDetector(event, doReload)
SessionStoreService aDocShell
function BrowserViewSourceOfDocument(aDocument)
function BrowserOnCommand(event)
function onExitPrintPreview()
function getNotificationBox(aWindow)
function UpdateMenus(event)
this _contentSandbox label
function BookmarkThisTab()
function loadOneOrMoreURIs(aURIString)
_collectFormDataForFrame aDocument
function setStyleDisabled(disabled)
function BrowserOpenFileWindow()
function onEnterPrintPreview()
function makeURI(aURLSpec, aCharset)
function isElementVisible(aElement)
return e ctrlKey(chr<' '||!chars||chars.indexOf(chr)>-1)
var gAutoHideTabbarPrefListener
function UpdateCurrentCharset()
var gBookmarkAllTabsHandler
function escapeNameValuePair(aName, aValue, aIsFormUrlEncoded)
function BrowserForward(aEvent, aIgnoreAlt)
function handleLinkClick(event, href, linkNode)
function openUILink(url, e, ignoreButton, ignoreAlt, allowKeywordFixup, postData, referrerUrl)
this _dialogInput val(dateText)
var contentAreaDNDObserver
function getPostDataStream(aStringData, aKeyword, aEncKeyword, aType)
aWindow setTimeout(function(){_this.restoreHistory(aWindow, aTabs, aTabData, aIdMap);}, 0)
function FillInHTMLTooltip(tipElement)
function isValidFeed(aLink, aPrincipal, aIsFeed)
function stylesheetSwitchAll(frameset, title)
function SetForcedDetector(doReload)
function BrowserReloadWithFlags(reloadFlags)
function openWebPanel(aTitle, aURI)
function BrowserSetForcedDetector(doReload)
function BookmarkAllTabsHandler()
const gPopupBlockerObserver
function WindowIsClosing()
function openAdvancedPreferences(tabID)
function whereToOpenLink(e, ignoreButton, ignoreAlt)
BogusChannel prototype owner
return!aWindow arguments!aWindow arguments[0]
function BrowserHandleBackspace()
function loadURI(uri, referrer, postData, allowThirdPartyFixup)
_updateTextAndScrollDataForTab aBrowser
function BrowserSetForcedCharacterSet(aCharset)
function middleMousePaste(event)
return aWindow document documentElement getAttribute(aAttribute)||dimension
this _dialogInput this _pos[1] px
function BrowserToolboxCustomizeDone(aToolboxChanged)
function toggle(toShow, toHide, data, clickedActive, down)
function SetPageProxyState(aState)
function AutoHideTabbarPrefListener()
function openNewWindowWith(aURL, aDocument, aPostData, aAllowThirdPartyFixup, aReferrer)
function BrowserToolboxCustomizeChange()
function URLBarSetURI(aURI, aValid)
ContinuingWebProgressListener prototype onStateChange
function AddKeywordForSearchField()
function getShellService()
function delayedStartup(isLoadingBlank, mustLoadSidebar)
function readFromClipboard()
function BrowserStartup()
function SetForcedCharset(charset)
function losslessDecodeURI(aURI)
function getMeOutOfHere()
function SwitchDocumentDirection(aWindow)
function getPluginInfo(pluginElement)
function getNavToolbox() gNavToolbox
_getSelectedPageStyle s i
function getWebNavigation()
function prepareForStartup()
function PageProxyClearIcon()
function UpdateCharsetDetector()
_updateTextAndScrollDataForFrame aData
function clickHandler(event)
function toggleAffectedChrome(aHide)
sbDeviceFirmwareAutoCheckForUpdate prototype observe
function undoCloseTab(aIndex)
function findChildShell(aDocument, aDocShell, aSoughtURI)
function charsetLoadListener(event)
function toOpenWindowByType(inType, uri, features)