From 322645e3a81199f2d7d18ad722a800dce67b41bb Mon Sep 17 00:00:00 2001 From: Matt Brubeck Date: Mon, 21 Mar 2011 10:28:34 -0700 Subject: [PATCH] Bug 637031 - Add "bookmark link" to context menu [r=vingtetun, uir=madhava] --- mobile/chrome/content/ContextCommands.js | 17 +++++++++++++++++ mobile/chrome/content/browser.xul | 3 +++ mobile/chrome/content/content.js | 4 ++++ mobile/locales/en-US/chrome/browser.dtd | 1 + mobile/locales/en-US/chrome/browser.properties | 1 + 5 files changed, 26 insertions(+) diff --git a/mobile/chrome/content/ContextCommands.js b/mobile/chrome/content/ContextCommands.js index 5a7b63386f7e..82666537c7c2 100644 --- a/mobile/chrome/content/ContextCommands.js +++ b/mobile/chrome/content/ContextCommands.js @@ -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 }); diff --git a/mobile/chrome/content/browser.xul b/mobile/chrome/content/browser.xul index d6eb7b3042aa..8372762fcfd7 100644 --- a/mobile/chrome/content/browser.xul +++ b/mobile/chrome/content/browser.xul @@ -612,6 +612,9 @@ + + diff --git a/mobile/chrome/content/content.js b/mobile/chrome/content/content.js index db793c679ab0..54e77ecf3ec9 100644 --- a/mobile/chrome/content/content.js +++ b/mobile/chrome/content/content.js @@ -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"; }); diff --git a/mobile/locales/en-US/chrome/browser.dtd b/mobile/locales/en-US/chrome/browser.dtd index 58004e173822..766fcd82af0c 100644 --- a/mobile/locales/en-US/chrome/browser.dtd +++ b/mobile/locales/en-US/chrome/browser.dtd @@ -95,6 +95,7 @@ + diff --git a/mobile/locales/en-US/chrome/browser.properties b/mobile/locales/en-US/chrome/browser.properties index 378c654c4093..d581d8aa4d26 100644 --- a/mobile/locales/en-US/chrome/browser.properties +++ b/mobile/locales/en-US/chrome/browser.properties @@ -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