Bug 1524688: Part 8 - Convert URL classifier to static registration r=Ehsan

--HG--
rename : toolkit/components/url-classifier/nsUrlClassifierHashCompleter.js => toolkit/components/url-classifier/UrlClassifierHashCompleter.jsm
rename : toolkit/components/url-classifier/nsUrlClassifierLib.js => toolkit/components/url-classifier/UrlClassifierLib.jsm
rename : toolkit/components/url-classifier/nsUrlClassifierListManager.js => toolkit/components/url-classifier/UrlClassifierListManager.jsm
extra : source : fdc6c4ed241a50b756e77560bc22d2cbd13c684e
This commit is contained in:
Kris Maglione 2019-01-29 18:41:19 -08:00
Родитель f34cca34b0
Коммит da054397cd
8 изменённых файлов: 39 добавлений и 52 удалений

Просмотреть файл

@ -344,12 +344,6 @@
@RESPATH@/browser/actors/*
@RESPATH@/actors/*
; Safe Browsing
@RESPATH@/components/nsURLClassifier.manifest
@RESPATH@/components/nsUrlClassifierHashCompleter.js
@RESPATH@/components/nsUrlClassifierListManager.js
@RESPATH@/components/nsUrlClassifierLib.js
; Security Reports
@RESPATH@/components/SecurityReporter.manifest
@RESPATH@/components/SecurityReporter.js

Просмотреть файл

@ -227,12 +227,6 @@
@BINPATH@/modules/*
@BINPATH@/actors/*
; Safe Browsing
@BINPATH@/components/nsURLClassifier.manifest
@BINPATH@/components/nsUrlClassifierHashCompleter.js
@BINPATH@/components/nsUrlClassifierListManager.js
@BINPATH@/components/nsUrlClassifierLib.js
; Security Reports
@BINPATH@/components/SecurityReporter.manifest
@BINPATH@/components/SecurityReporter.js

Просмотреть файл

@ -845,18 +845,10 @@ HashCompleterRequest.prototype = {
},
};
// Converts a URL safe base64 string to a normal base64 string. Will not change
// normal base64 strings. This is modelled after the same function in
// nsUrlClassifierUtils.h.
function unUrlsafeBase64(aStr) {
return !aStr ? "" : aStr.replace(/-/g, "+")
.replace(/_/g, "/");
}
function errorWithStack() {
let err = new Error();
err.value = Cr.NS_ERROR_FAILURE;
return err;
}
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([HashCompleter]);
var EXPORTED_SYMBOLS = ["HashCompleter"];

Просмотреть файл

@ -6,9 +6,6 @@
// the common JS files used by safebrowsing and url-classifier into a
// single component.
const G_GDEBUG = false;
const {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
const PREF_DISABLE_TEST_BACKOFF = "browser.safebrowsing.provider.test.disableBackoff";
@ -186,6 +183,7 @@ RequestBackoff.prototype.isErrorStatus = function(status) {
// since both listmanager and hashcompleter would use it.
// Note that |maxRequests| and |requestPeriod| is still configurable
// to throttle pending requests.
/* exported RequestBackoffV4 */
function RequestBackoffV4(maxRequests, requestPeriod,
provider = null) {
let rand = Math.random();
@ -208,7 +206,6 @@ var lib = this;
function UrlClassifierLib() {
this.wrappedJSObject = lib;
}
UrlClassifierLib.prototype.classID = Components.ID("{26a4a019-2827-4a89-a85c-5931a678823a}");
UrlClassifierLib.prototype.QueryInterface = ChromeUtils.generateQI([]);
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([UrlClassifierLib]);
var EXPORTED_SYMBOLS = ["UrlClassifierLib"];

Просмотреть файл

@ -2,7 +2,6 @@
* 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/. */
const {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
// This is the only implementation of nsIUrlListManager.
@ -697,17 +696,8 @@ function Init() {
}
function RegistrationData() {
Init();
return new PROT_ListManager();
}
RegistrationData.prototype = {
classID: Components.ID("{ca168834-cc00-48f9-b83c-fd018e58cae3}"),
_xpcom_factory: {
createInstance(outer, iid) {
if (outer != null)
throw Cr.NS_ERROR_NO_AGGREGATION;
Init();
return (new PROT_ListManager()).QueryInterface(iid);
},
},
};
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([RegistrationData]);
var EXPORTED_SYMBOLS = ["RegistrationData"];

Просмотреть файл

@ -0,0 +1,26 @@
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# 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/.
Classes = [
{
'cid': '{26a4a019-2827-4a89-a85c-5931a678823a}',
'contract_ids': ['@mozilla.org/url-classifier/jslib;1'],
'jsm': 'resource://gre/modules/UrlClassifierLib.jsm',
'constructor': 'UrlClassifierLib',
},
{
'cid': '{ca168834-cc00-48f9-b83c-fd018e58cae3}',
'contract_ids': ['@mozilla.org/url-classifier/listmanager;1'],
'jsm': 'resource://gre/modules/UrlClassifierListManager.jsm',
'constructor': 'RegistrationData',
},
{
'cid': '{9111de73-9322-4bfc-8b65-2b727f3e6ec8}',
'contract_ids': ['@mozilla.org/url-classifier/hashcompleter;1'],
'jsm': 'resource://gre/modules/UrlClassifierHashCompleter.jsm',
'constructor': 'HashCompleter',
},
]

Просмотреть файл

@ -53,15 +53,15 @@ SOURCES += [
'HashStore.cpp',
]
EXTRA_COMPONENTS += [
'nsURLClassifier.manifest',
'nsUrlClassifierHashCompleter.js',
'nsUrlClassifierLib.js',
'nsUrlClassifierListManager.js',
]
EXTRA_JS_MODULES += [
'SafeBrowsing.jsm',
'UrlClassifierHashCompleter.jsm',
'UrlClassifierLib.jsm',
'UrlClassifierListManager.jsm',
]
XPCOM_MANIFESTS += [
'components.conf',
]
EXPORTS += [

Просмотреть файл

@ -1,6 +0,0 @@
component {26a4a019-2827-4a89-a85c-5931a678823a} nsUrlClassifierLib.js
contract @mozilla.org/url-classifier/jslib;1 {26a4a019-2827-4a89-a85c-5931a678823a}
component {ca168834-cc00-48f9-b83c-fd018e58cae3} nsUrlClassifierListManager.js
contract @mozilla.org/url-classifier/listmanager;1 {ca168834-cc00-48f9-b83c-fd018e58cae3}
component {9111de73-9322-4bfc-8b65-2b727f3e6ec8} nsUrlClassifierHashCompleter.js
contract @mozilla.org/url-classifier/hashcompleter;1 {9111de73-9322-4bfc-8b65-2b727f3e6ec8}