From a65887afc984102f81c8e2bda15a442dc05a71c3 Mon Sep 17 00:00:00 2001 From: "roc+%cs.cmu.edu" Date: Tue, 23 Aug 2005 22:26:10 +0000 Subject: [PATCH] Bug 304434. Update link :visited status for URIs downloaded to helper apps. r+sr=dbaron git-svn-id: svn://10.0.0.236/trunk@178746 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/content/base/public/nsIDocument.h | 2 -- mozilla/docshell/base/nsIGlobalHistory2.idl | 8 ++++++++ mozilla/layout/base/nsPresShell.cpp | 1 + .../exthandler/nsExternalHelperAppService.cpp | 12 ++++++++++++ 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/mozilla/content/base/public/nsIDocument.h b/mozilla/content/base/public/nsIDocument.h index 3f56121707e..b76c489c021 100644 --- a/mozilla/content/base/public/nsIDocument.h +++ b/mozilla/content/base/public/nsIDocument.h @@ -106,8 +106,6 @@ class nsILayoutHistoryState; // Flag for AddStyleSheet(). #define NS_STYLESHEET_FROM_CATALOG (1 << 0) -#define NS_LINK_VISITED_EVENT_TOPIC "link-visited" - //---------------------------------------------------------------------- // Document interface diff --git a/mozilla/docshell/base/nsIGlobalHistory2.idl b/mozilla/docshell/base/nsIGlobalHistory2.idl index 89847b9b398..c2cca33b4b5 100644 --- a/mozilla/docshell/base/nsIGlobalHistory2.idl +++ b/mozilla/docshell/base/nsIGlobalHistory2.idl @@ -45,6 +45,14 @@ #include "nsISupports.idl" interface nsIURI; +%{ C++ + +// nsIObserver topic to fire when you add new visited URIs to the history; +// the nsIURI is the subject +#define NS_LINK_VISITED_EVENT_TOPIC "link-visited" + +%} + [scriptable, uuid(cf777d42-1270-4b34-be7b-2931c93feda5)] interface nsIGlobalHistory2 : nsISupports { diff --git a/mozilla/layout/base/nsPresShell.cpp b/mozilla/layout/base/nsPresShell.cpp index 1662c4ab065..518de479c6a 100644 --- a/mozilla/layout/base/nsPresShell.cpp +++ b/mozilla/layout/base/nsPresShell.cpp @@ -139,6 +139,7 @@ #include "nsSpaceManager.h" #include "prenv.h" #include "nsIAttribute.h" +#include "nsIGlobalHistory2.h" #ifdef MOZ_REFLOW_PERF_DSP #include "nsIRenderingContext.h" diff --git a/mozilla/uriloader/exthandler/nsExternalHelperAppService.cpp b/mozilla/uriloader/exthandler/nsExternalHelperAppService.cpp index e2fdc97ba3e..0b291c02905 100644 --- a/mozilla/uriloader/exthandler/nsExternalHelperAppService.cpp +++ b/mozilla/uriloader/exthandler/nsExternalHelperAppService.cpp @@ -106,6 +106,7 @@ #include "nsIWindowWatcher.h" #include "nsIGlobalHistory.h" // to mark downloads as visited +#include "nsIGlobalHistory2.h" // to mark downloads as visited #include "nsCRT.h" @@ -1785,7 +1786,18 @@ NS_IMETHODIMP nsExternalAppHandler::OnStartRequest(nsIRequest *request, nsISuppo mSourceUrl->GetSpec(spec); if (history && !spec.IsEmpty()) { + PRBool visited; + rv = history->IsVisited(spec.get(), &visited); + if (NS_FAILED(rv)) + return rv; history->AddPage(spec.get()); + if (!visited) { + nsCOMPtr obsService = + do_GetService("@mozilla.org/observer-service;1"); + if (obsService) { + obsService->NotifyObservers(mSourceUrl, NS_LINK_VISITED_EVENT_TOPIC, nsnull); + } + } } return NS_OK;