aboutsummaryrefslogtreecommitdiffstats
path: root/embed
diff options
context:
space:
mode:
authorChristian Persch <chpe@cvs.gnome.org>2005-02-11 21:56:43 +0800
committerChristian Persch <chpe@src.gnome.org>2005-02-11 21:56:43 +0800
commitaea39d8177f65432073b257d1b6e2ffa40ed5054 (patch)
treef8f8eec66f80a061aa52f2150d633183b05ea33e /embed
parent6603cf97ba05529d11d62176ba5075cb13a7bc74 (diff)
downloadgsoc2013-epiphany-aea39d8177f65432073b257d1b6e2ffa40ed5054.tar
gsoc2013-epiphany-aea39d8177f65432073b257d1b6e2ffa40ed5054.tar.gz
gsoc2013-epiphany-aea39d8177f65432073b257d1b6e2ffa40ed5054.tar.bz2
gsoc2013-epiphany-aea39d8177f65432073b257d1b6e2ffa40ed5054.tar.lz
gsoc2013-epiphany-aea39d8177f65432073b257d1b6e2ffa40ed5054.tar.xz
gsoc2013-epiphany-aea39d8177f65432073b257d1b6e2ffa40ed5054.tar.zst
gsoc2013-epiphany-aea39d8177f65432073b257d1b6e2ffa40ed5054.zip
Move wallet code to MozillaPrivate since nsIWalletService.h includes
2005-02-11 Christian Persch <chpe@cvs.gnome.org> * embed/mozilla/MozillaPrivate.cpp: * embed/mozilla/MozillaPrivate.h: * embed/mozilla/mozilla-embed-single.cpp: Move wallet code to MozillaPrivate since nsIWalletService.h includes nsString.h in older mozilla versions.
Diffstat (limited to 'embed')
-rw-r--r--embed/mozilla/MozillaPrivate.cpp67
-rw-r--r--embed/mozilla/MozillaPrivate.h4
-rw-r--r--embed/mozilla/mozilla-embed-single.cpp55
3 files changed, 72 insertions, 54 deletions
diff --git a/embed/mozilla/MozillaPrivate.cpp b/embed/mozilla/MozillaPrivate.cpp
index 8e2409225..37860a502 100644
--- a/embed/mozilla/MozillaPrivate.cpp
+++ b/embed/mozilla/MozillaPrivate.cpp
@@ -18,6 +18,10 @@
* $Id$
*/
+#include "mozilla-config.h"
+
+#include "config.h"
+
#include "MozillaPrivate.h"
#include <nsIPrintSettingsService.h>
@@ -27,6 +31,14 @@
#include <nsISupportsPrimitives.h>
#include <nsPromiseFlatString.h>
+#ifdef HAVE_NSIWALLETSERVICE_H
+#include <nsIPrefBranch.h>
+#include <nsIDOMWindowInternal.h>
+#include <wallet/nsIWalletService.h>
+#endif
+
+#include "ephy-debug.h"
+
/* IMPORTANT. Put only code that use internal mozilla strings (nsAutoString for
* example) in this file. Note that you cannot use embed strings here,
* the header inclusions will conflict.
@@ -71,3 +83,58 @@ MozillaPrivate::GetPrinterList ()
return g_list_reverse (printers);
}
+
+#ifdef HAVE_NSIWALLETSERVICE_H
+
+class DummyWindow : public nsIDOMWindowInternal
+{
+public:
+ DummyWindow () { LOG ("DummyWindow ctor"); };
+ virtual ~DummyWindow () { LOG ("DummyWindow dtor"); };
+
+ NS_DECL_ISUPPORTS
+ NS_FORWARD_SAFE_NSIDOMWINDOW(mFake);
+ NS_FORWARD_SAFE_NSIDOMWINDOW2(mFake2);
+ NS_FORWARD_SAFE_NSIDOMWINDOWINTERNAL(mFakeInt);
+private:
+ nsCOMPtr<nsIDOMWindow> mFake;
+ nsCOMPtr<nsIDOMWindow2> mFake2;
+ nsCOMPtr<nsIDOMWindowInternal> mFakeInt;
+};
+
+NS_IMPL_ISUPPORTS3(DummyWindow, nsIDOMWindow, nsIDOMWindow2, nsIDOMWindowInternal)
+
+#endif /* HAVE_NSIWALLETSERVICE_H */
+
+void
+MozillaPrivate::SecureWallet (nsIPrefBranch *pref)
+{
+#ifdef HAVE_NSIWALLETSERVICE_H
+ nsresult rv;
+ PRBool isEnabled = PR_FALSE;
+ rv = pref->GetBoolPref ("wallet.crypto", &isEnabled);
+ if (NS_SUCCEEDED (rv) && isEnabled) return;
+
+ nsCOMPtr<nsIWalletService> wallet (do_GetService (NS_WALLETSERVICE_CONTRACTID));
+ NS_ENSURE_TRUE (wallet, );
+
+ /* We cannot set nsnull as callback data here, since that will crash
+ * in case wallet needs to get the prompter from it (missing null check
+ * in wallet code). Therefore we create a dummy impl which will just
+ * always fail. There is no way to safely set nsnull after we're done,
+ * so we'll just leak our dummy window.
+ */
+ DummyWindow *win = new DummyWindow();
+ if (!win) return;
+
+ nsCOMPtr<nsIDOMWindowInternal> domWinInt (do_QueryInterface (win));
+ NS_ENSURE_TRUE (domWinInt, );
+
+ /* WALLET_InitReencryptCallback doesN'T addref but stores the pointer! */
+ NS_ADDREF (win);
+ wallet->WALLET_InitReencryptCallback (domWinInt);
+
+ /* Now set the pref. This will encrypt the existing data. */
+ pref->SetBoolPref ("wallet.crypto", PR_TRUE);
+#endif /* HAVE_NSIWALLETSERVICE_H */
+}
diff --git a/embed/mozilla/MozillaPrivate.h b/embed/mozilla/MozillaPrivate.h
index 5c7c0a8d6..73ef25253 100644
--- a/embed/mozilla/MozillaPrivate.h
+++ b/embed/mozilla/MozillaPrivate.h
@@ -20,7 +20,11 @@
#include <glib.h>
+class nsIPrefBranch;
+
namespace MozillaPrivate
{
GList *GetPrinterList ();
+
+ void SecureWallet (nsIPrefBranch *pref);
}
diff --git a/embed/mozilla/mozilla-embed-single.cpp b/embed/mozilla/mozilla-embed-single.cpp
index 53d1d40e8..961aced31 100644
--- a/embed/mozilla/mozilla-embed-single.cpp
+++ b/embed/mozilla/mozilla-embed-single.cpp
@@ -87,11 +87,6 @@
#include <nsIIDNService.h>
#endif /* ALLOW_PRIVATE_API */
-#ifdef HAVE_NSIWALLETSERVICE_H
-#include <nsIDOMWindowInternal.h>
-#include <wallet/nsIWalletService.h>
-#endif
-
#include <stdlib.h>
#define MOZILLA_PROFILE_DIR "/mozilla"
@@ -194,28 +189,6 @@ mozilla_embed_single_get_type (void)
return type;
}
-#ifdef HAVE_NSIWALLETSERVICE_H
-
-class DummyWindow : public nsIDOMWindowInternal
-{
-public:
- DummyWindow () { LOG ("DummyWindow ctor"); };
- virtual ~DummyWindow () { LOG ("DummyWindow dtor"); };
-
- NS_DECL_ISUPPORTS
- NS_FORWARD_SAFE_NSIDOMWINDOW(mFake);
- NS_FORWARD_SAFE_NSIDOMWINDOW2(mFake2);
- NS_FORWARD_SAFE_NSIDOMWINDOWINTERNAL(mFakeInt);
-private:
- nsCOMPtr<nsIDOMWindow> mFake;
- nsCOMPtr<nsIDOMWindow2> mFake2;
- nsCOMPtr<nsIDOMWindowInternal> mFakeInt;
-};
-
-NS_IMPL_ISUPPORTS3(DummyWindow, nsIDOMWindow, nsIDOMWindow2, nsIDOMWindowInternal)
-
-#endif /* HAVE_NSIWALLETSERVICE_H */
-
static gboolean
mozilla_set_default_prefs (MozillaEmbedSingle *mes)
{
@@ -272,33 +245,7 @@ mozilla_set_default_prefs (MozillaEmbedSingle *mes)
pref->SetBoolPref("network.protocol-handler.external.ftp",
have_gnome_url_handler ("ftp"));
-#ifdef HAVE_NSIWALLETSERVICE_H
- PRBool isEnabled = PR_FALSE;
- rv = pref->GetBoolPref ("wallet.crypto", &isEnabled);
- if (NS_FAILED (rv) || !isEnabled)
- {
- nsCOMPtr<nsIWalletService> wallet (do_GetService (NS_WALLETSERVICE_CONTRACTID));
- NS_ENSURE_TRUE (wallet, TRUE);
-
- /* We cannot set nsnull as callback data here, since that will crash
- * in case wallet needs to get the prompter from it (missing null check
- * in wallet code). Therefore we create a dummy impl which will just
- * always fail. There is no way to safely set nsnull after we're done,
- * so we'll just leak our dummy window.
- */
- DummyWindow *win = new DummyWindow();
- if (!win) return TRUE;
-
- nsCOMPtr<nsIDOMWindowInternal> domWinInt (do_QueryInterface (win));
- NS_ENSURE_TRUE (domWinInt, TRUE);
-
- NS_ADDREF (win);
- wallet->WALLET_InitReencryptCallback (domWinInt);
-
- /* Now set the pref. This will encrypt the existing data. */
- pref->SetBoolPref ("wallet.crypto", PR_TRUE);
- }
-#endif /* HAVE_NSIWALLETSERVICE_H */
+ MozillaPrivate::SecureWallet (pref);
return TRUE;
}