comparing with http://hg.mozilla.org/integration/mozilla-inbound/
☠☠ backed out by e750cf83e6c2 ☠ ☠
authorWes Johnston <wjohnston@mozilla.com>
Wed, 18 Jul 2012 15:43:34 -0700
changeset 99713 2c49724bcbfd0ab62b7d7242d0cf177042617747
parent 99712 f86536e718e83866479394a49852720ed2f9909d
child 99714 5a711846e73df3da5d7feb66c73a83447ef9be35
push id12156
push userwjohnston@mozilla.com
push dateWed, 18 Jul 2012 22:52:06 +0000
treeherdermozilla-inbound@2c49724bcbfd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs99712, 766802
milestone17.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
comparing with http://hg.mozilla.org/integration/mozilla-inbound/ 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
mobile/android/chrome/content/WebAppRT.js
mobile/android/chrome/content/browser.js
mobile/android/chrome/jar.mn
new file mode 100644
--- /dev/null
+++ b/mobile/android/chrome/content/WebAppRT.js
@@ -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();
+  }
+}
--- a/mobile/android/chrome/content/browser.js
+++ b/mobile/android/chrome/content/browser.js
@@ -27,16 +27,17 @@ XPCOMUtils.defineLazyGetter(this, "Debug
   return DebuggerServer;
 });
 
 // Lazily-loaded browser scripts:
 [
   ["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() {
     let sandbox = {};
     Services.scriptloader.loadSubScript(script, sandbox);
     return sandbox[name];
   });
 });
@@ -304,16 +305,19 @@ var BrowserApp = {
       this.addTab(url, loadParams);
 
       // show telemetry door hanger if we aren't restoring a session
 #ifdef MOZ_TELEMETRY_REPORTING
       Telemetry.prompt();
 #endif
     }
 
+    if (pinned)
+      WebAppRT.init();
+
     if (this.isAppUpdated())
       this.onAppUpdated();
 
     // notify java that gecko has loaded
     sendMessageToJava({
       gecko: {
         type: "Gecko:Ready"
       }
--- a/mobile/android/chrome/jar.mn
+++ b/mobile/android/chrome/jar.mn
@@ -31,14 +31,15 @@ chrome.jar:
   content/bindings/settings.xml        (content/bindings/settings.xml)
   content/sanitize.js                  (content/sanitize.js)
   content/exceptions.js                (content/exceptions.js)
 * content/downloads.js                 (content/downloads.js)
   content/netError.xhtml               (content/netError.xhtml)
   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/
 
 % override chrome://global/content/config.xul chrome://browser/content/config.xhtml
 % override chrome://global/content/netError.xhtml chrome://browser/content/netError.xhtml
 % override chrome://mozapps/content/extensions/extensions.xul chrome://browser/content/aboutAddons.xhtml