зеркало из https://github.com/mozilla/gecko-dev.git
fix wallet editor
This commit is contained in:
Родитель
74cd2a1d81
Коммит
3c51cf13ac
|
@ -0,0 +1,46 @@
|
|||
/* -*- Mode: C++; 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.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
A sample of XPConnect. This file contains a WalletEditor interface.
|
||||
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
#include "domstubs.idl"
|
||||
%{C++
|
||||
#include "nsIDOMWindow.h"
|
||||
%}
|
||||
|
||||
[scriptable, uuid(0A904580-1C88-11d3-ABA9-0080C787AD96)]
|
||||
interface nsIWalletEditor : nsISupports
|
||||
{
|
||||
void SetValue(in string aValue, in nsIDOMWindow win);
|
||||
string GetValue();
|
||||
};
|
||||
|
||||
|
||||
%{ C++
|
||||
// {F86A2E60-1C6A-11d3-ABA9-0080C787AD96}
|
||||
#define NS_WALLETEDITOR_CID \
|
||||
{ 0xf86a2e60, 0x1c6a, 0x11d3, { 0xab, 0xa9, 0x0, 0x80, 0xc7, 0x87, 0xad, 0x96 } }
|
||||
|
||||
extern nsresult
|
||||
NS_NewWalletEditor(nsIWalletEditor** aWalletEditor);
|
||||
%}
|
|
@ -0,0 +1,158 @@
|
|||
/* -*- Mode: C++; 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.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsIAllocator.h"
|
||||
#include "plstr.h"
|
||||
#include "stdio.h"
|
||||
#include "nsIWalletService.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIDOMWindow.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIWebShell.h"
|
||||
#include "nsIWebShellWindow.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsIWalletEditor.h"
|
||||
|
||||
static NS_DEFINE_IID(kIWalletServiceIID, NS_IWALLETSERVICE_IID);
|
||||
static NS_DEFINE_IID(kWalletServiceCID, NS_WALLETSERVICE_CID);
|
||||
|
||||
class WalletEditorImpl : public nsIWalletEditor
|
||||
{
|
||||
public:
|
||||
WalletEditorImpl();
|
||||
virtual ~WalletEditorImpl();
|
||||
|
||||
// nsISupports interface
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIWalletEditor interface
|
||||
NS_IMETHOD GetValue(char * *aValue);
|
||||
NS_IMETHOD SetValue(const char *aValue, nsIDOMWindow *win);
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
nsresult
|
||||
NS_NewWalletEditor(nsIWalletEditor** aWalletEditor)
|
||||
{
|
||||
NS_PRECONDITION(aWalletEditor != nsnull, "null ptr");
|
||||
if (!aWalletEditor) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
*aWalletEditor = new WalletEditorImpl();
|
||||
if (! *aWalletEditor) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
NS_ADDREF(*aWalletEditor);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
WalletEditorImpl::WalletEditorImpl()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
WalletEditorImpl::~WalletEditorImpl()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS(WalletEditorImpl, nsIWalletEditor::GetIID());
|
||||
|
||||
NS_IMETHODIMP
|
||||
WalletEditorImpl::GetValue(char** aValue)
|
||||
{
|
||||
NS_PRECONDITION(aValue != nsnull, "null ptr");
|
||||
if (!aValue) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
|
||||
nsIWalletService *walletservice;
|
||||
nsresult res;
|
||||
res = nsServiceManager::GetService(kWalletServiceCID,
|
||||
kIWalletServiceIID,
|
||||
(nsISupports **)&walletservice);
|
||||
if ((NS_SUCCEEDED(res)) && (nsnull != walletservice)) {
|
||||
nsAutoString walletList;
|
||||
res = walletservice->WALLET_PreEdit(walletList);
|
||||
if (NS_SUCCEEDED(res)) {
|
||||
*aValue = walletList.ToNewCString();
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
static void DOMWindowToWebShellWindow(
|
||||
nsIDOMWindow *DOMWindow,
|
||||
nsCOMPtr<nsIWebShellWindow> *webWindow)
|
||||
{
|
||||
if (!DOMWindow) {
|
||||
return; // with webWindow unchanged -- its constructor gives it a null ptr
|
||||
}
|
||||
nsCOMPtr<nsIScriptGlobalObject> globalScript(do_QueryInterface(DOMWindow));
|
||||
nsCOMPtr<nsIWebShell> webshell, rootWebshell;
|
||||
if (globalScript) {
|
||||
globalScript->GetWebShell(getter_AddRefs(webshell));
|
||||
}
|
||||
if (webshell) {
|
||||
webshell->GetRootWebShellEvenIfChrome(*getter_AddRefs(rootWebshell));
|
||||
}
|
||||
if (rootWebshell) {
|
||||
nsCOMPtr<nsIWebShellContainer> webshellContainer;
|
||||
rootWebshell->GetContainer(*getter_AddRefs(webshellContainer));
|
||||
*webWindow = do_QueryInterface(webshellContainer);
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
WalletEditorImpl::SetValue(const char* aValue, nsIDOMWindow* win)
|
||||
{
|
||||
/* close the window */
|
||||
if (!win) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
nsIDOMWindow* top;
|
||||
win->GetTop(&top);
|
||||
if (!top) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
nsCOMPtr<nsIWebShellWindow> parent;
|
||||
DOMWindowToWebShellWindow(top, &parent);
|
||||
if (parent) {
|
||||
parent->Close();
|
||||
}
|
||||
NS_IF_RELEASE(win);
|
||||
|
||||
/* process the value */
|
||||
NS_PRECONDITION(aValue != nsnull, "null ptr");
|
||||
if (! aValue) {
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
}
|
||||
nsIWalletService *walletservice;
|
||||
nsresult res;
|
||||
res = nsServiceManager::GetService(kWalletServiceCID,
|
||||
kIWalletServiceIID,
|
||||
(nsISupports **)&walletservice);
|
||||
if ((NS_SUCCEEDED(res)) && (nsnull != walletservice)) {
|
||||
nsAutoString walletList = aValue;
|
||||
res = walletservice->WALLET_PostEdit(walletList);
|
||||
}
|
||||
return res;
|
||||
}
|
|
@ -0,0 +1,206 @@
|
|||
/* -*- Mode: C++; 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.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
A sample of XPConnect. This file contains the XPCOM factory the
|
||||
creates for WalletEditorImpl objects.
|
||||
|
||||
*/
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nscore.h"
|
||||
#include "nsIWalletEditor.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsXPComFactory.h"
|
||||
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
|
||||
static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID);
|
||||
static NS_DEFINE_CID(kWalletEditorCID, NS_WALLETEDITOR_CID);
|
||||
|
||||
class WalletEditorFactoryImpl : public nsIFactory
|
||||
{
|
||||
public:
|
||||
WalletEditorFactoryImpl(const nsCID &aClass, const char* className, const char* progID);
|
||||
|
||||
// nsISupports methods
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIFactory methods
|
||||
NS_IMETHOD CreateInstance(nsISupports *aOuter,
|
||||
const nsIID &aIID,
|
||||
void **aResult);
|
||||
|
||||
NS_IMETHOD LockFactory(PRBool aLock);
|
||||
|
||||
protected:
|
||||
virtual ~WalletEditorFactoryImpl();
|
||||
|
||||
protected:
|
||||
nsCID mClassID;
|
||||
const char* mClassName;
|
||||
const char* mProgID;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
WalletEditorFactoryImpl::WalletEditorFactoryImpl(const nsCID &aClass,
|
||||
const char* className,
|
||||
const char* progID)
|
||||
: mClassID(aClass), mClassName(className), mProgID(progID)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
WalletEditorFactoryImpl::~WalletEditorFactoryImpl()
|
||||
{
|
||||
NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
WalletEditorFactoryImpl::QueryInterface(const nsIID &aIID, void **aResult)
|
||||
{
|
||||
if (! aResult)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
// Always NULL result, in case of failure
|
||||
*aResult = nsnull;
|
||||
|
||||
if (aIID.Equals(kISupportsIID)) {
|
||||
*aResult = NS_STATIC_CAST(nsISupports*, this);
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
} else if (aIID.Equals(kIFactoryIID)) {
|
||||
*aResult = NS_STATIC_CAST(nsIFactory*, this);
|
||||
AddRef();
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(WalletEditorFactoryImpl);
|
||||
NS_IMPL_RELEASE(WalletEditorFactoryImpl);
|
||||
|
||||
NS_IMETHODIMP
|
||||
WalletEditorFactoryImpl::CreateInstance(nsISupports *aOuter,
|
||||
const nsIID &aIID,
|
||||
void **aResult)
|
||||
{
|
||||
if (! aResult)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
if (aOuter)
|
||||
return NS_ERROR_NO_AGGREGATION;
|
||||
|
||||
*aResult = nsnull;
|
||||
|
||||
nsresult rv;
|
||||
|
||||
nsISupports *inst = nsnull;
|
||||
if (mClassID.Equals(kWalletEditorCID)) {
|
||||
if (NS_FAILED(rv = NS_NewWalletEditor((nsIWalletEditor**) &inst)))
|
||||
return rv;
|
||||
}
|
||||
else {
|
||||
return NS_ERROR_NO_INTERFACE;
|
||||
}
|
||||
|
||||
if (! inst)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
if (NS_FAILED(rv = inst->QueryInterface(aIID, aResult))) {
|
||||
// We didn't get the right interface.
|
||||
NS_ERROR("didn't support the interface you wanted");
|
||||
}
|
||||
|
||||
NS_IF_RELEASE(inst);
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult WalletEditorFactoryImpl::LockFactory(PRBool aLock)
|
||||
{
|
||||
// Not implemented in simplest case.
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
// return the proper factory to the caller
|
||||
extern "C" PR_IMPLEMENT(nsresult)
|
||||
NSGetFactory(nsISupports* aServMgr,
|
||||
const nsCID &aClass,
|
||||
const char *aClassName,
|
||||
const char *aProgID,
|
||||
nsIFactory **aFactory)
|
||||
{
|
||||
if (! aFactory)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
WalletEditorFactoryImpl* factory = new WalletEditorFactoryImpl(aClass, aClassName, aProgID);
|
||||
if (factory == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(factory);
|
||||
*aFactory = factory;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
extern "C" PR_IMPLEMENT(nsresult)
|
||||
NSRegisterSelf(nsISupports* aServMgr , const char* aPath)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIServiceManager> servMgr(do_QueryInterface(aServMgr, &rv));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
NS_WITH_SERVICE(nsIComponentManager, compMgr, kComponentManagerCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = compMgr->RegisterComponent(kWalletEditorCID,
|
||||
"WalletEditor World Component",
|
||||
"component://netscape/walleteditor/walleteditor-world",
|
||||
aPath, PR_TRUE, PR_TRUE);
|
||||
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
extern "C" PR_IMPLEMENT(nsresult)
|
||||
NSUnregisterSelf(nsISupports* aServMgr, const char* aPath)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsIServiceManager> servMgr(do_QueryInterface(aServMgr, &rv));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
NS_WITH_SERVICE(nsIComponentManager, compMgr, kComponentManagerCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = compMgr->UnregisterComponent(kWalletEditorCID, aPath);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
return NS_OK;
|
||||
}
|
|
@ -0,0 +1,519 @@
|
|||
<HTML>
|
||||
<HEAD>
|
||||
<TITLE>Wallet</TITLE>
|
||||
<SCRIPT>
|
||||
|
||||
/* for xpconnect */
|
||||
var walleteditor =
|
||||
Components.classes
|
||||
["component://netscape/walleteditor/walleteditor-world"].createInstance();
|
||||
walleteditor = walleteditor.QueryInterface(Components.interfaces.nsIWalletEditor);
|
||||
dump("walleteditor = " + walleteditor + "\n");
|
||||
|
||||
function get()
|
||||
{
|
||||
return walleteditor.GetValue();
|
||||
}
|
||||
|
||||
function set(value)
|
||||
{
|
||||
walleteditor.SetValue(value, window);
|
||||
}
|
||||
/* end of xpconnect stuff */
|
||||
|
||||
main_frame = 0;
|
||||
|
||||
var schemas = [];
|
||||
var schemasLength;
|
||||
var values = [];
|
||||
var valuesLength;
|
||||
var strings = [];
|
||||
var stringsLength;
|
||||
|
||||
var currentSchema=0;
|
||||
var currentValue=0;
|
||||
var currentSynonym=0;
|
||||
var BREAK;
|
||||
|
||||
function generateOutput(button) {
|
||||
var output = button + BREAK;
|
||||
for (i=0; i<schemasLength; i++) {
|
||||
for (j=schemas[i]; j<schemas[i+1]; j++) {
|
||||
for (k=values[j]; k<values[j+1]; k++) {
|
||||
output += strings[k] + BREAK;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
set(output);
|
||||
}
|
||||
|
||||
function parseInput() {
|
||||
var input;
|
||||
input = get();
|
||||
|
||||
/* following is for going to wallet editor from URL line */
|
||||
if (input.length == 0) {
|
||||
input = "+name.first+steve++";
|
||||
}
|
||||
|
||||
BREAK = input[0];
|
||||
|
||||
flushTables();
|
||||
strings = input.split(BREAK);
|
||||
stringsLength = strings.length;
|
||||
|
||||
j = 0;
|
||||
for (i=1; i<stringsLength; i++) {
|
||||
if (strings[i] != "" && strings[i-1] == "") {
|
||||
values[j++] = i;
|
||||
valuesLength++;
|
||||
}
|
||||
}
|
||||
values[j] = stringsLength;
|
||||
|
||||
j = 0;
|
||||
for (i=0; i<valuesLength; i++) {
|
||||
if (i == 0 || (strings[values[i]] != strings[values[i-1]])) {
|
||||
schemas[j++] = i;
|
||||
schemasLength++;
|
||||
}
|
||||
}
|
||||
schemas[j] = valuesLength;
|
||||
}
|
||||
|
||||
function dumpStrings() {
|
||||
/* for debugging purposes */
|
||||
for (i=0; i<schemasLength; i++) {
|
||||
alert(i+" "+schemas[i]+" "+values[schemas[i]]+" "+strings[values[schemas[i]]]);
|
||||
for (j=schemas[i]; j<schemas[i+1]; j++) {
|
||||
alert(" " + strings[values[j]+1]);
|
||||
for (k=values[j]+2; k<values[j+1]-1; k++) {
|
||||
alert("....." + strings[k]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function dumpRawStrings() {
|
||||
/* for debugging purposes */
|
||||
alert("Schemas follow");
|
||||
for (i=0; i<schemasLength; i++) {
|
||||
alert("{" + schemas[i] + "}");
|
||||
}
|
||||
alert("Values follow");
|
||||
for (i=0; i<valuesLength; i++) {
|
||||
alert("{" + values[i] + "}");
|
||||
}
|
||||
alert("Strings follow");
|
||||
for (i=0; i<stringsLength; i++) {
|
||||
alert("{" + strings[i] + "}");
|
||||
}
|
||||
}
|
||||
|
||||
function lostFocus() {
|
||||
schemalist = top.frames[main_frame].document.main.schemalist;
|
||||
valuelist = top.frames[main_frame].document.main.valuelist;
|
||||
synonymlist = top.frames[main_frame].document.main.synonymlist;
|
||||
|
||||
if (schemalist.selectedIndex<0) {
|
||||
currentSchema = 0;
|
||||
currentValue = 0;
|
||||
currentSynonym = 0;
|
||||
loadMain();
|
||||
return;
|
||||
} else if (schemalist.selectedIndex != currentSchema) {
|
||||
currentSchema = schemalist.selectedIndex;
|
||||
currentValue = 0;
|
||||
currentSynonym = 0;
|
||||
loadMain();
|
||||
return;
|
||||
}
|
||||
|
||||
if (valuelist.selectedIndex<0) {
|
||||
currentValue = 0;
|
||||
currentSynonym = 0;
|
||||
loadMain();
|
||||
return;
|
||||
} else if (valuelist.selectedIndex != currentValue) {
|
||||
currentValue = valuelist.selectedIndex;
|
||||
currentSynonym = 0;
|
||||
loadMain();
|
||||
return;
|
||||
}
|
||||
|
||||
if (synonymlist.selectedIndex<0) {
|
||||
currentSynonym = 0;
|
||||
loadMain();
|
||||
return;
|
||||
} else if (synonymlist.selectedIndex != currentSynonym) {
|
||||
currentSynonym = synonymlist.selectedIndex;
|
||||
loadMain();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
function flushTables() {
|
||||
strings[0] = "";
|
||||
strings[1] = "";
|
||||
values[0] = 0;
|
||||
values[1] = 2;
|
||||
schemas[0] = 0;
|
||||
schemas[1] = 0;
|
||||
schemasLength = 0;
|
||||
valuesLength = 0;
|
||||
stringsLength = 0;
|
||||
currentSchema = 0;
|
||||
currentValue = 0;
|
||||
currentSynonym = 0;
|
||||
}
|
||||
|
||||
function deleteSchema0() {
|
||||
|
||||
if (schemasLength == 1) {
|
||||
flushTables();
|
||||
return;
|
||||
}
|
||||
|
||||
currentValue = 0;
|
||||
numberOfValues = schemas[currentSchema+1] - schemas[currentSchema];
|
||||
for (i=0; i<numberOfValues; i++) {
|
||||
deleteValue0();
|
||||
}
|
||||
|
||||
deleteString(values[schemas[currentSchema]]+1); /* delete blank line */
|
||||
deleteString(values[schemas[currentSchema]]); /* delete name of schema */
|
||||
|
||||
schemasLength--;
|
||||
for (i=currentSchema; i<schemasLength; i++) {
|
||||
schemas[i] = schemas[i+1];
|
||||
}
|
||||
}
|
||||
|
||||
function deleteValue0() {
|
||||
valueToDelete = schemas[currentSchema]+currentValue;
|
||||
currentSynonym = 0;
|
||||
while (values[valueToDelete]+2 < values[valueToDelete+1]-1) {
|
||||
deleteSynonym0();
|
||||
}
|
||||
|
||||
if ((schemas[currentSchema+1] - schemas[currentSchema]) == 1) {
|
||||
if(strings[values[valueToDelete]+1] != "") {
|
||||
deleteString(values[valueToDelete]+1);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
while(strings[values[valueToDelete]] != "") {
|
||||
deleteString(values[valueToDelete]);
|
||||
}
|
||||
deleteString(values[valueToDelete]);
|
||||
|
||||
valuesLength--;
|
||||
for (i=valueToDelete; i<valuesLength; i++) {
|
||||
values[i] = values[i+1];
|
||||
}
|
||||
for (i=0; i<=schemasLength; i++) {
|
||||
if (schemas[i] > valueToDelete) {
|
||||
schemas[i]--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function deleteSynonym0() {
|
||||
stringToDelete = values[schemas[currentSchema]+currentValue]+2+currentSynonym;
|
||||
deleteString(stringToDelete);
|
||||
}
|
||||
|
||||
function addSchema0() {
|
||||
text = top.frames[main_frame].document.main.newSchema;
|
||||
schemaIndex = 0;
|
||||
while (strings[values[schemas[schemaIndex]]] < text.value) {
|
||||
schemaIndex++;
|
||||
}
|
||||
|
||||
schemasLength++;
|
||||
for (i=schemasLength; i>schemaIndex; i--) {
|
||||
schemas[i] = schemas[i-1]+1;
|
||||
}
|
||||
|
||||
valueIndex = schemas[schemaIndex];
|
||||
valuesLength++;
|
||||
for (i=valuesLength; i>valueIndex; i--) {
|
||||
values[i] = values[i-1];
|
||||
}
|
||||
|
||||
stringIndex = values[valueIndex];
|
||||
if (stringIndex == stringsLength) {
|
||||
stringIndex--;
|
||||
}
|
||||
|
||||
addString(stringIndex, text.value);
|
||||
addString(stringIndex+1, "");
|
||||
schemas[schemaIndex] = valueIndex;
|
||||
values[valueIndex] = stringIndex;
|
||||
}
|
||||
|
||||
function addValue0() {
|
||||
text = top.frames[main_frame].document.main.newValue;
|
||||
stringIndex = values[schemas[currentSchema]+currentValue];
|
||||
if(strings[values[schemas[currentSchema]+currentValue]+1]=="") {
|
||||
addString(values[schemas[currentSchema]+currentValue]+1, text.value);
|
||||
return;
|
||||
}
|
||||
|
||||
addString(stringIndex, strings[values[schemas[currentSchema]]]);
|
||||
addString(stringIndex+1, text.value);
|
||||
addString(stringIndex+2, "");
|
||||
|
||||
valuesLength++;
|
||||
for (i=valuesLength; i>schemas[currentSchema]+currentValue; i--) {
|
||||
values[i] = values[i-1];
|
||||
}
|
||||
values[schemas[currentSchema]+currentValue] = stringIndex;
|
||||
|
||||
for (i=currentSchema+1; i<=schemasLength; i++) {
|
||||
schemas[i]++;
|
||||
}
|
||||
}
|
||||
|
||||
function addSynonym0() {
|
||||
text = top.frames[main_frame].document.main.newSynonym;
|
||||
addString(values[schemas[currentSchema]+currentValue]+2, text.value);
|
||||
}
|
||||
|
||||
function deleteString(stringToDelete) {
|
||||
stringsLength--;
|
||||
for (i=stringToDelete; i<stringsLength; i++) {
|
||||
strings[i] = strings[i+1];
|
||||
}
|
||||
for (i=0; i<=valuesLength; i++) {
|
||||
if (values[i] > stringToDelete) {
|
||||
values[i]--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function addString(stringToAdd, text) {
|
||||
stringsLength++;
|
||||
for (i=stringsLength; i>stringToAdd; i--) {
|
||||
strings[i] = strings[i-1];
|
||||
}
|
||||
strings[stringToAdd] = text;
|
||||
for (i=0; i<=valuesLength; i++) {
|
||||
if (values[i] >= stringToAdd) {
|
||||
values[i]++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function addSchema() {
|
||||
addSchema0();
|
||||
loadMain();
|
||||
}
|
||||
|
||||
function addValue() {
|
||||
addValue0();
|
||||
loadMain();
|
||||
}
|
||||
|
||||
function addSynonym() {
|
||||
addSynonym0();
|
||||
loadMain();
|
||||
}
|
||||
|
||||
function deleteSchema() {
|
||||
deleteSchema0();
|
||||
loadMain();
|
||||
}
|
||||
|
||||
function deleteValue() {
|
||||
deleteValue0();
|
||||
loadMain();
|
||||
}
|
||||
|
||||
function deleteSynonym() {
|
||||
deleteSynonym0();
|
||||
loadMain();
|
||||
}
|
||||
|
||||
function loadMain() {
|
||||
|
||||
/* create the prologue */
|
||||
top.frames[main_frame].document.open();
|
||||
top.frames[main_frame].document.write(
|
||||
"<br> VALUES THAT WILL BE USED WHEN PRE-FILLING FORMS" +
|
||||
"<FORM name=main>" +
|
||||
"<BR> <BR> <BR>" +
|
||||
"<TABLE BORDER=0 WIDTH=50%>"
|
||||
);
|
||||
|
||||
/* create the schema list */
|
||||
top.frames[main_frame].document.write(
|
||||
"<TR>" +
|
||||
"<TD> names: </TD>" +
|
||||
"<TD>" +
|
||||
// "<SELECT NAME=schemalist ONCHANGE=top.lostFocus();>"
|
||||
// (bug 3317 workaround)
|
||||
"<SELECT NAME=schemalist ONCHANGE=\"setTimeout('top.lostFocus();',0)\">"
|
||||
);
|
||||
for (i=0; i<schemasLength; i++) {
|
||||
if (i == currentSchema) {
|
||||
selected = " SELECTED";
|
||||
} else {
|
||||
selected = "";
|
||||
}
|
||||
top.frames[main_frame].document.write(
|
||||
"<OPTION" + selected + ">" + strings[values[schemas[i]]] + "</OPTION>"
|
||||
);
|
||||
}
|
||||
top.frames[main_frame].document.write(
|
||||
"</SELECT><BR>" +
|
||||
"</TD>" +
|
||||
"<TD>" +
|
||||
// "<INPUT type=BUTTON value=delete onclick=parent.deleteSchema()>" +
|
||||
// (bug 3317 workaround)
|
||||
"<INPUT type=BUTTON value=delete onclick=\"setTimeout('parent.deleteSchema();',0)\">" +
|
||||
"</TD>" +
|
||||
"<TD>" +
|
||||
// "<INPUT type=BUTTON value=add onclick=parent.addSchema()>" +
|
||||
// (bug 3317 workaround)
|
||||
"<INPUT type=BUTTON value=add onclick=\"setTimeout('parent.addSchema();',0)\">" +
|
||||
"</TD>" +
|
||||
"<TD>" +
|
||||
"<INPUT type=text name=newSchema>" +
|
||||
"</TD>" +
|
||||
"</TR>"
|
||||
);
|
||||
|
||||
/* create the value list */
|
||||
top.frames[main_frame].document.write(
|
||||
"<TR>" +
|
||||
"<TD> values: </TD>" +
|
||||
"<TD>" +
|
||||
// "<SELECT NAME=valuelist ONCHANGE=top.lostFocus();>"
|
||||
// (bug 3317 workaround)
|
||||
"<SELECT NAME=valuelist ONCHANGE=\"setTimeout('top.lostFocus();',0)\">"
|
||||
);
|
||||
for (i=schemas[currentSchema]; i<schemas[currentSchema+1]; i++) {
|
||||
if ((i-schemas[currentSchema]) == currentValue) {
|
||||
selected = " SELECTED";
|
||||
} else {
|
||||
selected = "";
|
||||
}
|
||||
if (strings[values[i]+1] != "") {
|
||||
top.frames[main_frame].document.write(
|
||||
"<OPTION" + selected + ">" + strings[values[i]+1] + "</OPTION>"
|
||||
);
|
||||
}
|
||||
}
|
||||
top.frames[main_frame].document.write(
|
||||
"</SELECT><BR>" +
|
||||
"</TD>" +
|
||||
"<TD>" +
|
||||
// "<INPUT type=BUTTON value=delete onclick=parent.deleteValue()>" +
|
||||
// (bug 3317 workaround)
|
||||
"<INPUT type=BUTTON value=delete onclick=\"setTimeout('parent.deleteValue();',0)\">" +
|
||||
"</TD>" +
|
||||
"<TD>" +
|
||||
// "<INPUT type=BUTTON value=add onclick=parent.addValue()>" +
|
||||
// (bug 3317 workaround)
|
||||
"<INPUT type=BUTTON value=add onclick=\"setTimeout('parent.addValue();',0)\">" +
|
||||
"</TD>" +
|
||||
"<TD>" +
|
||||
"<INPUT type=text name=newValue>" +
|
||||
"</TD>" +
|
||||
"</TR>"
|
||||
);
|
||||
|
||||
/* create the synonym list */
|
||||
top.frames[main_frame].document.write(
|
||||
"<TR>" +
|
||||
"<TD> synonyms: </TD>" +
|
||||
"<TD>" +
|
||||
// "<SELECT NAME=synonymlist ONCHANGE=top.lostFocus();>"
|
||||
// (bug 3317 workaround)
|
||||
"<SELECT NAME=synonymlist ONCHANGE=\"setTimeout('top.lostFocus();',0)\">"
|
||||
);
|
||||
for (i=values[schemas[currentSchema]+currentValue]+2; i<values[schemas[currentSchema]+1]-1; i++) {
|
||||
if ((i-(values[schemas[currentSchema]+currentValue]+2)) == currentSynonym) {
|
||||
selected = " SELECTED";
|
||||
} else {
|
||||
selected = "";
|
||||
}
|
||||
top.frames[main_frame].document.write(
|
||||
"<OPTION" + selected + ">" + strings[i] + "</OPTION>"
|
||||
);
|
||||
}
|
||||
top.frames[main_frame].document.write(
|
||||
"</SELECT><BR>" +
|
||||
"</TD>" +
|
||||
"<TD>" +
|
||||
// "<INPUT type=BUTTON value=delete onclick=parent.deleteSynonym()>" +
|
||||
// (bug 3317 workaround)
|
||||
"<INPUT type=BUTTON value=delete onclick=\"setTimeout('parent.deleteSynonym();',0)\">" +
|
||||
"</TD>" +
|
||||
"<TD>" +
|
||||
// "<INPUT type=BUTTON value=add onclick=parent.addSynonym()>" +
|
||||
// (bug 3317 workaround)
|
||||
"<INPUT type=BUTTON value=add onclick=\"setTimeout('parent.addSynonym();',0)\">" +
|
||||
"</TD>" +
|
||||
"<TD>" +
|
||||
"<INPUT type=text name=newSynonym>" +
|
||||
"</TD>" +
|
||||
"</TR>"
|
||||
);
|
||||
|
||||
/* create the epilogue */
|
||||
top.frames[main_frame].document.write(
|
||||
"<TR>" +
|
||||
"<TD> </TD>" +
|
||||
"<TD> </TD>" +
|
||||
"<TD> </TD>" +
|
||||
"<TD> </TD>" +
|
||||
"<TD> <BR> <BR>" +
|
||||
"<DIV align=left>" +
|
||||
"<INPUT type=BUTTON value=OK width=80 onclick=parent.generateOutput(this.value)>" +
|
||||
" " +
|
||||
"<INPUT type=BUTTON value=Cancel width=80 onclick=parent.generateOutput(this.value)>" +
|
||||
"</DIV>" +
|
||||
"</TD>" +
|
||||
"</TR>" +
|
||||
"</TABLE>" +
|
||||
"</FORM>"
|
||||
);
|
||||
top.frames[main_frame].document.close();
|
||||
|
||||
}
|
||||
|
||||
function loadFrames() {
|
||||
parseInput();
|
||||
loadMain();
|
||||
}
|
||||
|
||||
</SCRIPT>
|
||||
</HEAD>
|
||||
|
||||
<FRAMESET ROWS=*,1
|
||||
BORDER=0
|
||||
FRAMESPACING=0
|
||||
onLoad=loadFrames()>
|
||||
<FRAME SRC=about:blank
|
||||
NAME=main_frame
|
||||
SCROLLING=AUTO
|
||||
MARGINWIDTH=0
|
||||
MARGINHEIGHT=0
|
||||
NORESIZE>
|
||||
<FRAME SRC=about:blank
|
||||
NAME=dummy_frame
|
||||
SCROLLING=AUTO
|
||||
MARGINWIDTH=0
|
||||
MARGINHEIGHT=0
|
||||
NORESIZE>
|
||||
</FRAMESET>
|
||||
|
||||
<NOFRAMES>
|
||||
<BODY> <P> </BODY>
|
||||
</NOFRAMES>
|
||||
</HTML>
|
|
@ -45,7 +45,7 @@ public:
|
|||
|
||||
NS_IMETHOD LoadInitialPage()=0;
|
||||
|
||||
NS_IMETHOD WalletEditor()=0;
|
||||
NS_IMETHOD WalletEditor(nsIDOMWindow* aWin)=0;
|
||||
|
||||
NS_IMETHOD WalletChangePassword()=0;
|
||||
|
||||
|
@ -85,7 +85,7 @@ public:
|
|||
NS_IMETHOD Stop(); \
|
||||
NS_IMETHOD LoadUrl(const nsString& aUrl); \
|
||||
NS_IMETHOD LoadInitialPage(); \
|
||||
NS_IMETHOD WalletEditor(); \
|
||||
NS_IMETHOD WalletEditor(nsIDOMWindow* aWin); \
|
||||
NS_IMETHOD WalletChangePassword(); \
|
||||
NS_IMETHOD WalletQuickFillin(nsIDOMWindow* aWin); \
|
||||
NS_IMETHOD WalletSamples(); \
|
||||
|
@ -110,7 +110,7 @@ public:
|
|||
NS_IMETHOD Stop() { return _to Stop(); } \
|
||||
NS_IMETHOD LoadUrl(const nsString& aUrl) { return _to LoadUrl(aUrl); } \
|
||||
NS_IMETHOD LoadInitialPage() { return _to LoadInitialPage(); } \
|
||||
NS_IMETHOD WalletEditor() { return _to WalletEditor(); } \
|
||||
NS_IMETHOD WalletEditor(nsIDOMWindow* aWin) { return _to WalletEditor(aWin); } \
|
||||
NS_IMETHOD WalletChangePassword() { return _to WalletChangePassword(); } \
|
||||
NS_IMETHOD WalletQuickFillin(nsIDOMWindow* aWin) { return _to WalletQuickFillin(aWin); } \
|
||||
NS_IMETHOD WalletSamples() { return _to WalletSamples(); } \
|
||||
|
|
|
@ -390,9 +390,73 @@ done:
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBrowserAppCore::WalletEditor()
|
||||
static void DOMWindowToWebShellWindow(
|
||||
nsIDOMWindow *DOMWindow,
|
||||
nsCOMPtr<nsIWebShellWindow> *webWindow)
|
||||
{
|
||||
if (!DOMWindow)
|
||||
return; // with webWindow unchanged -- its constructor gives it a null ptr
|
||||
|
||||
nsCOMPtr<nsIScriptGlobalObject> globalScript(do_QueryInterface(DOMWindow));
|
||||
nsCOMPtr<nsIWebShell> webshell, rootWebshell;
|
||||
if (globalScript)
|
||||
globalScript->GetWebShell(getter_AddRefs(webshell));
|
||||
if (webshell)
|
||||
webshell->GetRootWebShellEvenIfChrome(*getter_AddRefs(rootWebshell));
|
||||
if (rootWebshell) {
|
||||
nsCOMPtr<nsIWebShellContainer> webshellContainer;
|
||||
rootWebshell->GetContainer(*getter_AddRefs(webshellContainer));
|
||||
*webWindow = do_QueryInterface(webshellContainer);
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBrowserAppCore::WalletEditor(nsIDOMWindow* aWin)
|
||||
{
|
||||
// (code adapted from nsToolkitCore::ShowModal. yeesh.)
|
||||
nsresult rv;
|
||||
nsIAppShellService *appShell;
|
||||
nsIWebShellWindow *window;
|
||||
|
||||
window = nsnull;
|
||||
|
||||
nsCOMPtr<nsIURL> urlObj;
|
||||
rv = NS_NewURL(getter_AddRefs(urlObj), "resource:/res/samples/xpconnect-walleteditor.html");
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
rv = nsServiceManager::GetService(kAppShellServiceCID, kIAppShellServiceIID,
|
||||
(nsISupports**) &appShell);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
// Create "save to disk" nsIXULCallbacks...
|
||||
//nsIXULWindowCallbacks *cb = new nsFindDialogCallbacks( aURL, aContentType );
|
||||
nsIXULWindowCallbacks *cb = nsnull;
|
||||
|
||||
nsCOMPtr<nsIWebShellWindow> parent;
|
||||
DOMWindowToWebShellWindow(aWin, &parent);
|
||||
appShell->CreateDialogWindow(parent, urlObj, PR_TRUE, window,
|
||||
nsnull, cb, 504, 436);
|
||||
nsServiceManager::ReleaseService(kAppShellServiceCID, appShell);
|
||||
|
||||
if (window != nsnull) {
|
||||
nsCOMPtr<nsIWidget> parentWindowWidgetThing;
|
||||
nsresult gotParent;
|
||||
gotParent = parent ? parent->GetWidget(*getter_AddRefs(parentWindowWidgetThing)) :
|
||||
NS_ERROR_FAILURE;
|
||||
// Windows OS is the only one that needs the parent disabled, or cares
|
||||
// arguably this should be done by the new window, within ShowModal...
|
||||
if (NS_SUCCEEDED(gotParent))
|
||||
parentWindowWidgetThing->Enable(PR_FALSE);
|
||||
window->ShowModal();
|
||||
if (NS_SUCCEEDED(gotParent))
|
||||
parentWindowWidgetThing->Enable(PR_TRUE);
|
||||
}
|
||||
|
||||
return rv;
|
||||
|
||||
#ifdef xxx
|
||||
/* set a cookie for the wallet editor */
|
||||
nsIWalletService *walletservice;
|
||||
nsresult res;
|
||||
|
@ -415,6 +479,7 @@ nsBrowserAppCore::WalletEditor()
|
|||
|
||||
/* bring up the wallet editor in a new window */
|
||||
return newWind((char *)(u.GetURLString()));
|
||||
#endif
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
|
|
@ -65,7 +65,7 @@ class nsBrowserAppCore : public nsBaseAppCore,
|
|||
NS_IMETHOD Forward();
|
||||
NS_IMETHOD Stop();
|
||||
|
||||
NS_IMETHOD WalletEditor();
|
||||
NS_IMETHOD WalletEditor(nsIDOMWindow* aWin);
|
||||
NS_IMETHOD WalletChangePassword();
|
||||
NS_IMETHOD WalletQuickFillin(nsIDOMWindow* aWin);
|
||||
NS_IMETHOD WalletSamples();
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "nsJSUtils.h"
|
||||
#include "nscore.h"
|
||||
#include "nsIScriptContext.h"
|
||||
#include "nsIScriptSecurityManager.h"
|
||||
#include "nsIJSScriptObject.h"
|
||||
#include "nsIScriptObjectOwner.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
|
@ -59,11 +60,18 @@ GetBrowserAppCoreProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
|||
}
|
||||
|
||||
if (JSVAL_IS_INT(id)) {
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
PRBool ok;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(&secMan)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
switch(JSVAL_TO_INT(id)) {
|
||||
case 0:
|
||||
default:
|
||||
return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, id, vp);
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
else {
|
||||
return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, id, vp);
|
||||
|
@ -87,11 +95,18 @@ SetBrowserAppCoreProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
|||
}
|
||||
|
||||
if (JSVAL_IS_INT(id)) {
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
PRBool ok;
|
||||
if (NS_OK != scriptCX->GetSecurityManager(&secMan)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
switch(JSVAL_TO_INT(id)) {
|
||||
case 0:
|
||||
default:
|
||||
return nsJSUtils::nsCallJSScriptObjectSetProperty(a, cx, id, vp);
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
else {
|
||||
return nsJSUtils::nsCallJSScriptObjectSetProperty(a, cx, id, vp);
|
||||
|
@ -142,6 +157,21 @@ BrowserAppCoreBack(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval
|
|||
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
if (NS_OK == scriptCX->GetSecurityManager(&secMan)) {
|
||||
PRBool ok;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "browserappcore.back", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
else {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == nativeThis) {
|
||||
return JS_TRUE;
|
||||
|
@ -175,6 +205,21 @@ BrowserAppCoreForward(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsv
|
|||
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
if (NS_OK == scriptCX->GetSecurityManager(&secMan)) {
|
||||
PRBool ok;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "browserappcore.forward", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
else {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == nativeThis) {
|
||||
return JS_TRUE;
|
||||
|
@ -208,6 +253,21 @@ BrowserAppCoreStop(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval
|
|||
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
if (NS_OK == scriptCX->GetSecurityManager(&secMan)) {
|
||||
PRBool ok;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "browserappcore.stop", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
else {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == nativeThis) {
|
||||
return JS_TRUE;
|
||||
|
@ -242,6 +302,21 @@ BrowserAppCoreLoadUrl(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsv
|
|||
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
if (NS_OK == scriptCX->GetSecurityManager(&secMan)) {
|
||||
PRBool ok;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "browserappcore.loadurl", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
else {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == nativeThis) {
|
||||
return JS_TRUE;
|
||||
|
@ -277,6 +352,21 @@ BrowserAppCoreLoadInitialPage(JSContext *cx, JSObject *obj, uintN argc, jsval *a
|
|||
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
if (NS_OK == scriptCX->GetSecurityManager(&secMan)) {
|
||||
PRBool ok;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "browserappcore.loadinitialpage", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
else {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == nativeThis) {
|
||||
return JS_TRUE;
|
||||
|
@ -307,24 +397,48 @@ BrowserAppCoreWalletEditor(JSContext *cx, JSObject *obj, uintN argc, jsval *argv
|
|||
{
|
||||
nsIDOMBrowserAppCore *nativeThis = (nsIDOMBrowserAppCore*)JS_GetPrivate(cx, obj);
|
||||
JSBool rBool = JS_FALSE;
|
||||
nsIDOMWindowPtr b0;
|
||||
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
if (NS_OK == scriptCX->GetSecurityManager(&secMan)) {
|
||||
PRBool ok;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "browserappcore.walleteditor", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
else {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == nativeThis) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
if (argc >= 0) {
|
||||
if (argc >= 1) {
|
||||
|
||||
if (NS_OK != nativeThis->WalletEditor()) {
|
||||
if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&b0,
|
||||
kIWindowIID,
|
||||
"Window",
|
||||
cx,
|
||||
argv[0])) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if (NS_OK != nativeThis->WalletEditor(b0)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
*rval = JSVAL_VOID;
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Function walletEditor requires 0 parameters");
|
||||
JS_ReportError(cx, "Function walletEditor requires 1 parameters");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
|
@ -343,6 +457,21 @@ BrowserAppCoreWalletChangePassword(JSContext *cx, JSObject *obj, uintN argc, jsv
|
|||
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
if (NS_OK == scriptCX->GetSecurityManager(&secMan)) {
|
||||
PRBool ok;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "browserappcore.walletchangepassword", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
else {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == nativeThis) {
|
||||
return JS_TRUE;
|
||||
|
@ -377,6 +506,21 @@ BrowserAppCoreWalletQuickFillin(JSContext *cx, JSObject *obj, uintN argc, jsval
|
|||
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
if (NS_OK == scriptCX->GetSecurityManager(&secMan)) {
|
||||
PRBool ok;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "browserappcore.walletquickfillin", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
else {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == nativeThis) {
|
||||
return JS_TRUE;
|
||||
|
@ -418,6 +562,21 @@ BrowserAppCoreWalletSamples(JSContext *cx, JSObject *obj, uintN argc, jsval *arg
|
|||
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
if (NS_OK == scriptCX->GetSecurityManager(&secMan)) {
|
||||
PRBool ok;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "browserappcore.walletsamples", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
else {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == nativeThis) {
|
||||
return JS_TRUE;
|
||||
|
@ -452,6 +611,21 @@ BrowserAppCoreSetToolbarWindow(JSContext *cx, JSObject *obj, uintN argc, jsval *
|
|||
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
if (NS_OK == scriptCX->GetSecurityManager(&secMan)) {
|
||||
PRBool ok;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "browserappcore.settoolbarwindow", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
else {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == nativeThis) {
|
||||
return JS_TRUE;
|
||||
|
@ -494,6 +668,21 @@ BrowserAppCoreSetContentWindow(JSContext *cx, JSObject *obj, uintN argc, jsval *
|
|||
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
if (NS_OK == scriptCX->GetSecurityManager(&secMan)) {
|
||||
PRBool ok;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "browserappcore.setcontentwindow", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
else {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == nativeThis) {
|
||||
return JS_TRUE;
|
||||
|
@ -536,6 +725,21 @@ BrowserAppCoreSetWebShellWindow(JSContext *cx, JSObject *obj, uintN argc, jsval
|
|||
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
if (NS_OK == scriptCX->GetSecurityManager(&secMan)) {
|
||||
PRBool ok;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "browserappcore.setwebshellwindow", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
else {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == nativeThis) {
|
||||
return JS_TRUE;
|
||||
|
@ -577,6 +781,21 @@ BrowserAppCoreNewWindow(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, j
|
|||
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
if (NS_OK == scriptCX->GetSecurityManager(&secMan)) {
|
||||
PRBool ok;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "browserappcore.newwindow", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
else {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == nativeThis) {
|
||||
return JS_TRUE;
|
||||
|
@ -610,6 +829,21 @@ BrowserAppCoreOpenWindow(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
|||
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
if (NS_OK == scriptCX->GetSecurityManager(&secMan)) {
|
||||
PRBool ok;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "browserappcore.openwindow", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
else {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == nativeThis) {
|
||||
return JS_TRUE;
|
||||
|
@ -643,6 +877,21 @@ BrowserAppCorePrintPreview(JSContext *cx, JSObject *obj, uintN argc, jsval *argv
|
|||
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
if (NS_OK == scriptCX->GetSecurityManager(&secMan)) {
|
||||
PRBool ok;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "browserappcore.printpreview", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
else {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == nativeThis) {
|
||||
return JS_TRUE;
|
||||
|
@ -676,6 +925,21 @@ BrowserAppCoreCopy(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval
|
|||
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
if (NS_OK == scriptCX->GetSecurityManager(&secMan)) {
|
||||
PRBool ok;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "browserappcore.copy", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
else {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == nativeThis) {
|
||||
return JS_TRUE;
|
||||
|
@ -709,6 +973,21 @@ BrowserAppCorePrint(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval
|
|||
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
if (NS_OK == scriptCX->GetSecurityManager(&secMan)) {
|
||||
PRBool ok;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "browserappcore.print", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
else {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == nativeThis) {
|
||||
return JS_TRUE;
|
||||
|
@ -742,6 +1021,21 @@ BrowserAppCoreClose(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval
|
|||
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
if (NS_OK == scriptCX->GetSecurityManager(&secMan)) {
|
||||
PRBool ok;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "browserappcore.close", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
else {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == nativeThis) {
|
||||
return JS_TRUE;
|
||||
|
@ -775,6 +1069,21 @@ BrowserAppCoreExit(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval
|
|||
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
if (NS_OK == scriptCX->GetSecurityManager(&secMan)) {
|
||||
PRBool ok;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "browserappcore.exit", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
else {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == nativeThis) {
|
||||
return JS_TRUE;
|
||||
|
@ -808,6 +1117,21 @@ BrowserAppCoreFind(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval
|
|||
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
if (NS_OK == scriptCX->GetSecurityManager(&secMan)) {
|
||||
PRBool ok;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "browserappcore.find", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
else {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == nativeThis) {
|
||||
return JS_TRUE;
|
||||
|
@ -841,6 +1165,21 @@ BrowserAppCoreFindNext(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, js
|
|||
|
||||
*rval = JSVAL_NULL;
|
||||
|
||||
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
|
||||
nsIScriptSecurityManager *secMan;
|
||||
if (NS_OK == scriptCX->GetSecurityManager(&secMan)) {
|
||||
PRBool ok;
|
||||
secMan->CheckScriptAccess(scriptCX, obj, "browserappcore.findnext", &ok);
|
||||
if (!ok) {
|
||||
//Need to throw error here
|
||||
return JS_FALSE;
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
else {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (nsnull == nativeThis) {
|
||||
return JS_TRUE;
|
||||
|
@ -900,7 +1239,7 @@ static JSFunctionSpec BrowserAppCoreMethods[] =
|
|||
{"stop", BrowserAppCoreStop, 0},
|
||||
{"loadUrl", BrowserAppCoreLoadUrl, 1},
|
||||
{"loadInitialPage", BrowserAppCoreLoadInitialPage, 0},
|
||||
{"walletEditor", BrowserAppCoreWalletEditor, 0},
|
||||
{"walletEditor", BrowserAppCoreWalletEditor, 1},
|
||||
{"walletChangePassword", BrowserAppCoreWalletChangePassword, 0},
|
||||
{"walletQuickFillin", BrowserAppCoreWalletQuickFillin, 1},
|
||||
{"walletSamples", BrowserAppCoreWalletSamples, 0},
|
||||
|
|
|
@ -520,7 +520,7 @@
|
|||
{
|
||||
if (appCore != null) {
|
||||
dump("Wallet Editor\n");
|
||||
appCore.walletEditor();
|
||||
appCore.walletEditor(window);
|
||||
} else {
|
||||
dump("BrowserAppCore has not been created!\n");
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче