searching for changes
changeset:   99712:bbdfd47ad4d7
tag:         tip
user:        Wes Johnston <wjohnston@mozilla.com>
summary:     Bug 766802 - Clicks on links with target=blank in webapps should open in the browser. r=mfinkle
This commit is contained in:
Wes Johnston 2012-07-18 15:43:34 -07:00
parent a3df4ac39e
commit fb11286c15
3 changed files with 44 additions and 0 deletions

View File

@ -0,0 +1,39 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
let Cc = Components.classes;
let Ci = Components.interfaces;
let Cu = Components.utils;
Cu.import("resource://gre/modules/Services.jsm");
var WebAppRT = {
init: function() {
this.deck = document.getElementById("browsers");
this.deck.addEventListener("click", onContentClick, false, true);
},
handleEvent: function(event) {
let target = event.target;
if (!(target instanceof HTMLAnchorElement) ||
target.getAttribute("target") != "_blank") {
return;
}
let uri = Services.io.newURI(target.href,
target.ownerDocument.characterSet,
null);
// Direct the URL to the browser.
Cc["@mozilla.org/uriloader/external-protocol-service;1"].
getService(Ci.nsIExternalProtocolService).
getProtocolHandlerInfo(uri.scheme).
launchWithURI(uri);
// Prevent the runtime from loading the URL. We do this after directing it
// to the browser to give the runtime a shot at handling the URL if we fail
// to direct it to the browser for some reason.
event.preventDefault();
}
}

View File

@ -32,6 +32,7 @@ XPCOMUtils.defineLazyGetter(this, "DebuggerServer", function() {
["HelperApps", "chrome://browser/content/HelperApps.js"],
["SelectHelper", "chrome://browser/content/SelectHelper.js"],
["Readability", "chrome://browser/content/Readability.js"],
["WebAppRT", "chrome://browser/content/WebAppRT.js"],
].forEach(function (aScript) {
let [name, script] = aScript;
XPCOMUtils.defineLazyGetter(window, name, function() {
@ -309,6 +310,9 @@ var BrowserApp = {
#endif
}
if (pinned)
WebAppRT.init();
if (this.isAppUpdated())
this.onAppUpdated();

View File

@ -36,6 +36,7 @@ chrome.jar:
content/SelectHelper.js (content/SelectHelper.js)
content/HelperApps.js (content/HelperApps.js)
content/dbg-browser-actors.js (content/dbg-browser-actors.js)
content/WebAppRT.js (content/WebAppRT.js)
% content branding %content/branding/