part of fix for #46200 - extract wallet from nsIBrowserInstance, and fixup all callers to call

the wallet service directly.. yay!
r=jag, a=ben
This commit is contained in:
alecf%netscape.com 2000-11-02 23:00:08 +00:00
Родитель 0a58794dfe
Коммит 574fa5d34d
8 изменённых файлов: 82 добавлений и 173 удалений

Просмотреть файл

@ -52,8 +52,8 @@ interface nsIWalletService : nsISupports {
[noscript]void WALLET_PostEdit(in nsAutoString walletList);
boolean WALLET_ChangePassword();
void WALLET_DeleteAll();
PRUint32 WALLET_RequestToCapture(in nsIPresShell shell, in nsIDOMWindowInternal win);
boolean WALLET_Prefill(in nsIPresShell shell, in boolean quick, in nsIDOMWindowInternal win);
unsigned long WALLET_RequestToCapture(in nsIDOMWindowInternal win);
boolean WALLET_Prefill(in boolean quick, in nsIDOMWindowInternal win);
[noscript]void WALLET_PrefillReturn(in nsAutoString results);
void WALLET_FetchFromNetCenter();
boolean WALLET_ExpirePassword();

Просмотреть файл

@ -44,6 +44,9 @@
#include "nsIInterfaceRequestor.h"
#include "nsIPrompt.h"
// for making the leap from nsIDOMWindowInternal -> nsIPresShell
#include "nsIScriptGlobalObject.h"
static NS_DEFINE_IID(kDocLoaderServiceCID, NS_DOCUMENTLOADER_SERVICE_CID);
static NS_DEFINE_CID(kNetSupportDialogCID, NS_NETSUPPORTDIALOG_CID);
@ -89,13 +92,39 @@ NS_IMETHODIMP nsWalletlibService::WALLET_DeleteAll() {
return NS_OK;
}
NS_IMETHODIMP nsWalletlibService::WALLET_RequestToCapture(nsIPresShell* shell, nsIDOMWindowInternal* win, PRUint32* status) {
::WLLT_RequestToCapture(shell, win, status);
NS_IMETHODIMP
nsWalletlibService::WALLET_RequestToCapture(nsIDOMWindowInternal* aWin,
PRUint32* status)
{
nsCOMPtr<nsIScriptGlobalObject> scriptGlobalObject;
scriptGlobalObject = do_QueryInterface(aWin);
nsCOMPtr<nsIDocShell> docShell;
scriptGlobalObject->GetDocShell(getter_AddRefs(docShell));
nsCOMPtr<nsIPresShell> presShell;
if(docShell)
docShell->GetPresShell(getter_AddRefs(presShell));
::WLLT_RequestToCapture(presShell, aWin, status);
return NS_OK;
}
NS_IMETHODIMP nsWalletlibService::WALLET_Prefill(nsIPresShell* shell, PRBool quick, nsIDOMWindowInternal* win, PRBool* status) {
return ::WLLT_Prefill(shell, quick, win);
NS_IMETHODIMP
nsWalletlibService::WALLET_Prefill(PRBool quick,
nsIDOMWindowInternal* aWin,
PRBool* status)
{
nsCOMPtr<nsIScriptGlobalObject> scriptGlobalObject;
scriptGlobalObject = do_QueryInterface(aWin);
nsCOMPtr<nsIDocShell> docShell;
scriptGlobalObject->GetDocShell(getter_AddRefs(docShell));
nsCOMPtr<nsIPresShell> presShell;
if(docShell)
docShell->GetPresShell(getter_AddRefs(presShell));
return ::WLLT_Prefill(presShell, quick, aWin);
}
NS_IMETHODIMP nsWalletlibService::WALLET_PrefillReturn(nsAutoString results){

Просмотреть файл

@ -42,7 +42,6 @@
#include "nsIDirectoryService.h"
#include "nsAppDirectoryServiceDefs.h"
#include "nsSpecialSystemDirectory.h"
#include "nsIWalletService.h"
#include "nsIWindowMediator.h"
#include "nsIDOMWindowInternal.h"
#include "nsIClipboard.h"
@ -85,8 +84,6 @@
static NS_DEFINE_CID(kSoftUpdateCID, NS_SoftwareUpdate_CID);
static NS_DEFINE_CID(kWindowMediatorCID, NS_WINDOWMEDIATOR_CID);
static NS_DEFINE_CID(kWalletServiceCID, NS_WALLETSERVICE_CID);
static NS_DEFINE_CID(kBrowserContentHandlerCID, NS_BROWSERCONTENTHANDLER_CID);
static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
@ -1007,13 +1004,6 @@ static nsresult main1(int argc, char* argv[], nsISupports *nativeApp )
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to Ensure1Window");
if (NS_FAILED(rv)) return rv;
// Fire up the walletService. Why the heck is this here?
NS_WITH_SERVICE(nsIWalletService, walletService, kWalletServiceCID, &rv);
// if (NS_SUCCEEDED(rv))
// {
// // this is a no-op. What is going on?
// walletService->WALLET_FetchFromNetCenter();
// }
InitCachePrefs();

Просмотреть файл

@ -47,14 +47,6 @@ interface nsIBrowserInstance : nsISupports {
void gotoHistoryIndex(in PRInt32 index);
void updateGoMenu(in nsIDOMNode goMenu);
// Wallet (should reside elsewhere, somehow).
boolean walletPreview(in nsIDOMWindowInternal win, in nsIDOMWindowInternal form);
boolean walletChangePassword();
boolean walletQuickFillin(in nsIDOMWindowInternal win);
PRUint32 walletRequestToCapture(in nsIDOMWindowInternal win);
// Infrastructure.
void init();
void setContentWindow( in nsIDOMWindowInternal aWindow );

Просмотреть файл

@ -436,15 +436,13 @@ nsContextMenu.prototype = {
// Capture the values that are filled in on the form being displayed.
capture : function () {
if( appCore ) {
status = appCore.walletRequestToCapture(window._content);
}
var walletService = Components.classes["@mozilla.org/wallet/wallet-service;1"].getService(Components.interfaces.nsIWalletService);
walletService.WALLET_RequestToCapture(window._content);
},
// Prefill the form being displayed.
prefill : function () {
if( appCore ) {
appCore.walletPreview(window, window._content);
}
walletPreview(window._content);
},
// Determine if "Save Form Data" is to appear in the menu.

Просмотреть файл

@ -97,7 +97,6 @@
#include "nsFileLocations.h"
#include "nsIFileSpec.h"
#include "nsIWalletService.h"
#include "nsCURILoader.h"
#include "nsIContentHandler.h"
@ -126,8 +125,6 @@
#include "nsISecureBrowserUI.h"
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
static NS_DEFINE_IID(kIWalletServiceIID, NS_IWALLETSERVICE_IID);
static NS_DEFINE_IID(kWalletServiceCID, NS_WALLETSERVICE_CID);
static NS_DEFINE_CID(kPrefServiceCID, NS_PREF_CID);
static NS_DEFINE_CID(kDocumentCharsetInfoCID, NS_DOCUMENTCHARSETINFO_CID);
static NS_DEFINE_CID(kCharsetConverterManagerCID, NS_ICHARSETCONVERTERMANAGER_CID);
@ -1008,134 +1005,6 @@ nsBrowserInstance::GotoHistoryIndex(PRInt32 aIndex)
}
NS_IMETHODIMP
nsBrowserInstance::WalletPreview(nsIDOMWindowInternal* aWin, nsIDOMWindowInternal* aForm, PRBool* status)
{
NS_PRECONDITION(aForm != nsnull, "null ptr");
if (! aForm)
return NS_ERROR_NULL_POINTER;
nsCOMPtr<nsIScriptGlobalObject> scriptGlobalObject;
scriptGlobalObject = do_QueryInterface(aForm);
nsCOMPtr<nsIDocShell> docShell;
scriptGlobalObject->GetDocShell(getter_AddRefs(docShell));
nsCOMPtr<nsIPresShell> presShell;
if(docShell)
docShell->GetPresShell(getter_AddRefs(presShell));
nsIWalletService *walletservice;
nsresult res = nsServiceManager::GetService(kWalletServiceCID,
kIWalletServiceIID,
(nsISupports **)&walletservice);
if (NS_SUCCEEDED(res) && (nsnull != walletservice)) {
res = walletservice->WALLET_Prefill(presShell, PR_FALSE, aForm, status);
nsServiceManager::ReleaseService(kWalletServiceCID, walletservice);
if (NS_FAILED(res)) { /* this just means that there was nothing to prefill */
return NS_OK;
}
} else {
return res;
}
nsCOMPtr<nsIScriptGlobalObject> sgo(do_QueryInterface(aWin));
NS_ENSURE_TRUE(sgo, NS_ERROR_FAILURE);
nsCOMPtr<nsIScriptContext> scriptContext;
sgo->GetContext(getter_AddRefs(scriptContext));
NS_ENSURE_TRUE(scriptContext, NS_ERROR_FAILURE);
JSContext* jsContext = (JSContext*)scriptContext->GetNativeContext();
NS_ENSURE_TRUE(jsContext, NS_ERROR_FAILURE);
void* mark;
jsval* argv;
argv = JS_PushArguments(jsContext, &mark, "sss", "chrome://communicator/content/wallet/WalletPreview.xul", "_blank",
//"chrome,dialog=yes,modal=yes,all");
"chrome,modal=yes,dialog=yes,all,width=504,height=436");
NS_ENSURE_TRUE(argv, NS_ERROR_FAILURE);
nsCOMPtr<nsIDOMWindowInternal> newWindow;
aWin->OpenDialog(jsContext, argv, 3, getter_AddRefs(newWindow));
JS_PopArguments(jsContext, mark);
return NS_OK;
}
NS_IMETHODIMP
nsBrowserInstance::WalletChangePassword(PRBool* status)
{
nsIWalletService *walletservice;
nsresult res;
res = nsServiceManager::GetService(kWalletServiceCID,
kIWalletServiceIID,
(nsISupports **)&walletservice);
if ((NS_OK == res) && (nsnull != walletservice)) {
res = walletservice->WALLET_ChangePassword(status);
nsServiceManager::ReleaseService(kWalletServiceCID, walletservice);
}
return NS_OK;
}
#include "nsIDOMHTMLDocument.h"
static NS_DEFINE_IID(kIDOMHTMLDocumentIID, NS_IDOMHTMLDOCUMENT_IID);
NS_IMETHODIMP
nsBrowserInstance::WalletQuickFillin(nsIDOMWindowInternal* aWin, PRBool* status)
{
NS_PRECONDITION(aWin != nsnull, "null ptr");
if (! aWin)
return NS_ERROR_NULL_POINTER;
nsCOMPtr<nsIScriptGlobalObject> scriptGlobalObject;
scriptGlobalObject = do_QueryInterface(aWin);
nsCOMPtr<nsIDocShell> docShell;
scriptGlobalObject->GetDocShell(getter_AddRefs(docShell));
nsCOMPtr<nsIPresShell> presShell;
if(docShell)
docShell->GetPresShell(getter_AddRefs(presShell));
nsIWalletService *walletservice;
nsresult res;
res = nsServiceManager::GetService(kWalletServiceCID,
kIWalletServiceIID,
(nsISupports **)&walletservice);
if ((NS_OK == res) && (nsnull != walletservice)) {
res = walletservice->WALLET_Prefill(presShell, PR_TRUE, aWin, status);
nsServiceManager::ReleaseService(kWalletServiceCID, walletservice);
return NS_OK;
} else {
return res;
}
}
NS_IMETHODIMP
nsBrowserInstance::WalletRequestToCapture(nsIDOMWindowInternal* aWin, PRUint32* status)
{
NS_PRECONDITION(aWin != nsnull, "null ptr");
if (! aWin)
return NS_ERROR_NULL_POINTER;
nsCOMPtr<nsIScriptGlobalObject> scriptGlobalObject;
scriptGlobalObject = do_QueryInterface(aWin);
nsCOMPtr<nsIDocShell> docShell;
scriptGlobalObject->GetDocShell(getter_AddRefs(docShell));
nsCOMPtr<nsIPresShell> presShell;
if(docShell)
docShell->GetPresShell(getter_AddRefs(presShell));
nsIWalletService *walletservice;
nsresult res;
res = nsServiceManager::GetService(kWalletServiceCID,
kIWalletServiceIID,
(nsISupports **)&walletservice);
if ((NS_OK == res) && (nsnull != walletservice)) {
res = walletservice->WALLET_RequestToCapture(presShell, aWin, status);
nsServiceManager::ReleaseService(kWalletServiceCID, walletservice);
return NS_OK;
} else {
return res;
}
}
NS_IMETHODIMP
nsBrowserInstance::Init()

Просмотреть файл

@ -356,22 +356,22 @@ function WalletAction( action )
return;
}
if( appCore ) {
var walletService = Components.classes["@mozilla.org/wallet/wallet-service;1"].getService(Components.interfaces.nsIWalletService);
switch( action ) {
case "safefill":
appCore.walletPreview(window, window._content);
walletPreview(window._content);
break;
// case "password":
// appCore.walletChangePassword();
// walletService.WALLET_ChangePassword();
// break;
case "quickfill":
appCore.walletQuickFillin(window._content);
walletService.WALLET_Prefill(true, window._content);
break;
case "capture":
default:
status = appCore.walletRequestToCapture(window._content);
status = walletService.WALLET_RequestToCapture(window._content);
break;
}
}
}

Просмотреть файл

@ -1,3 +1,26 @@
/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Alec Flett <alecf@netscape.com>
*/
/**
* Communicator Shared Utility Library
* for shared application glue for the Communicator suite of applications
@ -192,16 +215,24 @@ function okToPrefill() {
function capture()
{
if( appCore ) {
status = appCore.walletRequestToCapture(window._content);
}
var walletService = Components.classes["@mozilla.org/wallet/wallet-service;1"].getService(Components.interfaces.nsIWalletService);
walletService.WALLET_RequestToCapture(window._content);
}
function prefill()
{
if( appCore ) {
appCore.walletPreview(window, window._content);
}
walletPreview(window._content);
}
// eventually should be moved into wallet code
function walletPreview(aForm) {
var walletService = Components.classes["@mozilla.org/wallet/wallet-service;1"].getService(Components.interfaces.nsIWalletService);
walletService.WALLET_Prefill(false, aForm);
window.openDialog("chrome://communicator/content/wallet/WalletPreview.xul",
"_blank", "chrome,modal=yes,dialog=yes,all, width=504, height=436");
}
function goToggleToolbar( id, elementID )