зеркало из https://github.com/mozilla/gecko-dev.git
Add support for updating a bookmark's "Last Visited" date when its URL is loaded.
This commit is contained in:
Родитель
76b19c9c12
Коммит
73a1e1b8aa
|
@ -665,6 +665,10 @@
|
|||
if ((shortcutURL != null) && (shortcutURL != "")) {
|
||||
document.getElementById('urlbar').value = shortcutURL;
|
||||
}
|
||||
|
||||
// if the URL is bookmarked, update its "Last Visited" date
|
||||
bmks.UpdateBookmarkLastVisitedDate(document.getElementById('urlbar').value);
|
||||
|
||||
}
|
||||
catch (ex) {
|
||||
// stifle any exceptions so we're sure to load the URL.
|
||||
|
|
|
@ -665,6 +665,10 @@
|
|||
if ((shortcutURL != null) && (shortcutURL != "")) {
|
||||
document.getElementById('urlbar').value = shortcutURL;
|
||||
}
|
||||
|
||||
// if the URL is bookmarked, update its "Last Visited" date
|
||||
bmks.UpdateBookmarkLastVisitedDate(document.getElementById('urlbar').value);
|
||||
|
||||
}
|
||||
catch (ex) {
|
||||
// stifle any exceptions so we're sure to load the URL.
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
interface nsIBookmarksService : nsISupports
|
||||
{
|
||||
void AddBookmark(in string aURI, in wstring aTitle);
|
||||
void UpdateBookmarkLastVisitedDate(in string aURL);
|
||||
string FindShortcut(in wstring aName);
|
||||
};
|
||||
|
||||
|
|
|
@ -951,6 +951,7 @@ public:
|
|||
// nsIRDFDataSource
|
||||
NS_IMETHOD AddBookmark(const char *aURI, const PRUnichar *aOptionalTitle);
|
||||
NS_IMETHOD FindShortcut(const PRUnichar *aUserInput, char **aShortcutURL);
|
||||
NS_IMETHOD UpdateBookmarkLastVisitedDate(const char *uri);
|
||||
|
||||
NS_IMETHOD GetURI(char* *uri);
|
||||
|
||||
|
@ -1213,6 +1214,51 @@ nsBookmarksService::AddBookmark(const char *aURI, const PRUnichar *aOptionalTitl
|
|||
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBookmarksService::UpdateBookmarkLastVisitedDate(const char *aURL)
|
||||
{
|
||||
nsCOMPtr<nsIRDFResource> bookmark;
|
||||
nsresult rv;
|
||||
|
||||
if (NS_SUCCEEDED(rv = gRDF->GetResource(aURL, getter_AddRefs(bookmark) )))
|
||||
{
|
||||
PRBool isBookmark = PR_FALSE;
|
||||
|
||||
// Note: always use mInner!! Otherwise, could get into an infinite loop
|
||||
// due to Assert/Change calling UpdateBookmarkLastModifiedDate()
|
||||
|
||||
if (NS_SUCCEEDED(rv = mInner->HasAssertion(bookmark, kRDF_type, kNC_Bookmark,
|
||||
PR_TRUE, &isBookmark)) && (isBookmark == PR_TRUE))
|
||||
{
|
||||
nsCOMPtr<nsIRDFDate> now;
|
||||
|
||||
if (NS_SUCCEEDED(rv = gRDF->GetDateLiteral(PR_Now(), getter_AddRefs(now))))
|
||||
{
|
||||
nsCOMPtr<nsIRDFNode> lastMod;
|
||||
|
||||
if (NS_SUCCEEDED(rv = mInner->GetTarget(bookmark, kWEB_LastVisitDate, PR_TRUE,
|
||||
getter_AddRefs(lastMod))) && (rv != NS_RDF_NO_VALUE))
|
||||
{
|
||||
rv = mInner->Change(bookmark, kWEB_LastVisitDate, lastMod, now);
|
||||
}
|
||||
else
|
||||
{
|
||||
rv = mInner->Assert(bookmark, kWEB_LastVisitDate, now, PR_TRUE);
|
||||
}
|
||||
|
||||
// XXX For the moment, do an immediate flush.
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
Flush();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return(rv);
|
||||
}
|
||||
|
||||
|
||||
|
||||
nsresult
|
||||
nsBookmarksService::UpdateBookmarkLastModifiedDate(nsIRDFResource *aSource)
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче