Skip to content

Commit

Permalink
https://github.com/AdguardTeam/AdguardBrowserExtension/issues/253
Browse files Browse the repository at this point in the history
  • Loading branch information
ameshkov committed May 30, 2016
1 parent 90ca5ac commit d0871ea
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Compiler/build.sh
@@ -1,6 +1,6 @@
#!/bin/bash

version="2.3.5"
version="2.3.6"

if [[ ! ("$#" == 1) ]] || [[ ! ($1 = dev) && ! ($1 = release) && ! ($1 = beta) ]] ; then
echo "Pass a single argument as an environment value"
Expand Down
63 changes: 63 additions & 0 deletions Extension/browser/chrome/lib/utils/rules-storage.js
@@ -0,0 +1,63 @@
/**
* This file is part of Adguard Browser Extension (https://github.com/AdguardTeam/AdguardBrowserExtension).
*
* Adguard Browser Extension is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Adguard Browser Extension is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Adguard Browser Extension. If not, see <http://www.gnu.org/licenses/>.
*/

/* global exports, browser */
/**
* Filter rules storage adapter
*/
var RulesStorage = exports.RulesStorage = {

read: function (path, callback) {
try {
browser.storage.local.get(path, function(results) {
if (browser.runtime.lastError) {
callback(browser.runtime.lastError);
} else {
var lines = [];

if (results && results[path] instanceof Array) {
lines = results[path];
}

callback(null, lines);
}
});
} catch (ex) {
callback(ex);
}
},

write: function (path, data, callback) {
var item = {};
item[path] = data;
try {
browser.storage.local.set(item, function() {
if (browser.runtime.lastError) {
callback(browser.runtime.lastError);
} else {
callback();
}
});
} catch (ex) {
callback(ex);
}
},

remove: function (path, successCallback) {
browser.storage.local.remove(path, successCallback);
}
};
1 change: 1 addition & 0 deletions Extension/browser/chrome/manifest.json
Expand Up @@ -129,6 +129,7 @@
"webRequest",
"webRequestBlocking",
"webNavigation",
"storage",
"unlimitedStorage",
"contextMenus"
],
Expand Down
1 change: 1 addition & 0 deletions Extension/browser/safari/lib/utils/local-storage.js
Expand Up @@ -14,6 +14,7 @@
* You should have received a copy of the GNU Lesser General Public License
* along with Adguard Browser Extension. If not, see <http://www.gnu.org/licenses/>.
*/
/* global exports, safari, Log */

/**
* Local storage adapter
Expand Down
1 change: 1 addition & 0 deletions Extension/browser/webkit/lib/utils/rules-storage.js
Expand Up @@ -15,6 +15,7 @@
* along with Adguard Browser Extension. If not, see <http://www.gnu.org/licenses/>.
*/

/* global exports, LS */
/**
* Filter rules storage adapter
*/
Expand Down
4 changes: 2 additions & 2 deletions Extension/lib/filter/update-service.js
Expand Up @@ -134,7 +134,7 @@ exports.ApplicationUpdateService = {
var adguardFilters = Object.create(null);

var processNextFilter = function () {
if (filters.length == 0) {
if (filters.length === 0) {
//update adguard-filters in local storage for next update iteration
LS.setItem('adguard-filters', JSON.stringify(adguardFilters));

Expand Down Expand Up @@ -285,7 +285,7 @@ exports.ApplicationUpdateService = {
},

/**
* Update chromium file storage by switching to local storage
* Updates filters storage - move from files to the storage API.
*
* Version 2.3.5
* @returns {exports.Promise}
Expand Down
3 changes: 3 additions & 0 deletions Extension/lib/utils/browser-utils.js
Expand Up @@ -55,6 +55,9 @@ var Utils = exports.Utils = {
return clientId;
},

/**
* Checks if left version is greater than the right version
*/
isGreaterVersion: function (leftVersion, rightVersion) {
var left = new Version(leftVersion);
var right = new Version(rightVersion);
Expand Down

0 comments on commit d0871ea

Please sign in to comment.