|
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/. */ |
|
6 |
|
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 |
|
14 //////////////////////////////////////////////////////////////////////////////// |
|
15 //// nsDownloadHistory |
|
16 |
|
17 NS_IMPL_ISUPPORTS(nsDownloadHistory, nsIDownloadHistory) |
|
18 |
|
19 //////////////////////////////////////////////////////////////////////////////// |
|
20 //// nsIDownloadHistory |
|
21 |
|
22 NS_IMETHODIMP |
|
23 nsDownloadHistory::AddDownload(nsIURI *aSource, |
|
24 nsIURI *aReferrer, |
|
25 PRTime aStartTime, |
|
26 nsIURI *aDestination) |
|
27 { |
|
28 NS_ENSURE_ARG_POINTER(aSource); |
|
29 |
|
30 nsCOMPtr<nsIGlobalHistory2> history = |
|
31 do_GetService("@mozilla.org/browser/global-history;2"); |
|
32 if (!history) |
|
33 return NS_ERROR_NOT_AVAILABLE; |
|
34 |
|
35 bool visited; |
|
36 nsresult rv = history->IsVisited(aSource, &visited); |
|
37 NS_ENSURE_SUCCESS(rv, rv); |
|
38 |
|
39 rv = history->AddURI(aSource, false, true, aReferrer); |
|
40 NS_ENSURE_SUCCESS(rv, rv); |
|
41 |
|
42 if (!visited) { |
|
43 nsCOMPtr<nsIObserverService> os = |
|
44 do_GetService("@mozilla.org/observer-service;1"); |
|
45 if (os) |
|
46 os->NotifyObservers(aSource, NS_LINK_VISITED_EVENT_TOPIC, nullptr); |
|
47 } |
|
48 |
|
49 return NS_OK; |
|
50 } |
|
51 |
|
52 NS_IMETHODIMP |
|
53 nsDownloadHistory::RemoveAllDownloads() |
|
54 { |
|
55 return NS_ERROR_NOT_IMPLEMENTED; |
|
56 } |