зеркало из https://github.com/mozilla/gecko-dev.git
improved cookie viewer, approved by valeski
This commit is contained in:
Родитель
b690d7b15c
Коммит
590d9c981f
|
@ -95,6 +95,8 @@ extern int MK_ACCESS_NO;
|
|||
extern int MK_ACCESS_SECURE;
|
||||
extern int MK_ACCESS_EXPIRES;
|
||||
extern int MK_ACCESS_END_OF_SESSION;
|
||||
extern int MK_ACCESS_VIEW_COOKIES;
|
||||
extern int MK_ACCESS_VIEW_SITES;
|
||||
|
||||
#define MAX_NUMBER_OF_COOKIES 300
|
||||
#define MAX_COOKIES_PER_SERVER 20
|
||||
|
@ -3387,7 +3389,7 @@ NET_AskForProxyAuth(MWContext * context,
|
|||
|
||||
#if defined(CookieManagement)
|
||||
#include "htmldlgs.h"
|
||||
extern int XP_EMPTY_STRINGS;
|
||||
extern int XP_CERT_PAGE_STRINGS;
|
||||
extern int SA_VIEW_BUTTON_LABEL;
|
||||
extern int SA_REMOVE_BUTTON_LABEL;
|
||||
|
||||
|
@ -3397,117 +3399,9 @@ extern int SA_REMOVE_BUTTON_LABEL;
|
|||
if (buffer) { \
|
||||
StrAllocCat(buffer2, buffer); \
|
||||
g = 0; \
|
||||
buffer[0] = '\0'; \
|
||||
}
|
||||
|
||||
MODULE_PRIVATE void
|
||||
net_DisplayCookieDetailsAsHTML(MWContext *context,
|
||||
char* cookie_path, char* cookie_host,
|
||||
char* cookie_name, char* cookie_cookie,
|
||||
time_t cookie_expires, Bool cookie_secure, Bool cookie_is_domain)
|
||||
{
|
||||
char *buffer = (char*)PR_Malloc(BUFLEN);
|
||||
char *buffer2 = 0;
|
||||
int g = 0;
|
||||
XP_List *list=net_cookie_list;
|
||||
char *expireDate = NULL;
|
||||
|
||||
static XPDialogInfo dialogInfo = {
|
||||
XP_DIALOG_OK_BUTTON,
|
||||
NULL,
|
||||
600,
|
||||
300
|
||||
};
|
||||
|
||||
XPDialogStrings* strings;
|
||||
StrAllocCopy(buffer2, "");
|
||||
|
||||
/* Write out cookie details */
|
||||
|
||||
g += PR_snprintf(buffer+g, BUFLEN-g,
|
||||
"<TABLE>");
|
||||
|
||||
g += PR_snprintf(buffer+g, BUFLEN-g,
|
||||
"<TR><TD><b>%s</b></TD> <TD>%s</TD></TR>",
|
||||
XP_GetString(MK_ACCESS_NAME), cookie_name);
|
||||
FLUSH_BUFFER
|
||||
|
||||
g += PR_snprintf(buffer+g, BUFLEN-g,
|
||||
"<TR><TD><b>%s</b></TD> <TD>%s</TD></TR>",
|
||||
XP_GetString(MK_ACCESS_VALUE), cookie_cookie);
|
||||
FLUSH_BUFFER
|
||||
|
||||
if (cookie_is_domain) {
|
||||
g += PR_snprintf(buffer+g, BUFLEN-g,
|
||||
"<TR><TD><b>%s</b></TD> <TD>%s</TD></TR>",
|
||||
XP_GetString(MK_ACCESS_DOMAIN), cookie_host);
|
||||
} else {
|
||||
g += PR_snprintf(buffer+g, BUFLEN-g,
|
||||
"<TR><TD><b>%s</b></TD> <TD>%s</TD></TR>",
|
||||
XP_GetString(MK_ACCESS_HOST), cookie_host);
|
||||
}
|
||||
FLUSH_BUFFER
|
||||
|
||||
g += PR_snprintf(buffer+g, BUFLEN-g,
|
||||
"<TR><TD><b>%s</b></TD> <TD>%s</TD></TR>",
|
||||
XP_GetString(MK_ACCESS_PATH), cookie_path);
|
||||
FLUSH_BUFFER
|
||||
|
||||
if(cookie_secure) {
|
||||
g += PR_snprintf(buffer+g, BUFLEN-g,
|
||||
"<TR><TD><b>%s</b></TD> <TD>%s</TD></TR>",
|
||||
XP_GetString(MK_ACCESS_SECURE), XP_GetString(MK_ACCESS_YES));
|
||||
} else {
|
||||
g += PR_snprintf(buffer+g, BUFLEN-g,
|
||||
"<TR><TD><b>%s</b></TD> <TD>%s</TD></TR>",
|
||||
XP_GetString(MK_ACCESS_SECURE), XP_GetString(MK_ACCESS_NO));
|
||||
}
|
||||
FLUSH_BUFFER
|
||||
|
||||
if(cookie_expires) {
|
||||
expireDate=ctime(&(cookie_expires));
|
||||
if (expireDate) {
|
||||
g += PR_snprintf(buffer+g, BUFLEN-g,
|
||||
"<TR><TD><b>%s</b></TD> <TD>%s</TD></TR>",
|
||||
XP_GetString(MK_ACCESS_EXPIRES), expireDate);
|
||||
} else {
|
||||
g += PR_snprintf(buffer+g, BUFLEN-g,
|
||||
"<TR><TD><b>%s</b></TD> <TD>%s</TD></TR>",
|
||||
XP_GetString(MK_ACCESS_EXPIRES), "");
|
||||
}
|
||||
} else {
|
||||
g += PR_snprintf(buffer+g, BUFLEN-g,
|
||||
"<TR><TD><b>%s</b></TD> <TD>%s</TD></TR>",
|
||||
XP_GetString(MK_ACCESS_EXPIRES),
|
||||
XP_GetString(MK_ACCESS_END_OF_SESSION));
|
||||
}
|
||||
|
||||
g += PR_snprintf(buffer+g, BUFLEN-g,"</TABLE>");
|
||||
FLUSH_BUFFER
|
||||
|
||||
/* free buffer since it is no longer needed */
|
||||
if (buffer) {
|
||||
PR_Free(buffer);
|
||||
}
|
||||
|
||||
/* do html dialog */
|
||||
strings = XP_GetDialogStrings(XP_EMPTY_STRINGS);
|
||||
if (!strings) {
|
||||
if (buffer2) {
|
||||
PR_Free(buffer2);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (buffer2) {
|
||||
XP_CopyDialogString(strings, 0, buffer2);
|
||||
PR_Free(buffer2);
|
||||
buffer2 = NULL;
|
||||
}
|
||||
XP_MakeHTMLDialog(context, &dialogInfo, MK_ACCESS_YOUR_COOKIES,
|
||||
strings, context, PR_FALSE);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/* return TRUE if "number" is in sequence of comma-separated numbers */
|
||||
Bool net_InSequence(char* sequence, int number) {
|
||||
char* ptr;
|
||||
|
@ -3526,29 +3420,32 @@ Bool net_InSequence(char* sequence, int number) {
|
|||
/* get to next comma */
|
||||
endptr = PL_strchr(ptr, ',');
|
||||
|
||||
/* if comma found, set it to null */
|
||||
if (endptr) {
|
||||
/* if comma found, process it */
|
||||
if (endptr) {
|
||||
|
||||
/* restore last comma-to-null back to comma */
|
||||
if (undo) {
|
||||
/* restore last comma-to-null back to comma */
|
||||
if (undo) {
|
||||
*undo = ',';
|
||||
}
|
||||
undo = endptr;
|
||||
}
|
||||
|
||||
/* set the comma to a null */
|
||||
undo = endptr;
|
||||
*endptr++ = '\0';
|
||||
}
|
||||
|
||||
/* if there is a number before the comma, compare it with "number" */
|
||||
if (*ptr) {
|
||||
i = atoi(ptr);
|
||||
if (i == number) {
|
||||
/* compare the number before the comma with "number" */
|
||||
if (*ptr) {
|
||||
i = atoi(ptr);
|
||||
if (i == number) {
|
||||
|
||||
/* "number" was in the sequence so return TRUE */
|
||||
retval = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* "number" was in the sequence so return TRUE */
|
||||
retval = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* restore last comma-to-null back to comma */
|
||||
if (undo) {
|
||||
*undo = ',';
|
||||
}
|
||||
|
@ -3562,7 +3459,7 @@ net_AboutCookiesDialogDone(XPDialogState* state, char** argv, int argc,
|
|||
XP_List *list;
|
||||
net_CookieStruct *cookie;
|
||||
net_CookiePermissionStruct *cookiePermission;
|
||||
char *buttonName, *cookieNumberAsString;
|
||||
char *buttonName;
|
||||
int cookieNumber;
|
||||
net_CookieStruct *cookieToDelete = 0;
|
||||
net_CookiePermissionStruct *cookiePermissionToDelete = 0;
|
||||
|
@ -3570,38 +3467,6 @@ net_AboutCookiesDialogDone(XPDialogState* state, char** argv, int argc,
|
|||
char* gone;
|
||||
|
||||
buttonName = XP_FindValueInArgs("button", argv, argc);
|
||||
if (buttonName &&
|
||||
!PL_strcasecmp(buttonName, XP_GetString(SA_VIEW_BUTTON_LABEL))) {
|
||||
|
||||
/* view button was pressed */
|
||||
|
||||
/* get "selname" value in argv list */
|
||||
if ((cookieNumberAsString = XP_FindValueInArgs("selname", argv, argc))) {
|
||||
|
||||
/* convert "selname" value from string to an integer */
|
||||
cookieNumber = atoi(cookieNumberAsString);
|
||||
|
||||
/* get the cookie corresponding to that integer */
|
||||
list=net_cookie_list;
|
||||
|
||||
while (cookieNumber-- >= 0) {
|
||||
if (!(cookie=(net_CookieStruct *) XP_ListNextObject(list))) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* display the details for that cookie */
|
||||
if (cookie) {
|
||||
net_DisplayCookieDetailsAsHTML
|
||||
((MWContext *)(state->arg),
|
||||
cookie->path, cookie->host,
|
||||
cookie->name, cookie->cookie,
|
||||
cookie->expires, HG78111, cookie->is_domain);
|
||||
}
|
||||
}
|
||||
return(PR_TRUE);
|
||||
}
|
||||
|
||||
if (button != XP_DIALOG_OK_BUTTON) {
|
||||
/* OK button not pressed (must be cancel button that was pressed) */
|
||||
return PR_FALSE;
|
||||
|
@ -3729,67 +3594,154 @@ NextCookieAfter(net_CookieStruct * cookie, int * cookieNum) {
|
|||
return lowestCookie;
|
||||
}
|
||||
|
||||
typedef struct _CookieViewerDialog CookieViewerDialog;
|
||||
|
||||
struct _CookieViewerDialog {
|
||||
void *window;
|
||||
void *parent_window;
|
||||
PRBool dialogUp;
|
||||
XPDialogState *state;
|
||||
};
|
||||
|
||||
#ifdef XP_MAC
|
||||
/* pinkerton - if we don't do this, it won't compile because it runs out of registers */
|
||||
#pragma global_optimizer on
|
||||
#endif
|
||||
|
||||
PUBLIC void
|
||||
NET_DisplayCookieInfoAsHTML(MWContext *context)
|
||||
{
|
||||
char *buffer = (char*)PR_Malloc(BUFLEN);
|
||||
char *buffer2 = 0;
|
||||
int g = 0, numOfCookies, cookieNum;
|
||||
int g = 0, count, cookieNum;
|
||||
XP_List *cookie_list;
|
||||
XP_List *cookie_permission_list;
|
||||
net_CookieStruct *cookie;
|
||||
net_CookiePermissionStruct *cookperm;
|
||||
CookieViewerDialog *dlg;
|
||||
int i;
|
||||
|
||||
static XPDialogInfo dialogInfo = {
|
||||
XP_DIALOG_OK_BUTTON | XP_DIALOG_CANCEL_BUTTON,
|
||||
0,
|
||||
net_AboutCookiesDialogDone,
|
||||
600,
|
||||
420
|
||||
400
|
||||
};
|
||||
|
||||
XPDialogStrings* strings;
|
||||
strings = XP_GetDialogStrings(XP_CERT_PAGE_STRINGS);
|
||||
if (!strings) {
|
||||
return;
|
||||
}
|
||||
StrAllocCopy(buffer2, "");
|
||||
|
||||
/* Write out the javascript */
|
||||
/* generate initial section of html file */
|
||||
g += PR_snprintf(buffer+g, BUFLEN-g,
|
||||
"<script>\n"
|
||||
"<HTML>\n"
|
||||
"<HEAD>\n"
|
||||
" <TITLE>Cookies</TITLE>\n"
|
||||
" <SCRIPT>\n"
|
||||
" index_frame = 0;\n"
|
||||
" title_frame = 1;\n"
|
||||
" spacer1_frame = 2;\n"
|
||||
" list_frame = 3;\n"
|
||||
" spacer2_frame = 4;\n"
|
||||
" prop_frame = 5;\n"
|
||||
" spacer3_frame = 6;\n"
|
||||
" button_frame = 7;\n"
|
||||
"\n"
|
||||
" var cookie_mode;\n"
|
||||
" var goneC;\n"
|
||||
" var goneP;\n"
|
||||
" deleted_cookies = new Array (0"
|
||||
);
|
||||
FLUSH_BUFFER
|
||||
|
||||
"function DeleteCookieSelected() {\n"
|
||||
" selname = document.theform.selname;\n"
|
||||
" goneC = document.theform.goneC;\n"
|
||||
" var i;\n"
|
||||
" var j;\n"
|
||||
" for (i=selname.options.length; i>0; i--) {\n"
|
||||
" if (selname.options[i-1].selected) {\n"
|
||||
" selname.options[i-1].selected = 0;\n"
|
||||
" goneC.value = goneC.value + \",\" + selname.options[i-1].value;\n"
|
||||
/* " temp = selname.options[i-1];\n" */
|
||||
" for (j=i ; j<selname.options.length ; j++) {\n"
|
||||
" selname.options[j-1] = selname.options[j];\n"
|
||||
|
||||
/* fill in initial 0's for deleted_cookies and deleted_sites arrays */
|
||||
count = XP_ListCount(net_cookie_list);
|
||||
for (i=1; i<count; i++) {
|
||||
g += PR_snprintf(buffer+g, BUFLEN-g,
|
||||
",0"
|
||||
);
|
||||
if ((i%50) == 0) {
|
||||
g += PR_snprintf(buffer+g, BUFLEN-g,
|
||||
"\n "
|
||||
);
|
||||
}
|
||||
}
|
||||
g += PR_snprintf(buffer+g, BUFLEN-g,
|
||||
");\n"
|
||||
" deleted_sites = new Array (0"
|
||||
);
|
||||
count = XP_ListCount(net_cookie_permission_list);
|
||||
for (i=1; i<count; i++) {
|
||||
g += PR_snprintf(buffer+g, BUFLEN-g,
|
||||
",0"
|
||||
);
|
||||
if ((i%50) == 0) {
|
||||
g += PR_snprintf(buffer+g, BUFLEN-g,
|
||||
"\n "
|
||||
);
|
||||
}
|
||||
}
|
||||
FLUSH_BUFFER
|
||||
|
||||
g += PR_snprintf(buffer+g, BUFLEN-g,
|
||||
");\n"
|
||||
"\n"
|
||||
" function DeleteItemSelected() {\n"
|
||||
" if (cookie_mode) {\n"
|
||||
" DeleteCookieSelected();\n"
|
||||
" } else {\n"
|
||||
" DeleteSiteSelected();\n"
|
||||
" }\n"
|
||||
" selname.options[selname.options.length-1] = null;\n"
|
||||
/* " selname.options[selname.options.length-1] = temp;\n" */
|
||||
/* " selname.options.length = selname.options.length-1;\n" */
|
||||
" }\n"
|
||||
" }\n"
|
||||
"}\n"
|
||||
"function DeleteCookiePermissionSelected() {\n"
|
||||
" selname2 = document.theform.selname2;\n"
|
||||
" goneP = document.theform.goneP;\n"
|
||||
" var i;\n"
|
||||
" var j;\n"
|
||||
" for (i=selname2.options.length; i>0; i--) {\n"
|
||||
" if (selname2.options[i-1].selected) {\n"
|
||||
" selname2.options[i-1].selected = 0;\n"
|
||||
" goneP.value = goneP.value + \",\" + selname2.options[i-1].value;\n"
|
||||
" for (j=i ; j<selname2.options.length ; j++) {\n"
|
||||
" selname2.options[j-1] = selname2.options[j];\n"
|
||||
"\n"
|
||||
" function DeleteCookieSelected() {\n"
|
||||
" selname = top.frames[list_frame].document.fSelectCookie.selname;\n"
|
||||
" goneC = top.frames[button_frame].document.buttons.goneC;\n"
|
||||
" var p;\n"
|
||||
" var i;\n"
|
||||
" for (i=selname.options.length; i>0; i--) {\n"
|
||||
" if (selname.options[i-1].selected) {\n"
|
||||
" selname.options[i-1].selected = 0;\n"
|
||||
" goneC.value = goneC.value + \",\" + selname.options[i-1].value;\n"
|
||||
" deleted_cookies[selname.options[i-1].value] = 1;\n"
|
||||
" for (j=i ; j<selname.options.length ; j++) {\n"
|
||||
" selname.options[j-1] = selname.options[j];\n"
|
||||
" }\n"
|
||||
" selname.options[selname.options.length-1] = null;\n"
|
||||
" }\n"
|
||||
" }\n"
|
||||
" selname2.options[selname2.options.length-1] = null;\n"
|
||||
" top.frames[prop_frame].document.open();\n"
|
||||
" top.frames[prop_frame].document.close();\n"
|
||||
" }\n"
|
||||
" }\n"
|
||||
"}\n"
|
||||
"</script>\n"
|
||||
"\n"
|
||||
" function DeleteSiteSelected() {\n"
|
||||
" selname = top.frames[list_frame].document.fSelectSite.selname;\n"
|
||||
" goneP = top.frames[button_frame].document.buttons.goneP;\n"
|
||||
" var p;\n"
|
||||
" var i;\n"
|
||||
" for (i=selname.options.length; i>0; i--) {\n"
|
||||
" if (selname.options[i-1].selected) {\n"
|
||||
" selname.options[i-1].selected = 0;\n"
|
||||
" goneP.value = goneP.value + \",\" + selname.options[i-1].value;\n"
|
||||
" deleted_sites[selname.options[i-1].value] = 1;\n"
|
||||
" for (j=i; j < selname.options.length; j++) {\n"
|
||||
" selname.options[j-1] = selname.options[j];\n"
|
||||
" }\n"
|
||||
" selname.options[selname.options.length-1] = null;\n"
|
||||
" }\n"
|
||||
" }\n"
|
||||
" top.frames[prop_frame].document.open();\n"
|
||||
" top.frames[prop_frame].document.close();\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
" function ViewCookieSelected(selCookie) {\n"
|
||||
" selname = top.frames[list_frame].document.fSelectCookie.selname;\n"
|
||||
" top.frames[prop_frame].document.open();\n"
|
||||
" switch (selname.options[selCookie].value) {\n"
|
||||
);
|
||||
FLUSH_BUFFER
|
||||
|
||||
|
@ -3798,141 +3750,370 @@ NET_DisplayCookieInfoAsHTML(MWContext *context)
|
|||
*/
|
||||
net_lock_cookie_list();
|
||||
net_remove_expired_cookies();
|
||||
numOfCookies=XP_ListCount(net_cookie_list);
|
||||
|
||||
/* Write out the initial statistics. */
|
||||
goto after_stats;
|
||||
|
||||
g += PR_snprintf(buffer+g, BUFLEN-g,
|
||||
"<h2>%s</h2>\n"
|
||||
"<TABLE>\n"
|
||||
"<TR>\n",
|
||||
XP_GetString(MK_ACCESS_YOUR_COOKIES));
|
||||
|
||||
g += PR_snprintf(buffer+g, BUFLEN-g,
|
||||
"<TD ALIGN=RIGHT><b>%s</TD>\n"
|
||||
"<TD>%ld</TD>\n"
|
||||
"</TR>\n"
|
||||
"<TR>\n",
|
||||
XP_GetString(MK_ACCESS_MAXIMUM_COOKS),
|
||||
MAX_NUMBER_OF_COOKIES);
|
||||
|
||||
g += PR_snprintf(buffer+g, BUFLEN-g,
|
||||
"<TD ALIGN=RIGHT><b>%s</TD>\n"
|
||||
"<TD>%ld</TD>\n"
|
||||
"</TR>\n"
|
||||
"<TR>\n",
|
||||
XP_GetString(MK_ACCESS_COOK_COUNT),
|
||||
numOfCookies);
|
||||
|
||||
g += PR_snprintf(buffer+g, BUFLEN-g,
|
||||
"<TD ALIGN=RIGHT><b>%s</TD>\n"
|
||||
"<TD>%ld</TD>\n"
|
||||
"</TR>\n"
|
||||
"<TR>\n",
|
||||
XP_GetString(MK_ACCESS_MAXIMUM_COOKS_PER_SERV),
|
||||
MAX_COOKIES_PER_SERVER);
|
||||
|
||||
g += PR_snprintf(buffer+g, BUFLEN-g,
|
||||
"<TD ALIGN=RIGHT><b>%s</TD>\n"
|
||||
"<TD>%ld</TD>\n"
|
||||
"</TR>\n"
|
||||
"</TABLE>\n",
|
||||
XP_GetString(MK_ACCESS_MAXIMUM_COOK_SIZE),
|
||||
MAX_BYTES_PER_COOKIE);
|
||||
FLUSH_BUFFER
|
||||
after_stats:
|
||||
|
||||
/* Write out each cookie in alphabetical order */
|
||||
g += PR_snprintf(buffer+g, BUFLEN-g,
|
||||
"<FORM><TABLE COLS=2>\n"
|
||||
"<TH><CENTER>%s<BR></CENTER><CENTER><SELECT NAME=\"selname\" MULTIPLE SIZE=15>\n",
|
||||
XP_GetString(MK_ACCESS_COOKIES_ACCEPTED));
|
||||
FLUSH_BUFFER
|
||||
/* Generate the html for the cookie properties (alphabetical order) */
|
||||
cookie_list=net_cookie_list;
|
||||
cookie = NULL;
|
||||
while (cookie = NextCookieAfter(cookie, &cookieNum)) {
|
||||
char * expireDate = NULL;
|
||||
StrAllocCopy (expireDate, ctime(&(cookie->expires)));
|
||||
if (expireDate && (expireDate[strlen(expireDate)-1] == '\n')) {
|
||||
expireDate[strlen(expireDate)-1] = ' ';
|
||||
}
|
||||
g += PR_snprintf(buffer+g, BUFLEN-g,
|
||||
"<OPTION VALUE=%d>%s: %s</OPTION>",
|
||||
" case %d:\n"
|
||||
" top.frames[prop_frame].document.write(\n"
|
||||
" \"<NOBR><b>%s</b> %s</NOBR><BR>\" +\n"
|
||||
" \"<NOBR><b>%s</b> %s</NOBR><BR>\" +\n"
|
||||
" \"<NOBR><b>%s</b> %s</NOBR><BR>\" +\n"
|
||||
" \"<NOBR><b>%s</b> %s</NOBR><BR>\" +\n"
|
||||
" \"<NOBR><b>%s</b> %s</NOBR><BR>\" +\n"
|
||||
" \"<NOBR><b>%s</b> %s</NOBR><BR>\"\n"
|
||||
" );\n"
|
||||
" break;\n",
|
||||
cookieNum,
|
||||
(*(cookie->host)=='.') ? (cookie->host)+1: cookie->host,
|
||||
cookie->name);
|
||||
XP_GetString(MK_ACCESS_NAME), cookie->name,
|
||||
XP_GetString(MK_ACCESS_VALUE), cookie->cookie,
|
||||
(cookie->is_domain
|
||||
? XP_GetString(MK_ACCESS_DOMAIN)
|
||||
: XP_GetString(MK_ACCESS_DOMAIN)),
|
||||
cookie->host,
|
||||
XP_GetString(MK_ACCESS_PATH), cookie->path,
|
||||
XP_GetString(MK_ACCESS_SECURE),
|
||||
(HG78111 ?
|
||||
XP_GetString(MK_ACCESS_YES): XP_GetString(MK_ACCESS_NO)),
|
||||
XP_GetString(MK_ACCESS_EXPIRES),
|
||||
cookie->expires
|
||||
? (expireDate ? expireDate : "")
|
||||
: XP_GetString(MK_ACCESS_END_OF_SESSION)
|
||||
);
|
||||
FLUSH_BUFFER
|
||||
PR_FREEIF(expireDate);
|
||||
}
|
||||
|
||||
/* generate next section of html file */
|
||||
g += PR_snprintf(buffer+g, BUFLEN-g,
|
||||
"</SELECT></CENTER>\n"
|
||||
" }\n"
|
||||
" top.frames[prop_frame].document.close();\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
" function loadCookies(){\n"
|
||||
" cookie_mode = 1;\n"
|
||||
" top.frames[index_frame].document.open();\n"
|
||||
" top.frames[index_frame].document.write(\n"
|
||||
" \"<BODY BGCOLOR=#C0C0C0>\" +\n"
|
||||
" \"<TABLE BORDER=0 WIDTH=100%>\" +\n"
|
||||
" \"<TR>\" +\n"
|
||||
" \"<TD> <SPACER TYPE=HORIZONTAL SIZE=10> </TD>\" +\n"
|
||||
" \"<TD ALIGN=CENTER VALIGN=MIDDLE BGCOLOR=#E4E3EA>\" +\n"
|
||||
" \"<FONT SIZE=2 COLOR=#666666>\" +\n"
|
||||
" \"<B>%s</B>\" +\n"
|
||||
" \"</FONT>\" +\n"
|
||||
" \"</TD>\" +\n"
|
||||
" \"<TD> </TD>\" +\n"
|
||||
" \"<TD ALIGN=CENTER VALIGN=MIDDLE BGCOLOR=#C0C0C0>\" +\n"
|
||||
" \"<A HREF=javascript:top.loadSites();>\" +\n"
|
||||
" \"<FONT SIZE=2>%s</FONT>\" +\n"
|
||||
" \"</A>\" +\n"
|
||||
" \"</TD>\" +\n"
|
||||
" \"<TD> </TD>\" +\n"
|
||||
" \"</TR>\" +\n"
|
||||
" \"</TABLE>\" +\n"
|
||||
" \"</BODY>\"\n"
|
||||
" );\n"
|
||||
" top.frames[index_frame].document.close();\n"
|
||||
"\n"
|
||||
" top.frames[title_frame].document.open();\n"
|
||||
" top.frames[title_frame].document.write\n"
|
||||
" (\" %s\");\n"
|
||||
" top.frames[title_frame].document.close();\n"
|
||||
"\n"
|
||||
" top.frames[list_frame].document.open();\n"
|
||||
" top.frames[list_frame].document.write(\n"
|
||||
" \"<FORM name=fSelectCookie>\" +\n"
|
||||
" \"<P>\" +\n"
|
||||
" \"<TABLE BORDER=0 WIDTH=100% HEIGHT=95%>\" +\n"
|
||||
" \"<TR>\" +\n"
|
||||
" \"<TD WIDTH=100% VALIGN=TOP>\" +\n"
|
||||
" \"<CENTER>\" +\n"
|
||||
" \"<P>\" +\n"
|
||||
" \"<SELECT NAME=selname \" +\n"
|
||||
" \"SIZE=15 \" +\n"
|
||||
" \"MULTIPLE \" +\n"
|
||||
" \"onchange=top.ViewCookieSelected(selname.selectedIndex);>\"\n"
|
||||
" );\n",
|
||||
XP_GetString(MK_ACCESS_VIEW_COOKIES),
|
||||
XP_GetString(MK_ACCESS_VIEW_SITES),
|
||||
XP_GetString(MK_ACCESS_COOKIES_ACCEPTED)
|
||||
);
|
||||
FLUSH_BUFFER
|
||||
|
||||
g += PR_snprintf(buffer+g, BUFLEN-g,
|
||||
"<CENTER>\n"
|
||||
"<INPUT TYPE=\"BUTTON\" VALUE=%s ONCLICK=\"DeleteCookieSelected();\">\n"
|
||||
"<INPUT TYPE=\"BUTTON\" NAME=\"view\" VALUE=%s ONCLICK=\"parent.clicker(this,window.parent)\">\n"
|
||||
"<INPUT TYPE=\"HIDDEN\" NAME=\"goneC\" VALUE=\"\">\n"
|
||||
"</CENTER></TH>\n",
|
||||
XP_GetString(SA_REMOVE_BUTTON_LABEL),
|
||||
XP_GetString(SA_VIEW_BUTTON_LABEL) );
|
||||
FLUSH_BUFFER
|
||||
/* generate the html for the list of cookies in alphabetical order */
|
||||
cookie_list=net_cookie_list;
|
||||
cookie = NULL;
|
||||
while (cookie = NextCookieAfter(cookie, &cookieNum)) {
|
||||
g += PR_snprintf(buffer+g, BUFLEN-g,
|
||||
" if (!deleted_cookies[%d]) {\n"
|
||||
" top.frames[list_frame].document.write(\n"
|
||||
" \"<OPTION value=%d>\" +\n"
|
||||
" \"%s:%s\" +\n"
|
||||
" \"</OPTION>\"\n"
|
||||
" );\n"
|
||||
" }\n",
|
||||
cookieNum, cookieNum,
|
||||
(*(cookie->host)=='.') ? (cookie->host)+1: cookie->host,
|
||||
cookie->name
|
||||
);
|
||||
FLUSH_BUFFER
|
||||
}
|
||||
net_unlock_cookie_list();
|
||||
|
||||
/* Write out each cookie permission */
|
||||
net_lock_cookie_permission_list();
|
||||
/* generate next section of html file */
|
||||
g += PR_snprintf(buffer+g, BUFLEN-g,
|
||||
"<TH><CENTER>%s<BR></CENTER><CENTER><SELECT NAME=\"selname2\" MULTIPLE SIZE=15>\n",
|
||||
XP_GetString(MK_ACCESS_COOKIES_PERMISSION));
|
||||
" top.frames[list_frame].document.write(\n"
|
||||
" \"</SELECT>\" +\n"
|
||||
" \"</CENTER>\" +\n"
|
||||
" \"</TD>\" +\n"
|
||||
" \"</TR>\" +\n"
|
||||
" \"</TABLE>\" +\n"
|
||||
" \"</FORM>\"\n"
|
||||
" );\n"
|
||||
" top.frames[list_frame].document.close();\n"
|
||||
"\n"
|
||||
" top.frames[prop_frame].document.open();\n"
|
||||
" top.frames[prop_frame].document.close();\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
" function loadSites(){\n"
|
||||
" cookie_mode = 0;\n"
|
||||
" top.frames[index_frame].document.open();\n"
|
||||
" top.frames[index_frame].document.write(\n"
|
||||
" \"<BODY BGCOLOR=#C0C0C0>\" +\n"
|
||||
" \"<TABLE BORDER=0 WIDTH=100%>\" +\n"
|
||||
" \"<TR>\" +\n"
|
||||
" \"<TD> <SPACER TYPE=HORIZONTAL SIZE=10> </TD>\" +\n"
|
||||
" \"<TD ALIGN=CENTER VALIGN=MIDDLE BGCOLOR=#C0C0C0>\" +\n"
|
||||
" \"<A HREF=javascript:top.loadCookies();>\" +\n"
|
||||
" \"<FONT SIZE=2>%s</FONT>\" +\n"
|
||||
" \"</A>\" +\n"
|
||||
" \"</TD>\" +\n"
|
||||
" \"<TD> </TD>\" +\n"
|
||||
" \"<TD ALIGN=CENTER VALIGN=MIDDLE BGCOLOR=#E4E3EA>\" +\n"
|
||||
" \"<FONT SIZE=2 COLOR=#666666>\" +\n"
|
||||
" \"<B>%s</B>\" +\n"
|
||||
" \"</FONT>\" +\n"
|
||||
" \"</TD>\" +\n"
|
||||
" \"<TD> </TD>\" +\n"
|
||||
" \"</TR>\" +\n"
|
||||
" \"</TABLE>\" +\n"
|
||||
" \"</BODY>\"\n"
|
||||
" );\n"
|
||||
" top.frames[index_frame].document.close();\n"
|
||||
"\n"
|
||||
" top.frames[title_frame].document.open();\n"
|
||||
" top.frames[title_frame].document.write\n"
|
||||
" (\" %s\");\n"
|
||||
" top.frames[title_frame].document.close();\n"
|
||||
"\n"
|
||||
" top.frames[list_frame].document.open();\n"
|
||||
" top.frames[list_frame].document.write(\n"
|
||||
" \"<FORM name=fSelectSite>\" +\n"
|
||||
" \"<P>\" +\n"
|
||||
" \"<TABLE BORDER=0 WIDTH=100% HEIGHT=95%>\" +\n"
|
||||
" \"<TR>\" +\n"
|
||||
" \"<TD WIDTH=100% VALIGN=TOP>\" +\n"
|
||||
" \"<CENTER>\" +\n"
|
||||
" \"<P>\" +\n"
|
||||
" \"<SELECT NAME=selname SIZE=15 MULTIPLE> \"\n"
|
||||
" );\n",
|
||||
XP_GetString(MK_ACCESS_VIEW_COOKIES),
|
||||
XP_GetString(MK_ACCESS_VIEW_SITES),
|
||||
XP_GetString(MK_ACCESS_COOKIES_PERMISSION)
|
||||
);
|
||||
FLUSH_BUFFER
|
||||
|
||||
/* generate the html for the list of cookie permissions */
|
||||
cookieNum = 0;
|
||||
cookie_permission_list=net_cookie_permission_list;
|
||||
net_lock_cookie_permission_list();
|
||||
while ( (cookperm=(net_CookiePermissionStruct *)
|
||||
XP_ListNextObject(cookie_permission_list)) ) {
|
||||
char permit = cookperm->permission ? '+' : '-';
|
||||
g += PR_snprintf(buffer+g, BUFLEN-g,
|
||||
"<OPTION VALUE=%d>%c %s</OPTION>",
|
||||
cookieNum, permit, cookperm->host);
|
||||
" if (!deleted_sites[%d]) {\n"
|
||||
" top.frames[list_frame].document.write(\n"
|
||||
" \"<OPTION value=\" +\n"
|
||||
" \"%d>\" +\n"
|
||||
" \"%s %s\" +\n"
|
||||
" \"</OPTION>\"\n"
|
||||
" );\n"
|
||||
" }\n",
|
||||
cookieNum, cookieNum,
|
||||
cookperm->permission ? "+" : "-",
|
||||
cookperm->host);
|
||||
FLUSH_BUFFER
|
||||
cookieNum++;
|
||||
}
|
||||
net_unlock_cookie_permission_list();
|
||||
|
||||
/* generate next section of html file */
|
||||
g += PR_snprintf(buffer+g, BUFLEN-g,
|
||||
"</SELECT></CENTER>\n"
|
||||
" top.frames[list_frame].document.write(\n"
|
||||
" \"</SELECT>\" +\n"
|
||||
" \"</CENTER>\" +\n"
|
||||
" \"</TD>\" +\n"
|
||||
" \"</TR>\" +\n"
|
||||
" \"</TABLE>\" +\n"
|
||||
" \"</FORM>\"\n"
|
||||
" );\n"
|
||||
" top.frames[list_frame].document.close();\n"
|
||||
"\n"
|
||||
" top.frames[prop_frame].document.open();\n"
|
||||
" top.frames[prop_frame].document.close();\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
" function loadButtons(){\n"
|
||||
" top.frames[button_frame].document.open();\n"
|
||||
" top.frames[button_frame].document.write(\n"
|
||||
" \"<FORM name=buttons action=internal-dialog-handler method=post>\" +\n"
|
||||
" \"<BR>\" +\n"
|
||||
" \" \" +\n"
|
||||
" \"<INPUT type=BUTTON \" +\n"
|
||||
" \"value=Remove \" +\n"
|
||||
" \"onclick=top.DeleteItemSelected();\" +\n"
|
||||
" \"name=BUTTON>\" +\n"
|
||||
" \"<DIV align=right>\" +\n"
|
||||
" \"<INPUT type=BUTTON value=OK width=80 onclick=parent.clicker(this,window.parent)>\" +\n"
|
||||
" \" \" +\n"
|
||||
" \"<INPUT type=BUTTON value=Cancel width=80 onclick=parent.clicker(this,window.parent)>\" +\n"
|
||||
" \"</DIV>\" +\n"
|
||||
" \"<INPUT type=HIDDEN name=xxxbuttonxxx>\" +\n"
|
||||
" \"<INPUT type=HIDDEN name=handle value="
|
||||
);
|
||||
FLUSH_BUFFER
|
||||
|
||||
/* transfer what we have so far into strings->args[0] */
|
||||
if (buffer2) {
|
||||
XP_SetDialogString(strings, 0, buffer2);
|
||||
buffer2 = NULL;
|
||||
}
|
||||
|
||||
/* Note: strings->args[1] will later be filled in with value of handle */
|
||||
|
||||
/* generate remainder of html, it will go into strings->arg[2] */
|
||||
g += PR_snprintf(buffer+g, BUFLEN-g,
|
||||
"<CENTER>\n"
|
||||
"<INPUT TYPE=\"BUTTON\" VALUE=%s ONCLICK=\"DeleteCookiePermissionSelected();\">\n"
|
||||
"<INPUT TYPE=\"HIDDEN\" NAME=\"goneP\" VALUE=\"\">\n"
|
||||
"</CENTER></TH>\n"
|
||||
"</TABLE></FORM>\n",
|
||||
XP_GetString(SA_REMOVE_BUTTON_LABEL) );
|
||||
">\" +\n"
|
||||
" \"<INPUT TYPE=HIDDEN NAME=goneC SIZE=-1>\" +\n"
|
||||
" \"<INPUT TYPE=HIDDEN NAME=goneP SIZE=-1>\" +\n"
|
||||
" \"</FORM>\"\n"
|
||||
" );\n"
|
||||
" top.frames[button_frame].document.close();\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
" function loadFrames(){\n"
|
||||
" loadCookies();\n"
|
||||
" loadButtons();\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
" function clicker(but,win){\n"
|
||||
" top.frames[button_frame].document.buttons.xxxbuttonxxx.value = but.value;\n"
|
||||
" top.frames[button_frame].document.buttons.xxxbuttonxxx.name = 'button';\n"
|
||||
" top.frames[button_frame].document.buttons.submit();\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
" </SCRIPT>\n"
|
||||
"</HEAD>\n"
|
||||
"<FRAMESET ROWS = 25,25,*,75\n"
|
||||
" BORDER=0\n"
|
||||
" FRAMESPACING=0\n"
|
||||
" onLoad=loadFrames()>\n"
|
||||
" <FRAME SRC=about:blank\n"
|
||||
" NAME=index_frame\n"
|
||||
" SCROLLING=NO\n"
|
||||
" MARGINWIDTH=1\n"
|
||||
" MARGINHEIGHT=1\n"
|
||||
" NORESIZE>\n"
|
||||
" <FRAME SRC=about:blank\n"
|
||||
" NAME=title_frame\n"
|
||||
" SCROLLING=NO\n"
|
||||
" MARGINWIDTH=1\n"
|
||||
" MARGINHEIGHT=1\n"
|
||||
" NORESIZE>\n"
|
||||
" <FRAMESET COLS=5,*,10,*,5\n"
|
||||
" BORDER=0\n"
|
||||
" FRAMESPACING=0>\n"
|
||||
" <FRAME SRC=about:blank\n"
|
||||
" NAME=spacer1_frame\n"
|
||||
" SCROLLING=AUTO\n"
|
||||
" MARGINWIDTH=0\n"
|
||||
" MARGINHEIGHT=0\n"
|
||||
" NORESIZE>\n"
|
||||
" <FRAME SRC=about:blank\n"
|
||||
" NAME=list_frame\n"
|
||||
" SCROLLING=AUTO\n"
|
||||
" MARGINWIDTH=0\n"
|
||||
" MARGINHEIGHT=0\n"
|
||||
" NORESIZE>\n"
|
||||
" <FRAME SRC=about:blank\n"
|
||||
" NAME=spacer2_frame\n"
|
||||
" SCROLLING=AUTO\n"
|
||||
" MARGINWIDTH=0\n"
|
||||
" MARGINHEIGHT=0\n"
|
||||
" NORESIZE>\n"
|
||||
" <FRAME SRC=about:blank\n"
|
||||
" NAME=prop_frame\n"
|
||||
" SCROLLING=AUTO\n"
|
||||
" MARGINWIDTH=0\n"
|
||||
" MARGINHEIGHT=0\n"
|
||||
" NORESIZE>\n"
|
||||
" <FRAME SRC=about:blank\n"
|
||||
" NAME=spacer3_frame\n"
|
||||
" SCROLLING=AUTO\n"
|
||||
" MARGINWIDTH=0\n"
|
||||
" MARGINHEIGHT=0\n"
|
||||
" NORESIZE>\n"
|
||||
" </FRAMESET>\n"
|
||||
" <FRAME SRC=about:blank\n"
|
||||
" NAME=button_frame\n"
|
||||
" SCROLLING=NO\n"
|
||||
" MARGINWIDTH=1\n"
|
||||
" MARGINHEIGHT=1\n"
|
||||
" NORESIZE>\n"
|
||||
"</FRAMESET>\n"
|
||||
"\n"
|
||||
"<NOFRAMES>\n"
|
||||
" <BODY> <P> </BODY>\n"
|
||||
"</NOFRAMES>\n"
|
||||
"</HTML>\n"
|
||||
);
|
||||
FLUSH_BUFFER
|
||||
net_unlock_cookie_permission_list();
|
||||
|
||||
/* free buffer since it is no longer needed */
|
||||
if (buffer) {
|
||||
PR_Free(buffer);
|
||||
}
|
||||
|
||||
/* do html dialog */
|
||||
strings = XP_GetDialogStrings(XP_EMPTY_STRINGS);
|
||||
if (!strings) {
|
||||
if (buffer2) {
|
||||
PR_Free(buffer2);
|
||||
}
|
||||
/* put html just generated into strings->arg[2] and invoke HTML dialog */
|
||||
if (buffer2) {
|
||||
XP_SetDialogString(strings, 2, buffer2);
|
||||
buffer2 = NULL;
|
||||
}
|
||||
dlg = PORT_ZAlloc(sizeof(CookieViewerDialog));
|
||||
if ( dlg == NULL ) {
|
||||
return;
|
||||
}
|
||||
if (buffer2) {
|
||||
XP_CopyDialogString(strings, 0, buffer2);
|
||||
PR_Free(buffer2);
|
||||
buffer2 = NULL;
|
||||
}
|
||||
XP_MakeHTMLDialog(context, &dialogInfo, MK_ACCESS_YOUR_COOKIES,
|
||||
strings, context, PR_FALSE);
|
||||
dlg->parent_window = (void *)context;
|
||||
dlg->dialogUp = PR_TRUE;
|
||||
dlg->state =XP_MakeRawHTMLDialog(context, &dialogInfo, MK_ACCESS_YOUR_COOKIES,
|
||||
strings, 1, (void *)dlg);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef XP_MAC
|
||||
/* pinkerton - reset optimization state (see above) */
|
||||
#pragma global_optimizer reset
|
||||
#endif
|
||||
|
||||
#else
|
||||
PUBLIC void
|
||||
NET_DisplayCookieInfoAsHTML(ActiveEntry * cur_entry)
|
||||
|
|
Загрузка…
Ссылка в новой задаче