diff options
author | Basilisk-Dev <basiliskdev@protonmail.com> | 2022-08-29 23:08:01 -0400 |
---|---|---|
committer | Basilisk-Dev <basiliskdev@protonmail.com> | 2022-08-29 23:08:01 -0400 |
commit | 84de8023bb02fe859a908b800652c48e05b55abd (patch) | |
tree | 68c2ba7593c270e3d35259a4b1c32bf35112baa6 | |
parent | 7c03d3388231dee25d54b91776cd30ce25ce81eb (diff) | |
download | basilisk-84de8023bb02fe859a908b800652c48e05b55abd.tar.gz |
Issue #29 - Remove telemetry from pdfjs completely
-rw-r--r-- | basilisk/extensions/pdfjs/content/PdfJsTelemetry.jsm | 70 | ||||
-rw-r--r-- | basilisk/extensions/pdfjs/content/PdfStreamConverter.jsm | 73 | ||||
-rw-r--r-- | basilisk/extensions/pdfjs/content/web/viewer.js | 22 |
3 files changed, 2 insertions, 163 deletions
diff --git a/basilisk/extensions/pdfjs/content/PdfJsTelemetry.jsm b/basilisk/extensions/pdfjs/content/PdfJsTelemetry.jsm deleted file mode 100644 index 275da9d..0000000 --- a/basilisk/extensions/pdfjs/content/PdfJsTelemetry.jsm +++ /dev/null @@ -1,70 +0,0 @@ -/* Copyright 2013 Mozilla Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* jshint esnext:true, maxlen: 100 */ -/* globals Components, Services */ - -'use strict'; - -this.EXPORTED_SYMBOLS = ['PdfJsTelemetry']; - -const Cu = Components.utils; -Cu.import('resource://gre/modules/Services.jsm'); - -this.PdfJsTelemetry = { - onViewerIsUsed: function () { - let histogram = Services.telemetry.getHistogramById('PDF_VIEWER_USED'); - histogram.add(true); - }, - onFallback: function () { - let histogram = Services.telemetry.getHistogramById('PDF_VIEWER_FALLBACK_SHOWN'); - histogram.add(true); - }, - onDocumentSize: function (size) { - let histogram = Services.telemetry.getHistogramById('PDF_VIEWER_DOCUMENT_SIZE_KB'); - histogram.add(size / 1024); - }, - onDocumentVersion: function (versionId) { - let histogram = Services.telemetry.getHistogramById('PDF_VIEWER_DOCUMENT_VERSION'); - histogram.add(versionId); - }, - onDocumentGenerator: function (generatorId) { - let histogram = Services.telemetry.getHistogramById('PDF_VIEWER_DOCUMENT_GENERATOR'); - histogram.add(generatorId); - }, - onEmbed: function (isObject) { - let histogram = Services.telemetry.getHistogramById('PDF_VIEWER_EMBED'); - histogram.add(isObject); - }, - onFontType: function (fontTypeId) { - let histogram = Services.telemetry.getHistogramById('PDF_VIEWER_FONT_TYPES'); - histogram.add(fontTypeId); - }, - onForm: function (isAcroform) { - let histogram = Services.telemetry.getHistogramById('PDF_VIEWER_FORM'); - histogram.add(isAcroform); - }, - onPrint: function () { - let histogram = Services.telemetry.getHistogramById('PDF_VIEWER_PRINT'); - histogram.add(true); - }, - onStreamType: function (streamTypeId) { - let histogram = Services.telemetry.getHistogramById('PDF_VIEWER_STREAM_TYPES'); - histogram.add(streamTypeId); - }, - onTimeToView: function (ms) { - let histogram = Services.telemetry.getHistogramById('PDF_VIEWER_TIME_TO_VIEW_MS'); - histogram.add(ms); - } -}; diff --git a/basilisk/extensions/pdfjs/content/PdfStreamConverter.jsm b/basilisk/extensions/pdfjs/content/PdfStreamConverter.jsm index b5b21f2..d4a0f05 100644 --- a/basilisk/extensions/pdfjs/content/PdfStreamConverter.jsm +++ b/basilisk/extensions/pdfjs/content/PdfStreamConverter.jsm @@ -14,7 +14,7 @@ */ /* jshint esnext:true */ /* globals Components, Services, XPCOMUtils, NetUtil, PrivateBrowsingUtils, - dump, NetworkManager, PdfJsTelemetry, PdfjsContentUtils */ + dump, NetworkManager, PdfjsContentUtils */ 'use strict'; @@ -44,9 +44,6 @@ XPCOMUtils.defineLazyModuleGetter(this, 'NetworkManager', XPCOMUtils.defineLazyModuleGetter(this, 'PrivateBrowsingUtils', 'resource://gre/modules/PrivateBrowsingUtils.jsm'); -XPCOMUtils.defineLazyModuleGetter(this, 'PdfJsTelemetry', - 'resource://pdf.js/PdfJsTelemetry.jsm'); - XPCOMUtils.defineLazyModuleGetter(this, 'PdfjsContentUtils', 'resource://pdf.js/PdfjsContentUtils.jsm'); @@ -214,13 +211,6 @@ PdfDataListener.prototype = { function ChromeActions(domWindow, contentDispositionFilename) { this.domWindow = domWindow; this.contentDispositionFilename = contentDispositionFilename; - this.telemetryState = { - documentInfo: false, - firstPageInfo: false, - streamTypesUsed: [], - fontTypesUsed: [], - startAt: Date.now() - }; } ChromeActions.prototype = { @@ -356,62 +346,6 @@ ChromeActions.prototype = { metaKey: Services.prefs.getIntPref('mousewheel.with_meta.action', 1) === 3, }; }, - reportTelemetry: function (data) { - var probeInfo = JSON.parse(data); - switch (probeInfo.type) { - case 'documentInfo': - if (!this.telemetryState.documentInfo) { - PdfJsTelemetry.onDocumentVersion(probeInfo.version | 0); - PdfJsTelemetry.onDocumentGenerator(probeInfo.generator | 0); - if (probeInfo.formType) { - PdfJsTelemetry.onForm(probeInfo.formType === 'acroform'); - } - this.telemetryState.documentInfo = true; - } - break; - case 'pageInfo': - if (!this.telemetryState.firstPageInfo) { - var duration = Date.now() - this.telemetryState.startAt; - PdfJsTelemetry.onTimeToView(duration); - this.telemetryState.firstPageInfo = true; - } - break; - case 'documentStats': - // documentStats can be called several times for one documents. - // if stream/font types are reported, trying not to submit the same - // enumeration value multiple times. - var documentStats = probeInfo.stats; - if (!documentStats || typeof documentStats !== 'object') { - break; - } - var i, streamTypes = documentStats.streamTypes; - if (Array.isArray(streamTypes)) { - var STREAM_TYPE_ID_LIMIT = 20; - for (i = 0; i < STREAM_TYPE_ID_LIMIT; i++) { - if (streamTypes[i] && - !this.telemetryState.streamTypesUsed[i]) { - PdfJsTelemetry.onStreamType(i); - this.telemetryState.streamTypesUsed[i] = true; - } - } - } - var fontTypes = documentStats.fontTypes; - if (Array.isArray(fontTypes)) { - var FONT_TYPE_ID_LIMIT = 20; - for (i = 0; i < FONT_TYPE_ID_LIMIT; i++) { - if (fontTypes[i] && - !this.telemetryState.fontTypesUsed[i]) { - PdfJsTelemetry.onFontType(i); - this.telemetryState.fontTypesUsed[i] = true; - } - } - } - break; - case 'print': - PdfJsTelemetry.onPrint(); - break; - } - }, fallback: function(args, sendResponse) { var featureId = args.featureId; var url = args.url; @@ -425,7 +359,6 @@ ChromeActions.prototype = { } else { message = getLocalizedString(strings, 'unsupported_feature'); } - PdfJsTelemetry.onFallback(); PdfjsContentUtils.displayWarning(domWindow, message, getLocalizedString(strings, 'open_with_different_viewer'), getLocalizedString(strings, 'open_with_different_viewer', 'accessKey')); @@ -940,9 +873,6 @@ PdfStreamConverter.prototype = { aRequest.setResponseHeader('Refresh', '', false); } - PdfJsTelemetry.onViewerIsUsed(); - PdfJsTelemetry.onDocumentSize(aRequest.contentLength); - // Creating storage for PDF data var contentLength = aRequest.contentLength; this.dataListener = new PdfDataListener(contentLength); @@ -996,7 +926,6 @@ PdfStreamConverter.prototype = { if (domWindow.frameElement) { var isObjectEmbed = domWindow.frameElement.tagName !== 'IFRAME' || domWindow.frameElement.className === 'previewPluginContentFrame'; - PdfJsTelemetry.onEmbed(isObjectEmbed); } } }; diff --git a/basilisk/extensions/pdfjs/content/web/viewer.js b/basilisk/extensions/pdfjs/content/web/viewer.js index 35fef2c..8baa5cf 100644 --- a/basilisk/extensions/pdfjs/content/web/viewer.js +++ b/basilisk/extensions/pdfjs/content/web/viewer.js @@ -6494,8 +6494,6 @@ var pdfjsWebLibs; }, fallback: function (data, callback) { }, - reportTelemetry: function (data) { - }, createDownloadManager: function () { return new downloadManagerLib.DownloadManager(); }, @@ -7259,12 +7257,6 @@ var pdfjsWebLibs; }.bind(null, info.Producer.toLowerCase())); } var formType = !info.IsAcroFormPresent ? null : info.IsXFAPresent ? 'xfa' : 'acroform'; - self.externalServices.reportTelemetry({ - type: 'documentInfo', - version: versionId, - generator: generatorId, - formType: formType - }); }); }, setInitialView: function pdfViewSetInitialView(storedHash, options) { @@ -7330,7 +7322,6 @@ var pdfjsWebLibs; this.printService = printService; this.forceRendering(); printService.layout(); - this.externalServices.reportTelemetry({ type: 'print' }); }, // Whether all pages of the PDF have the same width and height. get hasEqualPageSizes() { @@ -7640,14 +7631,6 @@ var pdfjsWebLibs; if (pageView.error) { PDFViewerApplication.error(mozL10n.get('rendering_error', null, 'An error occurred while rendering the page.'), pageView.error); } - PDFViewerApplication.externalServices.reportTelemetry({ type: 'pageInfo' }); - // It is a good time to report stream and font types. - PDFViewerApplication.pdfDocument.getStats().then(function (stats) { - PDFViewerApplication.externalServices.reportTelemetry({ - type: 'documentStats', - stats: stats - }); - }); } function webViewerTextLayerRendered(e) { if (e.numTextDivs > 0 && !PDFViewerApplication.supportsDocumentColors) { @@ -8507,9 +8490,6 @@ var pdfjsWebLibs; fallback: function (data, callback) { FirefoxCom.request('fallback', data, callback); }, - reportTelemetry: function (data) { - FirefoxCom.request('reportTelemetry', JSON.stringify(data)); - }, createDownloadManager: function () { return new DownloadManager(); }, @@ -8668,4 +8648,4 @@ function webViewerLoad() { window.PDFViewerApplication = pdfjsWebLibs.pdfjsWebApp.PDFViewerApplication; pdfjsWebLibs.pdfjsWebApp.PDFViewerApplication.run(config); } -document.addEventListener('DOMContentLoaded', webViewerLoad, true);
\ No newline at end of file +document.addEventListener('DOMContentLoaded', webViewerLoad, true); |