aboutsummaryrefslogtreecommitdiffstats
path: root/embed
diff options
context:
space:
mode:
authorChristian Persch <chpe@src.gnome.org>2008-03-11 05:57:45 +0800
committerChristian Persch <chpe@src.gnome.org>2008-03-11 05:57:45 +0800
commit7720c783b8a8f8911a79b965d9176aba839829e6 (patch)
tree7163a9238c97b44b40b0c455e7c7ebc70c08fa79 /embed
parent888c589bd3ee139571fccf55d2b4bdfee27c2c7f (diff)
downloadgsoc2013-epiphany-7720c783b8a8f8911a79b965d9176aba839829e6.tar
gsoc2013-epiphany-7720c783b8a8f8911a79b965d9176aba839829e6.tar.gz
gsoc2013-epiphany-7720c783b8a8f8911a79b965d9176aba839829e6.tar.bz2
gsoc2013-epiphany-7720c783b8a8f8911a79b965d9176aba839829e6.tar.lz
gsoc2013-epiphany-7720c783b8a8f8911a79b965d9176aba839829e6.tar.xz
gsoc2013-epiphany-7720c783b8a8f8911a79b965d9176aba839829e6.tar.zst
gsoc2013-epiphany-7720c783b8a8f8911a79b965d9176aba839829e6.zip
Allow building with xulrunner 1.9. Patch by Alexander Sack; part of bug #503657
svn path=/trunk/; revision=8094
Diffstat (limited to 'embed')
-rw-r--r--embed/Makefile.am1
-rw-r--r--embed/ephy-password-manager.c4
-rw-r--r--embed/ephy-password-manager.h5
-rw-r--r--embed/mozilla/AutoModalDialog.cpp1
-rw-r--r--embed/mozilla/EphyBrowser.cpp1
-rw-r--r--embed/mozilla/GtkNSSDialogs.cpp4
-rw-r--r--embed/mozilla/Makefile.am8
-rw-r--r--embed/mozilla/mozilla-embed-single.cpp250
8 files changed, 249 insertions, 25 deletions
diff --git a/embed/Makefile.am b/embed/Makefile.am
index e01687e74..7e93fe444 100644
--- a/embed/Makefile.am
+++ b/embed/Makefile.am
@@ -107,6 +107,7 @@ libephyembedfactory_la_CPPFLAGS += -I$(GECKO_INCLUDE_ROOT)/gtkembedmoz
endif
libephyembedfactory_la_CFLAGS = \
+ $(GECKO_CFLAGS) \
$(DEPENDENCIES_CFLAGS) \
$(AM_CFLAGS)
diff --git a/embed/ephy-password-manager.c b/embed/ephy-password-manager.c
index ef3bb1e2c..a702d713e 100644
--- a/embed/ephy-password-manager.c
+++ b/embed/ephy-password-manager.c
@@ -80,6 +80,10 @@ ephy_password_info_copy (const EphyPasswordInfo *info)
copy->host = g_strdup (info->host);
copy->username = g_strdup (info->username);
copy->password = g_strdup (info->password);
+ copy->httpRealm = g_strdup (info->httpRealm);
+ copy->passwordField = g_strdup (info->passwordField);
+ copy->usernameField = g_strdup (info->usernameField);
+ copy->formSubmitURL = g_strdup (info->formSubmitURL);
return copy;
}
diff --git a/embed/ephy-password-manager.h b/embed/ephy-password-manager.h
index 8dd2751af..499ccc9cf 100644
--- a/embed/ephy-password-manager.h
+++ b/embed/ephy-password-manager.h
@@ -44,6 +44,11 @@ typedef struct
char *host;
char *username;
char *password;
+
+ char *httpRealm;
+ char *formSubmitURL;
+ char *usernameField;
+ char *passwordField;
} EphyPasswordInfo;
struct _EphyPasswordManagerIface
diff --git a/embed/mozilla/AutoModalDialog.cpp b/embed/mozilla/AutoModalDialog.cpp
index 48df678fa..034730850 100644
--- a/embed/mozilla/AutoModalDialog.cpp
+++ b/embed/mozilla/AutoModalDialog.cpp
@@ -35,7 +35,6 @@
#include <nsIDOMDocument.h>
#include <nsIDOMEvent.h>
#include <nsIDOMEventTarget.h>
-#include <nsIJSContextStack.h>
#include <nsIPrivateDOMEvent.h>
#include <nsPIDOMWindow.h>
#include <nsServiceManagerUtils.h>
diff --git a/embed/mozilla/EphyBrowser.cpp b/embed/mozilla/EphyBrowser.cpp
index d4a53811b..3445e6d74 100644
--- a/embed/mozilla/EphyBrowser.cpp
+++ b/embed/mozilla/EphyBrowser.cpp
@@ -1567,6 +1567,7 @@ EphyBrowser::GetPIDOMWindow(nsPIDOMWindow **aPIWin)
// get the private DOM window
nsCOMPtr<nsPIDOMWindow> domWindowPrivate = do_QueryInterface(mDOMWindow);
+ NS_ENSURE_TRUE (domWindowPrivate, NS_ERROR_UNEXPECTED);
// and the root window for that DOM window
*aPIWin = domWindowPrivate->GetPrivateRoot();
diff --git a/embed/mozilla/GtkNSSDialogs.cpp b/embed/mozilla/GtkNSSDialogs.cpp
index c21460b8c..6346ecb83 100644
--- a/embed/mozilla/GtkNSSDialogs.cpp
+++ b/embed/mozilla/GtkNSSDialogs.cpp
@@ -217,7 +217,7 @@ higgy_setup_dialog (GtkDialog *dialog, const gchar *stock_icon,
}
}
-
+#ifndef HAVE_GECKO_1_9
/**
* Display a dialog box, showing 'View Certificate', 'Cancel',
* and 'Accept' buttons. Optionally a checkbox can be shown,
@@ -321,7 +321,7 @@ display_cert_warning_box (nsIInterfaceRequestor *ctx,
gtk_widget_destroy (dialog);
return res;
}
-
+#endif /* HAVE_GECKO_1_9 */
/* Helper functions */
diff --git a/embed/mozilla/Makefile.am b/embed/mozilla/Makefile.am
index 007cac5d0..f2581b887 100644
--- a/embed/mozilla/Makefile.am
+++ b/embed/mozilla/Makefile.am
@@ -91,6 +91,7 @@ libephymozillaembed_la_SOURCES += \
GtkNSSSecurityWarningDialogs.h
endif
+
if ENABLE_SPELLCHECKER
libephymozillaembed_la_SOURCES += \
GeckoSpellCheckEngine.cpp \
@@ -153,6 +154,13 @@ libephymozillaembed_la_CPPFLAGS = \
-DALLOW_PRIVATE_API \
$(AM_CPPFLAGS)
+if HAVE_GECKO_1_9
+if HAVE_GECKO_XPCOM_GLUE
+libephymozillaembed_la_CPPFLAGS += \
+ -DXPCOM_GLUE_USE_NSPR
+endif
+endif
+
libephymozillaembed_la_CXXFLAGS = \
$(GECKO_CFLAGS) \
$(DEPENDENCIES_CFLAGS) \
diff --git a/embed/mozilla/mozilla-embed-single.cpp b/embed/mozilla/mozilla-embed-single.cpp
index f95c8a107..7f71c1a0b 100644
--- a/embed/mozilla/mozilla-embed-single.cpp
+++ b/embed/mozilla/mozilla-embed-single.cpp
@@ -33,6 +33,11 @@
#include <nsStringAPI.h>
+#ifdef XPCOM_GLUE
+#include <nsXPCOMGlue.h>
+#include <gtkmozembed_glue.cpp>
+#endif
+
#include <gtkmozembed.h>
#include <gtkmozembed_internal.h>
#include <nsComponentManagerUtils.h>
@@ -62,8 +67,11 @@
#include <nsNetCID.h>
#endif /* ALLOW_PRIVATE_API */
-#ifndef HAVE_GECKO_1_9
-#include <nsIPassword.h>
+#ifdef HAVE_GECKO_1_9
+#include <nsILoginInfo.h>
+#include <nsILoginManager.h>
+#else
+init#include <nsIPassword.h>
#include <nsIPasswordManager.h>
#endif /* !HAVE_GECKO_1_9 */
@@ -324,6 +332,7 @@ mozilla_init_profile (void)
profile_path = g_build_filename (ephy_dot_dir (),
MOZILLA_PROFILE_DIR,
(char *) NULL);
+ gtk_moz_embed_set_comp_path (profile_path);
gtk_moz_embed_set_profile_path (profile_path, MOZILLA_PROFILE_NAME);
g_free (profile_path);
}
@@ -371,6 +380,19 @@ mozilla_init_observer (MozillaEmbedSingle *single)
}
static void
+mozilla_init_login_manager (MozillaEmbedSingle *single)
+{
+#ifdef HAVE_GECKO_1_9
+ nsCOMPtr<nsILoginManager> loginManager =
+ do_GetService (NS_LOGINMANAGER_CONTRACTID);
+ if (!loginManager)
+ g_warning ("Failed to instantiate LoginManager");
+ else
+ g_debug ("LoginManager tapped");
+#endif /* HAVE_GECKO_1_9 */
+}
+
+static void
user_css_register (MozillaEmbedSingle *single)
{
MozillaEmbedSinglePrivate *priv = single->priv;
@@ -565,6 +587,57 @@ impl_init (EphyEmbedSingle *esingle)
NS_LogInit ();
#endif
+ nsresult rv;
+#ifdef XPCOM_GLUE
+ static const GREVersionRange greVersion = {
+ "1.9a", PR_TRUE,
+ "2", PR_TRUE
+ };
+ char xpcomLocation[4096];
+ rv = GRE_GetGREPathWithProperties(&greVersion, 1, nsnull, 0, xpcomLocation, 4096);
+ if (NS_FAILED (rv))
+ {
+ g_warning ("Could not find a suitable GRE!\n");
+ return FALSE;
+ }
+
+ // Startup the XPCOM Glue that links us up with XPCOM.
+ rv = XPCOMGlueStartup(xpcomLocation);
+ if (NS_FAILED (rv))
+ {
+ g_warning ("Could not startup XPCOM glue!\n");
+ return FALSE;
+ }
+
+ rv = GTKEmbedGlueStartup();
+ if (NS_FAILED (rv))
+ {
+ g_warning ("Could not startup embed glue!\n");
+ return FALSE;
+ }
+
+ rv = GTKEmbedGlueStartupInternal();
+ if (NS_FAILED (rv))
+ {
+ g_warning ("Could not startup internal glue!\n");
+ return FALSE;
+ }
+
+ char *lastSlash = strrchr(xpcomLocation, '/');
+ if (lastSlash)
+ *lastSlash = '\0';
+
+ gtk_moz_embed_set_path(xpcomLocation);
+#else
+#ifdef HAVE_GECKO_1_9
+ gtk_moz_embed_set_path (MOZILLA_HOME);
+#else
+ gtk_moz_embed_set_comp_path (MOZILLA_HOME);
+#endif
+#endif // XPCOM_GLUE
+ /* Fire up the beast */
+ gtk_moz_embed_push_startup ();
+
/* Pre initialization */
mozilla_init_plugin_path ();
@@ -581,8 +654,6 @@ impl_init (EphyEmbedSingle *esingle)
gtk_moz_embed_set_directory_service_provider (dp);
- /* Fire up the beast */
- gtk_moz_embed_push_startup ();
/* FIXME check that it succeeded! */
mozilla_register_components ();
@@ -600,7 +671,9 @@ impl_init (EphyEmbedSingle *esingle)
mozilla_init_observer (single);
- mozilla_stylesheet_init (single);
+ mozilla_stylesheet_init (single);
+
+ mozilla_init_login_manager (single);
return TRUE;
}
@@ -848,16 +921,95 @@ impl_list_passwords (EphyPasswordManager *manager)
{
GList *passwords = NULL;
-#ifndef HAVE_GECKO_1_9
+ nsCOMPtr<nsIIDNService> idnService
+ (do_GetService ("@mozilla.org/network/idn-service;1"));
+ NS_ENSURE_TRUE (idnService, NULL);
+
+#ifdef HAVE_GECKO_1_9
+ nsILoginInfo **logins = nsnull;
+ PRUint32 count,i;
+ nsresult rv;
+
+ nsCOMPtr<nsILoginManager> loginManager =
+ do_GetService (NS_LOGINMANAGER_CONTRACTID);
+ NS_ENSURE_TRUE (loginManager, NULL);
+
+ loginManager -> GetAllLogins(&count, &logins);
+
+ for (i=0; i < count; i++) {
+ nsString transfer;
+ nsString unicodeName;
+ rv = logins[i]->GetHostname (transfer);
+ if (NS_FAILED (rv)) continue;
+
+ nsCString host;
+ idnService->ConvertACEtoUTF8 (NS_ConvertUTF16toUTF8(transfer), host);
+ if(transfer.IsVoid()) host.SetIsVoid(PR_TRUE);
+
+ rv = logins[i]->GetHttpRealm (unicodeName);
+ if (NS_FAILED (rv)) continue;
+ nsCString httpRealm;
+ NS_UTF16ToCString (unicodeName,
+ NS_CSTRING_ENCODING_UTF8, httpRealm);
+ if(unicodeName.IsVoid()) httpRealm.SetIsVoid(PR_TRUE);
+
+ rv = logins[i]->GetUsername (unicodeName);
+ if (NS_FAILED (rv)) continue;
+ nsCString userName;
+ NS_UTF16ToCString (unicodeName,
+ NS_CSTRING_ENCODING_UTF8, userName);
+ if(unicodeName.IsVoid()) userName.SetIsVoid(PR_TRUE);
+
+ rv = logins[i]->GetUsernameField (unicodeName);
+ if (NS_FAILED (rv)) continue;
+ nsCString usernameField;
+ NS_UTF16ToCString (unicodeName,
+ NS_CSTRING_ENCODING_UTF8, usernameField);
+ if(unicodeName.IsVoid()) usernameField.SetIsVoid(PR_TRUE);
+
+ rv = logins[i]->GetPassword (unicodeName);
+ if (NS_FAILED (rv)) continue;
+ nsCString userPassword;
+ NS_UTF16ToCString (unicodeName,
+ NS_CSTRING_ENCODING_UTF8, userPassword);
+ if(unicodeName.IsVoid()) userPassword.SetIsVoid(PR_TRUE);
+
+ rv = logins[i]->GetPasswordField (unicodeName);
+ if (NS_FAILED (rv)) continue;
+ nsCString passwordField;
+ NS_UTF16ToCString (unicodeName,
+ NS_CSTRING_ENCODING_UTF8, passwordField);
+ if(unicodeName.IsVoid()) passwordField.SetIsVoid(PR_TRUE);
+
+ rv = logins[i]->GetFormSubmitURL (unicodeName);
+ if (NS_FAILED (rv)) continue;
+ nsCString formSubmitURL;
+ NS_UTF16ToCString (unicodeName,
+ NS_CSTRING_ENCODING_UTF8, formSubmitURL);
+ if(unicodeName.IsVoid()) formSubmitURL.SetIsVoid(PR_TRUE);
+
+
+ EphyPasswordInfo *p = g_new0 (EphyPasswordInfo, 1);
+ p->host = !userName.IsVoid() ? g_strdup (host.get()) : nsnull;
+ p->username = !userName.IsVoid() ? g_strdup (userName.get()) : nsnull;
+ p->password = !userPassword.IsVoid() ? g_strdup (userPassword.get()) : nsnull;
+ p->httpRealm = !httpRealm.IsVoid() ? g_strdup(httpRealm.get()) : nsnull;
+ p->usernameField = !usernameField.IsVoid() ? g_strdup(usernameField.get()) : nsnull;
+ p->passwordField = !passwordField.IsVoid() ? g_strdup(passwordField.get()) : nsnull;
+ p->formSubmitURL = !formSubmitURL.IsVoid() ? g_strdup(formSubmitURL.get()) : nsnull;
+
+ passwords = g_list_prepend (passwords, p);
+ }
+
+ NS_FREE_XPCOM_ISUPPORTS_POINTER_ARRAY (count, logins);
+
+#else // HAVE_GECKO_1_9
+
nsresult rv;
nsCOMPtr<nsIPasswordManager> passwordManager =
do_GetService (NS_PASSWORDMANAGER_CONTRACTID);
if (!passwordManager) return NULL;
- nsCOMPtr<nsIIDNService> idnService
- (do_GetService ("@mozilla.org/network/idn-service;1"));
- NS_ENSURE_TRUE (idnService, NULL);
-
nsCOMPtr<nsISimpleEnumerator> passwordEnumerator;
passwordManager->GetEnumerator (getter_AddRefs(passwordEnumerator));
NS_ENSURE_TRUE (passwordEnumerator, NULL);
@@ -910,31 +1062,85 @@ static void
impl_remove_password (EphyPasswordManager *manager,
EphyPasswordInfo *info)
{
-#ifndef HAVE_GECKO_1_9
- nsCOMPtr<nsIPasswordManager> pm =
- do_GetService (NS_PASSWORDMANAGER_CONTRACTID);
- if (!pm) return;
+ nsresult rv;
+ nsString host;
+ nsString userName;
+ nsString userNameField;
+ nsString password;
+ nsString passwordField;
+ nsString httpRealm;
+ nsString formSubmitURL;
nsCOMPtr<nsIIDNService> idnService
(do_GetService ("@mozilla.org/network/idn-service;1"));
NS_ENSURE_TRUE (idnService, );
- nsresult rv;
- nsCString host;
- rv = idnService->ConvertUTF8toACE (nsCString(info->host), host);
- NS_ENSURE_SUCCESS (rv, );
+ if(info->formSubmitURL != nsnull)
+ g_debug("form submit url: %s", info->formSubmitURL);
+ else
+ g_debug("form submit url is NULL");
- nsString userName;
NS_CStringToUTF16 (nsCString(info->username),
NS_CSTRING_ENCODING_UTF8, userName);
- pm->RemoveUser (host, userName);
-#endif /* !HAVE_GECKO_1_9 */
+ NS_CStringToUTF16 (nsCString(info->usernameField),
+ NS_CSTRING_ENCODING_UTF8, userNameField);
+ NS_CStringToUTF16 (nsCString(info->host),
+ NS_CSTRING_ENCODING_UTF8, host);
+ NS_CStringToUTF16 (nsCString(info->httpRealm),
+ NS_CSTRING_ENCODING_UTF8, httpRealm);
+ NS_CStringToUTF16 (nsCString(info->password),
+ NS_CSTRING_ENCODING_UTF8, password);
+ NS_CStringToUTF16 (nsCString(info->passwordField),
+ NS_CSTRING_ENCODING_UTF8, passwordField);
+ NS_CStringToUTF16 (nsCString(info->formSubmitURL),
+ NS_CSTRING_ENCODING_UTF8, formSubmitURL);
+
+#ifdef HAVE_GECKO_1_9
+ if(!info->username) userName.SetIsVoid(PR_TRUE);
+ if(!info->usernameField) userNameField.SetIsVoid(PR_TRUE);
+ if(!info->host) host.SetIsVoid(PR_TRUE);
+ if(!info->httpRealm) httpRealm.SetIsVoid(PR_TRUE);
+ if(!info->password) password.SetIsVoid(PR_TRUE);
+ if(!info->passwordField) passwordField.SetIsVoid(PR_TRUE);
+ if(!info->formSubmitURL) formSubmitURL.SetIsVoid(PR_TRUE);
+
+ nsCOMPtr<nsILoginManager> loginManager =
+ do_GetService (NS_LOGINMANAGER_CONTRACTID);
+ NS_ENSURE_TRUE (loginManager, );
+
+ nsCOMPtr<nsILoginInfo> login
+ (do_CreateInstance(NS_LOGININFO_CONTRACTID));
+
+ login->SetUsername(userName);
+ login->SetUsernameField(userNameField);
+ login->SetHostname(host);
+ login->SetHttpRealm(httpRealm);
+ login->SetFormSubmitURL(formSubmitURL);
+ login->SetPassword(password);
+ login->SetPasswordField(passwordField);
+
+ rv = loginManager->RemoveLogin(login);
+
+#else /* !HAVE_GECKO_1_9 */
+ nsCOMPtr<nsIPasswordManager> pm =
+ do_GetService (NS_PASSWORDMANAGER_CONTRACTID);
+ if (!pm) return;
+
+ pm->RemoveUser (nsCString(info->host), userName);
+#endif /* HAVE_GECKO_1_9 */
}
static void
impl_remove_all_passwords (EphyPasswordManager *manager)
{
-#ifndef HAVE_GECKO_1_9
+#ifdef HAVE_GECKO_1_9
+ nsCOMPtr<nsILoginManager> loginManager =
+ do_GetService (NS_LOGINMANAGER_CONTRACTID);
+ NS_ENSURE_TRUE (loginManager, );
+
+ loginManager->RemoveAllLogins();
+
+#else /* HAVE_GECKO_1_9 */
nsresult rv;
nsCOMPtr<nsIPasswordManager> passwordManager =
do_GetService (NS_PASSWORDMANAGER_CONTRACTID);