2013-02-12 20:51:25 +00:00
|
|
|
/* 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/. */
|
|
|
|
|
2013-11-24 05:32:32 +00:00
|
|
|
let Ci = Components.interfaces;
|
|
|
|
let Cc = Components.classes;
|
|
|
|
|
|
|
|
this.kXLinkNamespace = "http://www.w3.org/1999/xlink";
|
2013-02-12 20:51:25 +00:00
|
|
|
|
|
|
|
dump("### ContextMenuHandler.js loaded\n");
|
|
|
|
|
|
|
|
var ContextMenuHandler = {
|
|
|
|
_types: [],
|
2013-03-06 23:56:15 +00:00
|
|
|
_previousState: null,
|
2013-02-12 20:51:25 +00:00
|
|
|
|
|
|
|
init: function ch_init() {
|
|
|
|
// Events we catch from content during the bubbling phase
|
|
|
|
addEventListener("contextmenu", this, false);
|
|
|
|
addEventListener("pagehide", this, false);
|
|
|
|
|
|
|
|
// Messages we receive from browser
|
2013-02-22 20:11:45 +00:00
|
|
|
// Command sent over from browser that only we can handle.
|
2013-02-12 20:51:25 +00:00
|
|
|
addMessageListener("Browser:ContextCommand", this, false);
|
|
|
|
|
|
|
|
this.popupNode = null;
|
|
|
|
},
|
|
|
|
|
|
|
|
handleEvent: function ch_handleEvent(aEvent) {
|
|
|
|
switch (aEvent.type) {
|
|
|
|
case "contextmenu":
|
|
|
|
this._onContentContextMenu(aEvent);
|
|
|
|
break;
|
|
|
|
case "pagehide":
|
|
|
|
this.reset();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
receiveMessage: function ch_receiveMessage(aMessage) {
|
2013-02-22 20:11:45 +00:00
|
|
|
switch (aMessage.name) {
|
|
|
|
case "Browser:ContextCommand":
|
|
|
|
this._onContextCommand(aMessage);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Handler for commands send over from browser's ContextCommands.js
|
|
|
|
* in response to certain context menu actions only we can handle.
|
|
|
|
*/
|
|
|
|
_onContextCommand: function _onContextCommand(aMessage) {
|
2013-02-12 20:51:25 +00:00
|
|
|
let node = this.popupNode;
|
|
|
|
let command = aMessage.json.command;
|
|
|
|
|
|
|
|
switch (command) {
|
2013-03-06 23:56:15 +00:00
|
|
|
case "cut":
|
|
|
|
this._onCut();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "copy":
|
|
|
|
this._onCopy();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case "paste":
|
|
|
|
this._onPaste();
|
|
|
|
break;
|
|
|
|
|
2013-02-12 20:51:25 +00:00
|
|
|
case "select-all":
|
|
|
|
this._onSelectAll();
|
|
|
|
break;
|
|
|
|
|
2013-02-13 11:10:00 +00:00
|
|
|
case "copy-image-contents":
|
|
|
|
this._onCopyImage();
|
|
|
|
break;
|
2013-02-12 20:51:25 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
/******************************************************
|
|
|
|
* Event handlers
|
|
|
|
*/
|
|
|
|
|
|
|
|
reset: function ch_reset() {
|
|
|
|
this.popupNode = null;
|
|
|
|
this._target = null;
|
|
|
|
},
|
|
|
|
|
2013-02-22 20:11:45 +00:00
|
|
|
// content contextmenu handler
|
2013-02-12 20:51:25 +00:00
|
|
|
_onContentContextMenu: function _onContentContextMenu(aEvent) {
|
|
|
|
if (aEvent.defaultPrevented)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Don't let these bubble up to input.js
|
|
|
|
aEvent.stopPropagation();
|
|
|
|
aEvent.preventDefault();
|
|
|
|
|
2013-02-22 20:11:45 +00:00
|
|
|
this._processPopupNode(aEvent.originalTarget, aEvent.clientX,
|
|
|
|
aEvent.clientY, aEvent.mozInputSource);
|
|
|
|
},
|
|
|
|
|
|
|
|
/******************************************************
|
|
|
|
* ContextCommand handlers
|
|
|
|
*/
|
|
|
|
|
|
|
|
_onSelectAll: function _onSelectAll() {
|
2013-03-17 14:55:37 +00:00
|
|
|
if (Util.isTextInput(this._target)) {
|
2013-02-22 20:11:45 +00:00
|
|
|
// select all text in the input control
|
|
|
|
this._target.select();
|
2014-01-17 09:47:02 +00:00
|
|
|
} else if (Util.isEditableContent(this._target)) {
|
|
|
|
this._target.ownerDocument.execCommand("selectAll", false);
|
2013-02-22 20:11:45 +00:00
|
|
|
} else {
|
|
|
|
// select the entire document
|
|
|
|
content.getSelection().selectAllChildren(content.document);
|
|
|
|
}
|
|
|
|
this.reset();
|
|
|
|
},
|
|
|
|
|
|
|
|
_onPaste: function _onPaste() {
|
|
|
|
// paste text if this is an input control
|
2013-03-17 14:55:37 +00:00
|
|
|
if (Util.isTextInput(this._target)) {
|
2013-02-22 20:11:45 +00:00
|
|
|
let edit = this._target.QueryInterface(Ci.nsIDOMNSEditableElement);
|
|
|
|
if (edit) {
|
|
|
|
edit.editor.paste(Ci.nsIClipboard.kGlobalClipboard);
|
|
|
|
} else {
|
|
|
|
Util.dumpLn("error: target element does not support nsIDOMNSEditableElement");
|
|
|
|
}
|
2014-01-17 09:47:02 +00:00
|
|
|
} else if (Util.isEditableContent(this._target)) {
|
2013-12-06 23:58:03 +00:00
|
|
|
try {
|
|
|
|
this._target.ownerDocument.execCommand("paste",
|
|
|
|
false,
|
|
|
|
Ci.nsIClipboard.kGlobalClipboard);
|
|
|
|
} catch (ex) {
|
|
|
|
dump("ContextMenuHandler: exception pasting into contentEditable: " + ex.message + "\n");
|
|
|
|
}
|
2013-02-22 20:11:45 +00:00
|
|
|
}
|
|
|
|
this.reset();
|
|
|
|
},
|
|
|
|
|
|
|
|
_onCopyImage: function _onCopyImage() {
|
|
|
|
Util.copyImageToClipboard(this._target);
|
|
|
|
},
|
|
|
|
|
2013-03-06 23:56:15 +00:00
|
|
|
_onCut: function _onCut() {
|
2013-03-17 14:55:37 +00:00
|
|
|
if (Util.isTextInput(this._target)) {
|
2013-03-06 23:56:15 +00:00
|
|
|
let edit = this._target.QueryInterface(Ci.nsIDOMNSEditableElement);
|
|
|
|
if (edit) {
|
|
|
|
edit.editor.cut();
|
|
|
|
} else {
|
|
|
|
Util.dumpLn("error: target element does not support nsIDOMNSEditableElement");
|
|
|
|
}
|
2014-01-17 09:47:02 +00:00
|
|
|
} else if (Util.isEditableContent(this._target)) {
|
2013-12-06 23:58:03 +00:00
|
|
|
try {
|
|
|
|
this._target.ownerDocument.execCommand("cut", false);
|
|
|
|
} catch (ex) {
|
|
|
|
dump("ContextMenuHandler: exception cutting from contentEditable: " + ex.message + "\n");
|
|
|
|
}
|
2013-03-06 23:56:15 +00:00
|
|
|
}
|
|
|
|
this.reset();
|
|
|
|
},
|
|
|
|
|
|
|
|
_onCopy: function _onCopy() {
|
2013-03-17 14:55:37 +00:00
|
|
|
if (Util.isTextInput(this._target)) {
|
2013-03-06 23:56:15 +00:00
|
|
|
let edit = this._target.QueryInterface(Ci.nsIDOMNSEditableElement);
|
|
|
|
if (edit) {
|
|
|
|
edit.editor.copy();
|
|
|
|
} else {
|
|
|
|
Util.dumpLn("error: target element does not support nsIDOMNSEditableElement");
|
|
|
|
}
|
2014-01-21 19:04:04 +00:00
|
|
|
} else if (Util.isEditableContent(this._target)) {
|
|
|
|
try {
|
|
|
|
this._target.ownerDocument.execCommand("copy", false);
|
|
|
|
} catch (ex) {
|
|
|
|
dump("ContextMenuHandler: exception copying from contentEditable: " +
|
|
|
|
ex.message + "\n");
|
|
|
|
}
|
2013-03-06 23:56:15 +00:00
|
|
|
} else {
|
|
|
|
let selectionText = this._previousState.string;
|
|
|
|
|
|
|
|
Cc["@mozilla.org/widget/clipboardhelper;1"]
|
|
|
|
.getService(Ci.nsIClipboardHelper).copyString(selectionText);
|
|
|
|
}
|
|
|
|
this.reset();
|
|
|
|
},
|
|
|
|
|
2013-02-22 20:11:45 +00:00
|
|
|
/******************************************************
|
|
|
|
* Utility routines
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* _processPopupNode - Generate and send a Content:ContextMenu message
|
|
|
|
* to browser detailing the underlying content types at this.popupNode.
|
|
|
|
* Note the event we receive targets the sub frame (if there is one) of
|
|
|
|
* the page.
|
|
|
|
*/
|
|
|
|
_processPopupNode: function _processPopupNode(aPopupNode, aX, aY, aInputSrc) {
|
|
|
|
if (!aPopupNode)
|
|
|
|
return;
|
2013-02-27 16:27:47 +00:00
|
|
|
|
|
|
|
let { targetWindow: targetWindow,
|
|
|
|
offsetX: offsetX,
|
|
|
|
offsetY: offsetY } =
|
2013-04-23 13:51:02 +00:00
|
|
|
Util.translateToTopLevelWindow(aPopupNode);
|
2013-02-27 16:27:47 +00:00
|
|
|
|
2013-02-22 20:11:45 +00:00
|
|
|
let popupNode = this.popupNode = aPopupNode;
|
|
|
|
let imageUrl = "";
|
|
|
|
|
2013-02-12 20:51:25 +00:00
|
|
|
let state = {
|
|
|
|
types: [],
|
|
|
|
label: "",
|
|
|
|
linkURL: "",
|
|
|
|
linkTitle: "",
|
|
|
|
linkProtocol: null,
|
|
|
|
mediaURL: "",
|
2013-03-06 23:56:15 +00:00
|
|
|
contentType: "",
|
|
|
|
contentDisposition: "",
|
|
|
|
string: "",
|
2013-02-12 20:51:25 +00:00
|
|
|
};
|
2013-12-06 23:58:03 +00:00
|
|
|
let uniqueStateTypes = new Set();
|
2013-02-12 20:51:25 +00:00
|
|
|
|
|
|
|
// Do checks for nodes that never have children.
|
|
|
|
if (popupNode.nodeType == Ci.nsIDOMNode.ELEMENT_NODE) {
|
|
|
|
// See if the user clicked on an image.
|
|
|
|
if (popupNode instanceof Ci.nsIImageLoadingContent && popupNode.currentURI) {
|
2013-12-06 23:58:03 +00:00
|
|
|
uniqueStateTypes.add("image");
|
2013-02-12 20:51:25 +00:00
|
|
|
state.label = state.mediaURL = popupNode.currentURI.spec;
|
|
|
|
imageUrl = state.mediaURL;
|
2013-02-13 11:10:00 +00:00
|
|
|
this._target = popupNode;
|
2013-02-12 20:51:25 +00:00
|
|
|
|
|
|
|
// Retrieve the type of image from the cache since the url can fail to
|
|
|
|
// provide valuable informations
|
|
|
|
try {
|
|
|
|
let imageCache = Cc["@mozilla.org/image/cache;1"].getService(Ci.imgICache);
|
|
|
|
let props = imageCache.findEntryProperties(popupNode.currentURI,
|
|
|
|
content.document.characterSet);
|
|
|
|
if (props) {
|
|
|
|
state.contentType = String(props.get("type", Ci.nsISupportsCString));
|
|
|
|
state.contentDisposition = String(props.get("content-disposition",
|
|
|
|
Ci.nsISupportsCString));
|
|
|
|
}
|
|
|
|
} catch (ex) {
|
|
|
|
Util.dumpLn(ex.message);
|
|
|
|
// Failure to get type and content-disposition off the image is non-fatal
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
let elem = popupNode;
|
|
|
|
let isText = false;
|
2013-12-06 23:58:03 +00:00
|
|
|
let isEditableText = false;
|
2013-02-12 20:51:25 +00:00
|
|
|
|
|
|
|
while (elem) {
|
|
|
|
if (elem.nodeType == Ci.nsIDOMNode.ELEMENT_NODE) {
|
|
|
|
// is the target a link or a descendant of a link?
|
2013-03-17 14:55:37 +00:00
|
|
|
if (Util.isLink(elem)) {
|
2013-02-12 20:51:25 +00:00
|
|
|
// If this is an image that links to itself, don't include both link and
|
|
|
|
// image otpions.
|
|
|
|
if (imageUrl == this._getLinkURL(elem)) {
|
|
|
|
elem = elem.parentNode;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2013-12-06 23:58:03 +00:00
|
|
|
uniqueStateTypes.add("link");
|
2013-02-12 20:51:25 +00:00
|
|
|
state.label = state.linkURL = this._getLinkURL(elem);
|
|
|
|
linkUrl = state.linkURL;
|
|
|
|
state.linkTitle = popupNode.textContent || popupNode.title;
|
|
|
|
state.linkProtocol = this._getProtocol(this._getURI(state.linkURL));
|
2013-02-20 01:51:02 +00:00
|
|
|
// mark as text so we can pickup on selection below
|
|
|
|
isText = true;
|
2013-02-12 20:51:25 +00:00
|
|
|
break;
|
2013-12-06 23:58:03 +00:00
|
|
|
}
|
|
|
|
// is the target contentEditable (not just inheriting contentEditable)
|
2014-01-17 09:47:02 +00:00
|
|
|
// or the entire document in designer mode.
|
|
|
|
else if (elem.contentEditable == "true" ||
|
|
|
|
Util.isOwnerDocumentInDesignMode(elem)) {
|
2013-12-06 23:58:03 +00:00
|
|
|
this._target = elem;
|
|
|
|
isEditableText = true;
|
|
|
|
isText = true;
|
|
|
|
uniqueStateTypes.add("input-text");
|
2013-02-12 20:51:25 +00:00
|
|
|
|
2013-12-06 23:58:03 +00:00
|
|
|
if (elem.textContent.length) {
|
|
|
|
uniqueStateTypes.add("selectable");
|
|
|
|
} else {
|
|
|
|
uniqueStateTypes.add("input-empty");
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
// is the target a text input
|
|
|
|
else if (Util.isTextInput(elem)) {
|
2013-02-12 20:51:25 +00:00
|
|
|
this._target = elem;
|
2013-12-06 23:58:03 +00:00
|
|
|
isEditableText = true;
|
|
|
|
uniqueStateTypes.add("input-text");
|
|
|
|
|
|
|
|
let selectionStart = elem.selectionStart;
|
|
|
|
let selectionEnd = elem.selectionEnd;
|
2013-02-12 20:51:25 +00:00
|
|
|
|
|
|
|
// Don't include "copy" for password fields.
|
|
|
|
if (!(elem instanceof Ci.nsIDOMHTMLInputElement) || elem.mozIsTextField(true)) {
|
2013-04-08 18:42:54 +00:00
|
|
|
// If there is a selection add cut and copy
|
2013-02-12 20:51:25 +00:00
|
|
|
if (selectionStart != selectionEnd) {
|
2013-12-06 23:58:03 +00:00
|
|
|
uniqueStateTypes.add("cut");
|
|
|
|
uniqueStateTypes.add("copy");
|
2013-02-12 20:51:25 +00:00
|
|
|
state.string = elem.value.slice(selectionStart, selectionEnd);
|
2013-04-08 18:42:54 +00:00
|
|
|
} else if (elem.value && elem.textLength) {
|
|
|
|
// There is text and it is not selected so add selectable items
|
2013-12-06 23:58:03 +00:00
|
|
|
uniqueStateTypes.add("selectable");
|
2013-02-12 20:51:25 +00:00
|
|
|
state.string = elem.value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!elem.textLength) {
|
2013-12-06 23:58:03 +00:00
|
|
|
uniqueStateTypes.add("input-empty");
|
2013-02-12 20:51:25 +00:00
|
|
|
}
|
|
|
|
break;
|
2013-12-06 23:58:03 +00:00
|
|
|
}
|
|
|
|
// is the target an element containing text content
|
|
|
|
else if (Util.isText(elem)) {
|
2013-02-12 20:51:25 +00:00
|
|
|
isText = true;
|
2013-12-06 23:58:03 +00:00
|
|
|
}
|
|
|
|
// is the target a media element
|
|
|
|
else if (elem instanceof Ci.nsIDOMHTMLMediaElement ||
|
2013-02-12 20:51:25 +00:00
|
|
|
elem instanceof Ci.nsIDOMHTMLVideoElement) {
|
|
|
|
state.label = state.mediaURL = (elem.currentSrc || elem.src);
|
2013-12-06 23:58:03 +00:00
|
|
|
uniqueStateTypes.add((elem.paused || elem.ended) ?
|
2013-02-12 20:51:25 +00:00
|
|
|
"media-paused" : "media-playing");
|
|
|
|
if (elem instanceof Ci.nsIDOMHTMLVideoElement) {
|
2013-12-06 23:58:03 +00:00
|
|
|
uniqueStateTypes.add("video");
|
2013-02-12 20:51:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
elem = elem.parentNode;
|
|
|
|
}
|
|
|
|
|
2013-02-20 01:51:02 +00:00
|
|
|
// Over arching text tests
|
2013-02-12 20:51:25 +00:00
|
|
|
if (isText) {
|
|
|
|
// If this is text and has a selection, we want to bring
|
|
|
|
// up the copy option on the context menu.
|
2013-02-27 16:27:47 +00:00
|
|
|
let selection = targetWindow.getSelection();
|
2013-08-19 09:25:58 +00:00
|
|
|
if (selection && this._tapInSelection(selection, aX, aY)) {
|
2013-02-27 16:27:47 +00:00
|
|
|
state.string = targetWindow.getSelection().toString();
|
2013-12-06 23:58:03 +00:00
|
|
|
uniqueStateTypes.add("copy");
|
|
|
|
uniqueStateTypes.add("selected-text");
|
|
|
|
if (isEditableText) {
|
|
|
|
uniqueStateTypes.add("cut");
|
|
|
|
}
|
2013-02-13 11:10:00 +00:00
|
|
|
} else {
|
|
|
|
// Add general content text if this isn't anything specific
|
2013-12-06 23:58:03 +00:00
|
|
|
if (!(
|
|
|
|
uniqueStateTypes.has("image") ||
|
|
|
|
uniqueStateTypes.has("media") ||
|
|
|
|
uniqueStateTypes.has("video") ||
|
|
|
|
uniqueStateTypes.has("link") ||
|
|
|
|
uniqueStateTypes.has("input-text")
|
|
|
|
)) {
|
|
|
|
uniqueStateTypes.add("content-text");
|
2013-02-12 20:51:25 +00:00
|
|
|
}
|
2013-02-13 11:10:00 +00:00
|
|
|
}
|
2013-02-12 20:51:25 +00:00
|
|
|
}
|
|
|
|
|
2013-12-06 23:58:03 +00:00
|
|
|
// Is paste applicable here?
|
|
|
|
if (isEditableText) {
|
|
|
|
let flavors = ["text/unicode"];
|
|
|
|
let cb = Cc["@mozilla.org/widget/clipboard;1"].getService(Ci.nsIClipboard);
|
|
|
|
let hasData = cb.hasDataMatchingFlavors(flavors,
|
|
|
|
flavors.length,
|
|
|
|
Ci.nsIClipboard.kGlobalClipboard);
|
|
|
|
// add paste if there's data
|
|
|
|
if (hasData && !elem.readOnly) {
|
|
|
|
uniqueStateTypes.add("paste");
|
|
|
|
}
|
|
|
|
}
|
2013-02-12 20:51:25 +00:00
|
|
|
// populate position and event source
|
2013-02-22 20:11:45 +00:00
|
|
|
state.xPos = offsetX + aX;
|
|
|
|
state.yPos = offsetY + aY;
|
2013-02-22 20:11:45 +00:00
|
|
|
state.source = aInputSrc;
|
2013-02-12 20:51:25 +00:00
|
|
|
|
|
|
|
for (let i = 0; i < this._types.length; i++)
|
|
|
|
if (this._types[i].handler(state, popupNode))
|
2013-12-06 23:58:03 +00:00
|
|
|
uniqueStateTypes.add(this._types[i].name);
|
2013-02-12 20:51:25 +00:00
|
|
|
|
2013-12-06 23:58:03 +00:00
|
|
|
state.types = [type for (type of uniqueStateTypes)];
|
2013-03-06 23:56:15 +00:00
|
|
|
this._previousState = state;
|
|
|
|
|
2013-02-12 20:51:25 +00:00
|
|
|
sendAsyncMessage("Content:ContextMenu", state);
|
|
|
|
},
|
|
|
|
|
2013-08-19 09:25:58 +00:00
|
|
|
_tapInSelection: function (aSelection, aX, aY) {
|
|
|
|
if (!aSelection || !aSelection.rangeCount) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
for (let idx = 0; idx < aSelection.rangeCount; idx++) {
|
|
|
|
let range = aSelection.getRangeAt(idx);
|
|
|
|
let rect = range.getBoundingClientRect();
|
|
|
|
if (Util.pointWithinDOMRect(aX, aY, rect)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
},
|
|
|
|
|
2013-02-22 20:11:45 +00:00
|
|
|
_getLinkURL: function ch_getLinkURL(aLink) {
|
|
|
|
let href = aLink.href;
|
|
|
|
if (href)
|
|
|
|
return href;
|
|
|
|
|
|
|
|
href = aLink.getAttributeNS(kXLinkNamespace, "href");
|
|
|
|
if (!href || !href.match(/\S/)) {
|
|
|
|
// Without this we try to save as the current doc,
|
|
|
|
// for example, HTML case also throws if empty
|
|
|
|
throw "Empty href";
|
|
|
|
}
|
|
|
|
|
|
|
|
return Util.makeURLAbsolute(aLink.baseURI, href);
|
|
|
|
},
|
|
|
|
|
|
|
|
_getURI: function ch_getURI(aURL) {
|
|
|
|
try {
|
|
|
|
return Util.makeURI(aURL);
|
|
|
|
} catch (ex) { }
|
|
|
|
|
|
|
|
return null;
|
|
|
|
},
|
|
|
|
|
|
|
|
_getProtocol: function ch_getProtocol(aURI) {
|
|
|
|
if (aURI)
|
|
|
|
return aURI.scheme;
|
|
|
|
return null;
|
|
|
|
},
|
|
|
|
|
2013-02-12 20:51:25 +00:00
|
|
|
/**
|
|
|
|
* For add-ons to add new types and data to the ContextMenu message.
|
|
|
|
*
|
|
|
|
* @param aName A string to identify the new type.
|
|
|
|
* @param aHandler A function that takes a state object and a target element.
|
|
|
|
* If aHandler returns true, then aName will be added to the list of types.
|
|
|
|
* The function may also modify the state object.
|
|
|
|
*/
|
|
|
|
registerType: function registerType(aName, aHandler) {
|
|
|
|
this._types.push({name: aName, handler: aHandler});
|
|
|
|
},
|
|
|
|
|
|
|
|
/** Remove all handlers registered for a given type. */
|
|
|
|
unregisterType: function unregisterType(aName) {
|
|
|
|
this._types = this._types.filter(function(type) type.name != aName);
|
|
|
|
}
|
|
|
|
};
|
2013-11-24 05:32:32 +00:00
|
|
|
this.ContextMenuHandler = ContextMenuHandler;
|
2013-02-12 20:51:25 +00:00
|
|
|
|
|
|
|
ContextMenuHandler.init();
|