aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Persch <chpe@src.gnome.org>2008-03-13 05:38:55 +0800
committerChristian Persch <chpe@src.gnome.org>2008-03-13 05:38:55 +0800
commitfdffd322181be333e39c2a039e37295587cf3284 (patch)
tree5f90f0b38e4ff1e91e87b4d38e43080b5bb022c2
parent40174913b001abad51dd5a4d4c0ce142b0ace2f9 (diff)
downloadgsoc2013-epiphany-fdffd322181be333e39c2a039e37295587cf3284.tar
gsoc2013-epiphany-fdffd322181be333e39c2a039e37295587cf3284.tar.gz
gsoc2013-epiphany-fdffd322181be333e39c2a039e37295587cf3284.tar.bz2
gsoc2013-epiphany-fdffd322181be333e39c2a039e37295587cf3284.tar.lz
gsoc2013-epiphany-fdffd322181be333e39c2a039e37295587cf3284.tar.xz
gsoc2013-epiphany-fdffd322181be333e39c2a039e37295587cf3284.tar.zst
gsoc2013-epiphany-fdffd322181be333e39c2a039e37295587cf3284.zip
Try again to fix the directory provider for 1.9. Branding still fails though
svn path=/trunk/; revision=8101
-rw-r--r--embed/mozilla/ContentHandler.cpp10
-rw-r--r--embed/mozilla/EphyPromptService.cpp228
-rw-r--r--embed/mozilla/EphyPromptService.h14
-rw-r--r--embed/mozilla/MozDownload.cpp22
-rw-r--r--embed/mozilla/MozDownload.h2
-rw-r--r--embed/mozilla/mozilla-embed-single.cpp9
6 files changed, 271 insertions, 14 deletions
diff --git a/embed/mozilla/ContentHandler.cpp b/embed/mozilla/ContentHandler.cpp
index c70f460c2..b7ba3b43f 100644
--- a/embed/mozilla/ContentHandler.cpp
+++ b/embed/mozilla/ContentHandler.cpp
@@ -416,6 +416,14 @@ NS_METHOD GContentHandler::MIMEDoAction (void)
mLauncher->GetMIMEInfo(getter_AddRefs(mimeInfo));
NS_ENSURE_TRUE (mimeInfo, NS_ERROR_FAILURE);
+#ifdef HAVE_GECKO_1_9
+ nsHandlerInfoAction action;
+ if (mAction == CONTENT_ACTION_DOWNLOAD) {
+ action = EPHY_ACTION_BROWSE_TO_FILE;
+ } else {
+ action = nsIMIMEInfo::useSystemDefault;
+ }
+#else
char *info = NULL;
if (mAction == CONTENT_ACTION_OPEN)
@@ -435,8 +443,6 @@ NS_METHOD GContentHandler::MIMEDoAction (void)
info = g_strdup_printf ("gnome-browse-to-file:%d", gtk_get_current_event_time());
}
- /* See http://bugzilla.gnome.org/show_bug.cgi?id=456945 */
-#ifndef HAVE_GECKO_1_9
if (info != NULL)
{
nsString desc;
diff --git a/embed/mozilla/EphyPromptService.cpp b/embed/mozilla/EphyPromptService.cpp
index 915649aea..c1105182d 100644
--- a/embed/mozilla/EphyPromptService.cpp
+++ b/embed/mozilla/EphyPromptService.cpp
@@ -31,6 +31,7 @@
#include <nsCOMPtr.h>
#include <nsIDOMWindow.h>
#include <nsServiceManagerUtils.h>
+#include <nsIStringBundle.h>
#include "ephy-embed-shell.h"
#include "ephy-gui.h"
@@ -40,6 +41,14 @@
#include "EphyUtils.h"
#include "EphyPromptService.h"
+#include "nsIChannel.h"
+#include "nsIProxiedChannel.h"
+#include "nsIProxyInfo.h"
+#include "nsNetCID.h"
+#include "nsIURI.h"
+#include "nsNetUtil.h"
+#include "nsIIDNService.h"
+#include "nsIAuthInformation.h"
#define TIMEOUT 1000 /* ms */
#define TIMEOUT_DATA_KEY "timeout"
@@ -640,12 +649,14 @@ Prompter::ConvertAndEscapeButtonText(const PRUnichar *aText,
/* FIXME: needs THREADSAFE? */
#if HAVE_NSINONBLOCKINGALERTSERVICE_H
-NS_IMPL_ISUPPORTS2 (EphyPromptService,
+NS_IMPL_ISUPPORTS3 (EphyPromptService,
nsIPromptService,
+ nsIPromptService2,
nsINonBlockingAlertService)
#else
-NS_IMPL_ISUPPORTS1 (EphyPromptService,
- nsIPromptService)
+NS_IMPL_ISUPPORTS2 (EphyPromptService,
+ nsIPromptService,
+ nsIPromptService2)
#endif
EphyPromptService::EphyPromptService()
@@ -882,3 +893,214 @@ EphyPromptService::ShowNonBlockingAlert (nsIDOMWindow *aParent,
}
#endif /* HAVE_NSINONBLOCKINGALERTSERVICE_H */
+
+static void
+NS_GetAuthHostPort(nsIChannel* aChannel, nsIAuthInformation* aAuthInfo,
+ PRBool machineProcessing, nsCString& host, PRInt32* port)
+{
+ nsCOMPtr<nsIURI> uri;
+ nsresult rv = aChannel->GetURI(getter_AddRefs(uri));
+ if (NS_FAILED(rv))
+ return;
+
+ // Have to distinguish proxy auth and host auth here...
+ PRUint32 flags;
+ aAuthInfo->GetFlags(&flags);
+ if (flags & nsIAuthInformation::AUTH_PROXY) {
+ nsCOMPtr<nsIProxiedChannel> proxied(do_QueryInterface(aChannel));
+ NS_ASSERTION(proxied, "proxy auth needs nsIProxiedChannel");
+
+ nsCOMPtr<nsIProxyInfo> info;
+ proxied->GetProxyInfo(getter_AddRefs(info));
+ NS_ASSERTION(info, "proxy auth needs nsIProxyInfo");
+
+ nsCAutoString idnhost;
+ info->GetHost(idnhost);
+ info->GetPort(port);
+
+ if (machineProcessing) {
+ nsCOMPtr<nsIIDNService> idnService =
+ do_GetService(NS_IDNSERVICE_CONTRACTID);
+ if (idnService) {
+ idnService->ConvertUTF8toACE(idnhost, host);
+ } else {
+ // Not much we can do here...
+ host = idnhost;
+ }
+ } else {
+ host = idnhost;
+ }
+ } else {
+ if (machineProcessing) {
+ uri->GetAsciiHost(host);
+ *port = NS_GetRealPort(uri);
+ } else {
+ uri->GetHost(host);
+ uri->GetPort(port);
+ }
+ }
+}
+
+static nsresult
+MakeDialogText(nsIChannel* aChannel, nsIAuthInformation* aAuthInfo,
+ nsString& message)
+{
+ nsresult rv;
+ nsCOMPtr<nsIStringBundleService> bundleSvc =
+ do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ nsCOMPtr<nsIStringBundle> bundle;
+ rv = bundleSvc->CreateBundle("chrome://global/locale/prompts.properties",
+ getter_AddRefs(bundle));
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ // figure out what message to display...
+ nsCAutoString host;
+ PRInt32 port;
+ NS_GetAuthHostPort(aChannel, aAuthInfo, PR_FALSE, host, &port);
+
+ nsAutoString displayHost;
+ CopyUTF8toUTF16(host, displayHost);
+
+ nsCOMPtr<nsIURI> uri;
+ aChannel->GetURI(getter_AddRefs(uri));
+
+ nsCAutoString scheme;
+ uri->GetScheme(scheme);
+
+ nsAutoString username;
+ aAuthInfo->GetUsername(username);
+
+ PRUint32 flags;
+ aAuthInfo->GetFlags(&flags);
+ PRBool proxyAuth = (flags & nsIAuthInformation::AUTH_PROXY) != 0;
+
+ nsAutoString realm;
+ aAuthInfo->GetRealm(realm);
+
+ // Append the port if it was specified
+ if (port != -1) {
+ displayHost.Append(PRUnichar(':'));
+ displayHost.AppendInt(port);
+ }
+
+ NS_NAMED_LITERAL_STRING(proxyText, "EnterUserPasswordForProxy");
+ NS_NAMED_LITERAL_STRING(originText, "EnterUserPasswordForRealm");
+ NS_NAMED_LITERAL_STRING(noRealmText, "EnterUserPasswordFor");
+ NS_NAMED_LITERAL_STRING(passwordText, "EnterPasswordFor");
+
+ const PRUnichar *text;
+ if (proxyAuth) {
+ text = proxyText.get();
+ } else {
+ text = originText.get();
+
+ // prepend "scheme://"
+ nsAutoString schemeU;
+ CopyASCIItoUTF16(scheme, schemeU);
+ schemeU.AppendLiteral("://");
+ displayHost.Insert(schemeU, 0);
+ }
+
+ const PRUnichar *strings[] = { realm.get(), displayHost.get() };
+ PRUint32 count = NS_ARRAY_LENGTH(strings);
+
+ if (flags & nsIAuthInformation::ONLY_PASSWORD) {
+ text = passwordText.get();
+ strings[0] = username.get();
+ } else if (!proxyAuth && realm.IsEmpty()) {
+ text = noRealmText.get();
+ count--;
+ strings[0] = strings[1];
+ }
+
+ rv = bundle->FormatStringFromName(text, strings, count, getter_Copies(message));
+ return rv;
+}
+
+/* static */ nsresult
+EphyPromptService::PromptPasswordAdapter(nsIPromptService* aService,
+ nsIDOMWindow* aParent,
+ nsIChannel* aChannel,
+ PRUint32 aLevel,
+ nsIAuthInformation* aAuthInfo,
+ const PRUnichar* aCheckLabel,
+ PRBool* aCheckValue,
+ PRBool* retval)
+{
+ // construct the message string
+ nsString message;
+ MakeDialogText(aChannel, aAuthInfo, message);
+
+ nsAutoString defaultUser, defaultDomain, defaultPass;
+ aAuthInfo->GetUsername(defaultUser);
+ aAuthInfo->GetDomain(defaultDomain);
+ aAuthInfo->GetPassword(defaultPass);
+
+ PRUint32 flags;
+ aAuthInfo->GetFlags(&flags);
+
+ if ((flags & nsIAuthInformation::NEED_DOMAIN) && !defaultDomain.IsEmpty()) {
+ defaultDomain.Append(PRUnichar('\\'));
+ defaultUser.Insert(defaultDomain, 0);
+ }
+
+ // NOTE: Allocation failure is not fatal here (just default to empty string
+ // if allocation fails)
+ PRUnichar *user = ToNewUnicode(defaultUser),
+ *pass = ToNewUnicode(defaultPass);
+ nsresult rv;
+ if (flags & nsIAuthInformation::ONLY_PASSWORD)
+ rv = aService->PromptPassword(aParent, nsnull, message.get(),
+ &pass, aCheckLabel,
+ aCheckValue, retval);
+ else
+ rv = aService->PromptUsernameAndPassword(aParent, nsnull, message.get(),
+ &user, &pass, aCheckLabel,
+ aCheckValue, retval);
+
+ nsString userStr(user);
+ nsString passStr(pass);
+ aAuthInfo->SetUsername(userStr);
+ aAuthInfo->SetPassword(passStr);
+
+ return rv;
+}
+
+/* boolean promptAuth (in nsIDOMWindow aParent, in nsIChannel aChannel, in PRUint32 level, in nsIAuthInformation authInfo, in wstring checkboxLabel, inout boolean checkValue); */
+NS_METHOD
+EphyPromptService::PromptAuth(nsIDOMWindow *aParent,
+ nsIChannel *aChannel,
+ PRUint32 level,
+ nsIAuthInformation *authInfo,
+ const PRUnichar *checkboxLabel,
+ PRBool *checkValue,
+ PRBool *_retval)
+{
+ NS_ENSURE_ARG_POINTER (_retval);
+ NS_ENSURE_ARG_POINTER (authInfo);
+
+ return EphyPromptService::PromptPasswordAdapter(this,
+ aParent,
+ aChannel,
+ level,
+ authInfo,
+ checkboxLabel,
+ checkValue,
+ _retval);
+}
+
+/* nsICancelable asyncPromptAuth (in nsIDOMWindow aParent, in nsIChannel aChannel, in nsIAuthPromptCallback aCallback, in nsISupports aContext, in PRUint32 level, in nsIAuthInformation authInfo, in wstring checkboxLabel, inout boolean checkValue); */
+NS_METHOD EphyPromptService::AsyncPromptAuth(nsIDOMWindow *aParent,
+ nsIChannel *aChannel,
+ nsIAuthPromptCallback *aCallback,
+ nsISupports *aContext,
+ PRUint32 level,
+ nsIAuthInformation *authInfo,
+ const PRUnichar *checkboxLabel,
+ PRBool *checkValue,
+ nsICancelable **_retval)
+{
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
diff --git a/embed/mozilla/EphyPromptService.h b/embed/mozilla/EphyPromptService.h
index 2416e5318..ffde73164 100644
--- a/embed/mozilla/EphyPromptService.h
+++ b/embed/mozilla/EphyPromptService.h
@@ -22,6 +22,7 @@
#define EPHY_PROMPT_SERVICE_H
#include <nsIPromptService.h>
+#include <nsIPromptService2.h>
#if HAVE_NSINONBLOCKINGALERTSERVICE_H
#include <nsINonBlockingAlertService.h>
@@ -34,7 +35,7 @@
#define EPHY_PROMPT_SERVICE_CLASSNAME "Epiphany Prompt Service"
-class EphyPromptService : public nsIPromptService
+class EphyPromptService : public nsIPromptService2
#if HAVE_NSINONBLOCKINGALERTSERVICE_H
, public nsINonBlockingAlertService
#endif
@@ -42,12 +43,23 @@ class EphyPromptService : public nsIPromptService
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIPROMPTSERVICE
+ NS_DECL_NSIPROMPTSERVICE2
#if HAVE_NSINONBLOCKINGALERTSERVICE_H
NS_DECL_NSINONBLOCKINGALERTSERVICE
#endif
EphyPromptService();
virtual ~EphyPromptService();
+
+ protected:
+ static nsresult PromptPasswordAdapter(nsIPromptService* aService,
+ nsIDOMWindow* aParent,
+ nsIChannel* aChannel,
+ PRUint32 aLevel,
+ nsIAuthInformation* aAuthInfo,
+ const PRUnichar* aCheckLabel,
+ PRBool* aCheckValue,
+ PRBool* retval);
};
#endif /* EPHY_PROMPT_SERVICE_H */
diff --git a/embed/mozilla/MozDownload.cpp b/embed/mozilla/MozDownload.cpp
index d3d13d32b..d24bcb25c 100644
--- a/embed/mozilla/MozDownload.cpp
+++ b/embed/mozilla/MozDownload.cpp
@@ -349,12 +349,30 @@ MozDownload::OnStateChange (nsIWebProgress *aWebProgress, nsIRequest *aRequest,
}
else if (NS_SUCCEEDED (aStatus))
{
- /* see http://bugzilla.gnome.org/show_bug.cgi?id=456945 */
+ NS_ENSURE_TRUE (mMIMEInfo, NS_ERROR_FAILURE);
#ifdef HAVE_GECKO_1_9
+ nsHandlerInfoAction action;
+ mMIMEInfo->GetPreferredAction(&action);
+
+ nsCOMPtr<nsIInterfaceRequestor> req (do_QueryInterface (mRequest));
+
+ if (action == EPHY_ACTION_BROWSE_TO_FILE) {
+ nsCString destSpec;
+ rv = mDestination->GetSpec (destSpec);
+ NS_ENSURE_SUCCESS (rv, NS_ERROR_FAILURE);
+
+ GFile *dest;
+ dest = g_file_new_for_uri (destSpec.get ());
+ ephy_file_browse_to (dest, 0 /* FIXME BUG BUG BUG */);
+ g_object_unref (dest);
+ } else {
+ rv = mMIMEInfo->LaunchWithURI (mDestination, req);
+ NS_ENSURE_SUCCESS(rv, rv);
+ }
+
return NS_OK;
#else
GDesktopAppInfo *helperApp;
- NS_ENSURE_TRUE (mMIMEInfo, NS_ERROR_FAILURE);
nsString description;
mMIMEInfo->GetApplicationDescription (description);
diff --git a/embed/mozilla/MozDownload.h b/embed/mozilla/MozDownload.h
index 411230bdb..fe3219033 100644
--- a/embed/mozilla/MozDownload.h
+++ b/embed/mozilla/MozDownload.h
@@ -83,6 +83,8 @@ class nsIWebBrowserPersist;
#define MOZ_DOWNLOAD_CLASSNAME "Ephy's Download Progress Dialog"
+#define EPHY_ACTION_BROWSE_TO_FILE (1024)
+
nsresult InitiateMozillaDownload (nsIDOMDocument *domDocument, nsIURI *sourceUri,
nsILocalFile* inDestFile, const char *contentType,
nsIURI* inOriginalURI, MozillaEmbedPersist *embedPersist,
diff --git a/embed/mozilla/mozilla-embed-single.cpp b/embed/mozilla/mozilla-embed-single.cpp
index 082e2cff2..f2a588f41 100644
--- a/embed/mozilla/mozilla-embed-single.cpp
+++ b/embed/mozilla/mozilla-embed-single.cpp
@@ -627,9 +627,11 @@ impl_init (EphyEmbedSingle *esingle)
*lastSlash = '\0';
gtk_moz_embed_set_path(xpcomLocation);
+ gtk_moz_embed_set_comp_path (MOZILLA_HOME);
#else
#ifdef HAVE_GECKO_1_9
gtk_moz_embed_set_path (MOZILLA_HOME);
+
#else
gtk_moz_embed_set_comp_path (MOZILLA_HOME);
#endif
@@ -639,12 +641,6 @@ impl_init (EphyEmbedSingle *esingle)
mozilla_init_profile ();
-#ifdef HAVE_GECKO_1_9
- gtk_moz_embed_set_path (MOZILLA_HOME);
-#endif
- /* Set mozilla binary path */
- gtk_moz_embed_set_comp_path (MOZILLA_HOME);
-
nsCOMPtr<nsIDirectoryServiceProvider> dp = new EphyDirectoryProvider ();
if (!dp) return FALSE;
@@ -652,6 +648,7 @@ impl_init (EphyEmbedSingle *esingle)
/* Fire up the beast */
gtk_moz_embed_push_startup ();
+
/* FIXME check that it succeeded! */
mozilla_register_components ();