Skip to content
This repository has been archived by the owner on Jul 21, 2021. It is now read-only.

Commit

Permalink
More unused code cleaning (#1009)
Browse files Browse the repository at this point in the history
* remove many unused functions

* remove XAL abstraction
  • Loading branch information
rhendric authored and gorhill committed Apr 7, 2019
1 parent fa795dd commit 3f2916e
Show file tree
Hide file tree
Showing 8 changed files with 3 additions and 413 deletions.
70 changes: 0 additions & 70 deletions platform/chromium/vapi-background.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,35 +294,13 @@ vAPI.tabs.replace = function(tabId, url) {

/******************************************************************************/

vAPI.tabs.remove = function(tabId) {
chrome.tabs.remove(tabId, resetLastError);
};

/******************************************************************************/

vAPI.tabs.reload = function(tabId, bypassCache) {
if ( typeof tabId !== 'number' || tabId < 0 ) { return; }
chrome.tabs.reload(tabId, { bypassCache: bypassCache === true });
};

/******************************************************************************/

vAPI.tabs.injectScript = function(tabId, details, callback) {
var onScriptExecuted = function() {
resetLastError();
if ( typeof callback === 'function' ) {
callback();
}
};
if ( tabId ) {
chrome.tabs.executeScript(tabId, details, onScriptExecuted);
} else {
chrome.tabs.executeScript(details, onScriptExecuted);
}
};

/******************************************************************************/

// Must read: https://code.google.com/p/chromium/issues/detail?id=410868#c8

// https://github.com/chrisaljoudi/uBlock/issues/19
Expand Down Expand Up @@ -562,50 +540,13 @@ vAPI.net = {
/******************************************************************************/
/******************************************************************************/

vAPI.contextMenu = {
create: function(details, callback) {
this.menuId = details.id;
this.callback = callback;
chrome.contextMenus.create(details);
chrome.contextMenus.onClicked.addListener(this.callback);
},
remove: function() {
chrome.contextMenus.onClicked.removeListener(this.callback);
chrome.contextMenus.remove(this.menuId);
}
};

/******************************************************************************/

vAPI.lastError = function() {
return chrome.runtime.lastError;
};

/******************************************************************************/
/******************************************************************************/

// This is called only once, when everything has been loaded in memory after
// the extension was launched. It can be used to inject content scripts
// in already opened web pages, to remove whatever nuisance could make it to
// the web pages before uBlock was ready.

vAPI.onLoadAllCompleted = function() {
};

/******************************************************************************/
/******************************************************************************/

vAPI.punycodeHostname = function(hostname) {
return hostname;
};

vAPI.punycodeURL = function(url) {
return url;
};

/******************************************************************************/
/******************************************************************************/

vAPI.browserData = {};

/******************************************************************************/
Expand All @@ -616,17 +557,6 @@ vAPI.browserData.clearCache = function(callback) {
chrome.browsingData.removeCache({ since: 0 }, callback);
};

/******************************************************************************/

// Not supported on Chromium

vAPI.browserData.clearOrigin = function(domain, callback) {
// unsupported on Chromium
if ( typeof callback === 'function' ) {
callback(undefined);
}
};

/******************************************************************************/
/******************************************************************************/

Expand Down
1 change: 0 additions & 1 deletion src/background.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
<script src="js/vapi-cachestorage.js"></script>

<script src="js/background.js"></script>
<script src="js/xal.js"></script>
<script src="js/usersettings.js"></script>
<script src="js/liquid-dict.js"></script>
<script src="js/matrix.js"></script>
Expand Down
116 changes: 0 additions & 116 deletions src/js/httpsb.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,93 +61,6 @@
return hn === '' ? '*' : hn;
};

µMatrix.scopeFromURL = µMatrix.hostnameFromURL;

/******************************************************************************/

µMatrix.evaluateURL = function(srcURL, desHostname, type) {
var srcHostname = this.URI.hostnameFromURI(srcURL);
return this.tMatrix.evaluateCellZXY(srcHostname, desHostname, type);
};


/******************************************************************************/

// Whitelist something

µMatrix.whitelistTemporarily = function(srcHostname, desHostname, type) {
this.tMatrix.whitelistCell(srcHostname, desHostname, type);
};

µMatrix.whitelistPermanently = function(srcHostname, desHostname, type) {
if ( this.pMatrix.whitelistCell(srcHostname, desHostname, type) ) {
this.saveMatrix();
}
};

/******************************************************************************/

// Auto-whitelisting the `all` cell is a serious action, hence this will be
// done only from within a scope.

µMatrix.autoWhitelistAllTemporarily = function(pageURL) {
var srcHostname = this.URI.hostnameFromURI(pageURL);
if ( this.mustBlock(srcHostname, '*', '*') === false ) {
return false;
}
this.tMatrix.whitelistCell(srcHostname, '*', '*');
return true;
};

/******************************************************************************/

// Blacklist something

µMatrix.blacklistTemporarily = function(srcHostname, desHostname, type) {
this.tMatrix.blacklistCell(srcHostname, desHostname, type);
};

µMatrix.blacklistPermanently = function(srcHostname, desHostname, type) {
if ( this.pMatrix.blacklist(srcHostname, desHostname, type) ) {
this.saveMatrix();
}
};

/******************************************************************************/

// Remove something from both black and white lists.

µMatrix.graylistTemporarily = function(srcHostname, desHostname, type) {
this.tMatrix.graylistCell(srcHostname, desHostname, type);
};

µMatrix.graylistPermanently = function(srcHostname, desHostname, type) {
if ( this.pMatrix.graylistCell(srcHostname, desHostname, type) ) {
this.saveMatrix();
}
};

/******************************************************************************/

// TODO: Should type be transposed by the caller or in place here? Not an
// issue at this point but to keep in mind as this function is called
// more and more from different places.

µMatrix.filterRequest = function(fromURL, type, toURL) {
// Block request?
var srcHostname = this.hostnameFromURL(fromURL);
var desHostname = this.hostnameFromURL(toURL);

// If no valid hostname, use the hostname of the source.
// For example, this case can happen with data URI.
if ( desHostname === '' ) {
desHostname = srcHostname;
}

// Blocked by matrix filtering?
return this.mustBlock(srcHostname, desHostname, type);
};

/******************************************************************************/

µMatrix.mustBlock = function(srcHostname, desHostname, type) {
Expand All @@ -160,35 +73,6 @@

/******************************************************************************/

// Commit temporary permissions.

µMatrix.commitPermissions = function(persist) {
this.pMatrix.assign(this.tMatrix);
if ( persist ) {
this.saveMatrix();
}
};

/******************************************************************************/

// Reset all rules to their default state.

µMatrix.revertAllRules = function() {
this.tMatrix.assign(this.pMatrix);
};

/******************************************************************************/

µMatrix.turnOff = function() {
vAPI.app.start();
};

µMatrix.turnOn = function() {
vAPI.app.stop();
};

/******************************************************************************/

µMatrix.formatCount = function(count) {
if ( typeof count !== 'number' ) {
return '';
Expand Down
8 changes: 2 additions & 6 deletions src/js/messaging.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,6 @@ function onMessage(request, sender, callback) {
µm.gotoExtensionURL(request);
break;

case 'gotoURL':
µm.gotoURL(request);
break;

case 'graylistMatrixCell':
µm.tMatrix.graylistCell(
request.srcHostname,
Expand Down Expand Up @@ -887,7 +883,7 @@ var restoreUserData = function(userData) {

// If we are going to restore all, might as well wipe out clean local
// storage
µm.XAL.keyvalRemoveAll(onAllRemoved);
vAPI.storage.clear(onAllRemoved);
};

/******************************************************************************/
Expand All @@ -896,7 +892,7 @@ var resetUserData = function() {
var onAllRemoved = function() {
vAPI.app.restart();
};
µm.XAL.keyvalRemoveAll(onAllRemoved);
vAPI.storage.clear(onAllRemoved);
};

/******************************************************************************/
Expand Down
2 changes: 1 addition & 1 deletion src/js/storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
/******************************************************************************/

µMatrix.saveUserSettings = function() {
this.XAL.keyvalSetMany(
vAPI.storage.set(
this.userSettings,
this.getBytesInUse.bind(this)
);
Expand Down
Loading

0 comments on commit 3f2916e

Please sign in to comment.