This commit is contained in:
morse%netscape.com 1999-06-04 21:51:57 +00:00
Родитель f0bf0952ce
Коммит 4080fe81f1
29 изменённых файлов: 4088 добавлений и 711 удалений

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

@ -0,0 +1,351 @@
<HTML>
<HEAD>
<TITLE>Cookies</TITLE>
<SCRIPT language="javascript" src="CookieWindow.js"></SCRIPT>
<SCRIPT>
index_frame = 0;
title_frame = 1;
spacer1_frame = 2;
list_frame = 3;
spacer2_frame = 4;
prop_frame = 5;
spacer3_frame = 6;
button_frame = 7;
var cookie_mode;
var cookieList = [];
var permissionList = [];
deleted_cookies = new Array;
deleted_permissions = new Array;
function DeleteItemSelected() {
if (cookie_mode == 0) {
DeleteCookieSelected();
} else if (cookie_mode == 1) {
DeletePermissionSelected();
}
}
function DeleteCookieSelected() {
selname = top.frames[list_frame].document.fSelectCookie.selname;
goneC = top.frames[button_frame].document.buttons.goneC;
var p;
var i;
for (i=selname.options.length; i>0; i--) {
if (selname.options[i-1].selected) {
selname.options[i-1].selected = 0;
goneC.value = goneC.value + selname.options[i-1].value + ",";
deleted_cookies[selname.options[i-1].value] = 1;
for (j=i ; j<selname.options.length ; j++) {
selname.options[j-1] = selname.options[j];
}
selname.options[selname.options.length-1] = null;
}
}
top.loadCookiesList(); /* not needed in 4.5 */
top.frames[prop_frame].document.open();
top.frames[prop_frame].document.close();
}
function DeletePermissionSelected() {
selname = top.frames[list_frame].document.fSelectPermission.selname;
goneP = top.frames[button_frame].document.buttons.goneP;
var p;
var i;
for (i=selname.options.length; i>0; i--) {
if (selname.options[i-1].selected) {
selname.options[i-1].selected = 0;
goneP.value = goneP.value + selname.options[i-1].value + ",";
deleted_permissions[selname.options[i-1].value] = 1;
for (j=i; j < selname.options.length; j++) {
selname.options[j-1] = selname.options[j];
}
selname.options[selname.options.length-1] = null;
}
}
top.loadPermissionsList(); /* not needed in 4.5 */
}
function loadCookies(){
cookie_mode = 0;
top.frames[index_frame].document.open();
top.frames[index_frame].document.write(
"<BODY BGCOLOR=#C0C0C0>" +
"<TABLE BORDER=0 WIDTH=100%>" +
"<TR>" +
"<TD ALIGN=CENTER VALIGN=MIDDLE BGCOLOR=#FFFFFF>" +
"<FONT SIZE=2 COLOR=#666666>" +
"<B>View stored cookies</B>" +
"</FONT>" +
"</TD>" +
"<TD ALIGN=CENTER VALIGN=MIDDLE BGCOLOR=#C0C0C0>" +
"<A HREF=javascript:top.loadPermissions();>" +
"<FONT SIZE=2>View sites that can or cannot store cookies</FONT>" +
"</A>" +
"</TD>" +
"</TR>" +
"</TABLE>" +
"</BODY>"
);
top.frames[index_frame].document.close();
top.frames[title_frame].document.open();
top.frames[title_frame].document.write
("&nbsp;Cookies stored on your system");
top.frames[title_frame].document.close();
top.frames[prop_frame].document.open();
top.frames[prop_frame].document.close();
loadCookiesList();
}
function ViewCookieSelected() {
index = 8*(top.frames[list_frame].document.fSelectCookie.selname.selectedIndex) + 1;
top.frames[prop_frame].document.open();
top.frames[prop_frame].document.write(
"<NOBR><b>Name: </b>" + cookieList[index+1] + "</NOBR><BR>" +
"<NOBR><b>Value: </b>" + cookieList[index+2] + "</NOBR><BR>" +
"<NOBR><b>" + cookieList[index+3] + ": </b>" + cookieList[index+4] + "</NOBR><BR>" +
"<NOBR><b>Path: </b>" + cookieList[index+5] + "</NOBR><BR>" +
"<NOBR><b>Secure: </b>" + cookieList[index+6] + "</NOBR><BR>" +
"<NOBR><b>Expires: </b>" + cookieList[index+7] + "</NOBR><BR>"
);
top.frames[prop_frame].document.close();
}
function loadCookiesList(){
top.frames[list_frame].document.open();
top.frames[list_frame].document.write(
"<FORM name=fSelectCookie>" +
"<P>" +
"<TABLE BORDER=0 WIDTH=100%HEIGHT=95%>" +
"<TR>" +
"<TD WIDTH=100%VALIGN=TOP>" +
"<CENTER>" +
"<P>" +
"<SELECT " +
"NAME=selname " +
"SIZE=15 " +
"MULTIPLE " +
"onchange=top.ViewCookieSelected();" +
">"
);
for (i=1; i<cookieList.length; i+=8) {
if (!deleted_cookies[cookieList[i]]) {
top.frames[list_frame].document.write(
"<OPTION value=" + cookieList[i] + ">" +
cookieList[i+4] + ":" + cookieList[i+1] +
"</OPTION>"
);
}
}
top.frames[list_frame].document.write(
"</SELECT>" +
"</CENTER>" +
"</TD>" +
"</TR>" +
"</TABLE>" +
"</FORM>"
);
top.frames[list_frame].document.close();
}
function loadPermissions(){
cookie_mode = 1;
top.frames[index_frame].document.open();
top.frames[index_frame].document.write(
"<BODY BGCOLOR=#C0C0C0>" +
"<TABLE BORDER=0 WIDTH=100%>" +
"<TR>" +
"<TD ALIGN=CENTER VALIGN=MIDDLE BGCOLOR=#C0C0C0>" +
"<A HREF=javascript:top.loadCookies();>" +
"<FONT SIZE=2>View stored cookies</FONT>" +
"</A>" +
"</TD>" +
"<TD ALIGN=CENTER VALIGN=MIDDLE BGCOLOR=#FFFFFF>" +
"<FONT SIZE=2 COLOR=#666666>" +
"<B>View sites that can or cannot store cookies</B>" +
"</FONT>" +
"</TD>" +
"<TD>&nbsp;&nbsp;&nbsp;</TD>" +
"</TR>" +
"</TABLE>" +
"</BODY>"
);
top.frames[index_frame].document.close();
top.frames[title_frame].document.open();
top.frames[title_frame].document.write
("&nbsp;Sites that can(+) or cannot(-) store cookies");
top.frames[title_frame].document.close();
top.frames[prop_frame].document.open();
top.frames[prop_frame].document.close();
loadPermissionsList();
}
function loadPermissionsList(){
top.frames[list_frame].document.open();
top.frames[list_frame].document.write(
"<FORM name=fSelectPermission>" +
"<P>" +
"<TABLE BORDER=0 WIDTH=100%HEIGHT=95%>" +
"<TR>" +
"<TD WIDTH=100%VALIGN=TOP>" +
"<CENTER>" +
"<P>" +
"<SELECT NAME=selname SIZE=15 MULTIPLE> "
);
for (i=1; i<permissionList.length; i+=2) {
if (!deleted_permissions[permissionList[i]]) {
top.frames[list_frame].document.write(
"<OPTION value=" + permissionList[i] + ">" +
permissionList[i+1] +
"</OPTION>"
);
}
}
top.frames[list_frame].document.write(
"</SELECT>" +
"</CENTER>" +
"</TD>" +
"</TR>" +
"</TABLE>" +
"</FORM>"
);
top.frames[list_frame].document.close();
}
function loadButtons(){
top.frames[button_frame].document.open();
top.frames[button_frame].document.write(
"<FORM name=buttons>" +
"<BR>" +
"&nbsp;" +
"<INPUT type=BUTTON " +
"value=Remove " +
"onclick=top.DeleteItemSelected();>" +
"<DIV align=right>" +
"<INPUT type=BUTTON value=OK width=80 onclick=parent.Save()>" +
" &nbsp;&nbsp;" +
"<INPUT type=BUTTON value=Cancel width=80 onclick=parent.DoCancel()>" +
"</DIV>" +
"<INPUT TYPE=HIDDEN NAME=goneC VALUE=\"\" SIZE=-1>" +
"<INPUT TYPE=HIDDEN NAME=goneP VALUE=\"\" SIZE=-1>" +
"<INPUT TYPE=HIDDEN NAME=cookieList VALUE=\"\" SIZE=-1>" +
"<INPUT TYPE=HIDDEN NAME=permissionList VALUE=\"\" SIZE=-1>" +
"</FORM>"
);
top.frames[button_frame].document.close();
}
function loadFrames(){
StartUp("Cookies");
/*
* The cookieList is a sequence of items separated by the BREAK character. These
* items are:
* empty
* number for first cookie
* name for first cookie
* value for first cookie
* domain indicator ("Domain" or "Host") for first cookie
* domain or host name for first cookie
* path for first cookie
* secure indicator ("Yes" or "No") for first cookie
* expiration for first cookie
* with the eight items above repeated for each successive cookie
*/
list = DoGetCookieList();
BREAK = list[0];
cookieList = list.split(BREAK);
/*
* The permissionList is a sequence of items separated by the BREAK character. These
* items are:
* empty
* number for first permission
* +/- hostname for first permission
* with the above two items repeated for each successive permission
*/
list = DoGetPermissionList();
BREAK = list[0];
permissionList = list.split(BREAK);
loadCookies();
loadButtons();
}
function Save(){
var goneC = top.frames[button_frame].document.buttons.goneC;
var goneP = top.frames[button_frame].document.buttons.goneP;
var result = "|goneC|"+goneC.value+"|goneP|"+goneP.value+"|";
DoSave(result);
}
</SCRIPT>
</HEAD>
<FRAMESET ROWS = 25,25,*,75
BORDER=0
FRAMESPACING=0
onLoad=loadFrames()>
<FRAME SRC=about:blank
NAME=index_frame
SCROLLING=NO
MARGINWIDTH=1
MARGINHEIGHT=1
NORESIZE>
<FRAME SRC=about:blank
NAME=title_frame
SCROLLING=NO
MARGINWIDTH=1
MARGINHEIGHT=1
NORESIZE>
<FRAMESET COLS=5,*,10,*,5
BORDER=0
FRAMESPACING=0>
<FRAME SRC=about:blank
NAME=spacer1_frame
SCROLLING=AUTO
MARGINWIDTH=0
MARGINHEIGHT=0
NORESIZE>
<FRAME SRC=about:blank
NAME=list_frame
SCROLLING=AUTO
MARGINWIDTH=0
MARGINHEIGHT=0
NORESIZE>
<FRAME SRC=about:blank
NAME=spacer2_frame
SCROLLING=AUTO
MARGINWIDTH=0
MARGINHEIGHT=0
NORESIZE>
<FRAME SRC=about:blank
NAME=prop_frame
SCROLLING=AUTO
MARGINWIDTH=0
MARGINHEIGHT=0
NORESIZE>
<FRAME SRC=about:blank
NAME=spacer3_frame
SCROLLING=AUTO
MARGINWIDTH=0
MARGINHEIGHT=0
NORESIZE>
</FRAMESET>
<FRAME SRC=about:blank
NAME=button_frame
SCROLLING=NO
MARGINWIDTH=1
MARGINHEIGHT=1
NORESIZE>
</FRAMESET>
<NOFRAMES>
<BODY> <P> </BODY>
</NOFRAMES>
</HTML>

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

@ -44,4 +44,6 @@ include $(topsrcdir)/config/rules.mk
install::
$(INSTALL) $(srcdir)/WalletPreview.html $(DIST)/bin/res/samples
$(INSTALL) $(srcdir)/SignonViewer.html $(DIST)/bin/res/samples
$(INSTALL) $(srcdir)/CookieViewer.html $(DIST)/bin/res/samples
$(INSTALL) $(srcdir)/cookie.properties $(DIST)/bin/res
$(INSTALL) $(srcdir)/wallet.properties $(DIST)/bin/res

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

@ -0,0 +1,24 @@
# 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.
#
Domain = Domain
Host = Host
Yes = Yes
No = No
AtEndOfSession = at end of session
PermissionToSetACookie = The site %1$s \nwants permission to set a cookie.
PermissionToSetSecondCookie = The site %1$s \nwants permission to set another cookie. You currently have a cookies from this site.
PermissionToSetAnotherCookie = The site %1$s \nwants permission to set another cookie. You currently have %2$d cookies from this site.
PermissionToModifyCookie = The site %1$s \nwants permission to modify an existing cookie.
RememberThisDecision = Remember this decision

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

@ -79,4 +79,6 @@ install:: $(DLL)
$(MAKE_INSTALL) .\$(OBJDIR)\$(DLLNAME).dll $(DIST)\bin\components
$(MAKE_INSTALL) WalletPreview.html $(DIST)\bin\res\samples
$(MAKE_INSTALL) SignonViewer.html $(DIST)\bin\res\samples
$(MAKE_INSTALL) CookieViewer.html $(DIST)\bin\res\samples
$(MAKE_INSTALL) cookie.properties $(DIST)\bin\res
$(MAKE_INSTALL) wallet.properties $(DIST)\bin\res

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

@ -26,11 +26,6 @@
executed.
*/
#if defined(CookieManagement)
/* #define TRUST_LABELS 1 */
#endif
/* make sure we only include this once */
#ifndef _NET_PROTO_H_
#define _NET_PROTO_H_
@ -1060,23 +1055,9 @@ extern void NET_RegisterCookiePrefCallbacks(void);
*/
extern int NET_SaveCookies(char *filename);
/* Start an anonymous list of cookies */
extern void NET_AnonymizeCookies();
/* Restore original list of cookies */
extern void NET_UnanonymizeCookies();
/* Should referer by supressed for anonymity sake */
extern Bool NET_SupressRefererForAnonymity();
#if defined(CookieManagement)
extern void NET_DisplayCookieInfoAsHTML(MWContext *context);
extern void NET_CookieViewerReturn();
extern void NET_DisplayCookieInfoOfSiteAsHTML(MWContext *context, char * URLName);
extern int NET_CookiePermission(char* URLName);
extern int NET_CookieCount(char * URLName);
#endif
#if defined(SingleSignon)
extern void SI_DisplaySignonInfoAsHTML(MWContext *context);
#endif

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

@ -19,6 +19,7 @@
#ifndef nsINetService_h___
#define nsINetService_h___
#include "nsString.h"
#include "nscore.h"
#include "nsISupports.h"
#include "nsIURL.h"
@ -107,22 +108,10 @@ struct nsINetService : public nsISupports
*/
NS_IMETHOD SetCookieString(nsIURL *aURL, const nsString& aCookie)=0;
#ifdef CookieManagement
NS_IMETHOD NET_DisplayCookieInfoAsHTML()=0;
#ifndef HTMLDialogs
NS_IMETHOD NET_CookieViewerReturn()=0;
#endif
#ifdef PrivacySiteInfo
NS_IMETHOD NET_DisplayCookieInfoOfSiteAsHTML(char * URLName)=0;
NS_IMETHOD NET_CookiePermission(char* URLName, PRInt32* permission)=0;
NS_IMETHOD NET_CookieCount(char* URLName, PRInt32* count)=0;
#endif
#endif
NS_IMETHOD NET_AnonymizeCookies()=0;
NS_IMETHOD NET_UnanonymizeCookies()=0;
NS_IMETHOD SI_AnonymizeSignons()=0;
NS_IMETHOD SI_UnanonymizeSignons()=0;
NS_IMETHOD Cookie_DisplayCookieInfoAsHTML()=0;
NS_IMETHOD Cookie_CookieViewerReturn(nsAutoString results)=0;
NS_IMETHOD Cookie_GetCookieListForViewer(nsString& aCookieList)=0;
NS_IMETHOD Cookie_GetPermissionListForViewer(nsString& aPermissionList)=0;
/**
* Get the http proxy used for http transactions.

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

@ -759,72 +759,40 @@ nsNetlibService::SetCookieString(nsIURL *aURL, const nsString& aCookie)
return NS_OK;
}
#ifdef CookieManagement
extern void
COOKIE_DisplayCookieInfoAsHTML();
extern void
COOKIE_GetCookieListForViewer (nsString& aCookieList);
extern void
COOKIE_GetPermissionListForViewer (nsString& aPermissionList);
extern void
COOKIE_CookieViewerReturn(nsAutoString results);
NS_IMETHODIMP
nsNetlibService::NET_DisplayCookieInfoAsHTML(){
::NET_DisplayCookieInfoAsHTML(NULL);
nsNetlibService::Cookie_DisplayCookieInfoAsHTML(){
::COOKIE_DisplayCookieInfoAsHTML();
return NS_OK;
}
#ifndef HTMLDialogs
NS_IMETHODIMP nsNetlibService::NET_CookieViewerReturn(){
::NET_CookieViewerReturn();
return NS_OK;
}
#endif
#ifdef PrivacySiteInfo
NS_IMETHODIMP
nsNetlibService::NET_DisplayCookieInfoOfSiteAsHTML(char * URLName){
::NET_DisplayCookieInfoOfSiteAsHTML(NULL, URLName);
return NS_OK;
}
NS_IMETHODIMP
nsNetlibService::NET_CookiePermission(char* URLName, PRInt32* permission){
*permission = ::NET_CookiePermission(URLName);
NS_IMETHODIMP nsNetlibService::Cookie_CookieViewerReturn(nsAutoString results){
::COOKIE_CookieViewerReturn(results);
return NS_OK;
}
NS_IMETHODIMP
nsNetlibService::NET_CookieCount(char* URLName, PRInt32* count){
*count = ::NET_CookieCount(URLName);
NS_IMETHODIMP nsNetlibService::Cookie_GetCookieListForViewer(nsString& aCookieList){
::COOKIE_GetCookieListForViewer(aCookieList);
return NS_OK;
}
#endif
#endif
NS_IMETHODIMP
nsNetlibService::NET_AnonymizeCookies(){
#ifdef CookieManagement
::NET_AnonymizeCookies();
#endif
NS_IMETHODIMP nsNetlibService::Cookie_GetPermissionListForViewer(nsString& aPermissionList){
::COOKIE_GetPermissionListForViewer(aPermissionList);
return NS_OK;
}
NS_IMETHODIMP
nsNetlibService::NET_UnanonymizeCookies(){
#ifdef CookieManagement
::NET_UnanonymizeCookies();
#endif
return NS_OK;
}
NS_IMETHODIMP
nsNetlibService::SI_AnonymizeSignons(){
#ifdef SingleSignon
::SI_AnonymizeSignons();
#endif
return NS_OK;
}
NS_IMETHODIMP
nsNetlibService::SI_UnanonymizeSignons(){
#ifdef SingleSignon
::SI_UnanonymizeSignons();
#endif
return NS_OK;
}
NS_IMETHODIMP
nsNetlibService::GetProxyHTTP(nsString& aProxyHTTP) {

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

@ -20,6 +20,7 @@
#ifndef nsNetService_h___
#define nsNetService_h___
#include "nsString.h"
#include "nspr.h"
#include "nsIPref.h"
#include "nsITransport.h"
@ -53,22 +54,10 @@ public:
NS_IMETHOD GetCookieString(nsIURL *aURL, nsString& aCookie);
NS_IMETHOD SetCookieString(nsIURL *aURL, const nsString& aCookie);
#ifdef CookieManagement
NS_IMETHOD NET_DisplayCookieInfoAsHTML();
#ifndef HTMLDialogs
NS_IMETHOD NET_CookieViewerReturn();
#endif
#ifdef PrivacySiteInfo
NS_IMETHOD NET_DisplayCookieInfoOfSiteAsHTML(char * URLName);
NS_IMETHOD NET_CookiePermission(char* URLName, PRInt32* permission);
NS_IMETHOD NET_CookieCount(char* URLName, PRInt32* count);
#endif
#endif
NS_IMETHOD NET_AnonymizeCookies();
NS_IMETHOD NET_UnanonymizeCookies();
NS_IMETHOD SI_AnonymizeSignons();
NS_IMETHOD SI_UnanonymizeSignons();
NS_IMETHOD Cookie_DisplayCookieInfoAsHTML();
NS_IMETHOD Cookie_CookieViewerReturn(nsAutoString results);
NS_IMETHOD Cookie_GetCookieListForViewer(nsString& aCookieList);
NS_IMETHOD Cookie_GetPermissionListForViewer(nsString& aPermissionList);
NS_IMETHOD GetProxyHTTP(nsString& aProxyHTTP);
NS_IMETHOD SetProxyHTTP(nsString& aProxyHTTP);

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

@ -30,6 +30,10 @@ CSRCS = \
mkaccess.c \
$(NULL)
CPPSRCS = \
nsCookie.cpp \
$(NULL)
ifdef MOZ_BRPROF
CPPSRCS += nsGetBrowsingProfile.cpp
endif

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

@ -47,6 +47,7 @@ OBJS= \
CPP_OBJS= \
.\$(OBJDIR)\nsGetBrowsingProfile.obj \
.\$(OBJDIR)\nsCookie.obj \
$(NULL)
CSRCS = \
@ -56,6 +57,7 @@ CSRCS = \
CPPSRCS = \
nsGetBrowsingProfile.cpp \
nsCookie.cpp \
$(NULL)
LIBRARY_NAME=httpurl
@ -89,6 +91,9 @@ LINCS= \
-I$(PUBLIC)\xpcom \
-I$(PUBLIC)\brprof \
-I$(PUBLIC)\raptor \
-I$(PUBLIC)\netlib \
-I$(PUBLIC)\intl \
-I$(PUBLIC)\locale \
$(NULL)
#!endif

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -641,7 +641,7 @@ nsBrowserWindow::DispatchMenuItem(PRInt32 aID)
kINetServiceIID,
(nsISupports **)&netservice);
if ((NS_OK == res) && (nsnull != netservice)) {
res = netservice->NET_DisplayCookieInfoAsHTML();
res = netservice->Cookie_DisplayCookieInfoAsHTML();
NS_RELEASE(netservice);
}
break;

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

@ -15,7 +15,6 @@ interface BrowserAppCore : BaseAppCore
void walletChangePassword();
void walletQuickFillin(in Window win);
void walletSamples();
void cookieViewer();
void setToolbarWindow(in Window win);
void setContentWindow(in Window win);

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

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

@ -36,6 +36,7 @@ IDLSRCS= \
EditorAppCore.idl \
PrefsCore.idl \
SignonCore.idl \
CookieCore.idl \
WalletCore.idl \
RDFCore.idl \
Toolbar.idl \

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

@ -30,6 +30,7 @@ EXPORTS = \
nsIDOMEditorAppCore.h \
nsIDOMPrefsCore.h \
nsIDOMSignonCore.h \
nsIDOMCookieCore.h \
nsIDOMWalletCore.h \
nsIDOMProfileCore.h \
nsIDOMRDFCore.h \

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

@ -27,6 +27,7 @@ EXPORTS= \
nsIDOMDOMPropsCore.h \
nsIDOMPrefsCore.h \
nsIDOMSignonCore.h \
nsIDOMCookieCore.h \
nsIDOMWalletCore.h \
nsIDOMProfileCore.h \
nsIDOMRDFCore.h \

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

@ -31,6 +31,11 @@
0x96a79e90, 0xe30, 0x11d3, { 0xab, 0x9f, 0x0, 0x80, 0xc7, 0x87, 0xad, 0x96} \
}
#define NS_COOKIECORE_CID \
{ /* {76C2DCD0-191F-11d3-ABA7-0080C787AD96 */ \
0x76c2dcd0, 0x191f, 0x11d3, { 0xab, 0xa7, 0x0, 0x80, 0xc7, 0x87, 0xad, 0x96} \
}
#define NS_WALLETCORE_CID \
{ /* {9D6E2541-108B-11d3-ABA3-0080C787AD96 */ \
0x9d6e2541, 0x108b, 0x11d3, { 0xab, 0xa3, 0x0, 0x80, 0xc7, 0x87, 0xad, 0x96} \

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

@ -53,8 +53,6 @@ public:
NS_IMETHOD WalletSamples()=0;
NS_IMETHOD CookieViewer()=0;
NS_IMETHOD SetToolbarWindow(nsIDOMWindow* aWin)=0;
NS_IMETHOD SetContentWindow(nsIDOMWindow* aWin)=0;
@ -91,7 +89,6 @@ public:
NS_IMETHOD WalletChangePassword(); \
NS_IMETHOD WalletQuickFillin(nsIDOMWindow* aWin); \
NS_IMETHOD WalletSamples(); \
NS_IMETHOD CookieViewer(); \
NS_IMETHOD SetToolbarWindow(nsIDOMWindow* aWin); \
NS_IMETHOD SetContentWindow(nsIDOMWindow* aWin); \
NS_IMETHOD SetWebShellWindow(nsIDOMWindow* aWin); \
@ -117,7 +114,6 @@ public:
NS_IMETHOD WalletChangePassword() { return _to WalletChangePassword(); } \
NS_IMETHOD WalletQuickFillin(nsIDOMWindow* aWin) { return _to WalletQuickFillin(aWin); } \
NS_IMETHOD WalletSamples() { return _to WalletSamples(); } \
NS_IMETHOD CookieViewer() { return _to CookieViewer(); } \
NS_IMETHOD SetToolbarWindow(nsIDOMWindow* aWin) { return _to SetToolbarWindow(aWin); } \
NS_IMETHOD SetContentWindow(nsIDOMWindow* aWin) { return _to SetContentWindow(aWin); } \
NS_IMETHOD SetWebShellWindow(nsIDOMWindow* aWin) { return _to SetWebShellWindow(aWin); } \

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

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

@ -0,0 +1,295 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (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 Communicator client 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.
*/
#include "nsCookieCore.h"
#include "nsINetService.h"
#include "nsIURL.h"
#include "nsIFileLocator.h"
#include "nsFileLocations.h"
#include "nsFileSpec.h"
#include "nsFileStream.h"
#include "nsIBrowserWindow.h"
#include "nsIWebShell.h"
#include "pratom.h"
#include "nsIComponentManager.h"
#include "nsAppCores.h"
#include "nsAppCoresCIDs.h"
#include "nsAppShellCIDs.h"
#include "nsAppCoresManager.h"
#include "nsIAppShellService.h"
#include "nsIServiceManager.h"
#include "nsIScriptGlobalObject.h"
#include "nsIScriptContext.h"
#include "nsIScriptContextOwner.h"
#include "nsIDOMWindow.h"
#include "nsIWebShellWindow.h"
#include "plstr.h"
#include "prmem.h"
#include <ctype.h>
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_IID(kIAppShellServiceIID, NS_IAPPSHELL_SERVICE_IID);
static NS_DEFINE_IID(kAppShellServiceCID, NS_APPSHELL_SERVICE_CID);
static NS_DEFINE_IID(kINetServiceIID, NS_INETSERVICE_IID);
static NS_DEFINE_IID(kNetServiceCID, NS_NETSERVICE_CID);
static void DOMWindowToWebShellWindow(nsIDOMWindow *DOMWindow, nsCOMPtr<nsIWebShellWindow> *webWindow);
//----------------------------------------------------------------------------------------
nsCookieCore::nsCookieCore()
//----------------------------------------------------------------------------------------
: mPanelWindow(nsnull)
{
printf("Created nsCookieCore\n");
}
//----------------------------------------------------------------------------------------
nsCookieCore::~nsCookieCore()
//----------------------------------------------------------------------------------------
{
NS_IF_RELEASE(mPanelWindow);
}
NS_IMPL_ISUPPORTS_INHERITED(nsCookieCore, nsBaseAppCore, nsIDOMCookieCore)
//----------------------------------------------------------------------------------------
NS_IMETHODIMP nsCookieCore::GetScriptObject(nsIScriptContext *aContext, void** aScriptObject)
//----------------------------------------------------------------------------------------
{
NS_PRECONDITION(nsnull != aScriptObject, "null arg");
nsresult res = NS_OK;
if (nsnull == mScriptObject)
{
res = NS_NewScriptCookieCore(aContext,
(nsISupports *)(nsIDOMCookieCore*)this,
nsnull,
&mScriptObject);
}
*aScriptObject = mScriptObject;
return res;
}
//----------------------------------------------------------------------------------------
NS_IMETHODIMP nsCookieCore::Init(const nsString& aId)
//----------------------------------------------------------------------------------------
{
nsresult rv = nsBaseAppCore::Init(aId);
return rv;
} // nsCookieCore::Init
//----------------------------------------------------------------------------------------
NS_IMETHODIMP nsCookieCore::ShowWindow(nsIDOMWindow* aCurrentFrontWin)
//----------------------------------------------------------------------------------------
{
nsINetService *netservice;
nsresult res;
res = nsServiceManager::GetService(kNetServiceCID,
kINetServiceIID,
(nsISupports **)&netservice);
if ((NS_OK == res) && (nsnull != netservice)) {
res = netservice->Cookie_DisplayCookieInfoAsHTML();
nsServiceManager::ReleaseService(kNetServiceCID, netservice);
}
// (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/CookieViewer.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(aCurrentFrontWin, &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;
} // nsCookieCore::ShowWindow
//----------------------------------------------------------------------------------------
NS_IMETHODIMP nsCookieCore::ChangePanel(const nsString& aURL)
// Start loading of a new cookie panel.
//----------------------------------------------------------------------------------------
{
NS_ASSERTION(mPanelWindow, "panel window is null");
if (!mPanelWindow)
return NS_OK;
nsCOMPtr<nsIScriptGlobalObject> globalScript(do_QueryInterface(mPanelWindow));
if (!globalScript)
return NS_ERROR_FAILURE;
nsCOMPtr<nsIWebShell> webshell;
globalScript->GetWebShell(getter_AddRefs(webshell));
if (!webshell)
return NS_ERROR_FAILURE;
webshell->LoadURL(aURL.GetUnicode());
return NS_OK;
}
//----------------------------------------------------------------------------------------
NS_IMETHODIMP nsCookieCore::PanelLoaded(nsIDOMWindow* aWin)
// Callback after loading of a new cookie panel.
//----------------------------------------------------------------------------------------
{
// Out with the old!
if (mPanelWindow != aWin)
{
NS_IF_RELEASE(mPanelWindow);
mPanelWindow = aWin;
NS_IF_ADDREF(mPanelWindow);
}
return NS_OK;
}
//----------------------------------------------------------------------------------------
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);
}
}
//----------------------------------------------------------------------------------------
static nsresult Close(nsIDOMWindow*& dw)
//----------------------------------------------------------------------------------------
{
if (!dw)
return NS_ERROR_FAILURE;
nsIDOMWindow* top;
dw->GetTop(&top);
if (!top)
return NS_ERROR_FAILURE;
nsCOMPtr<nsIWebShellWindow> parent;
DOMWindowToWebShellWindow(top, &parent);
if (parent)
parent->Close();
NS_IF_RELEASE(dw);
return NS_OK;
}
//----------------------------------------------------------------------------------------
NS_IMETHODIMP nsCookieCore::SaveCookie(const nsString& results)
//----------------------------------------------------------------------------------------
{
nsINetService *netservice;
nsresult res;
res = nsServiceManager::GetService(kNetServiceCID,
kINetServiceIID,
(nsISupports **)&netservice);
if ((NS_OK == res) && (nsnull != netservice)) {
res = netservice->Cookie_CookieViewerReturn (results);
nsServiceManager::ReleaseService(kNetServiceCID, netservice);
}
return Close(mPanelWindow);
}
//----------------------------------------------------------------------------------------
NS_IMETHODIMP nsCookieCore::CancelCookie()
//----------------------------------------------------------------------------------------
{
return Close(mPanelWindow);
}
//----------------------------------------------------------------------------------------
NS_IMETHODIMP nsCookieCore::GetCookieList(nsString& aCookieList)
//----------------------------------------------------------------------------------------
{
nsINetService *netservice;
nsresult res;
res = nsServiceManager::GetService(kNetServiceCID,
kINetServiceIID,
(nsISupports **)&netservice);
if ((NS_OK == res) && (nsnull != netservice)) {
res = netservice->Cookie_GetCookieListForViewer(aCookieList);
nsServiceManager::ReleaseService(kNetServiceCID, netservice);
}
return NS_OK;
}
//----------------------------------------------------------------------------------------
NS_IMETHODIMP nsCookieCore::GetPermissionList(nsString& aPermissionList)
//----------------------------------------------------------------------------------------
{
nsINetService *netservice;
nsresult res;
res = nsServiceManager::GetService(kNetServiceCID,
kINetServiceIID,
(nsISupports **)&netservice);
if ((NS_OK == res) && (nsnull != netservice)) {
res = netservice->Cookie_GetPermissionListForViewer(aPermissionList);
nsServiceManager::ReleaseService(kNetServiceCID, netservice);
}
return NS_OK;
}

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

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

@ -0,0 +1,118 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (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 Communicator client 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.
*/
#include "nsCookieCoreFactory.h"
#include "nsAppCores.h"
#include "nsCookieCore.h"
#include "pratom.h"
#include "nsISupportsUtils.h"
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
//----------------------------------------------------------------------------------------
nsCookieCoreFactory::nsCookieCoreFactory()
//----------------------------------------------------------------------------------------
{
NS_INIT_REFCNT();
IncInstanceCount();
}
//----------------------------------------------------------------------------------------
nsCookieCoreFactory::~nsCookieCoreFactory()
//----------------------------------------------------------------------------------------
{
DecInstanceCount();
}
NS_IMPL_ADDREF(nsCookieCoreFactory)
NS_IMPL_RELEASE(nsCookieCoreFactory)
//----------------------------------------------------------------------------------------
NS_IMETHODIMP nsCookieCoreFactory::QueryInterface(REFNSIID aIID,void** aInstancePtr)
//----------------------------------------------------------------------------------------
{
if (aInstancePtr == NULL)
return NS_ERROR_NULL_POINTER;
// Always NULL result, in case of failure
*aInstancePtr = NULL;
if ( aIID.Equals(kISupportsIID) )
*aInstancePtr = (void*) this;
else if ( aIID.Equals(kIFactoryIID) )
*aInstancePtr = (void*) this;
if (aInstancePtr == NULL)
return NS_ERROR_NO_INTERFACE;
AddRef();
return NS_OK;
} // nsCookieCoreFactory::QueryInterface
//----------------------------------------------------------------------------------------
NS_IMETHODIMP nsCookieCoreFactory::CreateInstance(
nsISupports* aOuter,
REFNSIID aIID,
void **aResult)
//----------------------------------------------------------------------------------------
{
if (aResult == NULL)
return NS_ERROR_NULL_POINTER;
*aResult = NULL;
#if 0
// There is a stupid bug that I don't feel competent to fix. Basically, the
// AppCore Manager is a waste of time (the manager gets created, an app core is
// added to the list, and then the app core manager is deleted, along with its list).
// I want to insist that
// there is always one instance of the Cookie app core. Hence this HACK.
static nsCookieCore* inst = nsnull;
PRBool firstTime = (inst == nsnull);
if (firstTime)
{
inst = new nsCookieCore();
if (!inst)
return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(inst);
}
nsresult result = inst->QueryInterface(aIID, aResult);
if (result != NS_OK && firstTime)
NS_RELEASE(inst);
#else
static nsCookieCore* inst = new nsCookieCore();
if (!inst)
return NS_ERROR_OUT_OF_MEMORY;
nsresult result = inst->QueryInterface(aIID, aResult);
#endif
return result;
} // nsCookieCoreFactory::CreateInstance
//----------------------------------------------------------------------------------------
NS_IMETHODIMP nsCookieCoreFactory::LockFactory(PRBool aLock)
//----------------------------------------------------------------------------------------
{
if (aLock)
IncLockCount();
else
DecLockCount();
return NS_OK;
} // nsCookieCoreFactory::LockFactory

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

@ -0,0 +1,47 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* 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.
*/
#ifndef nsCookieCoreFactory_h___
#define nsCookieCoreFactory_h___
//#include "nscore.h"
//#include "nsString.h"
#include "nsIFactory.h"
#include "nsISupports.h"
//========================================================================================
class nsCookieCoreFactory : public nsIFactory
//========================================================================================
{
public:
nsCookieCoreFactory();
virtual ~nsCookieCoreFactory();
PRBool CanUnload(void);
NS_DECL_ISUPPORTS
NS_IMETHOD CreateInstance(nsISupports *aOuter,
REFNSIID aIID,
void **aResult);
NS_IMETHOD LockFactory(PRBool aLock);
};
#endif // nsCookieCoreFactory_h___

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

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

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

@ -45,6 +45,7 @@ EXPORT_RESOURCE_SAMPLES = \
$(srcdir)/PrefsWindow.html \
$(srcdir)/PrefsWindow.js \
$(srcdir)/SignonWindow.js \
$(srcdir)/CookieWindow.js \
$(srcdir)/WalletWindow.js \
$(srcdir)/preftree.css \
$(srcdir)/preftree.xul \

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

@ -571,11 +571,15 @@
function CookieViewer()
{
if (appCore != null) {
dump("CookieViewer\n");
appCore.cookieViewer();
} else {
dump("BrowserAppCore has not been created!\n");
var cookieCore = XPAppCoresManager.Find("CookieCore");
if (!cookieCore) {
cookieCore = new CookieCore();
if (cookieCore) {
cookieCore.Init("CookieCore");
}
}
if (cookieCore) {
cookieCore.ShowWindow(window);
}
}