diff options
Diffstat (limited to 'embed/mozilla')
-rw-r--r-- | embed/mozilla/EphyHeaderSniffer.cpp | 43 | ||||
-rw-r--r-- | embed/mozilla/EphyHeaderSniffer.h | 7 |
2 files changed, 48 insertions, 2 deletions
diff --git a/embed/mozilla/EphyHeaderSniffer.cpp b/embed/mozilla/EphyHeaderSniffer.cpp index fe0e6ac4a..78135fe35 100644 --- a/embed/mozilla/EphyHeaderSniffer.cpp +++ b/embed/mozilla/EphyHeaderSniffer.cpp @@ -40,6 +40,7 @@ #include "EphyHeaderSniffer.h" #include "netCore.h" +#include "nsReadableUtils.h" #include "nsIChannel.h" #include "nsIHttpChannel.h" #include "nsIURL.h" @@ -64,13 +65,14 @@ EphyHeaderSniffer::EphyHeaderSniffer(nsIWebBrowserPersist* aPersist, MozillaEmbe , mDefaultFilename(aSuggestedFilename) , mBypassCache(aBypassCache) { + mPrompt = do_GetService("@mozilla.org/embedcomp/prompt-service;1"); } EphyHeaderSniffer::~EphyHeaderSniffer() { } -NS_IMPL_ISUPPORTS1(EphyHeaderSniffer, nsIWebProgressListener) +NS_IMPL_ISUPPORTS2(EphyHeaderSniffer, nsIWebProgressListener, nsIAuthPrompt) // Implementation of nsIWebProgressListener /* void onStateChange (in nsIWebProgress aWebProgress, in nsIRequest aRequest, in long aStateFlags, in unsigned long aStatus); */ @@ -250,3 +252,42 @@ nsresult EphyHeaderSniffer::InitiateDownload(nsISupports* inSourceData, nsILocal return rv; } + +NS_IMETHODIMP EphyHeaderSniffer::Prompt (const PRUnichar *dialogTitle, const PRUnichar *text, + const PRUnichar *passwordRealm, PRUint32 savePassword, + const PRUnichar *defaultText, PRUnichar **result, PRBool *_retval) +{ + PRBool checkValue; + + if (defaultText) *result = ToNewUnicode(nsDependentString(defaultText)); + checkValue = savePassword; + + return mPrompt->Prompt (nsnull, dialogTitle, text, result, + passwordRealm, &checkValue, _retval); +} + +NS_IMETHODIMP EphyHeaderSniffer::PromptUsernameAndPassword (const PRUnichar *dialogTitle, const PRUnichar *text, + const PRUnichar *passwordRealm, PRUint32 savePassword, + PRUnichar **user, PRUnichar **pwd, PRBool *_retval) +{ + PRBool checkValue; + + *_retval = savePassword; + checkValue = savePassword; + + return mPrompt->PromptUsernameAndPassword (nsnull, dialogTitle, text, user, pwd, + passwordRealm, &checkValue, _retval); +} + +NS_IMETHODIMP EphyHeaderSniffer::PromptPassword (const PRUnichar *dialogTitle, const PRUnichar *text, + const PRUnichar *passwordRealm, PRUint32 savePassword, + PRUnichar **pwd, PRBool *_retval) +{ + PRBool checkValue; + + *_retval = savePassword; + checkValue = savePassword; + + return mPrompt->PromptPassword (nsnull, dialogTitle, text, pwd, + passwordRealm, &checkValue, _retval); +} diff --git a/embed/mozilla/EphyHeaderSniffer.h b/embed/mozilla/EphyHeaderSniffer.h index 9124cfa16..01f5b7bd8 100644 --- a/embed/mozilla/EphyHeaderSniffer.h +++ b/embed/mozilla/EphyHeaderSniffer.h @@ -45,9 +45,12 @@ #include "nsILocalFile.h" #include "nsIInputStream.h" #include "nsIDOMDocument.h" +#include "nsIAuthPrompt.h" +#include "nsIPromptService.h" // Implementation of a header sniffer class that is used when saving Web pages and images. -class EphyHeaderSniffer : public nsIWebProgressListener +class EphyHeaderSniffer : public nsIWebProgressListener, + public nsIAuthPrompt { public: EphyHeaderSniffer(nsIWebBrowserPersist* aPersist, MozillaEmbedPersist *aEmbedPersist, @@ -58,6 +61,7 @@ public: NS_DECL_ISUPPORTS NS_DECL_NSIWEBPROGRESSLISTENER + NS_DECL_NSIAUTHPROMPT protected: @@ -76,5 +80,6 @@ private: PRBool mBypassCache; nsCString mContentType; nsCString mContentDisposition; + nsCOMPtr<nsIPromptService> mPrompt; }; |