WebPositive: Improve CookieWindow cookie deletion
Fixes Coverity issue CID 1340122. Also resolves two TODO items in the code: allowing the deletion of a selection of cookies, and deleting all cookies from a site when there are no specific cookies selected. Signed-off-by: Adrien Destugues <pulkomandy@pulkomandy.tk>
This commit is contained in:
parent
226f6c8bf1
commit
d2f5cd017c
@ -144,7 +144,7 @@ CookieWindow::CookieWindow(BRect frame, BNetworkCookieJar& jar)
|
|||||||
.Add(fCookies)
|
.Add(fCookies)
|
||||||
.AddGroup(B_HORIZONTAL, B_USE_DEFAULT_SPACING)
|
.AddGroup(B_HORIZONTAL, B_USE_DEFAULT_SPACING)
|
||||||
.SetInsets(5, 5, 5, 5)
|
.SetInsets(5, 5, 5, 5)
|
||||||
#if 0
|
#if DEBUG
|
||||||
.Add(new BButton("import", B_TRANSLATE("Import" B_UTF8_ELLIPSIS),
|
.Add(new BButton("import", B_TRANSLATE("Import" B_UTF8_ELLIPSIS),
|
||||||
NULL))
|
NULL))
|
||||||
.Add(new BButton("export", B_TRANSLATE("Export" B_UTF8_ELLIPSIS),
|
.Add(new BButton("export", B_TRANSLATE("Export" B_UTF8_ELLIPSIS),
|
||||||
@ -303,7 +303,7 @@ CookieWindow::_AddDomain(BString domain, bool fake)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if DEBUG
|
||||||
puts("==============================");
|
puts("==============================");
|
||||||
for (i = 0; i < fDomains->FullListCountItems(); i++) {
|
for (i = 0; i < fDomains->FullListCountItems(); i++) {
|
||||||
BStringItem* t = (BStringItem*)fDomains->FullListItemAt(i);
|
BStringItem* t = (BStringItem*)fDomains->FullListItemAt(i);
|
||||||
@ -373,19 +373,40 @@ CookieWindow::_ShowCookiesForDomain(BString domain)
|
|||||||
void
|
void
|
||||||
CookieWindow::_DeleteCookies()
|
CookieWindow::_DeleteCookies()
|
||||||
{
|
{
|
||||||
// TODO shall we handle multiple selection here?
|
CookieRow* row;
|
||||||
CookieRow* row = (CookieRow*)fCookies->CurrentSelection();
|
CookieRow* prevRow;
|
||||||
if (row == NULL) {
|
|
||||||
// TODO see if a domain is selected in the domain list, and delete all
|
for (prevRow = NULL; ; prevRow = row) {
|
||||||
// cookies for that domain
|
row = (CookieRow*)fCookies->CurrentSelection(prevRow);
|
||||||
return;
|
|
||||||
|
if (prevRow != NULL) {
|
||||||
|
fCookies->RemoveRow(prevRow);
|
||||||
|
delete prevRow;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (row == NULL)
|
||||||
|
break;
|
||||||
|
|
||||||
|
// delete this cookie
|
||||||
|
BNetworkCookie& cookie = row->Cookie();
|
||||||
|
cookie.SetExpirationDate(0);
|
||||||
|
fCookieJar.AddCookie(cookie);
|
||||||
}
|
}
|
||||||
|
|
||||||
fCookies->RemoveRow(row);
|
// A domain was selected in the domain list
|
||||||
|
if (prevRow == NULL) {
|
||||||
|
while (true) {
|
||||||
|
// Clear the first cookie continuously
|
||||||
|
row = (CookieRow*)fCookies->RowAt(0);
|
||||||
|
|
||||||
BNetworkCookie& cookie = row->Cookie();
|
if (row == NULL)
|
||||||
cookie.SetExpirationDate(0);
|
break;
|
||||||
fCookieJar.AddCookie(cookie);
|
|
||||||
|
|
||||||
delete row;
|
BNetworkCookie& cookie = row->Cookie();
|
||||||
|
cookie.SetExpirationDate(0);
|
||||||
|
fCookieJar.AddCookie(cookie);
|
||||||
|
fCookies->RemoveRow(row);
|
||||||
|
delete row;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user