2015-02-13 11:36:47 -08:00
|
|
|
/* -*- 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
|
2012-05-21 04:12:37 -07:00
|
|
|
* 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"
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//// nsDownloadHistory
|
|
|
|
|
2014-04-27 00:06:00 -07:00
|
|
|
NS_IMPL_ISUPPORTS(nsDownloadHistory, nsIDownloadHistory)
|
2007-11-23 12:20:41 -08:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//// nsIDownloadHistory
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2015-02-13 11:36:37 -08:00
|
|
|
nsDownloadHistory::AddDownload(nsIURI* aSource,
|
|
|
|
nsIURI* aReferrer,
|
2011-08-15 18:08:48 -07:00
|
|
|
PRTime aStartTime,
|
2015-02-13 11:36:37 -08:00
|
|
|
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");
|
2015-02-13 11:36:37 -08:00
|
|
|
if (!history) {
|
2007-11-23 12:20:41 -08:00
|
|
|
return NS_ERROR_NOT_AVAILABLE;
|
2015-02-13 11:36:37 -08:00
|
|
|
}
|
2007-11-23 12:20:41 -08:00
|
|
|
|
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);
|
2015-02-13 11:36:37 -08:00
|
|
|
|
2007-11-23 12:20:41 -08:00
|
|
|
if (!visited) {
|
|
|
|
nsCOMPtr<nsIObserverService> os =
|
|
|
|
do_GetService("@mozilla.org/observer-service;1");
|
2015-02-13 11:36:37 -08:00
|
|
|
if (os) {
|
2012-07-30 07:20:58 -07:00
|
|
|
os->NotifyObservers(aSource, NS_LINK_VISITED_EVENT_TOPIC, nullptr);
|
2015-02-13 11:36:37 -08:00
|
|
|
}
|
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;
|
|
|
|
}
|