function urlForCookie(cookie) {
|
var host = cookie.domain;
|
if (host[0] == '.')
|
host = host.substr(1);
|
var path = cookie.path;
|
if (path == "")
|
path = "/";
|
var scheme = "http";
|
if (cookie.secure)
|
scheme = "https";
|
return scheme + "://" + host + path
|
}
|
|
function clearCookies(cookies) {
|
for (var idx in cookies) {
|
var cookie = cookies[idx];
|
chrome.cookies.remove({"url": urlForCookie(cookie), "name": cookie.name})
|
}
|
}
|
|
function clearSessionCookies() {
|
chrome.cookies.getAll({"session": true}, clearCookies);
|
}
|
|
// Make sure we don't delete session cookies when the extension is installed,
|
// but only on browser start.
|
if ("installed" in localStorage) {
|
addEventListener("load", clearSessionCookies, false);
|
} else {
|
localStorage["installed"] = 1;
|
}
|