Bug 775770 - Add "Copy Phone Number" to long press context menu. r=mfinkle
authorMichael Comella <michael.l.comella@gmail.com>
Fri, 20 Jul 2012 20:19:39 -0400
changeset 105468 045c11dd41a6720d3040545f357ac3f4f53a6dbf
parent 105467 1be98690ab783d815dddada97efe6602aab660a5
child 105472 61835756b1cd2276a84fbaf04ef218b7c47bd407
child 105474 1dbd25c0205ed89688dad8d3a4274f2b729cd86d
push id1490
push userakeybl@mozilla.com
push dateMon, 08 Oct 2012 18:29:50 +0000
treeherdermozilla-beta@f335e7dacdc1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmfinkle
bugs775770
milestone17.0a1
first release with
nightly linux64
045c11dd41a6 / 17.0a1 / 20120721030555 / files
nightly mac
045c11dd41a6 / 17.0a1 / 20120721030555 / files
nightly linux32
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux64
nightly mac
Bug 775770 - Add "Copy Phone Number" to long press context menu. r=mfinkle
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
@@ -373,16 +373,24 @@ var BrowserApp = {
     NativeWindow.contextmenus.add(Strings.browser.GetStringFromName("contextmenu.copyEmailAddress"),
       NativeWindow.contextmenus.emailLinkCopyableContext,
       function(aTarget) {
         let url = NativeWindow.contextmenus._getLinkURL(aTarget);
         let emailAddr = NativeWindow.contextmenus._stripScheme(url);
         NativeWindow.contextmenus._copyStringToDefaultClipboard(emailAddr);
       });
 
+    NativeWindow.contextmenus.add(Strings.browser.GetStringFromName("contextmenu.copyPhoneNumber"),
+      NativeWindow.contextmenus.phoneNumberLinkCopyableContext,
+      function(aTarget) {
+        let url = NativeWindow.contextmenus._getLinkURL(aTarget);
+        let phoneNumber = NativeWindow.contextmenus._stripScheme(url);
+        NativeWindow.contextmenus._copyStringToDefaultClipboard(phoneNumber);
+    });
+
     NativeWindow.contextmenus.add(Strings.browser.GetStringFromName("contextmenu.shareLink"),
       NativeWindow.contextmenus.linkShareableContext,
       function(aTarget) {
         let url = NativeWindow.contextmenus._getLinkURL(aTarget);
         let title = aTarget.textContent || aTarget.title;
         let sharing = Cc["@mozilla.org/uriloader/external-sharing-app-service;1"].getService(Ci.nsIExternalSharingAppService);
         sharing.shareWithDefault(url, "text/plain", title);
       });
@@ -1286,16 +1294,26 @@ var NativeWindow = {
         let uri = NativeWindow.contextmenus._getLink(aElement);
         if (uri) {
           return uri.schemeIs("mailto");
         }
         return false;
       }
     },
 
+    phoneNumberLinkCopyableContext: {
+      matches: function phoneNumberLinkCopyableContextMatches(aElement) {
+        let uri = NativeWindow.contextmenus._getLink(aElement);
+        if (uri) {
+          return uri.schemeIs("tel");
+        }
+        return false;
+      }
+    },
+
     linkShareableContext: {
       matches: function linkShareableContextMatches(aElement) {
         let uri = NativeWindow.contextmenus._getLink(aElement);
         if (uri) {
           let scheme = uri.scheme;
           let dontShare = /^(chrome|about|file|javascript|resource)$/;
           return (scheme && !dontShare.test(scheme));
         }
--- a/mobile/android/locales/en-US/chrome/browser.properties
+++ b/mobile/android/locales/en-US/chrome/browser.properties
@@ -208,16 +208,17 @@ selectionHelper.textCopied=Text copied t
 
 # Context menu
 contextmenu.openInNewTab=Open Link in New Tab
 contextmenu.share=Share
 contextmenu.copyLink=Copy Link
 contextmenu.shareLink=Share Link
 contextmenu.bookmarkLink=Bookmark Link
 contextmenu.copyEmailAddress=Copy Email Address
+contextmenu.copyPhoneNumber=Copy Phone Number
 contextmenu.changeInputMethod=Select Input Method
 contextmenu.fullScreen=Full Screen
 contextmenu.shareImage=Share Image
 contextmenu.saveImage=Save Image
 contextmenu.addSearchEngine=Add Search Engine
 
 contextmenu.copy=Copy
 contextmenu.copyAll=Copy All