Bug 637031 - Add "bookmark link" to context menu [r=vingtetun, uir=madhava]

This commit is contained in:
Matt Brubeck 2011-03-21 10:28:34 -07:00
parent 2365897ad6
commit 322645e3a8
5 changed files with 26 additions and 0 deletions

View File

@ -73,6 +73,23 @@ var ContextCommands = {
SharingUI.show(ContextHelper.popupState.mediaURL, null);
},
bookmarkLink: function cc_bookmarkLink() {
let state = ContextHelper.popupState;
let bookmarks = PlacesUtils.bookmarks;
try {
bookmarks.insertBookmark(BookmarkList.panel.mobileRoot,
Util.makeURI(state.linkURL),
bookmarks.DEFAULT_INDEX,
state.linkTitle || state.linkURL);
} catch (e) {
return;
}
let message = Strings.browser.GetStringFromName("alertLinkBookmarked");
let toaster = Cc["@mozilla.org/toaster-alerts-service;1"].getService(Ci.nsIAlertsService);
toaster.showAlertNotification(null, message, "", false, "", null);
},
sendCommand: function cc_playVideo(aCommand) {
let browser = ContextHelper.popupState.target;
browser.messageManager.sendAsyncMessage("Browser:ContextCommand", { command: aCommand });

View File

@ -612,6 +612,9 @@
<richlistitem class="context-command" id="context-openinnewtab" type="link-openable" onclick="ContextCommands.openInNewTab();">
<label value="&contextOpenInNewTab.label;"/>
</richlistitem>
<richlistitem class="context-command" id="context-bookmark-link" type="link" onclick="ContextCommands.bookmarkLink();">
<label value="&contextBookmarkLink.label;"/>
</richlistitem>
<richlistitem class="context-command" id="context-savelink" type="link-saveable" onclick="ContextCommands.saveLink();">
<label value="&contextSaveLink.label;"/>
</richlistitem>

View File

@ -931,6 +931,10 @@ var ContextHandler = {
ContextHandler.init();
ContextHandler.registerType("link", function(aState, aElement) {
return !!aState.linkURL;
});
ContextHandler.registerType("mailto", function(aState, aElement) {
return aState.linkProtocol == "mailto";
});

View File

@ -95,6 +95,7 @@
<!ENTITY contextSaveImage.label "Save Image">
<!ENTITY contextShareLink.label "Share Link">
<!ENTITY contextShareImage.label "Share Image">
<!ENTITY contextBookmarkLink.label "Bookmark Link">
<!ENTITY contextSaveVideo.label "Save Video">
<!ENTITY contextShareVideo.label "Share Video">
<!ENTITY contextPlayMedia.label "Play">

View File

@ -91,6 +91,7 @@ alertAddonsInstalling=Installing add-on
alertAddonsInstalled=Installation complete. Restart required.
alertAddonsInstalledNoRestart=Installation complete
alertAddonsFail=Installation failed
alertLinkBookmarked=Bookmark added
alertLockScreen=Screen Orientation
alertLockScreen.locked=Locked
alertLockScreen.unlocked=Unlocked