changes for wallet

This commit is contained in:
morse%netscape.com 1999-03-10 21:42:45 +00:00
parent 80f1f01149
commit 997797e21a
9 changed files with 299 additions and 19 deletions

View File

@ -63,6 +63,7 @@ CPP_OBJS= \
LINCS=-I$(PUBLIC)\xpcom -I$(PUBLIC)\raptor -I$(PUBLIC)\js \
-I$(PUBLIC)\dom -I$(PUBLIC)\netlib \
-I$(PUBLIC)\walletlib \
-I..\..\base\src -I..\..\style\src \
-I..\..\..\base\src -I..\..\content\src

View File

@ -51,20 +51,40 @@
#include "nsHTMLParts.h"
#include "nsIReflowCommand.h"
// GetParentHTMLFrameDocument
#include "nsIWebShell.h"
#include "nsIContentViewerContainer.h"
#include "nsIDocumentViewer.h"
#include "net.h"
#include "xp_file.h"
#include "prio.h"
#include "prmem.h"
#include "prenv.h"
#if defined(ClientWallet) || defined(SingleSignon)
#include "nsIServiceManager.h"
#endif
// GetParentHTMLFrameDocument
static NS_DEFINE_IID(kIWebshellIID, NS_IWEB_SHELL_IID);
static NS_DEFINE_IID(kIContentViewerContainerIID, NS_ICONTENT_VIEWER_CONTAINER_IID);
static NS_DEFINE_IID(kIDocumentViewerIID, NS_IDOCUMENT_VIEWER_IID);
#ifdef SingleSignon
#define FORM_TYPE_TEXT 1
#define FORM_TYPE_PASSWORD 7
#include "nsINetService.h"
#include "nsIServiceManager.h"
static NS_DEFINE_IID(kINetServiceIID, NS_INETSERVICE_IID);
static NS_DEFINE_IID(kNetServiceCID, NS_NETSERVICE_CID);
#endif
#ifdef ClientWallet
#include "nsIWalletService.h"
static NS_DEFINE_IID(kIWalletServiceIID, NS_IWALLETSERVICE_IID);
static NS_DEFINE_IID(kWalletServiceCID, NS_WALLETSERVICE_CID);
#endif
//----------------------------------------------------------------------
static NS_DEFINE_IID(kIFormManagerIID, NS_IFORMMANAGER_IID);
@ -546,10 +566,14 @@ nsFormFrame::OnSubmit(nsIPresContext* aPresContext, nsIFrame* aFrame)
nsIURL* docURL = nsnull;
nsIDocument* doc = nsnull;
mContent->GetDocument(doc);
if (nsnull != doc) {
while (doc && !docURL) {
doc->GetBaseURL(docURL);
NS_RELEASE(doc);
if (!docURL) {
doc = GetParentHTMLFrameDocument(doc);
if (!doc) break;
}
}
NS_IF_RELEASE(doc);
nsAutoString target;
GetTarget(&target);
@ -564,6 +588,33 @@ nsFormFrame::OnSubmit(nsIPresContext* aPresContext, nsIFrame* aFrame)
NS_MakeAbsoluteURL(docURL, base, href, absURLSpec);
NS_IF_RELEASE(docURL);
#ifdef ClientWallet
#ifndef HTMLDialogs
if (href == "internal-walletPrefill-handler") {
nsresult res;
nsIWalletService *walletservice;
res = nsServiceManager::GetService(kWalletServiceCID,
kIWalletServiceIID,
(nsISupports **)&walletservice);
if ((NS_OK == res) && (nsnull != walletservice)) {
res = walletservice->WALLET_Prefill(nsnull, PR_FALSE);
NS_RELEASE(walletservice);
}
}
if (href == "internal-walletEditor-handler") {
nsresult res;
nsIWalletService *walletservice;
res = nsServiceManager::GetService(kWalletServiceCID,
kIWalletServiceIID,
(nsISupports **)&walletservice);
if ((NS_OK == res) && (nsnull != walletservice)) {
res = walletservice->WALLET_PreEdit(nsnull);
NS_RELEASE(walletservice);
}
}
#endif
#endif
// Now pass on absolute url to the click handler
nsIPostData* postData = nsnull;
if (isPost) {
@ -630,6 +681,44 @@ nsString* URLEncode(nsString& aString)
return result;
}
// Hack to get the document from the parent HTML Frame.
// We need this to find the base URL for submitting forms that are created in Javascript
nsIDocument*
nsFormFrame::GetParentHTMLFrameDocument(nsIDocument* doc) {
nsIDocument* parentDocument = nsnull;
nsIScriptContextOwner* webshellOwner = nsnull;
if (!doc) return nsnull;
if ((webshellOwner = doc->GetScriptContextOwner())) {
nsIWebShell* webshell = nsnull;
if (NS_OK == webshellOwner->QueryInterface(kIWebshellIID, (void **)&webshell)) {
nsIWebShell* pWebshell = nsnull;
if (NS_OK == webshell->GetParent(pWebshell)) {
nsIContentViewerContainer* pContentViewerContainer = nsnull;
if (NS_OK == pWebshell->QueryInterface(kIContentViewerContainerIID, (void **)&pContentViewerContainer)) {
nsIContentViewer* pContentViewer = nsnull;
if (NS_OK == pContentViewerContainer->GetContentViewer(&pContentViewer)) {
nsIDocumentViewer* pDocumentViewer;
if (NS_OK == pContentViewer->QueryInterface(kIDocumentViewerIID, (void **)&pDocumentViewer)) {
nsIDocument* pDocument = nsnull;
if (NS_OK == pDocumentViewer->GetDocument(pDocument)) {
parentDocument = pDocument;
NS_RELEASE(doc); // Release the child doc for the caller
}
NS_RELEASE (pDocumentViewer);
}
NS_RELEASE(pContentViewer);
}
NS_RELEASE(pContentViewerContainer);
}
NS_RELEASE(pWebshell);
}
NS_RELEASE(webshell);
}
NS_RELEASE(webshellOwner);
}
return parentDocument;
}
#define CRLF "\015\012"
void nsFormFrame::ProcessAsURLEncoded(PRBool isPost, nsString& aData, nsIFormControlFrame* aFrame)
{
@ -637,26 +726,59 @@ void nsFormFrame::ProcessAsURLEncoded(PRBool isPost, nsString& aData, nsIFormCon
PRBool firstTime = PR_TRUE;
PRUint32 numChildren = mFormControls.Count();
#if defined(ClientWallet) || defined(SingleSignon)
/* get url name as ascii string */
char *URLName = nsnull;
nsIURL* docURL = nsnull;
nsIDocument* doc = nsnull;
mContent->GetDocument(doc);
while (doc && !docURL) {
docURL = doc->GetDocumentURL();
if (!docURL) {
doc = GetParentHTMLFrameDocument(doc);
if (!doc) break;
}
}
if (nsnull != docURL) {
const char* spec;
(void)docURL->GetSpec(&spec);
URLName = (char*)PR_Malloc(PL_strlen(spec)+1);
PL_strcpy(URLName, spec);
NS_IF_RELEASE(docURL);
}
#endif
#ifdef SingleSignon
#define MAX_ARRAY_SIZE 50
char* name_array[MAX_ARRAY_SIZE];
char* value_array[MAX_ARRAY_SIZE];
uint8 type_array[MAX_ARRAY_SIZE];
PRInt32 value_cnt = 0;
#endif
/* get url name as ascii string */
char *URLName;
nsIURL* docURL = nsnull;
nsIDocument* doc = nsnull;
mContent->GetDocument(doc);
if (nsnull != doc) {
docURL = doc->GetDocumentURL();
NS_RELEASE(doc);
const char* spec;
(void)docURL->GetSpec(&spec);
URLName = (char*)PR_Malloc(PL_strlen(spec)+1);
PL_strcpy(URLName, spec);
NS_RELEASE(docURL);
#ifdef ClientWallet
/* determine if form is significant enough to capture data for */
PRBool OKToCapture = FALSE;
PRInt32 count = 0;
PRUint32 numChildren2 = mFormControls.Count();
for (PRUint32 childX2 = 0; childX2 < numChildren2; childX2++) {
nsIFormControlFrame* child = (nsIFormControlFrame*) mFormControls.ElementAt(childX2);
if (child && child->IsSuccessful(aFrame)) {
PRInt32 type;
child->GetType(&type);
if (type == NS_FORM_INPUT_TEXT) {
count++;
}
}
}
nsIWalletService *service2;
nsresult res2 = nsServiceManager::GetService(kWalletServiceCID,
kIWalletServiceIID,
(nsISupports **)&service2);
if ((NS_OK == res2) && (nsnull != service2)) {
service2->WALLET_OKToCapture(&OKToCapture, count, URLName);
NS_RELEASE(service2);
}
#endif
@ -672,9 +794,23 @@ void nsFormFrame::ProcessAsURLEncoded(PRBool isPost, nsString& aData, nsIFormCon
nsString* names = new nsString[maxNumValues];
nsString* values = new nsString[maxNumValues];
if (PR_TRUE == child->GetNamesValues(maxNumValues, numValues, values, names)) {
#ifdef SingleSignon
#if defined(ClientWallet) || defined(SingleSignon)
PRInt32 type;
child->GetType(&type);
#endif
#ifdef ClientWallet
if (OKToCapture && (NS_FORM_INPUT_TEXT == type)) {
nsIWalletService *service;
nsresult res = nsServiceManager::GetService(kWalletServiceCID,
kIWalletServiceIID,
(nsISupports **)&service);
if ((NS_OK == res) && (nsnull != service)) {
res = service->WALLET_Capture(doc, *names, *values);
NS_RELEASE(service);
}
}
#endif
#ifdef SingleSignon
if ((type == NS_FORM_INPUT_PASSWORD) || (type == NS_FORM_INPUT_TEXT)) {
if (type == NS_FORM_INPUT_PASSWORD) {
type_array[value_cnt] = FORM_TYPE_PASSWORD;
@ -718,12 +854,19 @@ void nsFormFrame::ProcessAsURLEncoded(PRBool isPost, nsString& aData, nsIFormCon
(URLName, (char**)name_array, (char**)value_array, (char**)type_array, value_cnt);
NS_RELEASE(service);
}
PR_FREEIF(URLName);
while (value_cnt--) {
PR_FREEIF(name_array[value_cnt]);
PR_FREEIF(value_array[value_cnt]);
}
#endif
#if defined(ClientWallet) || defined(SingleSignon)
if (nsnull != doc) {
NS_RELEASE(doc);
}
if (nsnull != URLName) {
PR_FREEIF(URLName);
}
#endif
aData.SetLength(0);
if (isPost) {

View File

@ -129,6 +129,9 @@ protected:
static char* Temp_GenerateTempFileName(PRInt32 aMaxSize, char* aBuffer);
static void Temp_GetContentType(char* aPathName, char* aContentType);
// XXX Hack to get document from parent html frame. Should Document do this?
nsIDocument* GetParentHTMLFrameDocument(nsIDocument* doc);
nsVoidArray mFormControls;
nsVoidArray mRadioGroups;
nsIFormControlFrame* mTextSubmitter;

View File

@ -45,6 +45,7 @@ LINCS=-I..\public -I$(PUBLIC)\xpcom -I$(PUBLIC)\raptor \
-I$(PUBLIC)\plugin -I$(PUBLIC)\java -I$(PUBLIC)\pref \
-I$(PUBLIC)\js -I$(DEPTH)\include -I$(PUBLIC)\jsurl \
-I$(PUBLIC)\editor -I$(PUBLIC)\rdf \
-I$(PUBLIC)\walletlib \
-I$(PUBLIC)\oji \
-I$(PUBLIC)\uconv \
-I$(PUBLIC)\strres \

View File

@ -69,6 +69,7 @@ LINCS= \
-I$(PUBLIC)\intl \
-I$(PUBLIC)\rdf \
-I$(PUBLIC)\silentdl \
-I$(PUBLIC)\walletlib \
!if defined(NGPREFS)
-I$(PUBLIC)\ngprefs \
!endif

View File

@ -89,6 +89,23 @@
#include "nsUnitConversion.h"
#include "nsIDeviceContext.h"
#if defined(CookieManagement) || defined(SingleSignon) || defined(ClientWallet)
#include "nsIServiceManager.h"
#endif
#if defined(CookieManagement) || defined(SingleSignon)
#include "nsINetService.h"
static NS_DEFINE_IID(kINetServiceIID, NS_INETSERVICE_IID);
static NS_DEFINE_IID(kNetServiceCID, NS_NETSERVICE_CID);
#endif
#ifdef ClientWallet
#include "nsIWalletService.h"
static NS_DEFINE_IID(kIWalletServiceIID, NS_IWALLETSERVICE_IID);
static NS_DEFINE_IID(kWalletServiceCID, NS_WALLETSERVICE_CID);
#endif
#define THROBBING_N
// XXX greasy constants
@ -450,6 +467,18 @@ HandleLocationEvent(nsGUIEvent *aEvent)
nsEventStatus
nsBrowserWindow::DispatchMenuItem(PRInt32 aID)
{
#if defined(CookieManagement) || defined(SingleSignon) || defined(ClientWallet)
nsresult res;
#if defined(CookieManagement) || defined(SingleSignon)
nsINetService *netservice;
#endif
#ifdef ClientWallet
#define WALLET_EDITOR_URL "file:///y|/walleted.html"
nsIWalletService *walletservice;
nsAutoString urlString(WALLET_EDITOR_URL);
#endif
#endif
nsEventStatus result;
#ifdef NS_DEBUG
result = DispatchDebugMenu(aID);
@ -575,6 +604,76 @@ nsBrowserWindow::DispatchMenuItem(PRInt32 aID)
DoImageInspector();
break;
#ifdef ClientWallet
case PRVCY_PREFILL:
case PRVCY_QPREFILL:
nsIPresShell* shell;
shell = nsnull;
shell = GetPresShell();
res = nsServiceManager::GetService(kWalletServiceCID,
kIWalletServiceIID,
(nsISupports **)&walletservice);
if ((NS_OK == res) && (nsnull != walletservice)) {
res = walletservice->WALLET_Prefill(shell, (PRVCY_QPREFILL == aID));
NS_RELEASE(walletservice);
}
#ifndef HTMLDialogs
if (aID == PRVCY_PREFILL) {
nsAutoString url("file:///y|/htmldlgs.htm");
nsIBrowserWindow* bw = nsnull;
mApp->OpenWindow(PRUint32(~0), bw);
bw->Show();
((nsBrowserWindow *)bw)->GoTo(url);
NS_RELEASE(bw);
}
#endif
break;
case PRVCY_DISPLAY_WALLET:
/* set a cookie for the javascript wallet editor */
res = nsServiceManager::GetService(kWalletServiceCID,
kIWalletServiceIID,
(nsISupports **)&walletservice);
if ((NS_OK == res) && (nsnull != walletservice)) {
nsIURL * url;
if (!NS_FAILED(NS_NewURL(&url, WALLET_EDITOR_URL))) {
res = walletservice->WALLET_PreEdit(url);
NS_RELEASE(walletservice);
}
}
/* invoke the javascript wallet editor */
mWebShell->LoadURL(urlString);
break;
#endif
#if defined(CookieManagement)
case PRVCY_DISPLAY_COOKIES:
res = nsServiceManager::GetService(kNetServiceCID,
kINetServiceIID,
(nsISupports **)&netservice);
if ((NS_OK == res) && (nsnull != netservice)) {
res = netservice->NET_DisplayCookieInfoAsHTML();
NS_RELEASE(netservice);
}
break;
#endif
#if defined(SingleSignon)
case PRVCY_DISPLAY_SIGNONS:
res = nsServiceManager::GetService(kNetServiceCID,
kINetServiceIID,
(nsISupports **)&netservice);
if ((NS_OK == res) && (nsnull != netservice)) {
res = netservice->SI_DisplaySignonInfoAsHTML();
NS_RELEASE(netservice);
}
break;
#endif
}
// Any menu IDs that the editor uses will be processed here
@ -838,7 +937,6 @@ nsEventStatus nsBrowserWindow::ProcessDialogEvent(nsGUIEvent *aEvent)
return result;
}
void
nsBrowserWindow::DoFind()
{

View File

@ -24,6 +24,9 @@
#include "nsViewsCID.h"
#include "nsPluginsCID.h"
#include "nsRDFCID.h"
#ifdef ClientWallet
#include "nsIWalletService.h"
#endif wallet
#include "nsIBrowserWindow.h"
#include "nsIWebShell.h"
@ -72,6 +75,9 @@
#define DOM_DLL "jsdom.dll"
#define LAYOUT_DLL "raptorhtml.dll"
#define NETLIB_DLL "netlib.dll"
#ifdef ClientWallet
#define WALLETLIB_DLL "walletlib.dll"
#endif
#define EDITOR_DLL "ender.dll"
#define RDF_DLL "rdf.dll"
#define CAPS_DLL "caps.dll"
@ -102,6 +108,9 @@
#define DOM_DLL "DOM_DLL"
#define LAYOUT_DLL "LAYOUT_DLL"
#define NETLIB_DLL "NETLIB_DLL"
#ifdef ClientWallet
#define WALLETLIB_DLL "WALLETLIB_DLL"
#endif
#define EDITOR_DLL "ENDER_DLL"
#define RDF_DLL "RDF_DLL"
#define UCONV_DLL "UCONV_DLL"
@ -133,6 +142,9 @@
#define DOM_DLL "libjsdom.so"
#define LAYOUT_DLL "libraptorhtml.so"
#define NETLIB_DLL "libnetlib.so"
#ifdef ClientWallet
#define WALLETLIB_DLL "walletlib.so"
#endif
#define EDITOR_DLL "libender.so"
#define RDF_DLL "librdf.so"
#define UCONV_DLL "libuconv.so"
@ -195,6 +207,9 @@ static NS_DEFINE_IID(kCImageDocument, NS_IMAGEDOCUMENT_CID);
static NS_DEFINE_IID(kCHTMLImageElement, NS_HTMLIMAGEELEMENT_CID);
static NS_DEFINE_CID(kNameSpaceManagerCID, NS_NAMESPACEMANAGER_CID);
static NS_DEFINE_IID(kNetServiceCID, NS_NETSERVICE_CID);
#ifdef ClientWallet
static NS_DEFINE_IID(kWalletServiceCID, NS_WALLETSERVICE_CID);
#endif
static NS_DEFINE_IID(kIEditFactoryIID, NS_IEDITORFACTORY_IID);
static NS_DEFINE_IID(kITextEditFactoryIID, NS_ITEXTEDITORFACTORY_IID);
static NS_DEFINE_IID(kIHTMLEditFactoryIID, NS_IHTMLEDITORFACTORY_IID);
@ -301,6 +316,9 @@ NS_SetupRegistry()
nsComponentManager::RegisterComponent(kCHTMLImageElement, NULL, NULL, LAYOUT_DLL, PR_FALSE, PR_FALSE);
nsComponentManager::RegisterComponent(kNameSpaceManagerCID, NULL, NULL, LAYOUT_DLL, PR_FALSE, PR_FALSE);
nsComponentManager::RegisterComponent(kNetServiceCID, NULL, NULL, NETLIB_DLL, PR_FALSE, PR_FALSE);
#ifdef ClientWallet
nsComponentManager::RegisterComponent(kWalletServiceCID, NULL, NULL, WALLETLIB_DLL, PR_FALSE, PR_FALSE);
#endif
nsComponentManager::RegisterComponent(kIEditFactoryIID, NULL, NULL, EDITOR_DLL, PR_FALSE, PR_FALSE);
nsComponentManager::RegisterComponent(kITextEditFactoryIID, NULL, NULL, EDITOR_DLL, PR_FALSE, PR_FALSE);
nsComponentManager::RegisterComponent(kIHTMLEditFactoryIID, NULL, NULL, EDITOR_DLL, PR_FALSE, PR_FALSE);

View File

@ -103,6 +103,12 @@
#define VIEWER_RL_BASE 41000
#define PRVCY_PREFILL 40290
#define PRVCY_QPREFILL 40291
#define PRVCY_DISPLAY_WALLET 40292
#define PRVCY_DISPLAY_COOKIES 40293
#define PRVCY_DISPLAY_SIGNONS 40294
#define VIEWER_TOP100 40300
#define VIEWER_XPTOOLKITDEMOBASE 40900

View File

@ -124,6 +124,15 @@ VIEWER MENU DISCARDABLE
MENUITEM "&JavaScript Console", JS_CONSOLE
MENUITEM "&Editor Mode", EDITOR_MODE
MENUITEM SEPARATOR
POPUP "&Privacy Tools"
{
MENUITEM "Safe Prefill from &Wallet", PRVCY_PREFILL
MENUITEM "&Quick Prefill from &Wallet", PRVCY_QPREFILL
MENUITEM SEPARATOR
MENUITEM "Display Wa&llet", PRVCY_DISPLAY_WALLET
MENUITEM "Display &Cookies", PRVCY_DISPLAY_COOKIES
MENUITEM "Display &Signons", PRVCY_DISPLAY_SIGNONS
}
POPUP "Editor Tests"
{
MENUITEM "Insert Table", VIEWER_EDIT_INSERT_TABLE