1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
|
/* 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/. */
"use strict";
/* global AppConstants, ExtensionAPI, Services */
function isTelemetryEnabled() {
return Services.prefs.getBoolPref(
"datareporting.healthreport.uploadEnabled",
false
);
}
function getSysinfoProperty(propertyName, defaultValue) {
try {
return Services.sysinfo.getProperty(propertyName);
} catch (e) {}
return defaultValue;
}
function getUserAgent() {
const { userAgent } = Cc[
"@mozilla.org/network/protocol;1?name=http"
].getService(Ci.nsIHttpProtocolHandler);
return userAgent;
}
function getGfxData() {
const gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo);
const data = {};
try {
const {
compositor,
hwCompositing,
openglCompositing,
wrCompositor,
wrSoftware,
} = gfxInfo.getFeatures();
data.features = {
compositor,
hwCompositing,
openglCompositing,
wrCompositor,
wrSoftware,
};
} catch (e) {}
try {
if (AppConstants.platform !== "android") {
data.monitors = gfxInfo.getMonitors();
}
} catch (e) {}
return data;
}
function limitStringToLength(str, maxLength) {
if (typeof str !== "string") {
return null;
}
return str.substring(0, maxLength);
}
function getSecurityAppData() {
const maxStringLength = 256;
const keys = [
["registeredAntiVirus", "antivirus"],
["registeredAntiSpyware", "antispyware"],
["registeredFirewall", "firewall"],
];
let result = {};
for (let [inKey, outKey] of keys) {
let prop = getSysinfoProperty(inKey, null);
if (prop) {
prop = limitStringToLength(prop, maxStringLength).split(";");
}
result[outKey] = prop;
}
return result;
}
function getAdditionalPrefs() {
const prefs = {};
for (const [name, dflt] of Object.entries({
"browser.opaqueResponseBlocking": false,
"extensions.InstallTrigger.enabled": false,
"gfx.canvas.accelerated.force-enabled": false,
"gfx.webrender.compositor.force-enabled": false,
"privacy.resistFingerprinting": false,
})) {
prefs[name] = Services.prefs.getBoolPref(name, dflt);
}
const cookieBehavior = "network.cookie.cookieBehavior";
prefs[cookieBehavior] = Services.prefs.getIntPref(cookieBehavior);
return prefs;
}
function getMemoryMB() {
let memoryMB = getSysinfoProperty("memsize", null);
if (memoryMB) {
memoryMB = Math.round(memoryMB / 1024 / 1024);
}
return memoryMB;
}
this.browserInfo = class extends ExtensionAPI {
getAPI(context) {
return {
browserInfo: {
async getGraphicsPrefs() {
const prefs = {};
for (const [name, dflt] of Object.entries({
"layers.acceleration.force-enabled": false,
"gfx.webrender.all": false,
"gfx.webrender.blob-images": true,
"gfx.webrender.enabled": false,
"image.mem.shared": true,
})) {
prefs[name] = Services.prefs.getBoolPref(name, dflt);
}
return prefs;
},
async getAppVersion() {
return AppConstants.MOZ_APP_VERSION;
},
async getBlockList() {
const trackingTable = Services.prefs.getCharPref(
"urlclassifier.trackingTable"
);
// If content-track-digest256 is in the tracking table,
// the user has enabled the strict list.
return trackingTable.includes("content") ? "strict" : "basic";
},
async getBuildID() {
return Services.appinfo.appBuildID;
},
async getUpdateChannel() {
return AppConstants.MOZ_UPDATE_CHANNEL;
},
async getPlatform() {
return AppConstants.platform;
},
async hasTouchScreen() {
const gfxInfo = Cc["@mozilla.org/gfx/info;1"].getService(
Ci.nsIGfxInfo
);
return gfxInfo.getInfo().ApzTouchInput == 1;
},
async getAdditionalData() {
const blockList = await this.getBlockList();
const userAgent = getUserAgent();
const gfxData = getGfxData();
const prefs = getAdditionalPrefs();
const memoryMb = getMemoryMB();
const data = {
applicationName: Services.appinfo.name,
version: Services.appinfo.version,
updateChannel: AppConstants.MOZ_UPDATE_CHANNEL,
osArchitecture: getSysinfoProperty("arch", null),
osName: getSysinfoProperty("name", null),
osVersion: getSysinfoProperty("version", null),
fissionEnabled: Services.appinfo.fissionAutostart,
userAgent,
gfxData,
blockList,
prefs,
memoryMb,
};
if (AppConstants.isPlatformAndVersionAtLeast("win", "6.2")) {
data.sec = getSecurityAppData();
}
if (AppConstants.platform === "android") {
data.device = getSysinfoProperty("device", null);
data.isTablet = getSysinfoProperty("tablet", false);
}
return data;
},
},
};
}
};
|