mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-29 10:32:23 +00:00
904e3bdf3a
- Bug 1183915 - Put images dragged from content processes in the drag data in the parent. r=smaug (72906fab07) - Bug 1192394 - Force an image load whenever the thumbnail file changes. r=adw (c194d868f9) - let-var (f5e9a53170) - Bug 1250109 - Change DOMEventTargetHelper subclasses to not assume that GetOwner() is non-null, since it can be nulled out by navigation. r=bzbarsky (deb440c2a4) - Bug 911216 - Part 1: Add tests directly testing content Promise constructor resolved with chrome Promise. r=bz (1b2f1ec6b8) - Bug 911216 - Part 2: Add self-hosting intrinsic for calling wrapped functions without wrapper security checks. r=efaust,bholley (de086e8422) - Bug 911216 - Part 3: Allow wrapped self-hosted functions and intrinsics in the callFunction debug check. r=efaust (c02e6337fe) - Bug 1251921 - Do not call debugger hooks with half-initialized frame if InterpeterFrame::prologue fails. (r=jorendorff) (9873720345) - Bug 1256342. Fix typed array iteration to work correctly over Xrays. r=till (6a7f5c12c6) - Bug 1256376. Fix forEach on typed arrays to work over Xrays from web extension sandboxes. r=till (ab19703ab5) - Bug 911216 - Part 4: Add self-hosting intrinsic for creating arrays in other compartments. r=efaust (37b14521fb) - Bug 1233497 - Temporarily allow unsafe CPOWs in Promise-backend.js and Task.jsm. r=billm (d2672a456a) - Bug 1225041 - Implement ES6 Annex B.3.5 for direct eval. (r=jorendorff) (daf24f0e34) - Bug 1254185 - Deal with missing arguments assigned to block bindings. (r=jimb) (3ce53dcd06) - Bug 1250506 - check if node is acceptable as a child before creating an accessible for it, r=davidb (5960ba726d) - Bug 1251941 - aria::GetRoleMap should take element, r=davidb (e9ee4e20ea) - Bug 1251944 - get rid of nsCoreUtils::GetRoleContent, r=davidb (a2bf199bb4) - Bug 1257030 - Add support for supplying preexisting stack instead of capturing one for use as the async parent stack of CallbackObject. r=bz,tromey (a4ddb41fac) - Bug 1232291 - Non-used header in MessagePortService.*, r=smaug (1e2398e314) - Bug 1255655 - Const-ify sWAIRoleMaps. r=tbsaunde. (09653e44af) - align (24667f7952) - Bug 1253438 - Expose Push observer notification topics. r=markh (b62a068d4b)
151 lines
4.3 KiB
JavaScript
151 lines
4.3 KiB
JavaScript
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
/**
|
|
* PageThumbsProtocol.js
|
|
*
|
|
* This file implements the moz-page-thumb:// protocol and the corresponding
|
|
* channel delivering cached thumbnails.
|
|
*
|
|
* URL structure:
|
|
*
|
|
* moz-page-thumb://thumbnail/?url=http%3A%2F%2Fwww.mozilla.org%2F&revision=XX
|
|
*
|
|
* This URL requests an image for 'http://www.mozilla.org/'.
|
|
* The value of the revision key may change when the stored thumbnail changes.
|
|
*/
|
|
|
|
"use strict";
|
|
|
|
const Cu = Components.utils;
|
|
const Cc = Components.classes;
|
|
const Cr = Components.results;
|
|
const Ci = Components.interfaces;
|
|
|
|
Cu.import("resource://gre/modules/PageThumbs.jsm");
|
|
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
|
Cu.import("resource://gre/modules/osfile.jsm", this);
|
|
|
|
XPCOMUtils.defineLazyModuleGetter(this, "Services",
|
|
"resource://gre/modules/Services.jsm");
|
|
XPCOMUtils.defineLazyModuleGetter(this, "FileUtils",
|
|
"resource://gre/modules/FileUtils.jsm");
|
|
|
|
const SUBSTITUTING_URL_CID = "{dea9657c-18cf-4984-bde9-ccef5d8ab473}";
|
|
|
|
/**
|
|
* Implements the thumbnail protocol handler responsible for moz-page-thumb: URLs.
|
|
*/
|
|
function Protocol() {
|
|
}
|
|
|
|
Protocol.prototype = {
|
|
/**
|
|
* The scheme used by this protocol.
|
|
*/
|
|
get scheme() PageThumbs.scheme,
|
|
|
|
/**
|
|
* The default port for this protocol (we don't support ports).
|
|
*/
|
|
get defaultPort() -1,
|
|
|
|
/**
|
|
* The flags specific to this protocol implementation.
|
|
*/
|
|
get protocolFlags() {
|
|
return Ci.nsIProtocolHandler.URI_DANGEROUS_TO_LOAD |
|
|
Ci.nsIProtocolHandler.URI_IS_LOCAL_RESOURCE |
|
|
Ci.nsIProtocolHandler.URI_NORELATIVE |
|
|
Ci.nsIProtocolHandler.URI_NOAUTH;
|
|
},
|
|
|
|
/**
|
|
* Creates a new URI object that is suitable for loading by this protocol.
|
|
* @param aSpec The URI string in UTF8 encoding.
|
|
* @param aOriginCharset The charset of the document from which the URI originated.
|
|
* @return The newly created URI.
|
|
*/
|
|
newURI: function Proto_newURI(aSpec, aOriginCharset) {
|
|
let uri = Components.classesByID[SUBSTITUTING_URL_CID].createInstance(Ci.nsIURL);
|
|
uri.spec = aSpec;
|
|
return uri;
|
|
},
|
|
|
|
/**
|
|
* Constructs a new channel from the given URI for this protocol handler.
|
|
* @param aURI The URI for which to construct a channel.
|
|
* @param aLoadInfo The Loadinfo which to use on the channel.
|
|
* @return The newly created channel.
|
|
*/
|
|
newChannel2: function Proto_newChannel2(aURI, aLoadInfo) {
|
|
let {file} = aURI.QueryInterface(Ci.nsIFileURL);
|
|
let fileuri = Services.io.newFileURI(file);
|
|
let channel = Services.io.newChannelFromURIWithLoadInfo(fileuri, aLoadInfo);
|
|
channel.originalURI = aURI;
|
|
return channel;
|
|
},
|
|
|
|
newChannel: function Proto_newChannel(aURI) {
|
|
return newChannel2(aURI, null);
|
|
},
|
|
|
|
/**
|
|
* Decides whether to allow a blacklisted port.
|
|
* @return Always false, we'll never allow ports.
|
|
*/
|
|
allowPort: function () false,
|
|
|
|
// nsISubstitutingProtocolHandler methods
|
|
|
|
/*
|
|
* Substituting the scheme and host isn't enough, we also transform the path.
|
|
* So declare no-op implementations for (get|set|has)Substitution methods and
|
|
* do all the work in resolveURI.
|
|
*/
|
|
|
|
setSubstitution(root, baseURI) {},
|
|
|
|
getSubstitution(root) {
|
|
throw Cr.NS_ERROR_NOT_AVAILABLE;
|
|
},
|
|
|
|
hasSubstitution(root) {
|
|
return false;
|
|
},
|
|
|
|
resolveURI(resURI) {
|
|
let {url} = parseURI(resURI);
|
|
let path = PageThumbsStorage.getFilePathForURL(url);
|
|
return OS.Path.toFileURI(path);
|
|
},
|
|
|
|
// xpcom machinery
|
|
classID: Components.ID("{5a4ae9b5-f475-48ae-9dce-0b4c1d347884}"),
|
|
QueryInterface: XPCOMUtils.generateQI([Ci.nsIProtocolHandler,
|
|
Ci.nsISubstitutingProtocolHandler])
|
|
};
|
|
|
|
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([Protocol]);
|
|
|
|
/**
|
|
* Parses a given URI and extracts all parameters relevant to this protocol.
|
|
* @param aURI The URI to parse.
|
|
* @return The parsed parameters.
|
|
*/
|
|
function parseURI(aURI) {
|
|
if (aURI.host != PageThumbs.staticHost)
|
|
throw Cr.NS_ERROR_NOT_AVAILABLE;
|
|
|
|
let {query} = aURI.QueryInterface(Ci.nsIURL);
|
|
let params = {};
|
|
|
|
query.split("&").forEach(function (aParam) {
|
|
let [key, value] = aParam.split("=").map(decodeURIComponent);
|
|
params[key.toLowerCase()] = value;
|
|
});
|
|
|
|
return params;
|
|
}
|