46 const Ci = Components.interfaces;
47 const Cc = Components.classes;
48 const Cr = Components.results;
49 const Cu = Components.utils;
51 const XULNS =
"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
53 Cu.import(
"resource://gre/modules/XPCOMUtils.jsm");
56 Cu.import(
"resource://app/jsmodules/Distribution.jsm");
75 throw Components.results.NS_ERROR_NO_AGGREGATION;
76 return this._instance ==
null ?
77 this._instance =
new BrowserGlue() : this._instance;
87 return this.
_prefs =
Cc[
"@mozilla.org/preferences-service;1"].
92 delete this._bundleService;
93 return this._bundleService =
Cc[
"@mozilla.org/intl/stringbundle;1"].
98 delete this._idleService;
99 return this._idleService =
Cc[
"@mozilla.org/widget/idleservice;1"].
104 delete this._observerService;
105 return this._observerService =
Cc[
'@mozilla.org/observer-service;1'].
110 delete this._distributionCustomizer;
119 # OS X has the concept of zero-window sessions and therefore ignores the
120 # browser-lastwindow-close-* topics.
121 #define OBSERVE_LASTWINDOW_CLOSE_TOPICS 1
128 _setPrefToSaveSession:
function()
130 this.
_prefs.setBoolPref(
"browser.sessionstore.resume_session_once",
true);
135 this.
_prefs.QueryInterface(
Ci.nsIPrefService).savePrefFile(
null);
142 case "xpcom-shutdown":
145 case "prefservice:after-app-defaults":
146 this._onAppDefaults();
148 case "final-ui-startup":
149 this._onProfileStartup();
151 case "sessionstore-windows-restored":
152 this._onBrowserStartup();
154 case "browser:purge-session-history":
156 const cs =
Cc[
"@mozilla.org/consoleservice;1"].
158 cs.logStringMessage(
null);
161 case "quit-application-requested":
162 this._onQuitRequest(subject,
data);
164 case "quit-application-granted":
165 if (this._saveSession) {
166 this._setPrefToSaveSession();
171 this._onProfileShutdown();
173 #ifdef OBSERVE_LASTWINDOW_CLOSE_TOPICS
174 case "browser-lastwindow-close-requested":
177 this._onQuitRequest(subject,
"lastwindow");
179 case "browser-lastwindow-close-granted":
180 if (this._saveSession)
181 this._setPrefToSaveSession();
185 this._setPrefToSaveSession();
186 subject.QueryInterface(
Ci.nsISupportsPRBool);
189 case "places-init-complete":
191 this._observerService.removeObserver(
this,
"places-init-complete");
193 this._observerService.removeObserver(
this,
"places-database-locked");
197 this._distributionCustomizer.applyBookmarks();
199 case "places-database-locked":
200 this._isPlacesDatabaseLocked =
true;
203 this._observerService.removeObserver(
this,
"places-database-locked");
208 this._archiveBookmarks();
211 case "distribution-customization-complete":
212 this._observerService
213 .removeObserver(
this,
"distribution-customization-complete");
215 delete this._distributionCustomizer;
224 const osvr = this._observerService;
225 osvr.addObserver(
this,
"xpcom-shutdown",
false);
226 osvr.addObserver(
this,
"prefservice:after-app-defaults",
false);
227 osvr.addObserver(
this,
"final-ui-startup",
false);
228 osvr.addObserver(
this,
"sessionstore-windows-restored",
false);
229 osvr.addObserver(
this,
"browser:purge-session-history",
false);
230 osvr.addObserver(
this,
"quit-application-requested",
false);
231 osvr.addObserver(
this,
"quit-application-granted",
false);
232 #ifdef OBSERVE_LASTWINDOW_CLOSE_TOPICS
233 osvr.addObserver(
this,
"browser-lastwindow-close-requested",
false);
234 osvr.addObserver(
this,
"browser-lastwindow-close-granted",
false);
236 osvr.addObserver(
this,
"session-save",
false);
237 osvr.addObserver(
this,
"places-init-complete",
false);
238 osvr.addObserver(
this,
"places-database-locked",
false);
239 osvr.addObserver(
this,
"distribution-customization-complete",
false);
246 const osvr = this._observerService;
247 osvr.removeObserver(
this,
"xpcom-shutdown");
248 osvr.removeObserver(
this,
"prefservice:after-app-defaults");
249 osvr.removeObserver(
this,
"final-ui-startup");
250 osvr.removeObserver(
this,
"sessionstore-windows-restored");
251 osvr.removeObserver(
this,
"browser:purge-session-history");
252 osvr.removeObserver(
this,
"quit-application-requested");
253 #ifdef OBSERVE_LASTWINDOW_CLOSE_TOPICS
254 osvr.removeObserver(
this,
"browser-lastwindow-close-requested");
255 osvr.removeObserver(
this,
"browser-lastwindow-close-granted");
257 osvr.removeObserver(
this,
"quit-application-granted");
258 osvr.removeObserver(
this,
"session-save");
261 _onAppDefaults:
function()
266 if (this._distributionCustomizer)
267 this._distributionCustomizer.applyPrefDefaults();
271 _onProfileStartup:
function()
275 var app =
Cc[
"@mozilla.org/xre/app-info;1"].getService(
Ci.nsIXULAppInfo).
277 if (app.inSafeMode) {
278 var
ww =
Cc[
"@mozilla.org/embedcomp/window-watcher;1"].
280 ww.openWindow(
null,
"chrome://browser/content/safeMode.xul",
281 "_blank",
"chrome,centerscreen,modal,resizable=no",
null);
287 if (this._distributionCustomizer)
288 this._distributionCustomizer.applyCustomizations();
293 this._observerService.notifyObservers(
null,
"browser-ui-startup-complete",
"");
297 _onProfileShutdown:
function()
302 let um =
Cc[
"@mozilla.org/updates/update-manager;1"].
304 if (um.activeUpdate && um.activeUpdate.state ==
"pending") {
307 cacheService.evictEntries(
Ci.nsICache.STORE_ANYWHERE);
311 this._shutdownPlaces();
317 _onBrowserStartup:
function()
320 if (this._shouldShowRights())
321 this._showRightsNotification();
325 var
args =
Cc[
"@mozilla.org/supports-array;1"].
327 var
str =
Cc[
"@mozilla.org/supports-string;1"].
330 args.AppendElement(str);
331 var str =
Cc[
"@mozilla.org/supports-string;1"].
334 args.AppendElement(str);
335 const EMURL =
"chrome://mozapps/content/extensions/extensions.xul";
336 const EMFEATURES =
"chrome,menubar,extra-chrome,toolbar,dialog=no,resizable";
337 var
ww =
Cc[
"@mozilla.org/embedcomp/window-watcher;1"].
339 ww.openWindow(
null, EMURL,
"_blank", EMFEATURES, args);
348 if (this._isPlacesDatabaseLocked) {
349 this._showPlacesLockedNotificationBox();
355 this._showPluginUpdatePage();
358 _onQuitRequest:
function(aCancelQuit, aQuitType)
361 if ((aCancelQuit instanceof
Ci.nsISupportsPRBool) && aCancelQuit.data)
364 var
wm =
Cc[
"@mozilla.org/appshell/window-mediator;1"].
369 var browserEnum = wm.getEnumerator(
"navigator:browser");
370 while (browserEnum.hasMoreElements()) {
373 var
browser = browserEnum.getNext();
374 var
tabbrowser = browser.document.getElementById(
"content");
376 pagecount += tabbrowser.browsers.length;
379 this._saveSession =
false;
383 if (aQuitType !=
"restart")
386 var showPrompt =
true;
392 var sessionWillBeSaved = this.
_prefs.getIntPref(
"browser.startup.page") == 3 ||
393 this.
_prefs.getBoolPref(
"browser.sessionstore.resume_session_once");
394 if (sessionWillBeSaved || !this.
_prefs.getBoolPref(
"browser.warnOnQuit"))
396 else if (aQuitType ==
"restart")
397 showPrompt = this.
_prefs.getBoolPref(
"browser.warnOnRestart");
399 showPrompt = this.
_prefs.getBoolPref(
"browser.tabs.warnOnClose");
404 var inPrivateBrowsing =
false;
405 if (
"@mozilla.org/privatebrowsing;1" in
Cc) {
406 inPrivateBrowsing = Cc[
"@mozilla.org/privatebrowsing;1"].
408 privateBrowsingEnabled;
410 if (!showPrompt || inPrivateBrowsing)
413 var quitBundle = this._bundleService.createBundle(
"chrome://browser/locale/quitDialog.properties");
414 var
brandBundle = this._bundleService.createBundle(
"chrome://branding/locale/brand.properties");
416 var appName = brandBundle.GetStringFromName(
"brandShortName");
417 var quitDialogTitle = quitBundle.formatStringFromName(aQuitType +
"DialogTitle",
421 if (aQuitType ==
"restart")
422 message = quitBundle.formatStringFromName(
"messageRestart",
424 else if (windowcount == 1)
425 message = quitBundle.formatStringFromName(
"messageNoWindows",
428 message = quitBundle.formatStringFromName(
"message",
431 var
promptService = Cc[
"@mozilla.org/embedcomp/prompt-service;1"].
434 var
flags = promptService.BUTTON_TITLE_IS_STRING * promptService.BUTTON_POS_0 +
435 promptService.BUTTON_TITLE_IS_STRING * promptService.BUTTON_POS_1 +
436 promptService.BUTTON_POS_0_DEFAULT;
438 var neverAsk = {
value:
false};
439 var button0Title, button2Title;
440 var button1Title = quitBundle.GetStringFromName(
"cancelTitle");
441 var neverAskText = quitBundle.GetStringFromName(
"neverAsk");
443 if (aQuitType ==
"restart")
444 button0Title = quitBundle.GetStringFromName(
"restartTitle");
446 flags += promptService.BUTTON_TITLE_IS_STRING * promptService.BUTTON_POS_2;
447 button0Title = quitBundle.GetStringFromName(
"saveTitle");
448 button2Title = quitBundle.GetStringFromName(
"quitTitle");
451 var mostRecentBrowserWindow = wm.getMostRecentWindow(
"navigator:browser");
453 promptService.confirmEx(mostRecentBrowserWindow, quitDialogTitle, message,
454 flags, button0Title, button1Title, button2Title,
455 neverAskText, neverAsk);
457 switch (buttonChoice) {
460 this.
_prefs.setBoolPref(
"browser.tabs.warnOnClose",
false);
463 aCancelQuit.QueryInterface(
Ci.nsISupportsPRBool);
464 aCancelQuit.data =
true;
467 this._saveSession =
true;
468 if (neverAsk.value) {
469 if (aQuitType ==
"restart")
470 this.
_prefs.setBoolPref(
"browser.warnOnRestart",
false);
473 this.
_prefs.setIntPref(
"browser.startup.page", 3);
488 _shouldShowRights :
function () {
492 return !this.
_prefs.getBoolPref(
"browser.rights.override");
496 return !this.
_prefs.getBoolPref(
"browser.EULA.override");
499 #ifndef OFFICIAL_BUILD
505 var currentVersion = this.
_prefs.getIntPref(
"browser.rights.version");
507 return !this.
_prefs.getBoolPref(
"browser.rights." + currentVersion +
".shown");
513 return !this.
_prefs.getBoolPref(
"browser.EULA." + currentVersion +
".accepted");
520 _showRightsNotification :
function () {
524 var notifyBox = browser.getNotificationBox();
526 var
brandBundle = this._bundleService.createBundle(
"chrome://branding/locale/brand.properties");
527 var rightsBundle = this._bundleService.createBundle(
"chrome://global/locale/aboutRights.properties");
529 var buttonLabel = rightsBundle.GetStringFromName(
"buttonLabel");
530 var buttonAccessKey = rightsBundle.GetStringFromName(
"buttonAccessKey");
531 var productName = brandBundle.GetStringFromName(
"brandFullName");
532 var notifyRightsText = rightsBundle.formatStringFromName(
"notifyRightsText", [productName], 1);
537 accessKey: buttonAccessKey,
539 callback:
function(aNotificationBar, aButton) {
540 browser.selectedTab = browser.addTab(
"about:rights");
546 var currentVersion = this.
_prefs.getIntPref(
"browser.rights.version");
547 this.
_prefs.setBoolPref(
"browser.rights." + currentVersion +
".shown",
true);
549 var box = notifyBox.appendNotification(notifyRightsText,
"about-rights",
null, notifyBox.PRIORITY_INFO_LOW, buttons);
553 _showPluginUpdatePage :
function () {
556 var formatter =
Cc[
"@mozilla.org/toolkit/URLFormatterService;1"].
562 browser.selectedTab = browser.addTab(updateUrl);
569 Cc[
"@mozilla.org/moz/jssubscript-loader;1"].
571 loadSubScript(
"chrome://browser/content/sanitize.js",
null);
596 _initPlaces:
function bg__initPlaces() {
603 var
histsvc =
Cc[
"@mozilla.org/browser/nav-history-service;1"].
608 var databaseStatus = histsvc.databaseStatus;
609 var importBookmarks = databaseStatus == histsvc.DATABASE_STATUS_CREATE ||
610 databaseStatus == histsvc.DATABASE_STATUS_CORRUPT;
612 if (databaseStatus == histsvc.DATABASE_STATUS_CREATE) {
617 var
bmsvc =
Cc[
"@mozilla.org/browser/nav-bookmarks-service;1"].
619 if (bmsvc.getIdForItemAt(bmsvc.bookmarksMenuFolder, 0) != -1 ||
620 bmsvc.getIdForItemAt(bmsvc.toolbarFolder, 0) != -1)
621 importBookmarks =
false;
625 var importBookmarksHTML =
false;
627 importBookmarksHTML =
628 this.
_prefs.getBoolPref(
"browser.places.importBookmarksHTML");
629 if (importBookmarksHTML)
630 importBookmarks =
true;
637 restoreDefaultBookmarks =
638 this.
_prefs.getBoolPref(
"browser.bookmarks.restore_default_bookmarks");
639 if (restoreDefaultBookmarks) {
641 this._archiveBookmarks();
642 importBookmarks =
true;
648 if (importBookmarks && !restoreDefaultBookmarks && !importBookmarksHTML) {
650 Cu.import(
"resource://gre/modules/utils.js");
651 var bookmarksBackupFile = PlacesUtils.getMostRecentBackup();
652 if (bookmarksBackupFile && bookmarksBackupFile.leafName.match(
"\.json$")) {
654 PlacesUtils.restoreBookmarksFromJSONFile(bookmarksBackupFile);
655 importBookmarks =
false;
659 importBookmarks =
true;
660 var dirService =
Cc[
"@mozilla.org/file/directory_service;1"].
662 var bookmarksHTMLFile = dirService.get(
"BMarks",
Ci.nsILocalFile);
663 if (bookmarksHTMLFile.exists()) {
665 importBookmarksHTML =
true;
669 restoreDefaultBookmarks =
true;
674 if (!importBookmarks) {
677 this.ensurePlacesDefaultQueriesInitialized();
683 var autoExportHTML =
false;
685 autoExportHTML = this.
_prefs.getBoolPref(
"browser.bookmarks.autoExportHTML");
687 var smartBookmarksVersion = 0;
689 smartBookmarksVersion = this.
_prefs.getIntPref(
"browser.places.smartBookmarksVersion");
691 if (!autoExportHTML && smartBookmarksVersion != -1)
692 this.
_prefs.setIntPref(
"browser.places.smartBookmarksVersion", 0);
695 var dirService =
Cc[
"@mozilla.org/file/directory_service;1"].
698 var bookmarksFile =
null;
699 if (restoreDefaultBookmarks) {
701 bookmarksFile = dirService.get(
"profDef",
Ci.nsILocalFile);
702 bookmarksFile.append(
"bookmarks.html");
705 bookmarksFile = dirService.get(
"BMarks",
Ci.nsILocalFile);
707 if (bookmarksFile.exists()) {
710 var
importer =
Cc[
"@mozilla.org/browser/places/import-export-service;1"].
712 importer.importHTMLFromFile(bookmarksFile,
true );
715 Cu.reportError(
"Bookmarks.html file could be corrupt. " + err);
719 Cu.reportError(
"Unable to find bookmarks.html file.");
722 if (importBookmarksHTML)
723 this.
_prefs.setBoolPref(
"browser.places.importBookmarksHTML",
false);
724 if (restoreDefaultBookmarks)
725 this.
_prefs.setBoolPref(
"browser.bookmarks.restore_default_bookmarks",
742 _shutdownPlaces:
function bg__shutdownPlaces() {
744 this._archiveBookmarks();
748 var autoExportHTML =
false;
750 autoExportHTML = this.
_prefs.getBoolPref(
"browser.bookmarks.autoExportHTML");
752 Components.utils.reportError(ex);
755 if (autoExportHTML) {
756 Cc[
"@mozilla.org/browser/places/import-export-service;1"].
758 backupBookmarksFile();
765 _archiveBookmarks:
function nsBrowserGlue__archiveBookmarks() {
766 Cu.import(
"resource://gre/modules/utils.js");
768 var lastBackup = PlacesUtils.getMostRecentBackup();
776 maxBackups = this.
_prefs.getIntPref(
"browser.bookmarks.max_backups");
779 PlacesUtils.archiveBookmarksFile(maxBackups,
false );
786 _showPlacesLockedNotificationBox:
function nsBrowserGlue__showPlacesLockedNotificationBox() {
787 var
brandBundle = this._bundleService.createBundle(
"chrome://branding/locale/brand.properties");
788 var applicationName = brandBundle.GetStringFromName(
"brandShortName");
789 var placesBundle = this._bundleService.createBundle(
"chrome://browser/locale/places/places.properties");
790 var title = placesBundle.GetStringFromName(
"lockPrompt.title");
791 var text = placesBundle.formatStringFromName(
"lockPrompt.text", [applicationName], 1);
792 var buttonText = placesBundle.GetStringFromName(
"lockPromptInfoButton.label");
793 var accessKey = placesBundle.GetStringFromName(
"lockPromptInfoButton.accessKey");
795 var helpTopic =
"places-locked";
796 var
url =
Cc[
"@mozilla.org/toolkit/URLFormatterService;1"].
797 getService(Components.interfaces.nsIURLFormatter).
798 formatURLPref(
"app.support.baseURL");
806 accessKey: accessKey,
808 callback:
function(aNotificationBar, aButton) {
809 browser.selectedTab = browser.addTab(url);
814 var notifyBox = browser.getNotificationBox();
815 var box = notifyBox.appendNotification(text, title,
null,
816 notifyBox.PRIORITY_CRITICAL_MEDIUM,
818 box.persistence = -1;
821 _migrateUI:
function bg__migrateUI() {
824 migration = this.
_prefs.getIntPref(
"browser.migration.version");
827 if (migration == 0) {
831 this._rdf =
Cc[
"@mozilla.org/rdf/rdf-service;1"].getService(
Ci.nsIRDFService);
832 this._dataSource = this._rdf.GetDataSource(
"rdf:local-store");
835 let currentsetResource = this._rdf.GetResource(
"currentset");
836 let toolbars = [
"nav-bar",
"toolbar-menubar",
"PersonalToolbar"];
837 for (let
i = 0;
i < toolbars.length;
i++) {
838 let toolbar = this._rdf.GetResource(
"chrome://browser/content/browser.xul#" + toolbars[
i]);
839 let currentset = this._getPersist(toolbar, currentsetResource);
847 if (/(?:^|,)unified-back-forward-button(?:$|,)/.
test(currentset))
850 if (/(?:^|,)back-button(?:$|,)/.
test(currentset)) {
851 let newset = currentset.replace(/(^|,)back-button($|,)/,
852 "$1unified-back-forward-button,back-button$2")
853 this._setPersist(toolbar, currentsetResource, newset);
861 this._dataSource.QueryInterface(
Ci.nsIRDFRemoteDataSource).Flush();
865 this._dataSource =
null;
868 this.
_prefs.setIntPref(
"browser.migration.version", 1);
872 _getPersist:
function bg__getPersist(aSource, aProperty) {
873 var
target = this._dataSource.GetTarget(aSource, aProperty,
true);
874 if (target instanceof
Ci.nsIRDFLiteral)
879 _setPersist:
function bg__setPersist(aSource, aProperty, aTarget) {
882 var oldTarget = this._dataSource.GetTarget(aSource, aProperty,
true);
885 this._dataSource.Change(aSource, aProperty, oldTarget, this._rdf.GetLiteral(aTarget));
887 this._dataSource.Unassert(aSource, aProperty, oldTarget);
890 this._dataSource.Assert(aSource, aProperty, this._rdf.GetLiteral(aTarget),
true);
905 ensurePlacesDefaultQueriesInitialized:
function() {
917 const MAX_RESULTS = 10;
921 var smartBookmarksCurrentVersion = 0;
927 if (smartBookmarksCurrentVersion == -1 ||
931 var
bmsvc =
Cc[
"@mozilla.org/browser/nav-bookmarks-service;1"].
933 var annosvc =
Cc[
"@mozilla.org/browser/annotation-service;1"].
937 _uri:
function(aSpec) {
938 return Cc[
"@mozilla.org/network/io-service;1"].
943 runBatched:
function() {
944 var smartBookmarks = [];
945 var bookmarksMenuIndex = 0;
946 var bookmarksToolbarIndex = 0;
948 var placesBundle =
Cc[
"@mozilla.org/intl/stringbundle;1"].
950 createBundle(
"chrome://browser/locale/places/places.properties");
953 var smart = {queryId:
"MostVisited",
955 title: placesBundle.GetStringFromName(
"mostVisitedTitle"),
956 uri: this._uri(
"place:redirectsMode=" +
957 Ci.nsINavHistoryQueryOptions.REDIRECTS_MODE_TARGET +
959 Ci.nsINavHistoryQueryOptions.SORT_BY_VISITCOUNT_DESCENDING +
960 "&maxResults=" + MAX_RESULTS),
961 parent: bmsvc.toolbarFolder,
964 smartBookmarks.push(smart);
967 smart = {queryId:
"RecentlyBookmarked",
969 title: placesBundle.GetStringFromName(
"recentlyBookmarkedTitle"),
970 uri: this._uri(
"place:folder=BOOKMARKS_MENU" +
971 "&folder=UNFILED_BOOKMARKS" +
974 Ci.nsINavHistoryQueryOptions.QUERY_TYPE_BOOKMARKS +
976 Ci.nsINavHistoryQueryOptions.SORT_BY_DATEADDED_DESCENDING +
977 "&excludeItemIfParentHasAnnotation=livemark%2FfeedURI" +
978 "&maxResults=" + MAX_RESULTS +
979 "&excludeQueries=1"),
980 parent: bmsvc.bookmarksMenuFolder,
983 smartBookmarks.push(smart);
986 smart = {queryId:
"RecentTags",
988 title: placesBundle.GetStringFromName(
"recentTagsTitle"),
989 uri: this._uri(
"place:"+
991 Ci.nsINavHistoryQueryOptions.RESULTS_AS_TAG_QUERY +
993 Ci.nsINavHistoryQueryOptions.SORT_BY_LASTMODIFIED_DESCENDING +
994 "&maxResults=" + MAX_RESULTS),
995 parent: bmsvc.bookmarksMenuFolder,
998 smartBookmarks.push(smart);
1004 for each(var itemId
in smartBookmarkItemIds) {
1006 for (var
i = 0;
i < smartBookmarks.length;
i++){
1007 if (smartBookmarks[
i].queryId == queryId) {
1008 smartBookmarks[
i].found =
true;
1009 smartBookmarks[
i].itemId = itemId;
1010 smartBookmarks[
i].parent = bmsvc.getFolderIdForItem(itemId);
1011 smartBookmarks[
i].position = bmsvc.getItemIndex(itemId);
1013 bmsvc.removeItem(itemId);
1019 if (
i == smartBookmarks.length - 1)
1025 for each(var smartBookmark
in smartBookmarks) {
1029 if (smartBookmarksCurrentVersion > 0 &&
1030 smartBookmark.newInVersion <= smartBookmarksCurrentVersion &&
1031 !smartBookmark.found)
1034 smartBookmark.itemId = bmsvc.insertBookmark(smartBookmark.parent,
1036 smartBookmark.position,
1037 smartBookmark.title);
1038 annosvc.setItemAnnotation(smartBookmark.itemId,
1040 0, annosvc.EXPIRE_NEVER);
1045 if (smartBookmarksCurrentVersion == 0 &&
1046 smartBookmarkItemIds.length == 0)
1047 bmsvc.insertSeparator(bmsvc.bookmarksMenuFolder, bookmarksMenuIndex);
1052 bmsvc.runInBatchMode(callback,
null);
1055 Components.utils.reportError(ex);
1059 this.
_prefs.QueryInterface(
Ci.nsIPrefService).savePrefFile(
null);
1064 #define BROKEN_WM_Z_ORDER
1070 var
wm =
Cc[
"@mozilla.org/appshell/window-mediator;1"].
1071 getService(Components.interfaces.nsIWindowMediator);
1073 #ifdef BROKEN_WM_Z_ORDER
1074 var
win = wm.getMostRecentWindow(
"navigator:browser",
true);
1077 if (win && win.document.documentElement.getAttribute(
"chromehidden")) {
1079 var windowList = wm.getEnumerator(
"navigator:browser",
true);
1081 while (windowList.hasMoreElements()) {
1082 var nextWin = windowList.getNext();
1083 if (!nextWin.document.documentElement.getAttribute(
"chromehidden"))
1088 var windowList = wm.getZOrderDOMWindowEnumerator(
"navigator:browser",
true);
1089 if (!windowList.hasMoreElements())
1092 var win = windowList.getNext();
1093 while (win.document.documentElement.getAttribute(
"chromehidden")) {
1094 if (!windowList.hasMoreElements())
1097 win = windowList.getNext();
1107 classID: Components.ID(
"{eab9012e-5f74-4cbc-b2b5-a590235513cc}"),
1108 contractID:
"@mozilla.org/browser/browserglue;1",
1111 Ci.nsISupportsWeakReference,
1112 Ci.nsIBrowserGlue]),
1120 { category:
"app-startup",
service:
true },
1125 category:
"prefservice:after-app-defaults",
service:
true }
1129 function GeolocationPrompt() {}
1131 GeolocationPrompt.prototype = {
1133 classID: Components.ID(
"{C6E8C44D-9F39-4AF7-BCC0-76E38A8310F5}"),
1134 contractID:
"@mozilla.org/geolocation/prompt;1",
1138 prompt:
function(request) {
1139 var pm =
Cc[
"@mozilla.org/permissionmanager;1"].getService(
Ci.nsIPermissionManager);
1141 var result = pm.testExactPermission(request.requestingURI,
"geo");
1143 if (result ==
Ci.nsIPermissionManager.ALLOW_ACTION) {
1148 if (result ==
Ci.nsIPermissionManager.DENY_ACTION) {
1153 function setPagePermission(
uri, allow) {
1155 pm.add(
uri,
"geo",
Ci.nsIPermissionManager.ALLOW_ACTION);
1157 pm.add(
uri,
"geo",
Ci.nsIPermissionManager.DENY_ACTION);
1160 function getChromeWindow(aWindow) {
1161 var chromeWin = aWindow
1162 .QueryInterface(
Ci.nsIInterfaceRequestor)
1163 .getInterface(
Ci.nsIWebNavigation)
1164 .QueryInterface(
Ci.nsIDocShellTreeItem)
1166 .QueryInterface(
Ci.nsIInterfaceRequestor)
1167 .getInterface(
Ci.nsIDOMWindow)
1168 .QueryInterface(
Ci.nsIDOMChromeWindow);
1172 var requestingWindow = request.requestingWindow.top;
1173 var chromeWindowObject = getChromeWindow(requestingWindow).wrappedJSObject;
1174 var
tabbrowser = chromeWindowObject.gBrowser;
1175 var
browser = tabbrowser.getBrowserForDocument(requestingWindow.document);
1176 var notificationBox = tabbrowser.getNotificationBox(browser);
1178 var notification = notificationBox.getNotificationWithValue(
"geolocation");
1179 if (!notification) {
1180 var bundleService =
Cc[
"@mozilla.org/intl/stringbundle;1"].getService(
Ci.nsIStringBundleService);
1181 var
browserBundle = bundleService.createBundle(
"chrome://browser/locale/browser.properties");
1184 label: browserBundle.GetStringFromName(
"geolocation.shareLocation"),
1185 accessKey: browserBundle.GetStringFromName(
"geolocation.shareLocation.accesskey"),
1187 var elements = notification.getElementsByClassName(
"rememberChoice");
1188 if (elements.length && elements[0].checked)
1189 setPagePermission(request.requestingURI,
true);
1194 label: browserBundle.GetStringFromName(
"geolocation.dontShareLocation"),
1195 accessKey: browserBundle.GetStringFromName(
"geolocation.dontShareLocation.accesskey"),
1197 var elements = notification.getElementsByClassName(
"rememberChoice");
1198 if (elements.length && elements[0].checked)
1199 setPagePermission(request.requestingURI,
false);
1204 var
message = browserBundle.formatStringFromName(
"geolocation.siteWantsToKnow",
1205 [request.requestingURI.host], 1);
1207 var newBar = notificationBox.appendNotification(message,
1209 "chrome://browser/skin/Geo.png",
1210 notificationBox.PRIORITY_INFO_HIGH,
1217 function geolocation_hacks_to_notification () {
1221 var inPrivateBrowsing =
false;
1222 if (
"@mozilla.org/privatebrowsing;1" in
Cc) {
1223 inPrivateBrowsing = Cc[
"@mozilla.org/privatebrowsing;1"].
1225 privateBrowsingEnabled;
1227 if (!inPrivateBrowsing) {
1228 var checkbox = newBar.ownerDocument.createElementNS(
XULNS,
"checkbox");
1229 checkbox.className =
"rememberChoice";
1230 checkbox.setAttribute(
"label", browserBundle.GetStringFromName(
"geolocation.remember"));
1231 checkbox.setAttribute(
"accesskey", browserBundle.GetStringFromName(
"geolocation.remember.accesskey"));
1232 newBar.appendChild(checkbox);
1235 var link = newBar.ownerDocument.createElementNS(
XULNS,
"label");
1236 link.className =
"text-link";
1237 link.setAttribute(
"value", browserBundle.GetStringFromName(
"geolocation.learnMore"));
1239 var formatter = Cc[
"@mozilla.org/toolkit/URLFormatterService;1"].getService(
Ci.nsIURLFormatter);
1240 link.href = formatter.formatURLPref(
"browser.geolocation.warning.infoURL");
1242 var description = newBar.ownerDocument.getAnonymousElementByAttribute(newBar,
"anonid",
"messageText");
1243 description.appendChild(link);
1246 chromeWindowObject.setTimeout(geolocation_hacks_to_notification, 0);
1259 return XPCOMUtils.generateModule([
BrowserGlue, GeolocationPrompt]);
const SMART_BOOKMARKS_VERSION
const PREF_PLUGINS_NOTIFYUSER
sbDeviceFirmwareAutoCheckForUpdate prototype flags
const SMART_BOOKMARKS_ANNO
sbDeviceFirmwareAutoCheckForUpdate prototype contractID
sbOSDControlService prototype QueryInterface
sbDeviceFirmwareAutoCheckForUpdate prototype classDescription
getService(Ci.sbIFaceplateManager)
this _contentSandbox label
function DistributionCustomizer()
const PREF_EM_NEW_ADDONS_LIST
const PREF_PLUGINS_UPDATEURL
function newURI(aURLString)
const SMART_BOOKMARKS_PREF
const BOOKMARKS_ARCHIVE_IDLE_TIME
function restoreDefaultBookmarks()
sbDeviceFirmwareAutoCheckForUpdate prototype classID
sbWindowsAutoPlayServiceCfg _xpcom_categories
const BrowserGlueServiceFactory
__defineGetter__("Application", function(){delete this.Application;return this.Application=Cc["@mozilla.org/fuel/application;1"].getService(Ci.fuelIApplication);})
function NSGetModule(aCompMgr, aFileSpec)
const BOOKMARKS_ARCHIVE_INTERVAL
_getSelectedPageStyle s i
function getMostRecentBrowserWindow()
sbDeviceFirmwareAutoCheckForUpdate prototype observe