зеркало из https://github.com/mozilla/gecko-dev.git
Bug 634883 - Hide Share/Open in context menu for non-shareable/openable links [r=mfinkle]
This commit is contained in:
Родитель
1ddc45a366
Коммит
28b23e37b0
|
@ -111,6 +111,11 @@ let Util = {
|
|||
return (aURL.indexOf("about:") == 0 && aURL != "about:blank" && aURL != "about:empty") || aURL.indexOf("chrome:") == 0;
|
||||
},
|
||||
|
||||
isOpenableScheme: function isShareableScheme(aProtocol) {
|
||||
let dontOpen = /^(mailto|javascript|news|snews)$/;
|
||||
return (aProtocol && !dontOpen.test(aProtocol));
|
||||
},
|
||||
|
||||
isShareableScheme: function isShareableScheme(aProtocol) {
|
||||
let dontShare = /^(chrome|about|file|javascript|resource)$/;
|
||||
return (aProtocol && !dontShare.test(aProtocol));
|
||||
|
|
|
@ -138,11 +138,20 @@
|
|||
if (!url)
|
||||
return;
|
||||
|
||||
let types = [];
|
||||
try { // In case makeURI fails.
|
||||
let uri = Util.makeURI(url);
|
||||
if (Util.isOpenableScheme(uri.scheme))
|
||||
types.push("link-openable");
|
||||
if (Util.isShareableScheme(uri.scheme))
|
||||
types.push("link-shareable");
|
||||
} catch (ex) { Util.dumpLn(ex); }
|
||||
|
||||
let value = this.getAttribute("value");
|
||||
let data = {
|
||||
target: this,
|
||||
json: {
|
||||
types: ["link-shareable", "link-openable"],
|
||||
types: types,
|
||||
label: value,
|
||||
linkTitle: value,
|
||||
linkURL: url
|
||||
|
@ -597,10 +606,18 @@
|
|||
if (!this.uri || this._isEditing)
|
||||
return;
|
||||
|
||||
let types = ["edit-bookmark"];
|
||||
try { // In case makeURI fails.
|
||||
if (Util.isOpenableScheme(this.uri.scheme))
|
||||
types.push("link-openable");
|
||||
if (Util.isShareableScheme(this.uri.scheme))
|
||||
types.push("link-shareable");
|
||||
} catch (ex) { Util.dumpLn(ex); }
|
||||
|
||||
let data = {
|
||||
target: this,
|
||||
json: {
|
||||
types: ["edit-bookmark", "link-shareable", "link-openable"],
|
||||
types: types,
|
||||
label: this.name,
|
||||
linkTitle: this.name,
|
||||
linkURL: this.spec
|
||||
|
|
|
@ -916,8 +916,7 @@ ContextHandler.registerType("link-saveable", function(aState, aElement) {
|
|||
});
|
||||
|
||||
ContextHandler.registerType("link-openable", function(aState, aElement) {
|
||||
let protocol = aState.linkProtocol;
|
||||
return (protocol && protocol != "mailto" && protocol != "javascript" && protocol != "news" && protocol != "snews");
|
||||
return Util.isOpenableScheme(aState.linkProtocol);
|
||||
});
|
||||
|
||||
ContextHandler.registerType("link-shareable", function(aState, aElement) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче