Bug 822020 - Remove the global PB specific code from the toolkit downloads UI; r=jdm
authorEhsan Akhgari <ehsan@mozilla.com>
Wed, 19 Dec 2012 00:13:43 -0500
changeset 125607 b063173f6cfa
parent 125606 df141c254625
child 125608 f6d35a8b7dad
push id2151
push userlsblakk@mozilla.com
push dateTue, 19 Feb 2013 18:06:57 +0000
treeherdermozilla-beta@4952e88741ec [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjdm
bugs822020
milestone20.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 822020 - Remove the global PB specific code from the toolkit downloads UI; r=jdm
toolkit/mozapps/downloads/content/downloads.js
toolkit/mozapps/downloads/content/downloads.xul
toolkit/mozapps/downloads/tests/chrome/Makefile.in
--- a/toolkit/mozapps/downloads/content/downloads.js
+++ b/toolkit/mozapps/downloads/content/downloads.js
@@ -431,18 +431,20 @@ function Startup()
   // downloads can finish before Startup() does, so check if the window should
   // close and act accordingly
   if (!autoRemoveAndClose())
     gDownloadsView.focus();
 
   let obs = Cc["@mozilla.org/observer-service;1"].
             getService(Ci.nsIObserverService);
   obs.addObserver(gDownloadObserver, "download-manager-remove-download", false);
+#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING
   obs.addObserver(gDownloadObserver, "private-browsing", false);
   obs.addObserver(gDownloadObserver, "private-browsing-change-granted", false);
+#endif
   obs.addObserver(gDownloadObserver, "browser-lastwindow-close-granted", false);
 
   // Clear the search box and move focus to the list on escape from the box
   gSearchBox.addEventListener("keypress", function(e) {
     if (e.keyCode == e.DOM_VK_ESCAPE) {
       // Move focus to the list instead of closing the window
       gDownloadsView.focus();
       e.preventDefault();
@@ -457,18 +459,20 @@ function Startup()
 }
 
 function Shutdown()
 {
   gDownloadManager.removeListener(gDownloadListener);
 
   let obs = Cc["@mozilla.org/observer-service;1"].
             getService(Ci.nsIObserverService);
+#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING
   obs.removeObserver(gDownloadObserver, "private-browsing");
   obs.removeObserver(gDownloadObserver, "private-browsing-change-granted");
+#endif
   obs.removeObserver(gDownloadObserver, "download-manager-remove-download");
   obs.removeObserver(gDownloadObserver, "browser-lastwindow-close-granted");
 
   clearTimeout(gBuilder);
   gStmt.reset();
   gStmt.finalize();
 }
 
@@ -483,16 +487,17 @@ let gDownloadObserver = {
           break;
         }
 
         // Otherwise, remove a single download
         let id = aSubject.QueryInterface(Ci.nsISupportsPRUint32);
         let dl = getDownload(id.data);
         removeFromView(dl);
         break;
+#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING
       case "private-browsing-change-granted":
         // Finalize our statements cause the connection will be closed by the
         // service during the private browsing transition.
         gStmt.finalize();
         gStmt = null;
         break;
       case "private-browsing":
         if (aData == "enter" || aData == "exit") {
@@ -510,16 +515,17 @@ let gDownloadObserver = {
           // yet.  Defer this until all private-browsing notifications
           // have been processed.
           setTimeout(function() {
             initStatement();
             buildDownloadList(true);
           }, 0);
         }
         break;
+#endif
       case "browser-lastwindow-close-granted":
 #ifndef XP_MACOSX
         if (gDownloadManager.activeDownloadCount == 0) {
           setTimeout(gCloseDownloadManager, 0);
         }
 #endif
         break;
     }
@@ -1341,20 +1347,22 @@ function updateClearListButton()
 
 function getDownload(aID)
 {
   return document.getElementById("dl" + aID);
 }
 
 /**
  * Initialize the statement which is used to retrieve the list of downloads.
+#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING
  *
  * This function gets called both at startup, and when entering the private
  * browsing mode (because the database connection is changed when entering
  * the private browsing mode, and a new statement should be initialized.
+#endif
  */
 function initStatement()
 {
   if (gStmt)
     gStmt.finalize();
 
   gStmt = gDownloadManager.DBConnection.createStatement(
     "SELECT id, target, name, source, state, startTime, endTime, referrer, " +
--- a/toolkit/mozapps/downloads/content/downloads.xul
+++ b/toolkit/mozapps/downloads/content/downloads.xul
@@ -20,17 +20,20 @@
 %downloadManagerDTD;
 <!ENTITY % editMenuOverlayDTD SYSTEM "chrome://global/locale/editMenuOverlay.dtd">
 %editMenuOverlayDTD;
 ]>
 
 <window xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
         id="downloadManager" windowtype="Download:Manager"
-        orient="vertical" title="&downloads.title;" statictitle="&downloads.title;"
+        orient="vertical" title="&downloads.title;"
+#ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING
+        statictitle="&downloads.title;"
+#endif
         width="&window.width2;" height="&window.height;" screenX="10" screenY="10"
         persist="width height screenX screenY sizemode"
         onload="Startup();" onunload="Shutdown();"
         onclose="return closeWindow(false);">
 
   <script type="application/javascript" src="chrome://mozapps/content/downloads/downloads.js"/>
   <script type="application/javascript" src="chrome://mozapps/content/downloads/DownloadProgressListener.js"/>
   <script type="application/javascript" src="chrome://global/content/contentAreaUtils.js"/>
--- a/toolkit/mozapps/downloads/tests/chrome/Makefile.in
+++ b/toolkit/mozapps/downloads/tests/chrome/Makefile.in
@@ -25,17 +25,16 @@ MOCHITEST_CHROME_FILES = \
   test_multi_select.xul \
   test_multiword_search.xul \
   test_pause_button_state.xul \
   test_removeDownload_updates_ui.xul \
   test_search_clearlist.xul \
   test_search_keys.xul \
   test_select_all.xul \
   test_space_key_pauses_resumes.xul \
-  test_privatebrowsing_title.xul \
   test_ui_stays_open_on_alert_clickback.xul \
   test_unknownContentType_dialog_layout.xul \
   test_bug_412360.xul \
   test_bug_429247.xul \
   test_bug_462172.xul \
   test_close_on_last_window.xul \
   unknownContentType_dialog_layout_data.txt \
   unknownContentType_dialog_layout_data.txt^headers^ \
@@ -51,9 +50,15 @@ endif
 
 ifeq ($(OS_ARCH),WINNT)
 MOCHITEST_CHROME_FILES += \
   test_taskbarprogress_downloadstates.xul \
   $(filter disabled-for-very-frequent-orange--bug-630567, test_taskbarprogress_service.xul) \
   $(NULL)
 endif
 
+ifndef MOZ_PER_WINDOW_PRIVATE_BROWSING
+MOCHITEST_CHROME_FILES += \
+  test_privatebrowsing_title.xul \
+  $(NULL)
+endif
+
 include $(topsrcdir)/config/rules.mk