2007-11-23 12:20:41 -08:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
* vim: sw=2 ts=2 sts=2
|
2012-05-21 04:12:37 -07:00
|
|
|
* 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/. */
|
2007-11-23 12:20:41 -08:00
|
|
|
|
|
|
|
#include "nsDownloadHistory.h"
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsServiceManagerUtils.h"
|
|
|
|
#include "nsIGlobalHistory2.h"
|
|
|
|
#include "nsIObserverService.h"
|
|
|
|
#include "nsIURI.h"
|
2007-11-30 23:18:43 -08:00
|
|
|
#include "nsIComponentRegistrar.h"
|
|
|
|
#include "nsDocShellCID.h"
|
2012-02-17 22:40:10 -08:00
|
|
|
#include "nsNetCID.h"
|
2007-11-23 12:20:41 -08:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//// nsDownloadHistory
|
|
|
|
|
|
|
|
NS_IMPL_ISUPPORTS1(nsDownloadHistory, nsIDownloadHistory)
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//// nsIDownloadHistory
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDownloadHistory::AddDownload(nsIURI *aSource,
|
|
|
|
nsIURI *aReferrer,
|
2011-08-15 18:08:48 -07:00
|
|
|
PRTime aStartTime,
|
|
|
|
nsIURI *aDestination)
|
2007-11-23 12:20:41 -08:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aSource);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIGlobalHistory2> history =
|
|
|
|
do_GetService("@mozilla.org/browser/global-history;2");
|
|
|
|
if (!history)
|
|
|
|
return NS_ERROR_NOT_AVAILABLE;
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool visited;
|
2007-11-23 12:20:41 -08:00
|
|
|
nsresult rv = history->IsVisited(aSource, &visited);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2011-10-17 07:59:28 -07:00
|
|
|
rv = history->AddURI(aSource, false, true, aReferrer);
|
2007-11-23 12:20:41 -08:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
if (!visited) {
|
|
|
|
nsCOMPtr<nsIObserverService> os =
|
|
|
|
do_GetService("@mozilla.org/observer-service;1");
|
|
|
|
if (os)
|
2012-07-30 07:20:58 -07:00
|
|
|
os->NotifyObservers(aSource, NS_LINK_VISITED_EVENT_TOPIC, nullptr);
|
2007-11-23 12:20:41 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2013-01-05 01:21:04 -08:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDownloadHistory::RemoveAllDownloads()
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|