Bug 775773 - Add "Copy Image Location" context menu item to long press. r=wesj
authorMichael Comella <michael.l.comella@gmail.com>
Mon, 27 Aug 2012 19:34:30 -0400
changeset 105649 1d702ef4214a0b25064e894151a49e451b7678ef
parent 105648 d8ac3833d2a143a04c3745a7f72eba601cc169fa
child 105650 07a27119d9c983c88687f406e53ce6cabf4ae028
push id55
push usershu@rfrn.org
push dateThu, 30 Aug 2012 01:33:09 +0000
reviewerswesj
bugs775773
milestone18.0a1
Bug 775773 - Add "Copy Image Location" context menu item to long press. r=wesj
mobile/android/chrome/content/browser.js
mobile/android/locales/en-US/chrome/browser.properties
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -431,16 +431,23 @@ var BrowserApp = {
       });
 
     NativeWindow.contextmenus.add(Strings.browser.GetStringFromName("contextmenu.fullScreen"),
       NativeWindow.contextmenus.SelectorContext("video:not(:-moz-full-screen)"),
       function(aTarget) {
         aTarget.mozRequestFullScreen();
       });
 
+    NativeWindow.contextmenus.add(Strings.browser.GetStringFromName("contextmenu.copyImageLocation"),
+      NativeWindow.contextmenus.imageLocationCopyableContext,
+      function(aTarget) {
+        let url = aTarget.src;
+        NativeWindow.contextmenus._copyStringToDefaultClipboard(url);
+      });
+
     NativeWindow.contextmenus.add(Strings.browser.GetStringFromName("contextmenu.shareImage"),
       NativeWindow.contextmenus.imageSaveableContext,
       function(aTarget) {
         let imageCache = Cc["@mozilla.org/image/cache;1"].getService(Ci.imgICache);
         let props = imageCache.findEntryProperties(aTarget.currentURI, aTarget.ownerDocument.characterSet);
         let src = aTarget.src;
         let type = "";
         try {
@@ -1354,16 +1361,22 @@ var NativeWindow = {
 
     textContext: {
       matches: function textContext(aElement) {
         return ((aElement instanceof Ci.nsIDOMHTMLInputElement && aElement.mozIsTextField(false))
                 || aElement instanceof Ci.nsIDOMHTMLTextAreaElement);
       }
     },
 
+    imageLocationCopyableContext: {
+      matches: function imageLinkCopyableContextMatches(aElement) {
+        return (aElement instanceof Ci.nsIImageLoadingContent && aElement.currentURI);
+      }
+    },
+
     imageSaveableContext: {
       matches: function imageSaveableContextMatches(aElement) {
         if (aElement instanceof Ci.nsIImageLoadingContent && aElement.currentURI) {
           // The image must be loaded to allow saving
           let request = aElement.getRequest(Ci.nsIImageLoadingContent.CURRENT_REQUEST);
           return (request && (request.imageStatus & request.STATUS_SIZE_AVAILABLE));
         }
         return false;
--- a/mobile/android/locales/en-US/chrome/browser.properties
+++ b/mobile/android/locales/en-US/chrome/browser.properties
@@ -213,16 +213,17 @@ contextmenu.copyLink=Copy Link
 contextmenu.shareLink=Share Link
 contextmenu.bookmarkLink=Bookmark Link
 contextmenu.copyEmailAddress=Copy Email Address
 contextmenu.shareEmailAddress=Share Email Address
 contextmenu.copyPhoneNumber=Copy Phone Number
 contextmenu.sharePhoneNumber=Share Phone Number
 contextmenu.changeInputMethod=Select Input Method
 contextmenu.fullScreen=Full Screen
+contextmenu.copyImageLocation=Copy Image Location
 contextmenu.shareImage=Share Image
 contextmenu.saveImage=Save Image
 contextmenu.addSearchEngine=Add Search Engine
 
 contextmenu.copy=Copy
 contextmenu.copyAll=Copy All
 contextmenu.selectWord=Select Word
 contextmenu.selectAll=Select All