Bug 674771 - Add a "Paste & Go" entry in the URL bar context menu. r=mfinkle

This commit is contained in:
Mounir Lamouri 2011-08-12 15:40:00 +02:00
parent cb92f6ff06
commit 82296710d2
4 changed files with 16 additions and 1 deletions

View File

@ -29,6 +29,13 @@ var ContextCommands = {
}
},
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") {

View File

@ -1820,8 +1820,12 @@
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>

View File

@ -626,6 +626,9 @@
<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>

View File

@ -16,6 +16,7 @@
<!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)">