Bug 674771 - Add a "Paste & Go" entry in the URL bar context menu. r=mfinkle
authorMounir Lamouri <mounir.lamouri@gmail.com>
Fri, 12 Aug 2011 15:40:00 +0200
changeset 74344 9e269bcacf43e00a3e7f9905f58dbf66afbdd236
parent 74343 6fd7a1b9ef64f8d358abb57f9b89b46832fda8c5
child 74345 cd7f694c9f2f099a31158fb5d292a97a49d3cad4
push id2
push userbsmedberg@mozilla.com
push dateFri, 19 Aug 2011 14:38:13 +0000
reviewersmfinkle
bugs674771
milestone8.0a1
Bug 674771 - Add a "Paste & Go" entry in the URL bar context menu. r=mfinkle
mobile/chrome/content/ContextCommands.js
mobile/chrome/content/bindings.xml
mobile/chrome/content/browser.xul
mobile/locales/en-US/chrome/browser.dtd
--- a/mobile/chrome/content/ContextCommands.js
+++ b/mobile/chrome/content/ContextCommands.js
@@ -24,16 +24,23 @@ var ContextCommands = {
       let json = {x: x, y: y, command: "paste" };
       messageManager.sendAsyncMessage("Browser:ContextCommand", json);
     } else {
       target.editor.paste(Ci.nsIClipboard.kGlobalClipboard);
       target.focus();
     }
   },
 
+  pasteAndGo: function cc_pasteAndGo() {
+    let target = ContextHelper.popupState.target;
+    target.editor.selectAll();
+    target.editor.paste(Ci.nsIClipboard.kGlobalClipboard);
+    BrowserUI.goToURI();
+  },
+
   selectAll: function cc_selectAll() {
     let target = ContextHelper.popupState.target;
     if (target.localName == "browser") {
       let x = ContextHelper.popupState.x;
       let y = ContextHelper.popupState.y;
       let json = {x: x, y: y, command: "select-all" };
       messageManager.sendAsyncMessage("Browser:ContextCommand", json);
     } else {
--- a/mobile/chrome/content/bindings.xml
+++ b/mobile/chrome/content/bindings.xml
@@ -1815,17 +1815,21 @@
 
           if (selectionStart > 0 || selectionEnd < aTextbox.textLength)
             json.types.push("select-all");
 
           let clipboard = Cc["@mozilla.org/widget/clipboard;1"].getService(Ci.nsIClipboard);
           let flavors = ["text/unicode"];
           let hasData = clipboard.hasDataMatchingFlavors(flavors, flavors.length, Ci.nsIClipboard.kGlobalClipboard);
 
-          if (hasData && (!aTextbox.readOnly || aIgnoreReadOnly))
+          if (hasData && (!aTextbox.readOnly || aIgnoreReadOnly)) {
             json.types.push("paste");
+            if (aTextbox.type == "url") {
+              json.types.push("paste-url");
+            }
+          }
 
           ContextHelper.showPopup({ target: aTextbox, json: json });
         ]]></body>
       </method>
     </implementation>
   </binding>
 </bindings>
--- a/mobile/chrome/content/browser.xul
+++ b/mobile/chrome/content/browser.xul
@@ -621,16 +621,19 @@
             <label value="&copy.label;"/>
           </richlistitem>
           <richlistitem class="context-command" id="context-copy-all" type="copy-all" onclick="ContextCommands.copy();">
             <label value="&copyAll.label;"/>
           </richlistitem>
           <richlistitem class="context-command" id="context-paste" type="paste" onclick="ContextCommands.paste();">
             <label value="&paste.label;"/>
           </richlistitem>
+          <richlistitem class="context-command" id="context-paste-n-go" type="paste-url" onclick="ContextCommands.pasteAndGo();">
+            <label value="&pasteAndGo.label;"/>
+          </richlistitem>
           <richlistitem class="context-command" id="context-select-all" type="select-all" onclick="ContextCommands.selectAll();">
             <label value="&selectAll.label;"/>
           </richlistitem>
           <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;"/>
--- a/mobile/locales/en-US/chrome/browser.dtd
+++ b/mobile/locales/en-US/chrome/browser.dtd
@@ -11,16 +11,17 @@
 <!ENTITY newtab.label          "New Tab">
 <!ENTITY closetab.label        "Close Tab">
 
 <!ENTITY cut.label             "Cut">
 <!ENTITY copy.label            "Copy">
 <!ENTITY copyAll.label         "Copy All">
 <!ENTITY copylink.label        "Copy Link Location">
 <!ENTITY paste.label           "Paste">
+<!ENTITY pasteAndGo.label      "Paste &amp; Go">
 <!ENTITY delete.label          "Delete">
 <!ENTITY selectAll.label       "Select All">
 <!ENTITY noSuggestions.label   "(No suggestions)">
 <!ENTITY addToDictionary.label "Add to Dictionary">
 <!ENTITY inputMethod.label     "Select Input Method">
 
 <!ENTITY allPagesHeader.label      "All Pages">
 <!ENTITY bookmarksHeader.label     "Bookmarks">