Backed out changesets aed22a2d8353 and c61fe8e1f887 (bug 908006) for OSX reftest...
[gecko.git] / docshell / base / nsDownloadHistory.cpp
blob63d9c6eeb190834a2998b1bc65b12683c9176513
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * vim: sw=2 ts=2 sts=2
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "nsDownloadHistory.h"
8 #include "nsCOMPtr.h"
9 #include "nsServiceManagerUtils.h"
10 #include "nsIGlobalHistory2.h"
11 #include "nsIObserverService.h"
12 #include "nsIURI.h"
13 #include "nsIComponentRegistrar.h"
14 #include "nsDocShellCID.h"
15 #include "nsNetCID.h"
17 ////////////////////////////////////////////////////////////////////////////////
18 //// nsDownloadHistory
20 NS_IMPL_ISUPPORTS1(nsDownloadHistory, nsIDownloadHistory)
22 ////////////////////////////////////////////////////////////////////////////////
23 //// nsIDownloadHistory
25 NS_IMETHODIMP
26 nsDownloadHistory::AddDownload(nsIURI *aSource,
27 nsIURI *aReferrer,
28 PRTime aStartTime,
29 nsIURI *aDestination)
31 NS_ENSURE_ARG_POINTER(aSource);
33 nsCOMPtr<nsIGlobalHistory2> history =
34 do_GetService("@mozilla.org/browser/global-history;2");
35 if (!history)
36 return NS_ERROR_NOT_AVAILABLE;
38 bool visited;
39 nsresult rv = history->IsVisited(aSource, &visited);
40 NS_ENSURE_SUCCESS(rv, rv);
42 rv = history->AddURI(aSource, false, true, aReferrer);
43 NS_ENSURE_SUCCESS(rv, rv);
45 if (!visited) {
46 nsCOMPtr<nsIObserverService> os =
47 do_GetService("@mozilla.org/observer-service;1");
48 if (os)
49 os->NotifyObservers(aSource, NS_LINK_VISITED_EVENT_TOPIC, nullptr);
52 return NS_OK;
55 NS_IMETHODIMP
56 nsDownloadHistory::RemoveAllDownloads()
58 return NS_ERROR_NOT_IMPLEMENTED;