Bug 1419704 - Remove nsIGlobalHistory2 and docshell's nsDownloadHistory as they are redundant. r=mak,bzbarsky
authorMark Banner <standard8@mozilla.com>
Wed, 04 Jul 2018 09:59:45 +0000
changeset 814166 2291d4737e170f01619bb7d7d0419cbb37d33ac7
parent 814165 d090f23cc74045b3783d67bafb1710eb76044a62
child 814167 6aee046a67d42bfb8fd49ad85f8a80d2e57dac52
push id115123
push userjdescottes@mozilla.com
push dateWed, 04 Jul 2018 17:42:29 +0000
reviewersmak, bzbarsky
bugs1419704
milestone63.0a1
Bug 1419704 - Remove nsIGlobalHistory2 and docshell's nsDownloadHistory as they are redundant. r=mak,bzbarsky nsIGlobalHistory2 is not implemented by any mozilla-central nor comm-central applications, and hence can be removed. As a result, nsDownloadHistory's implementation can also be removed. MozReview-Commit-ID: 5bQ2OHsV1Ky Differential Revision: https://phabricator.services.mozilla.com/D1929
docshell/base/moz.build
docshell/base/nsDocShell.cpp
docshell/base/nsDocShell.h
docshell/base/nsDownloadHistory.cpp
docshell/base/nsDownloadHistory.h
docshell/base/nsIGlobalHistory2.idl
docshell/build/nsDocShellModule.cpp
docshell/test/chrome/bug293235_window.xul
docshell/test/unit/test_nsIDownloadHistory.js
docshell/test/unit/xpcshell.ini
toolkit/components/downloads/DownloadCore.jsm
toolkit/components/places/History.cpp
toolkit/components/places/nsNavHistory.h
--- a/docshell/base/moz.build
+++ b/docshell/base/moz.build
@@ -41,17 +41,16 @@ XPIDL_SOURCES += [
     'nsIContentViewer.idl',
     'nsIContentViewerEdit.idl',
     'nsIDocShell.idl',
     'nsIDocShellLoadInfo.idl',
     'nsIDocShellTreeItem.idl',
     'nsIDocShellTreeOwner.idl',
     'nsIDocumentLoaderFactory.idl',
     'nsIDownloadHistory.idl',
-    'nsIGlobalHistory2.idl',
     'nsILoadContext.idl',
     'nsIPrivacyTransitionObserver.idl',
     'nsIReflowObserver.idl',
     'nsIRefreshURI.idl',
     'nsIScrollable.idl',
     'nsITextScroll.idl',
     'nsITooltipListener.idl',
     'nsITooltipTextProvider.idl',
@@ -89,19 +88,16 @@ UNIFIED_SOURCES += [
     'nsDocShellTreeOwner.cpp',
     'nsDSURIContentListener.cpp',
     'nsPingListener.cpp',
     'nsRefreshTimer.cpp',
     'nsWebNavigationInfo.cpp',
     'SerializedLoadContext.cpp',
 ]
 
-if not CONFIG['MOZ_PLACES']:
-    UNIFIED_SOURCES += ['nsDownloadHistory.cpp']
-
 include('/ipc/chromium/chromium-config.mozbuild')
 
 FINAL_LIBRARY = 'xul'
 LOCAL_INCLUDES += [
     '/docshell/shistory',
     '/dom/base',
     '/layout/base',
     '/layout/generic',
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -81,17 +81,16 @@
 #include "nsIDocument.h"
 #include "nsIDocumentLoaderFactory.h"
 #include "nsIDOMStorage.h"
 #include "nsIDOMWindow.h"
 #include "nsIEditingSession.h"
 #include "nsIExternalProtocolService.h"
 #include "nsIFormPOSTActionChannel.h"
 #include "nsIFrame.h"
-#include "nsIGlobalHistory2.h"
 #include "nsIGlobalObject.h"
 #include "nsIHttpChannel.h"
 #include "nsIHttpChannelInternal.h"
 #include "nsIIDNService.h"
 #include "nsIInputStreamChannel.h"
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsIJARChannel.h"
 #include "nsILayoutHistoryState.h"
@@ -3873,37 +3872,23 @@ nsDocShell::AddChildSHEntryToParent(nsIS
   }
 
   return rv;
 }
 
 NS_IMETHODIMP
 nsDocShell::SetUseGlobalHistory(bool aUseGlobalHistory)
 {
-  nsresult rv;
-
   mUseGlobalHistory = aUseGlobalHistory;
-
   if (!aUseGlobalHistory) {
-    mGlobalHistory = nullptr;
-    return NS_OK;
-  }
-
-  // No need to initialize mGlobalHistory if IHistory is available.
+    return NS_OK;
+  }
+
   nsCOMPtr<IHistory> history = services::GetHistoryService();
-  if (history) {
-    return NS_OK;
-  }
-
-  if (mGlobalHistory) {
-    return NS_OK;
-  }
-
-  mGlobalHistory = do_GetService(NS_GLOBALHISTORY2_CONTRACTID, &rv);
-  return rv;
+  return history ? NS_OK : NS_ERROR_FAILURE;
 }
 
 NS_IMETHODIMP
 nsDocShell::GetUseGlobalHistory(bool* aUseGlobalHistory)
 {
   *aUseGlobalHistory = mUseGlobalHistory;
   return NS_OK;
 }
@@ -12529,22 +12514,16 @@ nsDocShell::AddURIVisit(nsIURI* aURI,
     // connection problem.
     else if (aResponseStatus != 408 &&
              ((aResponseStatus >= 400 && aResponseStatus <= 501) ||
               aResponseStatus == 505)) {
       visitURIFlags |= IHistory::UNRECOVERABLE_ERROR;
     }
 
     (void)history->VisitURI(aURI, aPreviousURI, visitURIFlags);
-  } else if (mGlobalHistory) {
-    // Falls back to sync global history interface.
-    (void)mGlobalHistory->AddURI(aURI,
-                                 !!aChannelRedirectFlags,
-                                 !IsFrame(),
-                                 aReferrerURI);
   }
 }
 
 //*****************************************************************************
 // nsDocShell: Helper Routines
 //*****************************************************************************
 
 NS_IMETHODIMP
@@ -13920,18 +13899,16 @@ nsDocShell::HasUnloadedParent()
 
 void
 nsDocShell::UpdateGlobalHistoryTitle(nsIURI* aURI)
 {
   if (mUseGlobalHistory && !UsePrivateBrowsing()) {
     nsCOMPtr<IHistory> history = services::GetHistoryService();
     if (history) {
       history->SetURITitle(aURI, mTitle);
-    } else if (mGlobalHistory) {
-      mGlobalHistory->SetPageTitle(aURI, nsString(mTitle));
     }
   }
 }
 
 bool
 nsDocShell::IsInvisible()
 {
   return mInvisible;
--- a/docshell/base/nsDocShell.h
+++ b/docshell/base/nsDocShell.h
@@ -75,17 +75,16 @@ typedef uint32_t ScreenOrientationIntern
 } // namespace dom
 } // namespace mozilla
 
 class nsICommandManager;
 class nsIContentViewer;
 class nsIController;
 class nsIDocShellTreeOwner;
 class nsIDocument;
-class nsIGlobalHistory2;
 class nsIHttpChannel;
 class nsIMutableArray;
 class nsIPrompt;
 class nsIScrollableFrame;
 class nsISecureBrowserUI;
 class nsISHistory;
 class nsIStringBundle;
 class nsIURIFixup;
@@ -655,18 +654,17 @@ private: // member functions
    * @param aChannelRedirectFlags
    *        The nsIChannelEventSink redirect flags to save for later
    */
   void SaveLastVisit(nsIChannel* aChannel,
                      nsIURI* aURI,
                      uint32_t aChannelRedirectFlags);
 
   /**
-   * Helper function for adding a URI visit using IHistory. If IHistory is
-   * not available, the method tries nsIGlobalHistory2.
+   * Helper function for adding a URI visit using IHistory.
    *
    * The IHistory API maintains chains of visits, tracking both HTTP referrers
    * and redirects for a user session. VisitURI requires the current URI and
    * the previous URI in the chain.
    *
    * Visits can be saved either during a redirect or when the request has
    * reached its final destination. The previous URI in the visit may be
    * from another redirect or it may be the referrer.
@@ -923,17 +921,16 @@ private: // data members
   nsCOMPtr<nsIPrincipal> mParentCharsetPrincipal;
   nsCOMPtr<nsILoadURIDelegate> mLoadURIDelegate;
   nsCOMPtr<nsIMutableArray> mRefreshURIList;
   nsCOMPtr<nsIMutableArray> mSavedRefreshURIList;
   nsCOMPtr<nsIDOMStorageManager> mSessionStorageManager;
   nsCOMPtr<nsIContentViewer> mContentViewer;
   nsCOMPtr<nsIWidget> mParentWidget;
   RefPtr<mozilla::dom::ChildSHistory> mSessionHistory;
-  nsCOMPtr<nsIGlobalHistory2> mGlobalHistory;
   nsCOMPtr<nsIWebBrowserFind> mFind;
   nsCOMPtr<nsICommandManager> mCommandManager;
 
   // Dimensions of the docshell
   nsIntRect mBounds;
 
   /**
    * Content-Type Hint of the most-recently initiated load. Used for
deleted file mode 100644
--- a/docshell/base/nsDownloadHistory.cpp
+++ /dev/null
@@ -1,52 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#include "nsDownloadHistory.h"
-#include "nsCOMPtr.h"
-#include "nsServiceManagerUtils.h"
-#include "nsIGlobalHistory2.h"
-#include "nsIObserverService.h"
-#include "nsIURI.h"
-#include "mozilla/Services.h"
-
-NS_IMPL_ISUPPORTS(nsDownloadHistory, nsIDownloadHistory)
-
-NS_IMETHODIMP
-nsDownloadHistory::AddDownload(nsIURI* aSource,
-                               nsIURI* aReferrer,
-                               PRTime aStartTime,
-                               nsIURI* aDestination)
-{
-  NS_ENSURE_ARG_POINTER(aSource);
-
-  nsCOMPtr<nsIGlobalHistory2> history =
-    do_GetService("@mozilla.org/browser/global-history;2");
-  if (!history) {
-    return NS_ERROR_NOT_AVAILABLE;
-  }
-
-  bool visited;
-  nsresult rv = history->IsVisited(aSource, &visited);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  rv = history->AddURI(aSource, false, true, aReferrer);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  if (!visited) {
-    nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
-    if (os) {
-      os->NotifyObservers(aSource, NS_LINK_VISITED_EVENT_TOPIC, nullptr);
-    }
-  }
-
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsDownloadHistory::RemoveAllDownloads()
-{
-  return NS_ERROR_NOT_IMPLEMENTED;
-}
deleted file mode 100644
--- a/docshell/base/nsDownloadHistory.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* vim: set ts=8 sts=2 et sw=2 tw=80: */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-#ifndef __nsDownloadHistory_h__
-#define __nsDownloadHistory_h__
-
-#include "nsIDownloadHistory.h"
-#include "mozilla/Attributes.h"
-
-#define NS_DOWNLOADHISTORY_CID \
-  {0x2ee83680, 0x2af0, 0x4bcb, {0xbf, 0xa0, 0xc9, 0x70, 0x5f, 0x65, 0x54, 0xf1}}
-
-class nsDownloadHistory final : public nsIDownloadHistory
-{
-public:
-  NS_DECL_ISUPPORTS
-  NS_DECL_NSIDOWNLOADHISTORY
-
-  NS_DEFINE_STATIC_CID_ACCESSOR(NS_DOWNLOADHISTORY_CID)
-
-private:
-  ~nsDownloadHistory() {}
-};
-
-#endif // __nsDownloadHistory_h__
deleted file mode 100644
--- a/docshell/base/nsIGlobalHistory2.idl
+++ /dev/null
@@ -1,59 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-/**
- * Provides information about global history to gecko. 
- *
- * @note  This interface replaces and deprecates nsIGlobalHistory.
- */
-
-#include "nsISupports.idl"
-interface nsIURI;
-
-%{ C++
-
-// nsIObserver topic to fire when you add new visited URIs to the history;
-// the nsIURI is the subject
-#define NS_LINK_VISITED_EVENT_TOPIC "link-visited"
-
-%}
-
-[scriptable, uuid(cf777d42-1270-4b34-be7b-2931c93feda5)]
-interface nsIGlobalHistory2 : nsISupports
-{
-    /**
-     * Add a URI to global history
-     *
-     * @param aURI      the URI of the page
-     * @param aRedirect whether the URI was redirected to another location;
-     *                  this is 'true' for the original URI which is
-     *                  redirected.
-     * @param aToplevel whether the URI is loaded in a top-level window
-     * @param aReferrer the URI of the referring page
-     *
-     * @note  Docshell will not filter out URI schemes like chrome: data:
-     *        about: and view-source:.  Embedders should consider filtering out
-     *        these schemes and others, e.g. mailbox: for the main URI and the
-     *        referrer.
-     */
-    void addURI(in nsIURI aURI, in boolean aRedirect, in boolean aToplevel, in nsIURI aReferrer);
-
-    /**
-     * Checks to see whether the given URI is in history.
-     *
-     * @param aURI the uri to the page
-     * @return true if a URI has been visited
-     */
-    boolean isVisited(in nsIURI aURI);
-
-    /**
-     * Set the page title for the given uri. URIs that are not already in
-     * global history will not be added.
-     *
-     * @param aURI    the URI for which to set to the title
-     * @param aTitle  the page title
-     */
-    void setPageTitle(in nsIURI aURI, in AString aTitle);
-};
--- a/docshell/build/nsDocShellModule.cpp
+++ b/docshell/build/nsDocShellModule.cpp
@@ -31,22 +31,16 @@
 #endif
 
 // session history
 #include "nsSHEntry.h"
 #include "nsSHEntryShared.h"
 #include "nsSHistory.h"
 #include "nsSHTransaction.h"
 
-#ifndef MOZ_PLACES
-// download history
-#include "nsDownloadHistory.h"
-#endif
-
-
 // LoadContexts (used for testing)
 #include "LoadContext.h"
 
 using mozilla::dom::ContentHandlerService;
 
 static bool gInitialized = false;
 
 // The one time initialization for this module
@@ -96,21 +90,16 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsExterna
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsExternalURLHandlerService)
 #endif
 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(ContentHandlerService, Init)
 
 // session history
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsSHEntry)
 NS_GENERIC_FACTORY_CONSTRUCTOR(nsSHTransaction)
 
-#ifndef MOZ_PLACES
-// download history
-NS_GENERIC_FACTORY_CONSTRUCTOR(nsDownloadHistory)
-#endif
-
 NS_DEFINE_NAMED_CID(NS_DOCSHELL_CID);
 NS_DEFINE_NAMED_CID(NS_DEFAULTURIFIXUP_CID);
 NS_DEFINE_NAMED_CID(NS_WEBNAVIGATION_INFO_CID);
 NS_DEFINE_NAMED_CID(NS_ABOUT_REDIRECTOR_MODULE_CID);
 NS_DEFINE_NAMED_CID(NS_URI_LOADER_CID);
 NS_DEFINE_NAMED_CID(NS_DOCUMENTLOADER_SERVICE_CID);
 NS_DEFINE_NAMED_CID(NS_EXTERNALHELPERAPPSERVICE_CID);
 NS_DEFINE_NAMED_CID(NS_EXTERNALPROTOCOLHANDLER_CID);
@@ -122,19 +111,16 @@ NS_DEFINE_NAMED_CID(NS_LOCALHANDLERAPP_C
 NS_DEFINE_NAMED_CID(NS_DBUSHANDLERAPP_CID);
 #endif
 #if defined(MOZ_WIDGET_ANDROID)
 NS_DEFINE_NAMED_CID(NS_EXTERNALSHARINGAPPSERVICE_CID);
 NS_DEFINE_NAMED_CID(NS_EXTERNALURLHANDLERSERVICE_CID);
 #endif
 NS_DEFINE_NAMED_CID(NS_SHENTRY_CID);
 NS_DEFINE_NAMED_CID(NS_SHTRANSACTION_CID);
-#ifndef MOZ_PLACES
-NS_DEFINE_NAMED_CID(NS_DOWNLOADHISTORY_CID);
-#endif
 NS_DEFINE_NAMED_CID(NS_CONTENTHANDLERSERVICE_CID);
 NS_DEFINE_NAMED_CID(NS_LOADCONTEXT_CID);
 NS_DEFINE_NAMED_CID(NS_PRIVATELOADCONTEXT_CID);
 
 const mozilla::Module::CIDEntry kDocShellCIDs[] = {
   { &kNS_DOCSHELL_CID, false, nullptr, nsDocShellConstructor },
   { &kNS_DEFAULTURIFIXUP_CID, false, nullptr, nsDefaultURIFixupConstructor },
   { &kNS_WEBNAVIGATION_INFO_CID, false, nullptr, nsWebNavigationInfoConstructor },
@@ -153,19 +139,16 @@ const mozilla::Module::CIDEntry kDocShel
   { &kNS_DBUSHANDLERAPP_CID, false, nullptr, nsDBusHandlerAppConstructor },
 #endif
 #if defined(MOZ_WIDGET_ANDROID)
   { &kNS_EXTERNALSHARINGAPPSERVICE_CID, false, nullptr, nsExternalSharingAppServiceConstructor },
   { &kNS_EXTERNALURLHANDLERSERVICE_CID, false, nullptr, nsExternalURLHandlerServiceConstructor },
 #endif
   { &kNS_SHENTRY_CID, false, nullptr, nsSHEntryConstructor },
   { &kNS_SHTRANSACTION_CID, false, nullptr, nsSHTransactionConstructor },
-#ifndef MOZ_PLACES
-  { &kNS_DOWNLOADHISTORY_CID, false, nullptr, nsDownloadHistoryConstructor },
-#endif
   { &kNS_LOADCONTEXT_CID, false, nullptr, mozilla::CreateTestLoadContext },
   { &kNS_PRIVATELOADCONTEXT_CID, false, nullptr, mozilla::CreatePrivateTestLoadContext },
   { nullptr }
 };
 
 const mozilla::Module::ContractIDEntry kDocShellContracts[] = {
   { "@mozilla.org/docshell;1", &kNS_DOCSHELL_CID },
   { NS_URIFIXUP_CONTRACTID, &kNS_DEFAULTURIFIXUP_CID },
@@ -214,19 +197,16 @@ const mozilla::Module::ContractIDEntry k
   { NS_DBUSHANDLERAPP_CONTRACTID, &kNS_DBUSHANDLERAPP_CID },
 #endif
 #if defined(MOZ_WIDGET_ANDROID)
   { NS_EXTERNALSHARINGAPPSERVICE_CONTRACTID, &kNS_EXTERNALSHARINGAPPSERVICE_CID },
   { NS_EXTERNALURLHANDLERSERVICE_CONTRACTID, &kNS_EXTERNALURLHANDLERSERVICE_CID },
 #endif
   { NS_SHENTRY_CONTRACTID, &kNS_SHENTRY_CID },
   { NS_SHTRANSACTION_CONTRACTID, &kNS_SHTRANSACTION_CID },
-#ifndef MOZ_PLACES
-  { NS_DOWNLOADHISTORY_CONTRACTID, &kNS_DOWNLOADHISTORY_CID },
-#endif
   { NS_LOADCONTEXT_CONTRACTID, &kNS_LOADCONTEXT_CID },
   { NS_PRIVATELOADCONTEXT_CONTRACTID, &kNS_PRIVATELOADCONTEXT_CID },
   { nullptr }
 };
 
 static const mozilla::Module kDocShellModule = {
   mozilla::Module::kVersion,
   kDocShellCIDs,
--- a/docshell/test/chrome/bug293235_window.xul
+++ b/docshell/test/chrome/bug293235_window.xul
@@ -121,17 +121,17 @@
         uri: getHttpUrl("bug293235_p2.html"),
         onNavComplete: function() {
           observedPageShow = true;
           maybeRunNextTest();
         }
       });
       yield undefined;
 
-      // And the nodes get notified after the "link-visited" topic, so
+      // And the nodes get notified after the "uri-visit-saved" topic, so
       // we need to execute soon...
       SimpleTest.executeSoon(nextTest);
       yield undefined;
 
       // Go back, verify the original page was loaded from the bfcache,
       // and verify that the link is now purple, per the
       // :visited style.
       doPageNavigation({
deleted file mode 100644
--- a/docshell/test/unit/test_nsIDownloadHistory.js
+++ /dev/null
@@ -1,68 +0,0 @@
-/* This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-
-const NS_DOWNLOADHISTORY_CID = "{2ee83680-2af0-4bcb-bfa0-c9705f6554f1}";
-
-ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
-
-XPCOMUtils.defineLazyGetter(this, "Services", function() {
-  ChromeUtils.import("resource://gre/modules/Services.jsm");
-  return Services;
-});
-
-function testLinkVistedObserver()
-{
-  const NS_LINK_VISITED_EVENT_TOPIC = "link-visited";
-  var ios = Cc["@mozilla.org/network/io-service;1"].
-            getService(Ci.nsIIOService);
-  var testURI = ios.newURI("http://google.com/");
-
-  var gh = Cc["@mozilla.org/browser/global-history;2"].
-           getService(Ci.nsIGlobalHistory2);
-  Assert.ok(!gh.isVisited(testURI));
-
-  var topicReceived = false;
-  var obs = {
-    observe: function tlvo_observe(aSubject, aTopic, aData)
-    {
-      if (NS_LINK_VISITED_EVENT_TOPIC == aTopic) {
-        Assert.equal(testURI, aSubject);
-        topicReceived = true;
-      }
-    }
-  };
-
-  var os = Cc["@mozilla.org/observer-service;1"].
-           getService(Ci.nsIObserverService);
-  os.addObserver(obs, NS_LINK_VISITED_EVENT_TOPIC);
-
-  var dh = Components.classesByID[NS_DOWNLOADHISTORY_CID].
-           getService(Ci.nsIDownloadHistory);
-  dh.addDownload(testURI);
-  Assert.ok(topicReceived);
-  Assert.ok(gh.isVisited(testURI));
-}
-
-var tests = [testLinkVistedObserver];
-
-function run_test()
-{
-  // Not everyone uses/defines an nsGlobalHistory* service. Especially if
-  // MOZ_PLACES is not defined. If getService fails, then abort gracefully.
-  try {
-    Cc["@mozilla.org/browser/global-history;2"].
-      getService(Ci.nsIGlobalHistory2);
-  }
-  catch (ex) {
-    return;
-  }
-
-  // Needed to properly setup and shutdown the profile.
-  do_get_profile();
-
-  for (var i = 0; i < tests.length; i++)
-    tests[i]();
-
-  cleanup();
-}
--- a/docshell/test/unit/xpcshell.ini
+++ b/docshell/test/unit/xpcshell.ini
@@ -2,14 +2,13 @@
 head = head_docshell.js
 
 [test_bug442584.js]
 [test_nsDefaultURIFixup.js]
 [test_nsDefaultURIFixup_search.js]
 skip-if = os == 'android'
 [test_nsDefaultURIFixup_info.js]
 skip-if = os == 'android'
-[test_nsIDownloadHistory.js]
 [test_pb_notification.js]
 # Bug 751575: unrelated JS changes cause timeouts on random platforms
 skip-if = true
 [test_privacy_transition.js]
 [test_setUsePrivateBrowsing.js]
--- a/toolkit/components/downloads/DownloadCore.jsm
+++ b/toolkit/components/downloads/DownloadCore.jsm
@@ -1726,29 +1726,31 @@ this.DownloadSaver.prototype = {
     let referrer = this.download.source.referrer;
     let referrerUri = referrer ? NetUtil.newURI(referrer) : null;
     let targetUri = NetUtil.newURI(new FileUtils.File(
                                        this.download.target.path));
 
     // The start time is always available when we reach this point.
     let startPRTime = this.download.startTime.getTime() * 1000;
 
-    try {
-      gDownloadHistory.addDownload(sourceUri, referrerUri, startPRTime,
-                                   targetUri);
-    } catch (ex) {
-      if (!(ex instanceof Components.Exception) ||
-          ex.result != Cr.NS_ERROR_NOT_AVAILABLE) {
-        throw ex;
+    if ("@mozilla.org/browser/download-history;1" in Cc) {
+      try {
+        gDownloadHistory.addDownload(sourceUri, referrerUri, startPRTime,
+                                     targetUri);
+      } catch (ex) {
+        if (!(ex instanceof Components.Exception) ||
+            ex.result != Cr.NS_ERROR_NOT_AVAILABLE) {
+          throw ex;
+        }
+        //
+        // Under normal operation the download history service may not
+        // be available. We don't want all downloads that are public to fail
+        // when this happens so we'll ignore this error and this error only!
+        //
       }
-      //
-      // Under normal operation the download history service may not
-      // be available. We don't want all downloads that are public to fail
-      // when this happens so we'll ignore this error and this error only!
-      //
     }
   },
 
   /**
    * Returns a static representation of the current object state.
    *
    * @return A JavaScript object that can be serialized to JSON.
    */
--- a/toolkit/components/places/History.cpp
+++ b/toolkit/components/places/History.cpp
@@ -2758,23 +2758,16 @@ History::VisitURI(nsIURI* aURI,
   else {
     mozIStorageConnection* dbConn = GetDBConn();
     NS_ENSURE_STATE(dbConn);
 
     rv = InsertVisitedURIs::Start(dbConn, placeArray);
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
-  // Finally, notify that we've been visited.
-  nsCOMPtr<nsIObserverService> obsService =
-    mozilla::services::GetObserverService();
-  if (obsService) {
-    obsService->NotifyObservers(aURI, NS_LINK_VISITED_EVENT_TOPIC, nullptr);
-  }
-
   return NS_OK;
 }
 
 NS_IMETHODIMP
 History::RegisterVisitedCallback(nsIURI* aURI,
                                  Link* aLink)
 {
   MOZ_ASSERT(NS_IsMainThread());
@@ -2983,23 +2976,16 @@ History::AddDownload(nsIURI* aSource, ns
   if (aDestination) {
     callback = new nsMainThreadPtrHolder<mozIVisitInfoCallback>(
       "mozIVisitInfoCallback", new SetDownloadAnnotations(aDestination));
   }
 
   rv = InsertVisitedURIs::Start(dbConn, placeArray, callback);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  // Finally, notify that we've been visited.
-  nsCOMPtr<nsIObserverService> obsService =
-    mozilla::services::GetObserverService();
-  if (obsService) {
-    obsService->NotifyObservers(aSource, NS_LINK_VISITED_EVENT_TOPIC, nullptr);
-  }
-
   return NS_OK;
 }
 
 NS_IMETHODIMP
 History::RemoveAllDownloads()
 {
   MOZ_ASSERT(NS_IsMainThread());
 
--- a/toolkit/components/places/nsNavHistory.h
+++ b/toolkit/components/places/nsNavHistory.h
@@ -4,17 +4,16 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef nsNavHistory_h_
 #define nsNavHistory_h_
 
 #include "nsINavHistoryService.h"
 #include "nsINavBookmarksService.h"
 #include "nsIFaviconService.h"
-#include "nsIGlobalHistory2.h"
 
 #include "nsIObserverService.h"
 #include "nsICollation.h"
 #include "nsIStringBundle.h"
 #include "nsITimer.h"
 #include "nsMaybeWeakPtr.h"
 #include "nsCategoryCache.h"
 #include "nsNetCID.h"