[Pkg-mozext-commits] [greasemonkey] 43/55: Load new metadata for existing scripts.
David Prévot
taffit at moszumanska.debian.org
Thu Oct 29 15:38:06 UTC 2015
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository greasemonkey.
commit 2db84e7e577b12176cdcc589e336b7acd08b76c2
Author: Anthony Lieuallen <arantius at gmail.com>
Date: Wed Sep 30 10:05:31 2015 -0400
Load new metadata for existing scripts.
1) Trigger updateFromNewScript() on every script once when installing 3.5.
2) Fix updateFromNewScript() to handle new (author + homepageURL) values.
Fixes #1944
---
content/config.js | 41 ++++++++++++++++++-----------------------
modules/script.js | 8 +++++---
2 files changed, 23 insertions(+), 26 deletions(-)
diff --git a/content/config.js b/content/config.js
index b5798ea..3fd7a6c 100644
--- a/content/config.js
+++ b/content/config.js
@@ -1,9 +1,11 @@
-Components.utils.import('chrome://greasemonkey-modules/content/constants.js');
-Components.utils.import('chrome://greasemonkey-modules/content/miscapis.js');
-Components.utils.import('chrome://greasemonkey-modules/content/prefmanager.js');
-Components.utils.import('chrome://greasemonkey-modules/content/script.js');
-Components.utils.import('chrome://greasemonkey-modules/content/third-party/MatchPattern.js');
-Components.utils.import('chrome://greasemonkey-modules/content/util.js');
+var Cu = Components.utils;
+
+Cu.import('chrome://greasemonkey-modules/content/constants.js');
+Cu.import('chrome://greasemonkey-modules/content/miscapis.js');
+Cu.import('chrome://greasemonkey-modules/content/prefmanager.js');
+Cu.import('chrome://greasemonkey-modules/content/script.js');
+Cu.import('chrome://greasemonkey-modules/content/third-party/MatchPattern.js');
+Cu.import('chrome://greasemonkey-modules/content/util.js');
function Config() {
this._saveTimer = null;
@@ -239,7 +241,7 @@ Config.prototype.updateModifiedScripts = function(
for (var i = 0, script; script = scripts[i]; i++) {
if (0 == script.pendingExec.length) {
var scope = {};
- Components.utils.import('chrome://greasemonkey-modules/content/parseScript.js', scope);
+ Cu.import('chrome://greasemonkey-modules/content/parseScript.js', scope);
var parsedScript = scope.parse(
script.textContent, GM_util.uriFromUrl(script.downloadURL));
// TODO: Show PopupNotifications about parse error(s)?
@@ -271,7 +273,7 @@ Config.prototype.getScriptById = function(scriptId) {
* any necessary upgrades.
*/
Config.prototype._updateVersion = function() {
- Components.utils.import("resource://gre/modules/AddonManager.jsm");
+ Cu.import("resource://gre/modules/AddonManager.jsm");
AddonManager.getAddonByID(this.GM_GUID, GM_util.hitch(this, function(addon) {
var oldVersion = GM_prefRoot.getValue("version");
var newVersion = addon.version;
@@ -293,21 +295,14 @@ Config.prototype._updateVersion = function() {
}
}
- if ('3.2' == newVersion && oldVersion != newVersion) {
- var tmp_dir = Components
- .classes['@mozilla.org/file/directory_service;1']
- .getService(Components.interfaces.nsIProperties)
- .get('TmpD', Components.interfaces.nsIFile);
- // #2069 Clean up stray temp directories.
- for (var i = 1; ; i++) {
- var file = tmp_dir.clone();
- file.append('gm-temp' + i);
- if (file.exists()) {
- dump('Removing temp dir: ' + file.path + '\n');
- file.remove(true);
- } else {
- break;
- }
+ if (newVersion.match(/^3\.5/) && oldVersion != newVersion) {
+ // #1944 Re-scan config to load new metadata values.
+ var scope = {};
+ Cu.import('chrome://greasemonkey-modules/content/parseScript.js', scope);
+ for (var i = 0, script = null; script = this._scripts[i]; i++) {
+ var parsedScript = scope.parse(
+ script.textContent, GM_util.uriFromUrl(script.downloadURL));
+ script.updateFromNewScript(parsedScript);
}
}
}));
diff --git a/modules/script.js b/modules/script.js
index a28ac9f..6ccddd7 100644
--- a/modules/script.js
+++ b/modules/script.js
@@ -663,17 +663,19 @@ Script.prototype.updateFromNewScript = function(newScript, url, windowId, browse
// Copy new values.
// NOTE: User 'cludes are _not_ copied! They should remain as-is.
+ this._author = newScript._author;
+ this._description = newScript._description;
this._excludes = newScript._excludes;
this._grants = newScript._grants;
this._includes = newScript._includes;
- this._matches = newScript._matches;
- this._description = newScript._description;
- this._localized = newScript._localized;
this._locales = newScript._locales;
+ this._localized = newScript._localized;
+ this._matches = newScript._matches;
this._noframes = newScript._noframes;
this._runAt = newScript._runAt;
this._version = newScript._version;
this.downloadURL = newScript.downloadURL;
+ this.homepageURL = newScript.homepageURL;
this.updateURL = newScript.updateURL;
this.showGrantWarning();
--
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