mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
c4c18521be
This is probably the worst patch that I have ever written! We add a setPrivate method to nsIPrivateBrowsingChannel which will be implemented by channels who care about private browsing. This allows the client to explicitly override the private bit on the channel. NS_UsePrivateBrowsing is also taught about this override bit using the internal nsIPrivateBrowsingChannel::IsPrivateModeOverriden API. This patch implements the new API for HTTP, FTP and wyciwyg channels. This also modifies the IPC implementations of these channels to correctly transfer that bit to the parent process if it has been set in the child process channel.
80 lines
2.0 KiB
JavaScript
80 lines
2.0 KiB
JavaScript
var _CSvc;
|
|
function get_cache_service() {
|
|
if (_CSvc)
|
|
return _CSvc;
|
|
|
|
return _CSvc = Components.classes["@mozilla.org/network/cache-service;1"]
|
|
.getService(Components.interfaces.nsICacheService);
|
|
}
|
|
|
|
function evict_cache_entries(where)
|
|
{
|
|
if (where == null)
|
|
where = Components.interfaces.nsICache.STORE_ANYWHERE;
|
|
|
|
get_cache_service().evictEntries(where);
|
|
}
|
|
|
|
function asyncOpenCacheEntry(key, sessionName, storagePolicy, access, callback)
|
|
{
|
|
function CacheListener() { }
|
|
CacheListener.prototype = {
|
|
QueryInterface: function (iid) {
|
|
if (iid.equals(Components.interfaces.nsICacheListener) ||
|
|
iid.equals(Components.interfaces.nsISupports))
|
|
return this;
|
|
throw Components.results.NS_ERROR_NO_INTERFACE;
|
|
},
|
|
|
|
onCacheEntryAvailable: function (entry, access, status) {
|
|
callback(status, entry);
|
|
},
|
|
|
|
run: function () {
|
|
var cache = get_cache_service();
|
|
var session = cache.createSession(
|
|
sessionName,
|
|
storagePolicy,
|
|
Components.interfaces.nsICache.STREAM_BASED);
|
|
session.asyncOpenCacheEntry(key, access, this);
|
|
}
|
|
};
|
|
|
|
(new CacheListener()).run();
|
|
}
|
|
|
|
function syncWithCacheIOThread(callback)
|
|
{
|
|
asyncOpenCacheEntry(
|
|
"nonexistententry",
|
|
"HTTP",
|
|
Components.interfaces.nsICache.STORE_ANYWHERE,
|
|
Components.interfaces.nsICache.ACCESS_READ,
|
|
function(status, entry) {
|
|
do_check_eq(status, Components.results.NS_ERROR_CACHE_KEY_NOT_FOUND);
|
|
callback();
|
|
});
|
|
}
|
|
|
|
function get_device_entry_count(device) {
|
|
var cs = get_cache_service();
|
|
var entry_count = -1;
|
|
|
|
var visitor = {
|
|
visitDevice: function (deviceID, deviceInfo) {
|
|
if (device == deviceID)
|
|
entry_count = deviceInfo.entryCount;
|
|
return false;
|
|
},
|
|
visitEntry: function (deviceID, entryInfo) {
|
|
do_throw("nsICacheVisitor.visitEntry should not be called " +
|
|
"when checking the availability of devices");
|
|
}
|
|
};
|
|
|
|
// get the device entry count
|
|
cs.visitEntries(visitor);
|
|
|
|
return entry_count;
|
|
}
|