[Pkg-mozext-commits] [greasemonkey] 07/45: Move GM_openInTab to miscapis.js.

David Prévot taffit at moszumanska.debian.org
Mon Nov 3 20:59:18 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository greasemonkey.

commit d2822b79eaec63ab2f8aa7646a82bdf3350a312e
Author: Ventero <ventero at ventero.de>
Date:   Fri Sep 19 05:01:25 2014 +0200

    Move GM_openInTab to miscapis.js.
---
 components/greasemonkey.js | 31 +------------------------------
 modules/miscapis.js        | 34 +++++++++++++++++++++++++++++++++-
 2 files changed, 34 insertions(+), 31 deletions(-)

diff --git a/components/greasemonkey.js b/components/greasemonkey.js
index a52cd5c..7a9ceae 100644
--- a/components/greasemonkey.js
+++ b/components/greasemonkey.js
@@ -143,7 +143,7 @@ function createSandbox(aScript, aContentWin, aChromeWin, aUrl) {
   }
   if (GM_util.inArray(aScript.grants, 'GM_openInTab')) {
     sandbox.GM_openInTab = GM_util.hitch(
-        null, openInTab, aContentWin);
+        null, GM_openInTab, aContentWin);
   }
   if (GM_util.inArray(aScript.grants, 'GM_xmlhttpRequest')) {
     sandbox.GM_xmlhttpRequest = GM_util.hitch(
@@ -163,35 +163,6 @@ function isTempScript(uri) {
   return gTmpDir.contains(file, true);
 }
 
-function openInTab(safeContentWin, url, aLoadInBackground) {
-  if ('undefined' == typeof aLoadInBackground) aLoadInBackground = null;
-
-  // Resolve URL relative to the location of the content window.
-  var baseUri = gIoService.newURI(safeContentWin.location.href, null, null);
-  var uri = gIoService.newURI(url, null, baseUri);
-
-  // Get the chrome window currently corresponding to the content window, as
-  // this might have changed since the script was injected (e.g. by moving
-  // the tab to a different window).
-  var chromeWin = getChromeWinForContentWin(safeContentWin);
-  var browser = chromeWin.gBrowser;
-  var currentTab = browser.tabs[
-      browser.getBrowserIndexForDocument(safeContentWin.top.document)];
-  var newTab = browser.loadOneTab(
-      uri.spec, {'inBackground': aLoadInBackground});
-  var newWin = GM_windowForTab(newTab, browser);
-
-  var afterCurrent = Cc["@mozilla.org/preferences-service;1"]
-      .getService(Ci.nsIPrefService)
-      .getBranch("browser.tabs.")
-      .getBoolPref("insertRelatedAfterCurrent");
-  if (afterCurrent) {
-    browser.moveTabTo(newTab, currentTab._tPos + 1);
-  }
-
-  return newWin;
-};
-
 function registerMenuCommand(
     wrappedContentWin, script,
     commandName, commandFunc, accessKey, unused, accessKey2
diff --git a/modules/miscapis.js b/modules/miscapis.js
index fb03d38..66ea879 100644
--- a/modules/miscapis.js
+++ b/modules/miscapis.js
@@ -2,12 +2,13 @@ var Cu = Components.utils;
 
 Cu.import("resource://gre/modules/Services.jsm");
 
+Cu.import("resource://greasemonkey/third-party/getChromeWinForContentWin.js");
 Cu.import('resource://greasemonkey/prefmanager.js');
 Cu.import("resource://greasemonkey/util.js");
 
 
 var EXPORTED_SYMBOLS = [
-    'GM_addStyle', 'GM_console', 'GM_Resources',
+    'GM_addStyle', 'GM_console', 'GM_openInTab', 'GM_Resources',
     'GM_ScriptLogger', 'GM_ScriptStorage', 'GM_ScriptStoragePrefs'];
 
 
@@ -286,3 +287,34 @@ function GM_console(script) {
 
 GM_console.prototype.log = function() {
 };
+
+// \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ //
+
+function GM_openInTab(safeContentWin, url, aLoadInBackground) {
+  if ('undefined' == typeof aLoadInBackground) aLoadInBackground = null;
+
+  // Resolve URL relative to the location of the content window.
+  var baseUri = Services.io.newURI(safeContentWin.location.href, null, null);
+  var uri = Services.io.newURI(url, null, baseUri);
+
+  // Get the chrome window currently corresponding to the content window, as
+  // this might have changed since the script was injected (e.g. by moving
+  // the tab to a different window).
+  var chromeWin = getChromeWinForContentWin(safeContentWin);
+  var browser = chromeWin.gBrowser;
+  var currentTab = browser.tabs[
+      browser.getBrowserIndexForDocument(safeContentWin.top.document)];
+  var newTab = browser.loadOneTab(
+      uri.spec, {'inBackground': aLoadInBackground});
+  var newWin = GM_windowForTab(newTab, browser);
+
+  var afterCurrent = Cc["@mozilla.org/preferences-service;1"]
+      .getService(Ci.nsIPrefService)
+      .getBranch("browser.tabs.")
+      .getBoolPref("insertRelatedAfterCurrent");
+  if (afterCurrent) {
+    browser.moveTabTo(newTab, currentTab._tPos + 1);
+  }
+
+  return newWin;
+};

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/greasemonkey.git



More information about the Pkg-mozext-commits mailing list