michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- michael@0: * vim: sw=2 ts=2 sts=2 michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "nsDownloadHistory.h" michael@0: #include "nsCOMPtr.h" michael@0: #include "nsServiceManagerUtils.h" michael@0: #include "nsIGlobalHistory2.h" michael@0: #include "nsIObserverService.h" michael@0: #include "nsIURI.h" michael@0: michael@0: //////////////////////////////////////////////////////////////////////////////// michael@0: //// nsDownloadHistory michael@0: michael@0: NS_IMPL_ISUPPORTS(nsDownloadHistory, nsIDownloadHistory) michael@0: michael@0: //////////////////////////////////////////////////////////////////////////////// michael@0: //// nsIDownloadHistory michael@0: michael@0: NS_IMETHODIMP michael@0: nsDownloadHistory::AddDownload(nsIURI *aSource, michael@0: nsIURI *aReferrer, michael@0: PRTime aStartTime, michael@0: nsIURI *aDestination) michael@0: { michael@0: NS_ENSURE_ARG_POINTER(aSource); michael@0: michael@0: nsCOMPtr history = michael@0: do_GetService("@mozilla.org/browser/global-history;2"); michael@0: if (!history) michael@0: return NS_ERROR_NOT_AVAILABLE; michael@0: michael@0: bool visited; michael@0: nsresult rv = history->IsVisited(aSource, &visited); michael@0: NS_ENSURE_SUCCESS(rv, rv); michael@0: michael@0: rv = history->AddURI(aSource, false, true, aReferrer); michael@0: NS_ENSURE_SUCCESS(rv, rv); michael@0: michael@0: if (!visited) { michael@0: nsCOMPtr os = michael@0: do_GetService("@mozilla.org/observer-service;1"); michael@0: if (os) michael@0: os->NotifyObservers(aSource, NS_LINK_VISITED_EVENT_TOPIC, nullptr); michael@0: } michael@0: michael@0: return NS_OK; michael@0: } michael@0: michael@0: NS_IMETHODIMP michael@0: nsDownloadHistory::RemoveAllDownloads() michael@0: { michael@0: return NS_ERROR_NOT_IMPLEMENTED; michael@0: }