2015-02-13 22:36:47 +03: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 15:12:37 +04: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 23:20:41 +03:00
|
|
|
|
|
|
|
#include "nsDownloadHistory.h"
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsServiceManagerUtils.h"
|
|
|
|
#include "nsIGlobalHistory2.h"
|
|
|
|
#include "nsIObserverService.h"
|
|
|
|
#include "nsIURI.h"
|
2014-04-29 21:31:06 +04:00
|
|
|
#include "mozilla/Services.h"
|
2007-11-23 23:20:41 +03:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//// nsDownloadHistory
|
|
|
|
|
2014-04-27 11:06:00 +04:00
|
|
|
NS_IMPL_ISUPPORTS(nsDownloadHistory, nsIDownloadHistory)
|
2007-11-23 23:20:41 +03:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//// nsIDownloadHistory
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2015-02-13 22:36:37 +03:00
|
|
|
nsDownloadHistory::AddDownload(nsIURI* aSource,
|
|
|
|
nsIURI* aReferrer,
|
2011-08-16 05:08:48 +04:00
|
|
|
PRTime aStartTime,
|
2015-02-13 22:36:37 +03:00
|
|
|
nsIURI* aDestination)
|
2007-11-23 23:20:41 +03:00
|
|
|
{
|
|
|
|
NS_ENSURE_ARG_POINTER(aSource);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIGlobalHistory2> history =
|
|
|
|
do_GetService("@mozilla.org/browser/global-history;2");
|
2015-02-13 22:36:37 +03:00
|
|
|
if (!history) {
|
2007-11-23 23:20:41 +03:00
|
|
|
return NS_ERROR_NOT_AVAILABLE;
|
2015-02-13 22:36:37 +03:00
|
|
|
}
|
2007-11-23 23:20:41 +03:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool visited;
|
2007-11-23 23:20:41 +03:00
|
|
|
nsresult rv = history->IsVisited(aSource, &visited);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
rv = history->AddURI(aSource, false, true, aReferrer);
|
2007-11-23 23:20:41 +03:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2015-02-13 22:36:37 +03:00
|
|
|
|
2007-11-23 23:20:41 +03:00
|
|
|
if (!visited) {
|
|
|
|
nsCOMPtr<nsIObserverService> os =
|
2014-04-29 21:31:06 +04:00
|
|
|
mozilla::services::GetObserverService();
|
2015-02-13 22:36:37 +03:00
|
|
|
if (os) {
|
2012-07-30 18:20:58 +04:00
|
|
|
os->NotifyObservers(aSource, NS_LINK_VISITED_EVENT_TOPIC, nullptr);
|
2015-02-13 22:36:37 +03:00
|
|
|
}
|
2007-11-23 23:20:41 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2013-01-05 13:21:04 +04:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsDownloadHistory::RemoveAllDownloads()
|
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|